@standardagents/builder 0.13.1 → 0.13.2

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,15 +1,15 @@
1
- import{d as Ce,i as da,c as q,t as rn,r as m,w as Ee,o as qe,a as ut,p as an,b as o,e as r,n as yt,f as e,g as We,h as Ne,j as nn,k as S,l as He,m as ce,q as w,s as F,F as we,u as Ae,v as de,x as C,y as dt,z as J,A as De,B as Qe,C as on,D as ln,I as ca,E as sn,G as un,T as Xt,H as I,J as ht,K as mt,L as It,M as tt,N as dn,O as Ge,P as Rt,Q as pa,R as ma,S as Tt,U as Ot,V as Ar,W as Ht,X as bt,Y as va,Z as cn,_ as pn,$ as fa,a0 as ot,a1 as Sr,a2 as Xe,a3 as ga,a4 as gt,a5 as _t,a6 as Ir,a7 as Pr,a8 as mn,a9 as Tr,aa as vn,ab as ha,ac as fn,ad as ba,ae as er,af as tr,ag as xa,ah as ya,ai as jr,aj as rr,ak as Rr,al as gn,am as hn,an as bn,ao as xn,ap as yn,aq as kn,ar as wn,as as _n,at as $n,au as Cn,av as Sn,aw as In,ax as ka,ay as Tn,az as Mn,aA as zn,aB as Vn,aC as En,aD as Ln,aE as An,aF as Pn,aG as jn,aH as Rn,aI as On}from"./vue.js";import{a6 as Dn,a7 as Un,a8 as Bn,a9 as ar,aa as Nn,r as nr}from"./vendor.js";import{W as qn,a as Fn,e as Or}from"./monaco.js";(function(){const n=document.createElement("link").relList;if(n&&n.supports&&n.supports("modulepreload"))return;for(const l of document.querySelectorAll('link[rel="modulepreload"]'))s(l);new MutationObserver(l=>{for(const u of l)if(u.type==="childList")for(const i of u.addedNodes)i.tagName==="LINK"&&i.rel==="modulepreload"&&s(i)}).observe(document,{childList:!0,subtree:!0});function a(l){const u={};return l.integrity&&(u.integrity=l.integrity),l.referrerPolicy&&(u.referrerPolicy=l.referrerPolicy),l.crossOrigin==="use-credentials"?u.credentials="include":l.crossOrigin==="anonymous"?u.credentials="omit":u.credentials="same-origin",u}function s(l){if(l.ep)return;l.ep=!0;const u=a(l);fetch(l.href,u)}})();var wa=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 n=await fetch(`${this.endpoint}/threads`,{method:"POST",headers:{...this.getHeaders(),"Content-Type":"application/json"},body:JSON.stringify(t)});if(!n.ok)throw new Error(`Failed to create thread: ${n.statusText}`);return n.json()}async getThread(t){const n=await fetch(`${this.endpoint}/threads/${t}`,{method:"GET",headers:this.getHeaders()});if(!n.ok)throw new Error(`Failed to get thread: ${n.statusText}`);return n.json()}async getMessages(t,n={}){const a=new URLSearchParams;n.limit!==void 0&&a.set("limit",String(n.limit)),n.offset!==void 0&&a.set("offset",String(n.offset)),n.depth!==void 0&&a.set("depth",String(n.depth)),n.includeSilent!==void 0&&a.set("includeSilent",String(n.includeSilent));const s=a.toString(),l=`${this.endpoint}/threads/${t}/messages${s?`?${s}`:""}`,u=await fetch(l,{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,n){const a=await fetch(`${this.endpoint}/threads/${t}/messages`,{method:"POST",headers:{...this.getHeaders(),"Content-Type":"application/json"},body:JSON.stringify(n)});if(!a.ok)throw new Error(`Failed to send message: ${a.statusText}`);return a.json()}async stopExecution(t){const n=await fetch(`${this.endpoint}/threads/${t}/stop`,{method:"POST",headers:this.getHeaders()});if(!n.ok)throw new Error(`Failed to stop execution: ${n.statusText}`);await n.json()}async deleteMessage(t,n){const a=await fetch(`${this.endpoint}/threads/${t}/messages/${n}`,{method:"DELETE",headers:this.getHeaders()});if(!a.ok)throw new Error(`Failed to delete message: ${a.statusText}`);return a.json()}async uploadFile(t,n,a){const s=encodeURIComponent(n.name),l=`${this.endpoint}/threads/${t}/fs/${s}`;if(a?.thumbnail){const i=await this.fileToBase64(n),p=await fetch(l,{method:"POST",headers:{...this.getHeaders(),"Content-Type":"application/json"},body:JSON.stringify({data:i,mimeType:n.type,thumbnail:a.thumbnail,metadata:{width:a.width,height:a.height}})});if(!p.ok)throw new Error(`Failed to upload file: ${p.statusText}`);return p.json()}const u=await fetch(l,{method:"POST",headers:{...this.getHeaders(),"Content-Type":n.type},body:n});if(!u.ok)throw new Error(`Failed to upload file: ${u.statusText}`);return u.json()}fileToBase64(t){return new Promise((n,a)=>{const s=new FileReader;s.onload=()=>{const u=s.result.split(",")[1];n(u)},s.onerror=()=>a(new Error("Failed to read file")),s.readAsDataURL(t)})}getFileUrl(t,n){const s=(n.startsWith("/")?n.slice(1):n).split("/").map(l=>encodeURIComponent(l)).join("/");return`${this.endpoint}/threads/${t}/fs/${s}`}getThumbnailUrl(t,n){return`${this.getFileUrl(t,n)}?thumbnail=true`}async listFiles(t){const n=await fetch(`${this.endpoint}/threads/${t}/fs?find=**/*&type=file`,{method:"GET",headers:this.getHeaders()});if(!n.ok)throw new Error(`Failed to list files: ${n.statusText}`);return(await n.json()).files||[]}connectMessageWebSocket(t,n={},a={}){const s=new URLSearchParams;this.token&&s.set("token",this.token),a.includeSilent!==void 0&&s.set("includeSilent",String(a.includeSilent)),a.depth!==void 0&&s.set("depth",String(a.depth));const l=this.endpoint.startsWith("https")?"wss":"ws",i=`${this.endpoint.replace(/^https?/,l)}/threads/${t}/stream?${s.toString()}`,p=new WebSocket(i);return p.onopen=()=>{n.onOpen?.()},p.onmessage=x=>{try{if(typeof x.data=="string"&&x.data==="pong")return;const k=JSON.parse(x.data);switch(k.type){case"message_data":n.onMessage?.(k);break;case"message_chunk":n.onChunk?.(k);break;case"event":n.onEvent?.(k);break;case"error":n.onError?.(k);break}}catch(k){console.error("Failed to parse WebSocket message:",k)}},p.onerror=x=>{console.error("WebSocket error:",x),n.onError?.({type:"error",error:"WebSocket connection error"})},p.onclose=x=>{console.log(`[AgentBuilderClient] Message WebSocket closed - code: ${x.code}, reason: ${x.reason||"none"}, wasClean: ${x.wasClean}`),n.onClose?.()},p}connectLogWebSocket(t,n={}){const a=new URLSearchParams;this.token&&a.set("token",this.token);const s=this.endpoint.startsWith("https")?"wss":"ws",u=`${this.endpoint.replace(/^https?/,s)}/threads/${t}?${a.toString()}`,i=new WebSocket(u);return i.onopen=()=>{n.onOpen?.()},i.onmessage=p=>{try{if(typeof p.data=="string"&&p.data==="pong")return;const x=JSON.parse(p.data);switch(x.type){case"log_data":n.onLog?.(x);break;case"custom":n.onCustom?.(x);break;case"stopped_by_user":n.onStopped?.(x);break}}catch(x){console.error("Failed to parse WebSocket message:",x)}},i.onerror=p=>{console.error("WebSocket error:",p)},i.onclose=()=>{n.onClose?.()},i}getHeaders(){const t={};return this.token&&(t.Authorization=`Bearer ${this.token}`),t}},Hn=class{client;threadId;callbacks;options;ws=null;status="disconnected";reconnectAttempts=0;reconnectTimeout=null;heartbeatInterval=null;isReconnecting=!1;shouldReconnect=!0;constructor(t,n,a={},s={}){this.client=t,this.threadId=n,this.callbacks=a,this.options={depth:s.depth??0,includeSilent:s.includeSilent??!1,heartbeatInterval:s.heartbeatInterval??3e4,maxReconnectDelay:s.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 Dr(t){return t.toLowerCase().startsWith("image/")}var Ur=256;function Wn(t){return new Promise((n,a)=>{const s=new Image,l=URL.createObjectURL(t);s.onload=()=>{URL.revokeObjectURL(l),n(s)},s.onerror=()=>{URL.revokeObjectURL(l),a(new Error("Failed to load image"))},s.src=l})}function Kn(t){const{width:n,height:a}=t,s=n/a;let l,u;s>1?(l=Math.min(Ur,n),u=Math.floor(l/s)):(u=Math.min(Ur,a),l=Math.floor(u*s));const i=document.createElement("canvas");i.width=l,i.height=u;const p=i.getContext("2d");if(!p)throw new Error("Failed to get canvas context");return p.drawImage(t,0,0,l,u),i.toDataURL("image/webp",.8).split(",")[1]}async function Jn(t){const n=await Wn(t);return{thumbnail:Kn(n),width:n.width,height:n.height}}function Gn(){return`pending-${Date.now()}-${Math.random().toString(36).substr(2,9)}`}function Yn(t){return new Promise((n,a)=>{const s=new FileReader;s.onload=()=>n(s.result),s.onerror=a,s.readAsDataURL(t)})}var Zn=class{createPendingFile(t){return{id:Gn(),name:t.name,mimeType:t.type,size:t.size,isImage:Dr(t.type),localPreviewUrl:null,status:"uploading"}}queueFiles(t){return Array.from(t).map(n=>({pending:this.createPendingFile(n),file:n}))}async executeUpload(t,n,a,s,l,u={}){const{generateThumbnail:i=!0,generatePreview:p=!0}=u,x=Dr(n.type);x&&p&&Yn(n).then(k=>l({localPreviewUrl:k})).catch(k=>console.error("Failed to generate preview:",k));try{let k;if(x&&i)try{const g=await Jn(n);k={thumbnail:g.thumbnail,width:g.width,height:g.height}}catch(g){console.warn("Failed to generate thumbnail:",g)}const h=await s.uploadFile(t,n,k);return l({id:h.id,status:"ready",path:h.path,width:h.width,height:h.height}),h}catch(k){throw l({status:"error",error:k instanceof Error?k.message:"Failed to upload file"}),k}}async executeUploads(t,n,a,s,l={}){const u=n.map(({pending:i,file:p})=>this.executeUpload(t,p,i.id,a,x=>s(i.id,x),l).catch(x=>x instanceof Error?x:new Error(String(x))));return Promise.all(u)}};function _a(t){if(t.length===0)return[];const n=[];let a=0;for(;a<t.length;){const s=t[a];if(s.role==="assistant"&&s.tool_calls){let l;try{l=JSON.parse(s.tool_calls)}catch{n.push(s),a++;continue}const u=[],i=[];let p=s.reasoning_content||null,x="completed";const k=s.id,h=s.created_at,g=s.depth;s.status==="pending"?x="pending":s.status==="failed"&&(x="failed"),s.content&&i.push(s.content);for(const c of l)u.push({id:c.id||s.id,type:"tool_call",name:c.function?.name,content:c.function?.arguments||null,status:null,tool_call_id:c.id});let y=a+1;for(;y<t.length;){const c=t[y];if(c.role==="tool"){const f=c.tool_status||"pending";u.push({id:c.id,type:"tool_result",name:c.name||void 0,content:c.content,status:f,tool_call_id:c.tool_call_id||void 0}),y++}else if(c.role==="assistant"&&c.tool_calls){let f;try{f=JSON.parse(c.tool_calls)}catch{break}c.status==="pending"?x="pending":c.status==="failed"&&x!=="pending"&&(x="failed"),c.content&&i.push(c.content),!p&&c.reasoning_content&&(p=c.reasoning_content);for(const $ of f)u.push({id:$.id||c.id,type:"tool_call",name:$.function?.name,content:$.function?.arguments||null,status:null,tool_call_id:$.id});y++}else break}const _=new Set(u.filter(c=>c.type==="tool_call").map(c=>c.tool_call_id)),v=u.filter(c=>c.type==="tool_result"&&c.tool_call_id&&!_.has(c.tool_call_id));for(const c of v){const f=u.indexOf(c),$=c.content?.match(/Tool not found: (\w+)/)?.[1]||"unknown_tool",N={id:`synthetic-${c.tool_call_id}`,type:"tool_call",name:$,content:null,status:c.status,tool_call_id:c.tool_call_id};u.splice(f,0,N)}for(const c of u)if(c.type==="tool_call"&&c.tool_call_id&&c.status===null){const f=u.find($=>$.type==="tool_result"&&$.tool_call_id===c.tool_call_id);f?c.status=f.status:c.status="pending"}const d=i.length>0?i.join(""):null,b={id:k,type:"workblock",content:d,reasoning_content:p,workItems:u,status:x,created_at:h,depth:g};n.push(b),a=y}else n.push(s),a++}return n}var sr=new Set(["subagent_create","subagent_message","send_to_agent"]),Xn=/subagent/i;function fr(t){return t.type==="workblock"}function Br(t){return t.type==="status"}function Ct(t){if(typeof t!="string")return null;const n=t.trim();return n.length>0?n:null}function Nr(t,n){return!t.metadata||typeof t.metadata!="object"?null:Ct(t.metadata[n])}function $a(t){if(!t)return null;const n=t.match(/Reference:\s*([0-9a-fA-F-]{36})/);if(n?.[1])return n[1].toLowerCase();const a=t.match(/reference:\s*([0-9a-fA-F-]{36})/i);return a?.[1]?a[1].toLowerCase():null}function Ca(t){const n=Ct(t.subagent_status);if(n)return n;const a=t.content||"";return/was initiated successfully/i.test(a)||/Message sent to subagent/i.test(a)?"running":/has returned the following result/i.test(a)?"idle":/has reported a failure/i.test(a)||/execution stopped before completion/i.test(a)?"terminated":null}function wr(t){if(t.role!=="system")return null;const n=Nr(t,"status_kind");if(n==="execution_stopped"||n==="subagent_started"||n==="subagent_event")return n;if(Nr(t,"subagent_event")==="parent_handoff")return"subagent_event";const a=(t.content||"").trim();return/execution\s+stopped/i.test(a)?"execution_stopped":/subagents?\s+started:/i.test(a)?"subagent_started":null}function qr(t){const n=wr(t)??void 0;return{id:`status:${t.id}`,type:"status",role:"system",content:t.content||"Execution stopped by user",created_at:t.created_at,depth:t.depth,silent:!1,status_kind:n}}function Qn(t){if(t.role==="tool"&&Ct(t.subagent_id)||t.role==="tool"&&t.name&&sr.has(t.name))return!0;const n=t.content||"";return!!(/subagent\s*\(reference:/i.test(n)||/the subagent was initiated successfully/i.test(n)||/message sent to subagent/i.test(n))}function Dt(t){const n=Ct(t.subagent_id);if(n)return n;const a=t.metadata;if(a&&typeof a=="object"){const s=Ct(a.subagent_id);if(s)return s;const l=Ct(a.subagentId);if(l)return l}return $a(t.content)}function eo(t){if(!t)return{};try{const n=JSON.parse(t);return n&&typeof n=="object"?n:{}}catch{return{}}}function to(t){return t?sr.has(t)?!0:Xn.test(t):!1}function Sa(t){const n=eo(t.content);return Ct(n.name)}function ro(t,n){if(t.tool_call_id){const a=n.get(t.tool_call_id);if(a)return a}return $a(t.content)}function ao(t,n){const a=Ca(n);return{id:`subagent:${t}`,type:"subagent_block",subagent_id:t,subagent_name:n.subagent_name??null,subagent_title:n.subagent_title??null,subagent_description:n.subagent_description??null,subagent_status:a??null,subagent_resumable:n.subagent_resumable??null,subagent_blocking:n.subagent_blocking??null,subagent_thread_name:n.subagent_thread_name??null,subagent_spawn_group_id:n.subagent_spawn_group_id??null,messages:[n],created_at:n.created_at,updated_at:n.created_at,depth:n.depth}}function no(t,n){t.messages.push(n),t.updated_at=Math.max(t.updated_at,n.created_at),t.created_at=Math.min(t.created_at,n.created_at),t.depth=n.depth??t.depth,n.subagent_name!==void 0&&(t.subagent_name=n.subagent_name??t.subagent_name??null),n.subagent_title!==void 0&&(t.subagent_title=n.subagent_title??t.subagent_title??null),n.subagent_description!==void 0&&(t.subagent_description=n.subagent_description??t.subagent_description??null);const a=Ca(n);a!==null&&(t.subagent_status=a),n.subagent_resumable!==void 0&&(t.subagent_resumable=n.subagent_resumable??t.subagent_resumable??null),n.subagent_blocking!==void 0&&(t.subagent_blocking=n.subagent_blocking??t.subagent_blocking??null),n.subagent_thread_name!==void 0&&(t.subagent_thread_name=n.subagent_thread_name??t.subagent_thread_name??null),n.subagent_spawn_group_id!==void 0&&(t.subagent_spawn_group_id=n.subagent_spawn_group_id??t.subagent_spawn_group_id??null)}function oo(t,n){const a=t.workItems.filter(s=>s.type==="tool_call");return a.length===0||!a.every(s=>s.name&&sr.has(s.name))?!1:n.size>0}function lo(t,n){if(!n)return null;const a=t.workItems.find(l=>l.type==="tool_result"&&l.tool_call_id===n);if(!a||a.status!=="success")return null;const s=(a.content||"").toLowerCase();return s.includes("was initiated successfully")||s.includes("results will be delivered when complete")?!1:s.length>0?!0:null}function so(t,n,a,s){const l=Ct(n.name)??"Subagent",u=n.tool_call_id?`pending:${n.tool_call_id}`:`pending:${t.id}:${a}`,i=t.created_at+a,p=!!n.name&&sr.has(n.name);return{id:`subagent:${u}`,type:"subagent_block",subagent_id:u,subagent_name:l,subagent_title:l,subagent_description:null,subagent_status:s,subagent_resumable:!!p,subagent_blocking:p?null:!0,subagent_thread_name:Sa(n),subagent_spawn_group_id:t.id,messages:[],created_at:i,updated_at:i,depth:t.depth}}function io(t){if(t.startIndex===void 0||t.displayIndex===void 0||t.startIndex===t.displayIndex)return null;const n=t.blocks.map(u=>u.subagent_thread_name||u.subagent_title||u.subagent_name||"Subagent").filter((u,i,p)=>p.indexOf(u)===i);let a;n.length<=1?a=`Subagent started: ${n[0]||"Subagent"}`:n.length<=3?a=`Subagents started: ${n.join(", ")}`:a=`Subagents started: ${n.length} subagents`;const s=Math.min(...t.blocks.map(u=>u.created_at))||Date.now()*1e3,l=t.blocks[0]?.depth;return{id:`subagent-start:${t.groupKey}`,type:"status",role:"system",content:a,created_at:s,status_kind:"subagent_started",silent:!1,depth:l}}function uo(t){return t?.subagent_thread_name||t?.subagent_title||t?.subagent_name||"Subagent"}function co(t,n){if(!t.content)return null;const a=t.content,s=uo(n);let l=null;return/has returned the following result/i.test(a)?l=`Subagent replied: ${s}`:(/has reported a failure/i.test(a)||/execution stopped before completion/i.test(a))&&(l=`Subagent failed: ${s}`),l?{id:`status:subagent-event:${t.id}`,type:"status",role:"system",content:l,created_at:t.created_at,depth:t.depth,silent:!1,status_kind:"subagent_event",subagent_id:n?.subagent_id??t.subagent_id??null}:null}function po(t){if(t.blocks.length===1)return t.blocks[0];const n=[...t.blocks].sort((a,s)=>{const l=(a.subagent_thread_name||a.subagent_title||a.subagent_name||"").toLowerCase(),u=(s.subagent_thread_name||s.subagent_title||s.subagent_name||"").toLowerCase();return l!==u?l.localeCompare(u):a.created_at-s.created_at});return{id:`subagent-group:${t.groupKey}`,type:"subagent_group_block",group_id:t.groupKey,subagents:n,created_at:Math.min(...n.map(a=>a.created_at)),updated_at:Math.max(...n.map(a=>a.updated_at)),depth:n[0]?.depth}}function mo(t,n={}){if(t.length===0)return[];const s=n.includeWorkblocks??!1?_a(t):t,l=new Map;for(const E of t){if(E.role!=="tool"||!E.tool_call_id)continue;const L=Dt(E);L&&l.set(E.tool_call_id,L)}const u=new Map,i=new Map,p=new Map,x=[],k=new Set,h=new Map;s.forEach((E,L)=>{if(h.set(E.id,L),!fr(E))return;const V=new Set,A=E.workItems.filter(ee=>ee.type==="tool_call"),G=[];for(const ee of A){if(!to(ee.name))continue;const ie=ro(ee,l);if(!ie){ee.status==="pending"&&G.push(ee);continue}V.add(ie),u.has(ie)||u.set(ie,L);const be=Sa(ee);be&&!i.has(ie)&&i.set(ie,be);const Q=p.get(ie)??{resumable:null,blocking:null};if((ee.name==="subagent_create"||ee.name==="subagent_message"||ee.name==="send_to_agent")&&(Q.resumable=!0),ee.name==="subagent_create"){const U=lo(E,ee.tool_call_id);U!==null&&(Q.blocking=U)}p.set(ie,Q)}G.length>0&&G.forEach((ee,ie)=>{const Q=so(E,ee,ie,ie===0?"running":"pending");x.push({block:Q,startIndex:L,displayIndex:L,groupKey:`start:${L}`})}),oo(E,V)&&k.add(L)});const g=new Map,y=new Set;for(const E of t){const L=Dt(E);L&&Qn(E)&&y.add(L)}for(const E of t){const L=Dt(E);if(!L||!y.has(L))continue;const V=g.get(L);V?no(V,E):g.set(L,ao(L,E))}if(g.size===0&&x.length===0)return s.map(E=>{if(Br(E)||fr(E))return E;const L=E;return wr(L)?qr(L):L});const _=[],v=[];for(const[E,L]of g){const V=i.get(E);!L.subagent_thread_name&&V&&(L.subagent_thread_name=V);const A=p.get(E);L.subagent_resumable===null&&A?.resumable!==null&&A?.resumable!==void 0&&(L.subagent_resumable=A.resumable),L.subagent_blocking===null&&A?.blocking!==null&&A?.blocking!==void 0&&(L.subagent_blocking=A.blocking);let G=u.get(E),ee;for(const be of L.messages){const Q=h.get(be.id);Q!==void 0&&(ee===void 0||Q>ee)&&(ee=Q)}if(G===void 0&&L.subagent_spawn_group_id&&(G=h.get(L.subagent_spawn_group_id)),ee===void 0&&(G!==void 0?ee=G:L.subagent_spawn_group_id&&(ee=h.get(L.subagent_spawn_group_id))),G===void 0&&ee!==void 0&&(G=ee),ee===void 0){v.push(L);continue}const ie=L.subagent_spawn_group_id?`spawn:${L.subagent_spawn_group_id}`:G!==void 0?`start:${G}`:`subagent:${E}`;_.push({block:L,startIndex:G,displayIndex:ee,groupKey:ie})}for(const E of x)_.push(E);const d=new Map;for(const E of _){const L=d.get(E.groupKey);if(!L){d.set(E.groupKey,{groupKey:E.groupKey,startIndex:E.startIndex,displayIndex:E.displayIndex,blocks:[E.block]});continue}L.startIndex===void 0&&(L.startIndex=E.startIndex),E.startIndex!==void 0&&L.startIndex!==void 0&&(L.startIndex=Math.min(L.startIndex,E.startIndex)),L.displayIndex===void 0&&(L.displayIndex=E.displayIndex),E.displayIndex!==void 0&&L.displayIndex!==void 0&&(L.displayIndex=Math.max(L.displayIndex,E.displayIndex)),L.blocks.push(E.block)}const b=new Map,c=new Map,f=new Map;for(const E of d.values()){const L=po(E);if(E.displayIndex!==void 0){const A=b.get(E.displayIndex)??[];A.push(L),b.set(E.displayIndex,A)}const V=io(E);if(V&&E.startIndex!==void 0){const A=c.get(E.startIndex)??[];A.push(V),c.set(E.startIndex,A)}}for(const E of t){const L=Dt(E);if(!L)continue;const V=h.get(E.id);if(V===void 0)continue;const A=g.get(L),G=co(E,A);if(!G)continue;const ee=f.get(V)??[];ee.push(G),f.set(V,ee)}for(const[E,L]of b)L.sort((V,A)=>V.created_at-A.created_at),b.set(E,L);for(const[E,L]of c)L.sort((V,A)=>V.created_at-A.created_at),c.set(E,L);for(const[E,L]of f)L.sort((V,A)=>V.created_at-A.created_at),f.set(E,L);v.sort((E,L)=>E.created_at-L.created_at);const $=[],N=new Set;for(let E=0;E<s.length;E++){const L=c.get(E)??[];for(const ie of L)$.push(ie);const V=f.get(E)??[];for(const ie of V)$.push(ie);const A=b.get(E)??[];for(const ie of A)if(ie.type==="subagent_group_block"){const be=ie;for(const Q of be.subagents)N.add(Q.subagent_id);$.push(be)}else{const be=ie;N.has(be.subagent_id)||($.push(be),N.add(be.subagent_id))}const G=s[E];if(Br(G)){$.push(G);continue}if(fr(G)){if(k.has(E))continue;$.push(G);continue}const ee=G;if(wr(ee)){$.push(qr(ee));continue}Dt(ee)||$.push(ee)}for(const E of v)N.has(E.subagent_id)||($.push(E),N.add(E.subagent_id));return $}var Ia=Symbol("StandardAgents"),Ta=Symbol("Thread"),vo={install(t,n){if(!n?.endpoint)throw new Error("StandardAgentsPlugin requires an endpoint option");const s={client:new wa(n.endpoint),endpoint:n.endpoint};t.provide(Ia,s)}};function fo(){const t=da(Ia);if(!t)throw new Error("useStandardAgents must be used within a component where StandardAgentsPlugin is installed");return t}var Fr=new Zn;function go(t){return new Promise((n,a)=>{const s=new FileReader;s.onload=()=>{const u=s.result.split(",")[1];n(u)},s.onerror=()=>a(new Error("Failed to read file")),s.readAsDataURL(t)})}function ho(t,n={}){const{preload:a=!0,live:s=!0,useWorkblocks:l=!1,useSubagentBlocks:u=!1,depth:i=0,includeSilent:p=!1,endpoint:x}=n,k=q(()=>rn(t)),h=fo(),g=x?new wa(x):h.client,y={preload:a,live:s,useWorkblocks:l,useSubagentBlocks:u,depth:i,includeSilent:p},_=m([]),v=m("disconnected"),d=m(a),b=m(null),c=m([]),f=m([]),$=m([]),N=q(()=>{const ne=new Set(f.value.map(_e=>_e.path));return[...c.value.filter(_e=>!_e.path||!ne.has(_e.path)),...f.value]}),E=new Map;let L=null;const V=q(()=>l?_a(_.value):_.value),A=q(()=>u?mo(_.value,{includeWorkblocks:l}):_.value),G=q(()=>u?A.value:l?V.value:_.value);async function ee(){d.value=!0,b.value=null;try{const ne=await g.getMessages(k.value,{depth:i,includeSilent:p});_.value=ne}catch(ne){b.value=ne instanceof Error?ne:new Error(String(ne))}finally{d.value=!1}}async function ie(){try{const ne=await g.listFiles(k.value);f.value=ne.filter(ke=>!ke.isDirectory).map(ke=>({id:ke.path,name:ke.name,path:ke.path,mimeType:ke.mimeType,size:ke.size,isImage:ke.mimeType.startsWith("image/"),status:"committed",localPreviewUrl:null}))}catch(ne){console.error("Failed to load files:",ne)}}function be(ne){if(ne.file.isDirectory)return;const ke={id:ne.path,name:ne.file.name,path:ne.path,mimeType:ne.file.mimeType,size:ne.file.size,isImage:ne.file.mimeType?.startsWith("image/")||!1,status:"committed",localPreviewUrl:null},_e=f.value.findIndex(O=>O.path===ne.path);_e>=0?f.value[_e]=ke:f.value=[...f.value,ke]}function Q(ne){if(ne.file.isDirectory)return;const ke={id:ne.path,name:ne.file.name,path:ne.path,mimeType:ne.file.mimeType,size:ne.file.size,isImage:ne.file.mimeType?.startsWith("image/")||!1,status:"committed",localPreviewUrl:null},_e=f.value.findIndex(O=>O.path===ne.path);_e>=0?f.value[_e]=ke:f.value=[...f.value,ke]}function U(ne){f.value=f.value.filter(ke=>ke.path!==ne.path)}function R(){s&&(L=new Hn(g,k.value,{onStatusChange:ne=>{v.value=ne},onMessage:ne=>{if(ne.type==="message_data"){const ke=_.value.findIndex(_e=>_e.id===ne.data.id);ke>=0?_.value[ke]=ne.data:_.value=[..._.value,ne.data]}},onChunk:ne=>{const ke=_.value.findIndex(_e=>_e.id===ne.message_id);if(ke>=0){const _e=_.value[ke];_.value[ke]={..._e,content:(_e.content||"")+ne.chunk}}},onEvent:ne=>{ne.eventType==="file_created"?be(ne.data):ne.eventType==="file_updated"?Q(ne.data):ne.eventType==="file_deleted"&&U(ne.data);const ke=E.get(ne.eventType);ke&&ke.forEach(_e=>{try{_e(ne.data)}catch(O){console.error(`Error in event listener for "${ne.eventType}":`,O)}})},onError:ne=>{b.value=ne instanceof Error?ne:new Error(String(ne))}},{depth:i,includeSilent:p}),L.connect())}async function K(ne){const ke=`optimistic-${crypto.randomUUID()}`,_e=$.value.map(z=>({id:z.id,type:"file",path:"",name:z.name,mimeType:z.mimeType,size:z.size,width:z.width,height:z.height,localPreviewUrl:z.previewUrl||void 0})),O={id:ke,role:ne.role,content:ne.content,attachments:_e.length>0?JSON.stringify(_e):null,created_at:Date.now()*1e3,status:"pending"};_.value=[..._.value,O];const j=[...$.value];$.value=[];try{const z=await Promise.all(j.map(async P=>({name:P.name,mimeType:P.mimeType,data:await go(P.file),width:P.width,height:P.height}))),M=await g.sendMessage(k.value,{...ne,attachments:z.length>0?z:void 0});return _.value=_.value.filter(P=>P.id!==ke),j.forEach(P=>{P.previewUrl&&URL.revokeObjectURL(P.previewUrl)}),M}catch(z){throw $.value=j,_.value=_.value.filter(M=>M.id!==ke),b.value=z instanceof Error?z:new Error(String(z)),z}}async function H(){try{await g.stopExecution(k.value)}catch(ne){throw b.value=ne instanceof Error?ne:new Error(String(ne)),ne}}async function ve(ne){const ke=[..._.value];_.value=_.value.filter(_e=>_e.id!==ne);try{await g.deleteMessage(k.value,ne)}catch(_e){throw _.value=ke,b.value=_e instanceof Error?_e:new Error(String(_e)),_e}}function X(ne){const ke=Fr.queueFiles(ne);c.value=[...c.value,...ke.map(_e=>_e.pending)];for(const{pending:_e,file:O}of ke)Fr.executeUpload(k.value,O,_e.id,g,j=>{c.value=c.value.map(z=>z.id===_e.id?{...z,...j}:z)}).catch(()=>{})}function D(ne){c.value=c.value.filter(ke=>ke.id!==ne)}function W(ne){return ne.path?g.getFileUrl(k.value,ne.path):""}function me(ne){return ne.path?g.getThumbnailUrl(k.value,ne.path):""}function ue(ne){return ne.isImage?ne.localPreviewUrl?ne.localPreviewUrl:ne.path?me(ne):null:null}function te(ne){const _e=(ne instanceof FileList?Array.from(ne):Array.isArray(ne)?ne:[ne]).map(O=>{const j=O.type.startsWith("image/");return{id:crypto.randomUUID(),file:O,name:O.name,mimeType:O.type,size:O.size,isImage:j,previewUrl:j?URL.createObjectURL(O):null}});$.value=[...$.value,..._e]}function Y(ne){const ke=$.value.find(_e=>_e.id===ne);ke?.previewUrl&&URL.revokeObjectURL(ke.previewUrl),$.value=$.value.filter(_e=>_e.id!==ne)}function ae(){$.value.forEach(ne=>{ne.previewUrl&&URL.revokeObjectURL(ne.previewUrl)}),$.value=[]}function ye(ne,ke){return E.has(ne)||E.set(ne,new Set),E.get(ne).add(ke),()=>{const _e=E.get(ne);_e&&(_e.delete(ke),_e.size===0&&E.delete(ne))}}function Te(){L?.disconnect(),L=null,v.value="disconnected"}return Ee(k,(ne,ke)=>{ne!==ke&&(Te(),_.value=[],b.value=null,c.value=[],f.value=[],$.value.forEach(_e=>{_e.previewUrl&&URL.revokeObjectURL(_e.previewUrl)}),$.value=[],a&&ee(),ie(),R())}),qe(()=>{a&&ee(),ie(),R()}),ut(()=>{L?.disconnect(),E.clear(),$.value.forEach(ne=>{ne.previewUrl&&URL.revokeObjectURL(ne.previewUrl)})}),{threadId:k,options:y,messages:_,workblocks:V,subagentBlocks:A,groupedMessages:G,status:v,connectionStatus:v,isLoading:d,loading:d,error:b,sendMessage:K,stopExecution:H,deleteMessage:ve,onEvent:ye,subscribeToEvent:ye,files:N,addFiles:X,removeFile:D,getFileUrl:W,getThumbnailUrl:me,getPreviewUrl:ue,attachments:$,addAttachment:te,removeAttachment:Y,clearAttachments:ae}}var bo=Ce({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},useSubagentBlocks:{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:n}){const a={};t.preload!==void 0&&(a.preload=t.preload),t.live!==void 0&&(a.live=t.live),t.useWorkblocks!==void 0&&(a.useWorkblocks=t.useWorkblocks),t.useSubagentBlocks!==void 0&&(a.useSubagentBlocks=t.useSubagentBlocks),t.depth!==void 0&&(a.depth=t.depth),t.includeSilent!==void 0&&(a.includeSilent=t.includeSilent),t.endpoint!==void 0&&(a.endpoint=t.endpoint);const s=ho(()=>t.threadId,a);return an(Ta,s),()=>n.default?.()}});function Ma(){const t=da(Ta);if(!t)throw new Error('useThread must be used within a <ThreadProvider>. Wrap your component with <ThreadProvider threadId="...">.');return t}function xo(t,n){const a=`${n.props.type}__${t}`,s=`formkit-${t}`,l=n.props.family?`family:${n.props.family}__${t}`:"",u=`${a}__${l}`;if(!(u in zt)){const i=zt[a]??yo[t]??{};i[s]=!0,l in zt?zt[u]={...zt[l],...i}:zt[u]=i}return zt[u]??{[s]:!0}}const zt={"family:button__wrapper":{"group-data-[disabled=true]:grayscale":!0},"family:button__input":{"appearance-none":!0,"[color-scheme:light]":!0,"dark:[color-scheme:dark]":!0,"selection:bg-accent-100":!0,"selection:text-zinc-700":!0,"group-data-[has-overlay]:selection:!text-transparent":!0,"font-bold":!0,"rounded-sm":!0,"outline-hidden":!0,flex:!0,"!text-xs":!0,"px-7":!0,"py-3":!0,"items-center":!0,"mb-1.5":!0,"text-xs":!0,"ring-accent-400":!0,"focus-visible:ring-2":!0,"focus-visible:ring-offset-2":!0,"group-data-[disabled]:!cursor-not-allowed":!0,"shadow-none":!0,"group-data-[prefix-icon]:pl-5":!0,"group-data-[suffix-icon]:pr-5":!0,border:!0,"border-accent-500":!0,"text-accent-500":!0,"group-[&]/repeater:shadow-none":!0,"group-[&]/multistep:shadow-none":!0,"dark:border-accent-500":!0},"family:box__wrapper":{"inline-flex":!0,"items-center":!0,"mb-1":!0,"group-data-[multiple]:mb-0":!0},"family:box__legend":{block:!0,"text-zinc-700":!0,"text-xs":!0,"font-bold":!0,"dark:text-zinc-300":!0,"mb-2":!0},"family:box__input":{"appearance-none":!0,"[color-scheme:light]":!0,"dark:[color-scheme:dark]":!0,"selection:bg-accent-100":!0,"selection:text-zinc-700":!0,"group-data-[has-overlay]:selection:!text-transparent":!0,peer:!0,"pointer-events-none":!0,absolute:!0,"h-0":!0,"w-0":!0,"overflow-hidden":!0,"opacity-0":!0},"family:box__decorator":{"mr-1.5":!0,"bg-white":!0,"ring-accent-400":!0,"peer-checked:border-accent-500":!0,relative:!0,block:!0,"text-base":!0,"w-[1em]":!0,"aspect-[1/1]":!0,border:!0,"border-zinc-300":!0,"text-transparent":!0,"peer-checked:bg-accent-50":!0,"peer-checked:text-accent-500":!0,"peer-focus-visible:ring-2":!0,"peer-focus-visible:ring-offset-1":!0,"select-none":!0,"group-data-[disabled]:!cursor-not-allowed":!0,"peer-disabled:bg-zinc-100":!0,"group-data-[disabled]:grayscale":!0,"shadow-none":!0,"peer-disabled:cursor-not-allowed":!0,"group-[&]/repeater:shadow-none":!0,"group-[&]/multistep:shadow-none":!0,"dark:border-zinc-700":!0,"dark:bg-transparent":!0,"dark:ring-offset-accent-400":!0,"dark:peer-focus-visible:ring-1":!0,"dark:peer-disabled:bg-zinc-600/50":!0,"dark:peer-checked:bg-accent-800":!0,"dark:peer-checked:text-accent-300":!0},"family:box__decoratorIcon":{absolute:!0,"left-1/2":!0,"top-1/2":!0,flex:!0,"h-full":!0,"w-full":!0,"-translate-x-1/2":!0,"-translate-y-1/2":!0},"family:box__option":{"mb-1.5":!0,"last:mb-0":!0,"data-[disabled]:opacity-50":!0,"data-[disabled]:select-none":!0,"group-data-[disabled]:data-[disabled]:opacity-100":!0},"family:box__label":{block:!0,"text-zinc-700":!0,"text-xs":!0,"font-bold":!0,"mb-1":!0,"!mb-0":!0,"!font-normal":!0,"!text-sm":!0,"dark:text-zinc-300":!0},"family:box__optionHelp":{"text-zinc-500":!0,"text-[11px]":!0,"[line-height:1em]":!0,"-mt-1":!0,"mb-1.5":!0,"ml-[min(2em,1.7rem)]":!0,relative:!0,"left-px":!0},"family:box__help":{"text-zinc-500":!0,"text-[11px]":!0,"[line-height:1em]":!0,"dark:text-zinc-400":!0,"mb-1":!0,"group-data-[multiple]:mb-2":!0,"group-data-[multiple]:-mt-1.5":!0},"family:text__wrapper":{flex:!0,"flex-col":!0,"items-start":!0,"justify-start":!0,"mb-1.5":!0,"last:mb-0":!0},"family:text__label":{block:!0,"text-zinc-700":!0,"text-xs":!0,"font-bold":!0,"dark:text-zinc-300":!0,"!inline-flex":!0,"mb-1":!0},"family:text__inner":{"text-sm":!0,flex:!0,"items-center":!0,"w-full":!0,"py-2":!0,"px-3":!0,"rounded-sm":!0,border:!0,"border-zinc-300":!0,"bg-white":!0,"focus-within:ring-1":!0,"focus-within:!ring-accent-400":!0,"focus-within:!border-accent-400":!0,"group-data-[invalid]:border-red-400":!0,"group-data-[invalid]:ring-1":!0,"group-data-[invalid]:ring-red-400":!0,"group-data-[disabled]:bg-zinc-100":!0,"group-data-[disabled]:!cursor-not-allowed":!0,"shadow-none":!0,"group-[&]/repeater:shadow-none":!0,"group-[&]/multistep:shadow-none":!0,"dark:bg-transparent":!0,"dark:border-zinc-700":!0,"dark:group-data-[disabled]:bg-zinc-800/5":!0,"dark:group-data-[invalid]:border-red-400":!0,"dark:group-data-[invalid]:ring-red-400":!0},"family:text__input":{"appearance-none":!0,"[color-scheme:light]":!0,"dark:[color-scheme:dark]":!0,"selection:text-zinc-700":!0,"group-data-[has-overlay]:selection:!text-transparent":!0,"text-sm":!0,"text-zinc-700":!0,"min-w-0":!0,"min-h-[1.5em]":!0,grow:!0,"outline-hidden":!0,"bg-transparent":!0,"selection:bg-accent-100":!0,"placeholder:text-zinc-400":!0,"group-data-[disabled]:!cursor-not-allowed":!0,"dark:placeholder-zinc-400/50":!0,"dark:text-zinc-300":!0,"border-none":!0,"p-0":!0,"focus:ring-0":!0},"family:text__prefixIcon":{flex:!0,"items-center":!0,"-ml-1":!0,"mr-2":!0,"text-sm":!0,"h-[1em]":!0,"w-[1em]":!0,"shrink-0":!0,"[&>svg]:w-full":!0,"text-zinc-600":!0,"dark:text-zinc-300":!0},"family:text__suffixIcon":{flex:!0,"items-center":!0,"-mr-1":!0,"ml-2":!0,"text-sm":!0,"h-[1em]":!0,"w-[1em]":!0,"shrink-0":!0,"[&>svg]:w-full":!0,"text-zinc-600":!0,"dark:text-zinc-300":!0},"family:dropdown__wrapper":{"mb-1.5":!0},"family:dropdown__inner":{relative:!0,flex:!0,"items-center":!0,"w-full":!0,"py-2":!0,"px-3":!0,"text-sm":!0,"bg-white":!0,border:!0,"border-zinc-300":!0,"rounded-sm":!0,"group-data-[is-multiline]:!rounded-sm":!0,"focus-within:ring-1":!0,"focus-within:!ring-accent-400":!0,"focus-within:!border-accent-400":!0,"group-data-[invalid]:border-red-400":!0,"group-data-[invalid]:ring-1":!0,"group-data-[invalid]:ring-red-400":!0,"group-data-[disabled]:bg-zinc-100":!0,"group-data-[disabled]:!cursor-not-allowed":!0,"shadow-none":!0,"group-[&]/repeater:shadow-none":!0,"group-[&]/multistep:shadow-none":!0,"dark:bg-transparent":!0,"dark:border-zinc-700":!0,"dark:group-data-[disabled]:bg-zinc-700/40":!0,"dark:group-data-[invalid]:border-red-400":!0,"dark:group-data-[invalid]:ring-red-400":!0},"family:dropdown__input":{"appearance-none":!0,"[color-scheme:light]":!0,"dark:[color-scheme:dark]":!0,"selection:text-zinc-700":!0,"group-data-[has-overlay]:selection:!text-transparent":!0,grow:!0,"p-2":!0,"pr-0":!0,"pl-3":!0,"text-sm":!0,"text-zinc-700":!0,"text-ellipsis":!0,"min-w-0":!0,"outline-hidden":!0,"bg-transparent":!0,"group-data-[disabled]:!cursor-not-allowed":!0,"group-data-[prefix-icon]:!pl-0":!0,"group-data-[suffix-icon]:!pr-0":!0,"placeholder:text-zinc-400":!0,"selection:bg-accent-100":!0,"dark:placeholder:text-zinc-500":!0,"dark:text-zinc-300":!0,"border-none":!0,"focus:ring-0":!0,"bg-none":!0},"family:dropdown__listboxButton":{"w-[2.5em]":!0,"self-stretch":!0,"text-sm":!0,flex:!0,"items-center":!0,"text-zinc-700":!0,"z-10":!0,"dark:text-zinc-300":!0,"data-[disabled]:cursor-not-allowed":!0},"family:dropdown__removeSelection":{"w-[2.5em]":!0,"self-stretch":!0,"text-sm":!0,flex:!0,"items-center":!0,"text-zinc-700":!0,"hover:text-red-400":!0,"z-10":!0,"dark:text-zinc-300":!0},"family:dropdown__controlLabel":{absolute:!0,"opacity-0":!0,"pointer-events-none":!0,"text-[0px]":!0},"family:dropdown__selectIcon":{"text-sm":!0,"inline-flex":!0,"justify-center":!0,"w-[2.5em]":!0,relative:!0,"my-auto":!0,"[&>svg]:w-[1em]":!0,"[&>svg]:mx-auto":!0},"family:dropdown__closeIcon":{"text-sm":!0,"w-[0.75em]":!0,relative:!0,"m-auto":!0},"family:dropdown__prefixIcon":{flex:!0,"items-center":!0,"-ml-1":!0,"mr-2":!0,"text-sm":!0,"h-[1em]":!0,"w-[1em]":!0,"shrink-0":!0,"[&>svg]:w-full":!0,"!ml-2":!0,"!mr-0":!0,"text-zinc-600":!0,"dark:text-zinc-300":!0},"family:dropdown__suffixIcon":{flex:!0,"items-center":!0,"-mr-1":!0,"ml-2":!0,"text-sm":!0,"h-[1em]":!0,"w-[1em]":!0,"shrink-0":!0,"[&>svg]:w-full":!0,"!mr-2":!0,"!ml-0":!0,"text-zinc-600":!0,"dark:text-zinc-300":!0},"family:dropdown__dropdownWrapper":{"rounded-sm":!0,"shadow-md":!0,"mt-1":!0,"overflow-clip":!0,"empty:hidden":!0,border:!0,"border-zinc-200":!0,"dark:border-zinc-700":!0,"group-data-[expanded]:opacity-100":!0,"group-data-[overscroll]:m-0":!0,"group-data-[overscroll]:shadow-none":!0,"group-data-[overscroll]:border-none":!0},"family:dropdown__listitemGroup":{"group/optgroup":!0,"last:pb-0":!0,"border-t":!0,"border-b":!0,"-mb-px":!0,"border-zinc-200":!0,"dark:border-zinc-700":!0},"family:dropdown__groupLabel":{block:!0,"pt-1.5":!0,"pb-1":!0,"px-2.5":!0,"font-bold":!0,"pointer-events-none":!0,"text-zinc-500":!0,"dark:text-zinc-500":!0},"family:dropdown__listbox":{"bg-white":!0,"rounded-sm":!0,"empty:hidden":!0,"dark:bg-zinc-800":!0,"group-data-[overscroll]:shadow-md":!0,"group-data-[overscroll]:border":!0,"group-data-[overscroll]:border-zinc-200":!0,"group-data-[overscroll]:dark:border-zinc-700":!0},"family:dropdown__listitem":{relative:!0,flex:!0,"items-center":!0,"px-2":!0,"py-1.5":!0,"first:pt-2":!0,"last:pb-2":!0,"text-zinc-700":!0,"text-sm":!0,"data-[is-active]:bg-accent-100":!0,"dark:text-zinc-200":!0,"dark:data-[is-active]:text-zinc-700":!0,"before:content-['']":!0,"before:absolute":!0,"before:inset-0":!0,"data-[is-active]:first:before:rounded-sm":!0,"data-[is-active]:first:before:rounded-b-none":!0,"data-[is-active]:last:before:rounded-sm":!0,"data-[is-active]:last:before:rounded-t-none":!0,"data-[is-active]:first:last:before:rounded-sm":!0,"data-[is-active]:before:ring-1":!0,"data-[is-active]:before:ring-accent-400":!0,"data-[is-active]:before:ring-inset":!0,"data-[is-active]:before:ring-offset-accent-100":!0,"group-[&]/optgroup:first:before:!rounded-none":!0,"group-[&]/optgroup:last:before:!rounded-none":!0},"family:dropdown__selectedIcon":{flex:!0,absolute:!0,"items-center":!0,"text-accent-500":!0,"left-2":!0,"text-sm":!0,"h-[1em]":!0,"w-[1em]":!0,"shrink-0":!0,"[&>svg]:w-full":!0},"family:dropdown__option":{"ml-[1.5em]":!0},"family:dropdown__loadMore":{"data-[is-active]:bg-accent-100":!0},"family:dropdown__loadMoreInner":{flex:!0,"text-xs":!0,"text-zinc-500":!0,"p-2":!0,"items-center":!0,"justify-center":!0,"[&>span]:mr-2":!0,"cursor-pointer":!0,"dark:text-zinc-200":!0,"dark:hover:text-accent-400":!0},"family:dropdown__selectionWrapper":{grow:!0,flex:!0,"items-center":!0,"text-zinc-700":!0},"family:dropdown__selection":{grow:!0,"text-zinc-700":!0,"group-data-[multiple]:p-2":!0,"dark:text-zinc-300":!0},"family:dropdown__tagsWrapper":{"w-full":!0},"family:dropdown__tagWrapper":{"group/tag":!0,"rounded-sm":!0,"mr-1":!0,"mb-1":!0,"outline-hidden":!0,"data-[active-selection=true]:ring-2":!0,"data-[active-selection=true]:ring-accent-400":!0},"family:dropdown__tags":{"inline-flex":!0,"flex-wrap":!0,"items-center":!0,"w-full":!0,"-mb-1":!0,"empty:mb-0":!0},"family:dropdown__tag":{flex:!0,"items-center":!0,"cursor-default":!0,"rounded-sm":!0,"text-xs":!0,"px-1.5":!0,"py-0.5":!0,"bg-accent-500":!0,"text-white":!0,"[&>[type=button]]:!w-[0.5em]":!0,"[&>[type=button]]:aspect-[1/1]":!0,"[&>[type=button]]:!text-inherit":!0,"[&>[type=button]]:cursor-pointer":!0,"group-data-[active-selection=true]/tag:bg-accent-300":!0,"group-data-[active-selection=true]/tag:text-zinc-700":!0},"family:dropdown__tagLabel":{"mr-1":!0},"family:dropdown__emptyMessage":{flex:!0,"items-center":!0,"px-2":!0,"py-1.5":!0,"first:pt-2":!0,"last:pb-2":!0,"text-zinc-700":!0,"text-xs":!0,"aria-selected:text-white":!0,"aria-selected:bg-accent-500":!0},button__input:{"appearance-none":!0,"[color-scheme:light]":!0,"dark:[color-scheme:dark]":!0,"selection:bg-accent-100":!0,"selection:text-zinc-700":!0,"group-data-[has-overlay]:selection:!text-transparent":!0,"bg-accent-50":!0,"hover:bg-accent-100":!0,"dark:text-accent-500":!0,"dark:bg-transparent":!0,"dark:hover:bg-accent-50/5":!0},checkbox__decorator:{"rounded-sm":!0},checkbox__decoratorIcon:{"max-w-[66.66%]":!0},color__inner:{"!w-auto":!0,"!p-1.5":!0,"!inline-flex":!0,"group-data-[prefix-icon]:border":!0,"group-data-[prefix-icon]:border-zinc-300":!0,"group-data-[suffix-icon]:border":!0,"group-data-[suffix-icon]:border-zinc-300":!0,"dark:group-data-[prefix-icon]:border-zinc-700":!0,"dark:group-data-[suffix-icon]:border-zinc-700":!0},color__input:{"appearance-none":!0,"[color-scheme:light]":!0,"dark:[color-scheme:dark]":!0,"selection:bg-accent-100":!0,"selection:text-zinc-700":!0,"group-data-[has-overlay]:selection:!text-transparent":!0,"!w-14":!0,"bg-transparent":!0,"cursor-pointer":!0,"rounded-sm":!0,"overflow-clip":!0,"[&::-webkit-color-swatch-wrapper]:p-0":!0,"[&::-webkit-color-swatch]:border-none":!0,"[&::-moz-color-swatch]:border-none":!0,"group-data-[prefix-icon]:mx-2":!0,"group-data-[suffix-icon]:mx-2":!0},color__prefixIcon:{flex:!0,"items-center":!0,"-ml-1":!0,"mr-2":!0,"text-sm":!0,"h-[1em]":!0,"w-[1em]":!0,"shrink-0":!0,"[&>svg]:w-full":!0,"group-data-[prefix-icon]:m-1.5":!0,"group-data-[prefix-icon]:mr-0":!0},color__suffixIcon:{flex:!0,"items-center":!0,"-mr-1":!0,"ml-2":!0,"text-sm":!0,"h-[1em]":!0,"w-[1em]":!0,"shrink-0":!0,"[&>svg]:w-full":!0,"group-data-[suffix-icon]:m-1.5":!0,"group-data-[prefix-icon]:ml-0":!0},date__input:{"appearance-none":!0,"[color-scheme:light]":!0,"dark:[color-scheme:dark]":!0,"selection:bg-accent-100":!0,"selection:text-zinc-700":!0,"group-data-[has-overlay]:selection:!text-transparent":!0,"focus:[&::-webkit-datetime-edit-day-field]:bg-accent-100":!0,"focus:[&::-webkit-datetime-edit-month-field]:bg-accent-100":!0,"focus:[&::-webkit-datetime-edit-year-field]:bg-accent-100":!0},"datetime-local__input":{"appearance-none":!0,"[color-scheme:light]":!0,"dark:[color-scheme:dark]":!0,"selection:bg-accent-100":!0,"selection:text-zinc-700":!0,"group-data-[has-overlay]:selection:!text-transparent":!0,"focus:[&::-webkit-datetime-edit-day-field]:bg-accent-100":!0,"focus:[&::-webkit-datetime-edit-month-field]:bg-accent-100":!0,"focus:[&::-webkit-datetime-edit-year-field]:bg-accent-100":!0,"focus:[&::-webkit-datetime-edit-hour-field]:bg-accent-100":!0,"focus:[&::-webkit-datetime-edit-minute-field]:bg-accent-100":!0,"focus:[&::-webkit-datetime-edit-ampm-field]:bg-accent-100":!0},file__fileList:{"group/list":!0,peer:!0,"w-full":!0,"min-w-0":!0,"data-[has-multiple]:mb-[1.25em]":!0},file__fileItemIcon:{"h-[1em]":!0,"w-[1em]":!0,"mr-2":!0,"shrink-0":!0},file__fileItem:{flex:!0,"min-w-0":!0,"items-center":!0,"text-zinc-700":!0,"mb-1.5":!0,"last:mb-0":!0,"dark:text-zinc-300":!0},file__fileName:{truncate:!0,"min-w-0":!0,"w-full":!0,shrink:!0,"leading-5":!0,"group-data-[has-multiple]/list:text-xs":!0},file__fileRemove:{"right-2":!0,"ring-accent-400":!0,"rounded-sm":!0,"z-20":!0,flex:!0,"appearance-none":!0,"items-center":!0,"text-[0px]":!0,"outline-hidden":!0,"hover:!text-red-400":!0,"focus-visible:ring-2":!0,"group-data-[disabled]:pointer-events-none":!0,"group-data-[disabled]:!text-zinc-500":!0,"peer-data-[has-multiple]:absolute":!0,"peer-data-[has-multiple]:bottom-[max(0.5em,8px)]":!0,"peer-data-[has-multiple]:left-3":!0,"peer-data-[has-multiple]:text-accent-500":!0,"peer-data-[has-multiple]:text-[11px]":!0,"[line-height:1em]":!0,"peer-data-[has-multiple]:whitespace-nowrap":!0,"group-data-[prefix-icon]:peer-data-[has-multiple]:left-2":!0,"dark:hover:!text-red-400":!0},file__fileRemoveIcon:{block:!0,"text-base":!0,"w-[0.75em]":!0,relative:!0,"z-10":!0},file__inner:{relative:!0,"cursor-pointer":!0,"group-data-[has-multiple]:rounded-sm":!0},file__input:{"appearance-none":!0,"[color-scheme:light]":!0,"dark:[color-scheme:dark]":!0,"selection:bg-accent-100":!0,"selection:text-zinc-700":!0,"group-data-[has-overlay]:selection:!text-transparent":!0,"cursor-pointer":!0,"text-transparent":!0,absolute:!0,"inset-0":!0,"opacity-0":!0,"z-10":!0,"file:pointer-events-none":!0,"file:w-0":!0,"file:h-0":!0,"file:overflow-hidden":!0},file__noFiles:{flex:!0,"w-full":!0,"items-center":!0,"text-zinc-400":!0,"dark:text-zinc-500":!0},file__noFilesIcon:{"w-[1em]":!0,"mr-2":!0},form__form:{"group/form":!0},form__actions:{"":!0},form__summaryInner:{"group/summary":!0,border:!0,"border-zinc-300":!0,"bg-white":!0,"rounded-sm":!0,"py-2":!0,"px-3":!0,"shadow-none":!0,"dark:bg-transparent":!0,"dark:border-zinc-700":!0},form__summaryHeader:{"text-base":!0,"text-zinc-700":!0,"font-bold":!0,"mb-2":!0,"dark:text-zinc-300":!0},form__messages:{"":!0},form__message:{"text-red-500":!0,"mb-1.5":!0,"text-[11px]":!0,"[line-height:1em]":!0,"dark:text-red-400":!0,"group-[&]/summary:text-xs":!0},form__messageLink:{"group-[&]/summary:outline-hidden":!0,"group-[&]/summary:focus-visible:ring-2":!0,"group-[&]/summary:ring-accent-500":!0},month__input:{"appearance-none":!0,"[color-scheme:light]":!0,"dark:[color-scheme:dark]":!0,"selection:bg-accent-100":!0,"selection:text-zinc-700":!0,"group-data-[has-overlay]:selection:!text-transparent":!0,"focus:[&::-webkit-datetime-edit-month-field]:bg-accent-100":!0,"focus:[&::-webkit-datetime-edit-year-field]:bg-accent-100":!0},radio__decorator:{"rounded-full":!0},radio__decoratorIcon:{"max-w-[50%]":!0},range__inner:{relative:!0,"!border-none":!0,"!ring-0":!0,"!px-0":!0,"!bg-transparent":!0,"!shadow-none":!0},range__input:{"appearance-none":!0,"[color-scheme:light]":!0,"dark:[color-scheme:dark]":!0,"selection:bg-accent-100":!0,"selection:text-zinc-700":!0,"group-data-[has-overlay]:selection:!text-transparent":!0,"group/input":!0,"cursor-pointer":!0,"[&::-webkit-slider-runnable-track]:bg-zinc-300/50":!0,"[&::-webkit-slider-runnable-track]:h-[0.25em]":!0,"[&::-webkit-slider-runnable-track]:rounded-sm":!0,"dark:[&::-webkit-slider-runnable-track]:bg-zinc-600/50":!0,"[&::-webkit-slider-thumb]:appearance-none":!0,"[&::-webkit-slider-thumb]:w-[0.85em]":!0,"[&::-webkit-slider-thumb]:aspect-[1/1]":!0,"[&::-webkit-slider-thumb]:bg-accent-500":!0,"[&::-webkit-slider-thumb]:rounded-full":!0,"[&::-webkit-slider-thumb]:relative":!0,"[&::-webkit-slider-thumb]:top-1/2":!0,"[&::-webkit-slider-thumb]:-translate-y-1/2":!0,"[&::-webkit-slider-thumb]:group-data-[disabled]:bg-zinc-500":!0,"[&::-webkit-slider-thumb]:group-data-[disabled]:!ring-zinc-200":!0,"[&::-webkit-slider-thumb]:focus-visible:ring-2":!0,"[&::-webkit-slider-thumb]:focus:!ring-accent-400":!0,"[&::-webkit-slider-thumb]:focus:ring-offset-2":!0,"[&::-webkit-slider-thumb]:shadow-none":!0,"dark:[&::-webkit-slider-thumb]:group-data-[disabled]:!ring-zinc-700":!0,"dark:[&::-webkit-slider-thumb]:focus:ring-offset-zinc-700":!0,"[&::-moz-range-track]:bg-zinc-300/50":!0,"[&::-moz-range-track]:h-[0.25]":!0,"[&::-moz-range-track]:rounded-sm":!0,"dark:[&::-moz-range-track]:bg-zinc-600/50":!0,"[&::-moz-range-thumb]:appearance-none":!0,"[&::-moz-range-thumb]:border-none":!0,"[&::-moz-range-thumb]:w-[0.85em]":!0,"[&::-moz-range-thumb]:h-[0.85em]":!0,"[&::-moz-range-thumb]:bg-accent-500":!0,"[&::-moz-range-thumb]:rounded-full":!0,"[&::-moz-range-thumb]:group-data-[disabled]:bg-zinc-500":!0,"[&::-moz-range-thumb]:group-data-[disabled]:!ring-zinc-300":!0,"[&::-moz-range-thumb]:focus-visible:ring-2":!0,"[&::-moz-range-thumb]:focus:!ring-accent-400":!0,"[&::-moz-range-thumb]:focus:ring-offset-2":!0,"[&::-moz-range-thumb]:shadow-none":!0,"dark:[&::-moz-range-thumb]:group-data-[disabled]:!ring-zinc-500":!0,"dark:[&::-moz-range-thumb]:focus:ring-offset-zinc-700":!0},select__wrapper:{"mb-1.5":!0},select__inner:{relative:!0,flex:!0,"items-center":!0,"bg-white":!0,border:!0,"border-zinc-300":!0,"rounded-sm":!0,"focus-within:ring-1":!0,"focus-within:!ring-accent-400":!0,"focus-within:!border-accent-400":!0,"group-data-[invalid]:border-red-400":!0,"group-data-[invalid]:ring-1":!0,"group-data-[invalid]:ring-red-400":!0,"group-data-[disabled]:bg-zinc-100":!0,"group-data-[disabled]:!cursor-not-allowed":!0,"shadow-none":!0,"group-[&]/repeater:shadow-none":!0,"group-[&]/multistep:shadow-none":!0,"group-data-[multiple]:rounded-sm":!0,"dark:bg-transparent":!0,"dark:border-zinc-700":!0,"dark:group-data-[disabled]:bg-zinc-800/5":!0,"dark:group-data-[invalid]:border-red-400":!0,"dark:group-data-[invalid]:ring-red-400":!0},select__input:{"appearance-none":!0,"[color-scheme:light]":!0,"dark:[color-scheme:dark]":!0,"selection:text-zinc-700":!0,"group-data-[has-overlay]:selection:!text-transparent":!0,grow:!0,"p-2":!0,"py-2":!0,"px-3":!0,"pr-[2em]":!0,"text-sm":!0,"text-zinc-700":!0,"text-ellipsis":!0,"min-w-0":!0,"outline-hidden":!0,"bg-transparent":!0,"group-data-[disabled]:!cursor-not-allowed":!0,"group-data-[prefix-icon]:!pl-0":!0,"group-data-[suffix-icon]:!pr-0":!0,"data-[placeholder]:text-zinc-400":!0,"group-data-[multiple]:!p-0":!0,"selection:bg-accent-100":!0,"dark:data-[placeholder]:text-zinc-400/50":!0,"dark:text-zinc-300":!0,"border-none":!0,"focus:ring-0":!0,"bg-none":!0},select__selectIcon:{absolute:!0,"w-[1em]":!0,"text-zinc-700":!0,"pointer-events-none":!0,"right-2":!0,"group-data-[suffix-icon]:mr-[1.5em]":!0,"dark:text-zinc-300":!0},select__optGroup:{"bg-white":!0,"text-zinc-700":!0,"group/optgroup":!0,"group-data-[multiple]:px-1.5":!0,"pt-1.5":!0,"font-bold":!0,"text-xs":!0,"dark:bg-zinc-800":!0,"dark:text-zinc-300":!0},select__option:{"bg-white":!0,"text-zinc-700":!0,"group-data-[disabled]:opacity-50":!0,"group-data-[disabled]:select-none":!0,"group-data-[multiple]:checked:bg-accent-100":!0,"group-data-[multiple]:focus:bg-accent-100":!0,"group-data-[multiple]:text-xs":!0,"group-data-[multiple]:outline-hidden":!0,"group-data-[multiple]:border-none":!0,"group-data-[multiple]:py-1.5":!0,"group-data-[multiple]:px-2":!0,"dark:bg-zinc-800":!0,"dark:text-zinc-300":!0,"dark:group-data-[multiple]:focus:bg-accent-700":!0,"dark:group-data-[multiple]:checked:bg-accent-700":!0},select__prefixIcon:{flex:!0,"items-center":!0,"mr-2":!0,"text-sm":!0,"h-[1em]":!0,"w-[1em]":!0,"shrink-0":!0,"[&>svg]:w-full":!0,"ml-2":!0,"text-zinc-600":!0,"dark:text-zinc-300":!0},select__suffixIcon:{flex:!0,"items-center":!0,"ml-2":!0,"text-sm":!0,"h-[1em]":!0,"w-[1em]":!0,"shrink-0":!0,"[&>svg]:w-full":!0,"mr-2":!0,"text-zinc-600":!0,"dark:text-zinc-300":!0},submit__outer:{group:!0,"max-w-none":!0,"min-w-0":!0,grow:!0,"mb-4":!0,"data-[disabled]:select-none":!0,"text-sm":!0,"data-[disabled]:opacity-100":!0},submit__input:{"appearance-none":!0,"[color-scheme:light]":!0,"dark:[color-scheme:dark]":!0,"selection:bg-accent-100":!0,"selection:text-zinc-700":!0,"group-data-[has-overlay]:selection:!text-transparent":!0,"bg-accent-500":!0,"!text-white":!0,"active:text-accent-100":!0,"active:bg-accent-600":!0,"hover:bg-accent-600":!0,"disabled:border-zinc-300":!0,"disabled:bg-zinc-400":!0,"disabled:text-zinc-100":!0,"group-data-[disabled]:!cursor-not-allowed":!0,"dark:disabled:border-zinc-100":!0,"dark:disabled:bg-zinc-500":!0,"dark:disabled:text-zinc-200":!0,"dark:text-white":!0,"dark:ring-offset-accent-400":!0,"before:transition-all":!0,"group-data-[loading=true]/form:before:content['']":!0,"group-data-[loading=true]/form:before:block":!0,"group-data-[loading=true]/form:before:animate-spin":!0,"group-data-[loading=true]/form:before:w-5":!0,"group-data-[loading=true]/form:before:h-5":!0,"group-data-[loading=true]/form:before:rounded-full":!0,"group-data-[loading=true]/form:before:mr-3":!0,"group-data-[loading=true]/form:before:-ml-1.5":!0,"group-data-[loading=true]/form:before:border-2":!0,"group-data-[loading=true]/form:before:border-solid":!0,"group-data-[loading=true]/form:before:border-white":!0,"group-data-[loading=true]/form:before:border-r-transparent":!0},submit__prefixIcon:{flex:!0,"items-center":!0,"-ml-1":!0,"mr-2":!0,"text-sm":!0,"h-[1em]":!0,"w-[1em]":!0,"shrink-0":!0,"[&>svg]:w-full":!0,"text-zinc-100":!0},submit__suffixIcon:{flex:!0,"items-center":!0,"-mr-1":!0,"ml-2":!0,"text-sm":!0,"h-[1em]":!0,"w-[1em]":!0,"shrink-0":!0,"[&>svg]:w-full":!0,"text-zinc-100":!0},textarea__inner:{flex:!0,"items-center":!0,"mb-1.5":!0,"bg-white":!0,border:!0,"border-zinc-300":!0,"rounded-sm":!0,"focus-within:ring-1":!0,"focus-within:!ring-accent-400":!0,"focus-within:!border-accent-400":!0,"group-data-[invalid]:border-red-400":!0,"group-data-[invalid]:ring-1":!0,"group-data-[invalid]:ring-red-400":!0,"group-data-[disabled]:bg-zinc-100":!0,"shadow-none":!0,"group-[&]/repeater:shadow-none":!0,"group-[&]/multistep:shadow-none":!0,"dark:border-zinc-700":!0,"dark:group-data-[disabled]:bg-zinc-800/5":!0,"dark:group-data-[invalid]:border-red-400":!0,"dark:group-data-[invalid]:ring-red-400":!0,"dark:bg-transparent":!0},textarea__input:{"appearance-none":!0,"[color-scheme:light]":!0,"dark:[color-scheme:dark]":!0,"selection:text-zinc-700":!0,"group-data-[has-overlay]:selection:!text-transparent":!0,"text-sm":!0,"h-24":!0,"text-zinc-700":!0,"min-w-0":!0,grow:!0,shrink:!0,"!py-2":!0,"!px-3":!0,"outline-hidden":!0,"bg-transparent":!0,"selection:bg-accent-100":!0,"placeholder:text-zinc-400":!0,"group-data-[disabled]:!cursor-not-allowed":!0,"dark:placeholder-zinc-400/50":!0,"dark:text-zinc-300":!0,"p-0":!0,"border-none":!0,"focus:ring-0":!0},textarea__prefixIcon:{flex:!0,"items-center":!0,"-ml-1":!0,"mr-2":!0,"text-sm":!0,"h-[1em]":!0,"w-[1em]":!0,"shrink-0":!0,"[&>svg]:w-full":!0,"!ml-2":!0,"!mr-0":!0,"text-zinc-600":!0,"dark:text-zinc-300":!0},textarea__suffixIcon:{flex:!0,"items-center":!0,"-mr-1":!0,"ml-2":!0,"text-sm":!0,"h-[1em]":!0,"w-[1em]":!0,"shrink-0":!0,"[&>svg]:w-full":!0,"!mr-2":!0,"!ml-0":!0,"text-zinc-600":!0,"dark:text-zinc-300":!0},time__input:{"appearance-none":!0,"[color-scheme:light]":!0,"dark:[color-scheme:dark]":!0,"selection:bg-accent-100":!0,"selection:text-zinc-700":!0,"group-data-[has-overlay]:selection:!text-transparent":!0,"focus:[&::-webkit-datetime-edit-hour-field]:bg-accent-100":!0,"focus:[&::-webkit-datetime-edit-minute-field]:bg-accent-100":!0,"focus:[&::-webkit-datetime-edit-ampm-field]:bg-accent-100":!0},week__input:{"appearance-none":!0,"[color-scheme:light]":!0,"dark:[color-scheme:dark]":!0,"selection:bg-accent-100":!0,"selection:text-zinc-700":!0,"group-data-[has-overlay]:selection:!text-transparent":!0,"focus:[&::-webkit-datetime-edit-week-field]:bg-accent-100":!0,"focus:[&::-webkit-datetime-edit-year-field]:bg-accent-100":!0},autocomplete__selections:{flex:!0,absolute:!0,"inset-0":!0,"group-data-[multiple]:static":!0,"group-data-[multiple]:block":!0,"group-data-[empty]:hidden":!0,"group-data-[multiple]:mt-1.5":!0},autocomplete__selectionWrapper:{"bg-zinc-100":!0,"rounded-sm":!0,"group-data-[multiple]:border":!0,"group-data-[multiple]:border-zinc-200":!0,"group-data-[multiple]:mb-1.5":!0,"outline-hidden":!0,"data-[active-selection=true]:ring-2":!0,"data-[active-selection=true]:ring-accent-400":!0,"dark:bg-zinc-600":!0,"dark:group-data-[multiple]:border-zinc-700":!0,"[&.formkit-dropZone]:opacity-25":!0,"[&.formkit-touchDropZone]:opacity-25":!0,"[&.formkit-touchDragging]:!flex":!0,"[&.formkit-longTouch]:opacity-25":!0},autocomplete__selection:{"rounded-sm":!0,just:!0,"pl-2":!0,"[&>*]:ml-0":!0,"dark:text-zinc-200":!0},colorpicker__outer:{group:!0,"max-w-none":!0,"min-w-0":!0,grow:!0,"mb-4":!0,"data-[disabled]:select-none":!0,"data-[disabled]:opacity-50":!0,"text-sm":!0,"data-[disabled]:cursor-not-allowed":!0,"data-[disabled]:pointer-events-none":!0},colorpicker__help:{"text-zinc-500":!0,"text-[11px]":!0,"[line-height:1em]":!0,"dark:text-zinc-400":!0,"group-data-[inline]:-mt-1":!0,"group-data-[inline]:mb-2":!0},colorpicker__inner:{relative:!0,"inline-flex":!0,"!w-auto":!0,"pl-2":!0,"group-data-[inline]:border-none":!0,"group-data-[inline]:shadow-none":!0,"group-data-[inline]:p-0":!0,"group-data-[inline]:bg-transparent":!0,"group-data-[inline]:outline-hidden":!0,"group-data-[inline]:!ring-0":!0,"group-data-[inline]:!w-full":!0,"group-data-[inline]:rounded-sm":!0},colorpicker__swatchPreview:{"w-full":!0,flex:!0,"justify-start":!0,"items-center":!0,"rounded-sm":!0,"text-sm":!0,"cursor-pointer":!0,"outline-hidden":!0},colorpicker__canvasSwatchPreviewWrapper:{relative:!0,"before:content-['']":!0,"before:absolute":!0,"before:inset-0":!0,"before:rounded-sm":!0,"before:shadow-[inset_0_0_0_1px_rgba(0,0,0,0.2)]":!0,"before:z-[2]":!0},colorpicker__canvasSwatchPreview:{"text-sm":!0,"rounded-sm":!0,"aspect-[1/1]":!0,"shrink-0":!0,grow:!0,"!w-[1.5em]":!0},colorpicker__valueString:{"text-sm":!0,"text-zinc-700":!0,"selection:bg-accent-100":!0,"font-mono":!0,"inline-block":!0,"ml-2":!0,"mr-1.5":!0,"dark:text-zinc-300":!0,"dark:selection:text-zinc-700":!0},colorpicker__panel:{absolute:!0,"left-0":!0,"top-full":!0,"z-[99]":!0,flex:!0,"w-[100vw]":!0,"max-w-[18.5em]":!0,"touch-manipulation":!0,"flex-col":!0,"rounded-sm":!0,border:!0,"bg-white":!0,"p-2":!0,"shadow-xs":!0,"group-data-[inline]:static":!0,"group-data-[inline]:max-w-none":!0,"border-zinc-300":!0,"group-data-[inline]:z-auto":!0,"group-data-[inline]:w-full":!0,"group-data-[inline]:shadow-none":!0,"group-data-[inline]:group-data-[disabled]:!cursor-not-allowed":!0,"group-data-[inline]:group-data-[disabled]:!pointer-events-none":!0,"group-data-[inline]:[&:has([id^=swatches]:first-child:last-child)]:w-auto":!0,"group-data-[inline]:[&:has([id^=swatches]:first-child:last-child)_[id^=swatches]>div]:w-[1.5em]":!0,"dark:bg-zinc-800":!0,"dark:border-zinc-700":!0,"dark:group-data-[inline]:bg-transparent":!0,"[@media(max-width:431px)_and_(hover:none)]:group-[&:not([data-inline])]:!fixed":!0,"[@media(max-width:431px)_and_(hover:none)]:group-[&:not([data-inline])]:top-auto":!0,"[@media(max-width:431px)_and_(hover:none)]:group-[&:not([data-inline])]:max-w-none":!0,"[@media(max-width:431px)_and_(hover:none)]:group-[&:not([data-inline])]:bottom-0":!0,"[@media(max-width:431px)_and_(hover:none)]:group-[&:not([data-inline])]:left-0":!0,"[@media(max-width:431px)_and_(hover:none)]:group-[&:not([data-inline])]:rounded-none":!0},colorpicker__panelClose:{flex:!0,"justify-end":!0,"items-center":!0,"text-zinc-600":!0,"mb-1.5":!0,"-mt-1":!0,"border-none":!0,"bg-none":!0,"border-b":!0,"border-zinc-200":!0,"w-[calc(100%+1rem)]":!0,"-ml-2":!0,"pt-0":!0,"pr-2":!0,"pb-1.5":!0,"pl-2":!0,"dark:border-zinc-800":!0},colorpicker__closeIcon:{"w-[2rem]":!0,"aspect-[1/1]":!0,"p-1":!0,"rounded-sm":!0,border:!0,"[&>svg]:w-full":!0,"[&>svg]:aspect-[1/1]":!0,"[&>svg]:max-w-none":!0,"[&>svg]:max-h-none":!0},colorpicker__controlGroup:{grid:!0,"[grid-template-areas:'a_a_a'_'b_c_e'_'b_d_e']":!0,"mb-2":!0},colorpicker__LS:{"[grid-area:a]":!0,relative:!0,"mb-2":!0},colorpicker__canvas:{block:!0,"w-full":!0},colorpicker__canvasLS:{"aspect-[2/1]":!0,"cursor-pointer":!0,"rounded-xs":!0},colorpicker__canvasHue:{"rounded-xs":!0},colorpicker__canvasAlpha:{"rounded-xs":!0},colorpicker__preview:{"rounded-sm":!0,"after:rounded-sm":!0,relative:!0,"inline-flex":!0,"aspect-[1/1]":!0,"overflow-hidden":!0,"[grid-area:b]":!0,"mr-2":!0,"after:absolute":!0,"after:left-0":!0,"after:top-0":!0,"after:h-full":!0,"after:w-full":!0,"after:shadow-[inset_0_0_0_1px_rgba(0,0,0,0.2)]":!0,"after:content-['']":!0,"w-[2em]":!0,"dark:after:shadow-[inset_0_0_0_1px_rgba(255,255,255,0.25)]":!0},colorpicker__hue:{"[grid-area:c]":!0,relative:!0,"inline-flex":!0,"h-3/4":!0},colorpicker__alpha:{"[grid-area:d]":!0,relative:!0,"inline-flex":!0,"h-3/4":!0},colorpicker__eyeDropper:{"[grid-area:e]":!0,"w-[2em]":!0,"ml-2":!0,"inline-flex":!0,"self-center":!0,"justify-center":!0,"justify-self-center":!0,"aspect-[1/1]":!0,"rounded-sm":!0,border:!0,"border-zinc-200":!0,"cursor-pointer":!0,"content-center":!0,"items-center":!0,"text-zinc-600":!0,"dark:border-zinc-800":!0},colorpicker__eyeDropperIcon:{"w-auto":!0,"[&>svg]:w-[1em]":!0,"dark:text-zinc-400":!0},colorpicker__control:{absolute:!0,"bg-white":!0,"shadow-[0_0_0_2px_rgba(255,255,255,1),0_0_0_3px_rgba(0,0,0,0.2)]":!0,"-translate-y-1/2":!0,"-translate-x-1/2":!0,"pointer-events-none":!0,"data-[prevent-focus-style]:shadow-[0_0_0_2px_rgba(255,255,255,1),0_0_0_3px_rgba(0,0,0,0.2)]":!0,"focus-visible:outline-hidden":!0,"focus-visible:ring-2":!0,"focus-visible:ring-offset-2":!0,"focus-visible:ring-accent-400":!0},colorpicker__controlLS:{"w-[10px]":!0,"h-[10px]":!0,"rounded-full":!0},colorpicker__controlHue:{"w-[4px]":!0,"h-[calc(100%-2px)]":!0,"top-1/2":!0,"rounded-sm":!0},colorpicker__controlAlpha:{"w-[4px]":!0,"h-[calc(100%-2px)]":!0,"top-1/2":!0,"rounded-sm":!0},colorpicker__formatField:{flex:!0,"items-center":!0,"justify-center":!0,grow:!0},colorpicker__colorField:{"bg-transparent":!0,"text-zinc-700":!0,border:!0,"border-zinc-200":!0,"dark:border-zinc-800":!0,"dark:text-zinc-300":!0,"dark:selection:text-zinc-700":!0},colorpicker__colorInputGroup:{flex:!0,"items-center":!0,"justify-center":!0,grow:!0},colorpicker__fieldGroup:{flex:!0,"flex-col":!0,"items-center":!0,"justify-center":!0,"w-full":!0,"mr-1":!0,"[&>input]:p-1":!0,"[&>input]:text-sm":!0,"[&>input]:text-zinc-700":!0,"[&>input]:selection:bg-accent-100":!0,"[&>input]:m-0":!0,"[&>input]:grow":!0,"[&>input]:shrink":!0,"[&>input]:w-full":!0,"[&>input]:border":!0,"[&>input]:border-zinc-200":!0,"[&>input]:rounded-sm":!0,"[&>input]:text-center":!0,"[&>input]:appearance-none":!0,"[&>input::-webkit-outer-spin-button]:appearance-none":!0,"[&>input::-webkit-inner-spin-button]:appearance-none":!0,"[&>input::-webkit-inner-spin-button]:m-0":!0,"[&>input:focus]:outline-hidden":!0,"[&>input:focus]:ring-1":!0,"[&>input:focus]:ring-accent-500":!0,"[&>input:focus]:border-accent-500":!0,"max-[431px]:[&>input]:text-base":!0},colorpicker__fieldLabel:{"text-xs":!0,"text-zinc-500":!0,"mt-1.5":!0,"dark:text-zinc-400":!0},colorpicker__formatSwitcher:{flex:!0,"justify-end":!0,"self-start":!0,uppercase:!0,"shrink-0":!0,"p-1":!0,"mt-0.5":!0,"text-zinc-600":!0,"rounded-sm":!0,"select-none":!0,"dark:text-zinc-400":!0},colorpicker__switchIcon:{"[&>svg]:w-3":!0},colorpicker__swatches:{"inline-flex":!0,"flex-wrap":!0,"w-full":!0,"justify-self-center":!0,"min-w-0":!0,"mx-auto":!0,"px-[1px]":!0,"pt-2":!0,"pb-2":!0,"mt-2":!0,"-mb-2":!0,"border-t":!0,"border-zinc-200":!0,"overflow-auto":!0,"max-h-[200px]":!0,"select-none":!0,"first:-mt-[3px]":!0,"first:last:-mb-[3px]":!0,"first:last:pb-[2px]":!0,"first:pt-px":!0,"first:border-t-0":!0,"dark:border-zinc-800":!0},colorpicker__swatchGroup:{flex:!0,"flex-wrap":!0,"w-full":!0,"mb-2":!0,"last:mb-0":!0},colorpicker__swatchGroupLabel:{"ml-1":!0,block:!0,"w-full":!0,"text-xs":!0,"text-zinc-500":!0,"dark:text-zinc-400":!0},colorpicker__swatch:{relative:!0,"text-sm":!0,"w-[calc((100%/10)-0.5em)]":!0,"max-w-[22px]":!0,"m-[0.16em]":!0,"cursor-pointer":!0,"before:content-['']":!0,"before:absolute":!0,"before:inset-0":!0,"before:rounded-sm":!0,"before:shadow-[inset_0_0_0_1px_rgba(0,0,0,0.2)]":!0,"before:pointer-events-none":!0,"before:z-[2]":!0,"dark:before:shadow-[inset_0_0_0_1px_rgba(255,255,255,0.25)]":!0,"data-[active=true]:after:content-['']":!0,"data-[active=true]:after:block":!0,"data-[active=true]:after:absolute":!0,"data-[active=true]:after:w-1.5":!0,"data-[active=true]:after:h-1.5":!0,"data-[active=true]:after:top-1/2":!0,"data-[active=true]:after:left-1/2":!0,"data-[active=true]:after:pointer-events-none":!0,"data-[active=true]:after:rounded-full":!0,"data-[active=true]:after:-translate-x-1/2":!0,"data-[active=true]:after:-translate-y-1/2":!0,"data-[active=true]:after:bg-white":!0,"data-[active=true]:after:z-[2]":!0,"data-[active=true]:after:ring-1":!0,"data-[active=true]:after:ring-[rgba(0,0,0,0.33)]":!0,"[&>canvas]:block":!0,"[&>canvas]:w-full":!0,"[&>canvas]:aspect-[1/1]":!0,"[&>canvas]:rounded-sm":!0,"[&>canvas:focus-visible]:outline-hidden":!0,"[&>canvas:focus-visible]:ring-2":!0,"[&>canvas:focus-visible]:ring-accent-400":!0,"[&>canvas:focus-visible]:ring-offset-2":!0,"[&>canvas:focus-visible]:ring-offset-white":!0,"dark:[&>canvas:focus-visible]:ring-offset-zinc-700":!0},datepicker__inner:{relative:!0},datepicker__removeSelection:{"self-stretch":!0,"text-sm":!0,flex:!0,"items-center":!0,"ml-1":!0,"mr-2":!0,"text-zinc-700":!0,"hover:text-red-400":!0,"z-10":!0,"dark:text-zinc-300":!0},datepicker__clearIcon:{"[&>svg]:w-[0.75em]":!0},datepicker__panelWrapper:{"group/panel":!0,absolute:!0,"min-w-[20em]":!0,"top-[calc(100%_+_0.5em)]":!0,"left-0":!0,"shadow-[0_0_1.25em_rgba(0,0,0,.25)]":!0,"rounded-sm":!0,"p-4":!0,"bg-white":!0,"z-10":!0,"dark:bg-zinc-800":!0,"[@media(max-width:431px)_and_(hover:none)]:group-[&:not([data-inline])]:!fixed":!0,"[@media(max-width:431px)_and_(hover:none)]:group-[&:not([data-inline])]:top-auto":!0,"[@media(max-width:431px)_and_(hover:none)]:group-[&:not([data-inline])]:max-w-none":!0,"[@media(max-width:431px)_and_(hover:none)]:group-[&:not([data-inline])]:bottom-0":!0,"[@media(max-width:431px)_and_(hover:none)]:group-[&:not([data-inline])]:left-0":!0,"[@media(max-width:431px)_and_(hover:none)]:group-[&:not([data-inline])]:rounded-none":!0,"[@media(max-width:431px)_and_(hover:none)]:group-[&:not([data-inline])]:w-full":!0},datepicker__panelHeader:{grid:!0,"grid-cols-[2.5em_1fr_2.5em]":!0,"justify-center":!0,"items-center":!0,"border-b-2":!0,"border-zinc-200":!0,"mb-2":!0,"pb-2.5":!0,"dark:border-zinc-700":!0,"[@media(max-width:431px)_and_(hover:none)]:group-[&:not([data-inline])]:grid-cols-[2.5em_1fr_2.5em_2.5em]":!0,"[@media(max-width:431px)_and_(hover:none)]:group-[&:not([data-inline])]:group-data-[panel=time]/panel:grid-cols-[2.5em_1fr_2.5em]":!0,"[@media(max-width:431px)_and_(hover:none)]:group-[&:not([data-inline])]:group-data-[panel=month]/panel:grid-cols-[2.5em_1fr_2.5em]":!0},datepicker__panelClose:{"aspect-[1/1]":!0,border:!0,"border-zinc-200":!0,"rounded-sm":!0,flex:!0,"items-center":!0,"justify-center":!0,"text-zinc-700":!0,"[&_svg]:w-[1.25em]":!0,"dark:text-zinc-300":!0,"dark:border-zinc-800":!0,"[@media(max-width:431px)_and_(hover:none)]:group-data-[panel=time]/panel:col-start-3":!0,"[@media(max-width:431px)_and_(hover:none)]:group-data-[panel=month]/panel:col-start-3":!0},datepicker__panel:{flex:!0,"justify-center":!0},datepicker__input:{"appearance-none":!0,"[color-scheme:light]":!0,"dark:[color-scheme:dark]":!0,"selection:bg-accent-100":!0,"selection:text-zinc-700":!0,"group-data-[has-overlay]:selection:!text-transparent":!0,"placeholder:text-zinc-400":!0},datepicker__monthsHeader:{flex:!0,"items-center":!0,"justify-center":!0,"col-start-2":!0,"col-end-2":!0},datepicker__timeHeader:{flex:!0,"items-center":!0,"justify-center":!0,"col-start-2":!0,"col-end-2":!0},datepicker__months:{grid:!0,"grid-cols-3":!0,"w-full":!0},datepicker__month:{"m-1.5":!0,"p-1.5":!0,"text-center":!0,"text-zinc-700":!0,"rounded-sm":!0,"bg-zinc-200":!0,"aria-selected:!bg-accent-500":!0,"aria-selected:!text-white":!0,"focus:outline":!0,"focus:outline-2":!0,"focus:outline-accent-500":!0,"focus:outline-offset-2":!0,"focus:bg-white":!0,"focus:text-zinc-700":!0,"data-[is-extra=true]:opacity-25":!0,"group-data-[disabled=true]:opacity-50":!0,"group-data-[disabled=true]:cursor-default":!0,"group-data-[disabled=true]:pointer-events-none":!0,"dark:bg-zinc-700":!0,"dark:text-zinc-300":!0},datepicker__yearsHeader:{flex:!0,"items-center":!0,"justify-center":!0,"text-zinc-700":!0,"col-start-2":!0,"col-end-2":!0,"dark:text-zinc-300":!0},datepicker__years:{grid:!0,"grid-cols-5":!0,"w-full":!0},datepicker__year:{"text-sm":!0,"text-center":!0,"text-zinc-700":!0,"items-center":!0,"m-1.5":!0,"p-1.5":!0,"rounded-sm":!0,"bg-zinc-200":!0,"aria-selected:!bg-accent-500":!0,"aria-selected:!text-white":!0,"focus:outline":!0,"focus:outline-2":!0,"focus:outline-accent-500":!0,"focus:outline-offset-2":!0,"focus:bg-white":!0,"data-[is-extra=true]:opacity-25":!0,"group-data-[disabled=true]:opacity-50":!0,"group-data-[disabled=true]:cursor-default":!0,"group-data-[disabled=true]:pointer-events-none":!0,"dark:bg-zinc-700":!0,"dark:text-zinc-300":!0},datepicker__weekDays:{grid:!0,"grid-cols-7":!0},datepicker__weekDay:{"w-[2.25em]":!0,"text-zinc-700":!0,"m-1.5":!0,"rounded-sm":!0,"font-medium":!0,lowercase:!0,"dark:text-zinc-500":!0},datepicker__calendarWeeks:{"":!0},datepicker__week:{grid:!0,"grid-cols-7":!0,"group-data-[disabled=true]:opacity-50":!0,"group-data-[disabled=true]:cursor-default":!0,"group-data-[disabled=true]:pointer-events-none":!0},datepicker__dayCell:{flex:!0,"items-center":!0,"justify-center":!0,"text-center":!0,"text-zinc-700":!0,"w-[2.25em]":!0,"h-[2.25em]":!0,"m-1":!0,"p-2":!0,"rounded-sm":!0,"bg-zinc-200":!0,"aria-selected:bg-accent-500":!0,"aria-selected:text-white":!0,"focus:outline":!0,"focus:outline-2":!0,"focus:outline-accent-500":!0,"focus:outline-offset-2":!0,"focus:bg-white":!0,"data-[is-extra=true]:opacity-25":!0,"data-[disabled=true]:opacity-50":!0,"data-[disabled=true]:cursor-default":!0,"data-[disabled=true]:pointer-events-none":!0,"dark:bg-zinc-600":!0,"dark:text-zinc-300":!0,"dark:aria-selected:bg-accent-500":!0,"dark:aria-selected:text-white":!0,"dark:focus:outline-accent-500":!0,"dark:focus:bg-zinc-200":!0,"dark:focus:text-zinc-700":!0},datepicker__timeInput:{"w-full":!0,"border-2":!0,"[color-scheme:light]":!0,"dark:[color-scheme:dark]":!0,"text-zinc-700":!0,"border-zinc-200":!0,"rounded-sm":!0,"p-1.5":!0,"my-2.5":!0,"focus-visible:outline-accent-500":!0,"dark:text-zinc-300":!0,"dark:bg-transparent":!0,"dark:border-zinc-700":!0},datepicker__daysHeader:{flex:!0,"items-center":!0,"justify-center":!0},datepicker__prev:{"mr-auto":!0,"px-2.5":!0,"py-0.5":!0,"hover:bg-zinc-100":!0,"rounded-sm":!0,"col-start-1":!0,"col-end-1":!0,"focus-visible:outline-hidden":!0,"focus-visible:ring-2":!0,"focus-visible:ring-accent-400":!0,"focus-visible:ring-offset-2":!0},datepicker__prevLabel:{hidden:!0},datepicker__prevIcon:{flex:!0,"w-[0.75em]":!0,"select-none":!0,"text-zinc-700":!0,"[&>svg]:w-full":!0,"dark:text-zinc-300":!0},datepicker__dayButton:{"appearance-none":!0,"text-zinc-700":!0,"cursor-pointer":!0,"px-2.5":!0,"py-0.5":!0,"border-2":!0,"border-zinc-200":!0,"rounded-sm":!0,"mx-1":!0,"hover:border-accent-500":!0,"focus-visible:outline-hidden":!0,"focus-visible:ring-2":!0,"focus-visible:ring-accent-400":!0,"focus-visible:ring-offset-2":!0,"dark:text-zinc-300":!0,"dark:border-zinc-700":!0,"dark:hover:border-accent-400":!0},datepicker__monthButton:{"appearance-none":!0,"text-zinc-700":!0,"cursor-pointer":!0,"px-2.5":!0,"py-0.5":!0,"border-2":!0,"border-zinc-200":!0,"rounded-sm":!0,"mx-1":!0,"hover:border-accent-500":!0,"focus-visible:outline-hidden":!0,"focus-visible:ring-2":!0,"focus-visible:ring-accent-400":!0,"focus-visible:ring-offset-2":!0,"dark:text-zinc-300":!0,"dark:border-zinc-700":!0,"dark:hover:border-accent-400":!0},datepicker__yearButton:{"appearance-none":!0,"text-zinc-700":!0,"cursor-pointer":!0,"px-2.5":!0,"py-0.5":!0,"border-2":!0,"border-zinc-200":!0,"rounded-sm":!0,"mx-1":!0,"hover:border-accent-500":!0,"focus-visible:outline-hidden":!0,"focus-visible:ring-2":!0,"focus-visible:ring-accent-400":!0,"focus-visible:ring-offset-2":!0,"dark:text-zinc-300":!0,"dark:border-zinc-700":!0,"dark:hover:border-accent-400":!0},datepicker__next:{"ml-auto":!0,"px-2.5":!0,"py-0.5":!0,"rounded-sm":!0,"hover:bg-zinc-100":!0,"hover:rounded-sm":!0,"col-start-3":!0,"col-end-3":!0,"focus-visible:outline-hidden":!0,"focus-visible:ring-2":!0,"focus-visible:ring-accent-400":!0,"focus-visible:ring-offset-2":!0},datepicker__nextLabel:{hidden:!0},datepicker__nextIcon:{flex:!0,"w-[0.75em]":!0,"select-none":!0,"text-zinc-700":!0,"[&>svg]:w-full":!0,"dark:text-zinc-300":!0},datepicker__openButton:{"appearance-none":!0,"border-0":!0,"bg-transparent":!0,flex:!0,"p-0":!0,"self-stretch":!0,"cursor-pointer":!0,"focus-visible:outline-hidden":!0,"focus-visible:ring-2":!0,"focus-visible:ring-accent-400":!0,"focus-visible:ring-offset-2":!0,"focus-visible:rounded-sm":!0},datepicker__calendarIcon:{"text-zinc-600":!0,"focus-visible:text-accent-500":!0,flex:!0,"w-[1em]":!0,"grow-0":!0,"shrink-0":!0,"self-stretch":!0,"select-none":!0,"[&>svg]:w-full":!0,"[&>svg]:m-auto":!0,"[&>svg]:max-h-[1em]":!0,"[&>svg]:max-w-[1em]":!0},dropdown__placeholder:{"text-zinc-400":!0,grow:!0,"dark:text-zinc-400/50":!0},dropdown__selector:{flex:!0,grow:!0,"justify-between":!0,"w-full":!0,"py-2":!0,"pl-3":!0,"pr-0":!0,"text-sm":!0,"text-zinc-700":!0,"text-left":!0,"group-data-[disabled]:!cursor-not-allowed":!0,"group-data-[prefix-icon]:!pl-0":!0,"group-data-[suffix-icon]:!pr-0":!0,"data-[placeholder]:text-zinc-400":!0,"selection:bg-accent-100":!0,"dark:data-[placeholder]:text-zinc-400/50":!0,"dark:text-zinc-300":!0},dropdown__selectIcon:{"shrink-0":!0},dropdown__selectionsWrapper:{"w-[85%]":!0,"overflow-hidden":!0},dropdown__selection:{"[&>*]:ml-0":!0},dropdown__selections:{"inline-flex":!0,"items-center":!0},dropdown__selectionsItem:{"whitespace-nowrap":!0,"mr-1":!0},dropdown__tagWrapper:{"[&.formkit-dropZone_.formkit-tag]:opacity-25":!0,"[&.formkit-touchDropZone_.formkit-tag]:opacity-25":!0},dropdown__truncationCount:{flex:!0,"items-center":!0,"justify-center":!0,"h-[1.5em]":!0,"rounded-sm":!0,"bg-zinc-400":!0,"text-white":!0,"whitespace-nowrap":!0,"text-[11px]":!0,"[line-height:1em]":!0,"tracking-tighter":!0,"leading-0":!0,"py-1":!0,"px-1":!0,"shrink-0":!0,"my-auto":!0},mask__inner:{relative:!0},mask__input:{"appearance-none":!0,"[color-scheme:light]":!0,"dark:[color-scheme:dark]":!0,"selection:bg-accent-100":!0,"selection:text-zinc-700":!0,"group-data-[has-overlay]:selection:!text-transparent":!0,"group-data-[has-overlay]:!caret-zinc-700":!0,"dark:group-data-[has-overlay]:!caret-zinc-300":!0},rating__inner:{"text-zinc-300":!0},rating__itemsWrapper:{relative:!0,"inline-flex":!0,"focus:border-accent-500":!0},rating__onItemRow:{"h-full":!0,"w-full":!0},rating__offItemRow:{"h-full":!0,"w-full":!0},rating__onItemWrapper:{"[&>*]:w-full":!0,"[&>*]:h-full":!0,"w-full":!0,"h-full":!0,"text-yellow-400":!0},rating__offItemWrapper:{"text-zinc-300":!0,"w-full":!0,"h-full":!0,"[&>*]:w-full":!0,"[&>*]:h-full":!0,"dark:text-zinc-600":!0},rating__ratingItem:{relative:!0,"focus-within:outline":!0,"focus-within:outline-accent-500":!0,"w-[1.5em]":!0,"h-[1.5em]":!0},rating__itemLabelInner:{"h-px":!0,"w-px":!0,"overflow-hidden":!0,absolute:!0,"white-space-nowrap":!0},rating__itemLabel:{absolute:!0,"h-full":!0},rating__ratingIcon:{"w-[1.5em]":!0,"h-[1.5em]":!0,flex:!0},rating__input:{"appearance-none":!0,"[color-scheme:light]":!0,"dark:[color-scheme:dark]":!0,"selection:bg-accent-100":!0,"selection:text-zinc-700":!0,"group-data-[has-overlay]:selection:!text-transparent":!0,"outline-hidden":!0},rating__messages:{"mt-1.5":!0},repeater__outer:{"min-w-0":!0,grow:!0,"mb-4":!0,"text-sm":!0,"group/repeater":!0,"max-w-full":!0},repeater__fieldset:{"min-w-0":!0},repeater__legend:{block:!0,"text-zinc-700":!0,"text-xs":!0,"font-bold":!0,"dark:text-zinc-300":!0,"mb-2":!0},repeater__content:{"min-w-0":!0,grow:!0,"p-5":!0,flex:!0,"flex-col":!0,"align-center":!0,"[&>div[data-type]]:max-w-none":!0,"[&>div[data-type]:last-child]:mb-0":!0},repeater__addButton:{"!mb-0":!0,"group-data-[disabled]/repeater:pointer-events-none":!0,"group-data-[disabled]/repeater:opacity-50":!0,"group-data-[disabled]/repeater:grayscale":!0},repeater__controlLabel:{absolute:!0,"opacity-0":!0,"pointer-events-none":!0,"text-[0px]":!0},repeater__controls:{flex:!0,"flex-col":!0,"items-center":!0,"justify-center":!0,"bg-zinc-50":!0,"p-2":!0,"[&>li]:aspect-[1/1]":!0,"dark:bg-zinc-800":!0,"rounded-sm":!0,"rounded-tl-none":!0,"rounded-bl-none":!0},repeater__downControl:{"w-[1.5em]":!0,"h-[1.5em]":!0,"my-1.5":!0,"mx-auto":!0,flex:!0,"items-center":!0,"appearance-none":!0,"justify-center":!0,"aspect-[1/1]":!0,"text-zinc-500":!0,"hover:text-accent-500":!0,"disabled:hover:text-inherit":!0,"disabled:opacity-25":!0,"disabled:!text-zinc-500":!0,"dark:text-zinc-300":!0,"dark:disabled:!text-zinc-300":!0,"dark:hover:text-accent-400":!0},repeater__upControl:{"w-[1.5em]":!0,"h-[1.5em]":!0,"my-1.5":!0,"mx-auto":!0,flex:!0,"items-center":!0,"appearance-none":!0,"justify-center":!0,"aspect-[1/1]":!0,"text-zinc-500":!0,"hover:text-accent-500":!0,"disabled:hover:text-inherit":!0,"disabled:opacity-25":!0,"disabled:!text-zinc-500":!0,"dark:text-zinc-300":!0,"dark:disabled:!text-zinc-300":!0,"dark:hover:text-accent-400":!0},repeater__removeControl:{"w-[1.5em]":!0,"h-[1.5em]":!0,"my-1.5":!0,"mx-auto":!0,flex:!0,"items-center":!0,"appearance-none":!0,"justify-center":!0,"aspect-[1/1]":!0,"text-zinc-500":!0,"hover:text-accent-500":!0,"disabled:hover:text-inherit":!0,"disabled:opacity-25":!0,"disabled:!text-zinc-500":!0,"dark:text-zinc-300":!0,"dark:disabled:!text-zinc-300":!0,"dark:hover:text-accent-400":!0},repeater__insertControl:{"w-[1.5em]":!0,"h-[1.5em]":!0,"my-1.5":!0,"mx-auto":!0,flex:!0,"items-center":!0,"appearance-none":!0,"justify-center":!0,"aspect-[1/1]":!0,"text-zinc-500":!0,"hover:text-accent-500":!0,"disabled:hover:text-inherit":!0,"disabled:opacity-25":!0,"disabled:!text-zinc-500":!0,"dark:text-zinc-300":!0,"dark:disabled:!text-zinc-300":!0,"dark:hover:text-accent-400":!0},repeater__help:{"text-zinc-500":!0,"text-[11px]":!0,"[line-height:1em]":!0,"dark:text-zinc-400":!0,"mb-2":!0,"-mt-1":!0},repeater__item:{flex:!0,relative:!0,"w-full":!0,"mb-2":!0,"bg-white":!0,border:!0,"border-zinc-200":!0,"rounded-sm":!0,"shadow-none":!0,"dark:border-zinc-700":!0,"dark:bg-transparent":!0,"[&.formkit-dropZone]:opacity-30":!0,"[&.formkit-dropZone]:blur-[2px]":!0},repeater__dragHandleWrapper:{relative:!0,"w-8":!0,"bg-zinc-50":!0,"rounded-sm":!0,"rounded-tr-none":!0,"rounded-br-none":!0,"dark:bg-zinc-800":!0},repeater__dragHandle:{"w-full":!0,"h-full":!0,flex:!0,absolute:!0,"top-0":!0,"left-0":!0,"cursor-grab":!0,"active:cursor-grabbing":!0},repeater__dragHandleIcon:{"w-2":!0,"m-auto":!0,"text-zinc-400":!0,"dark:text-zinc-600":!0,"[&>svg>path]:fill-current":!0},repeater__moveDownIcon:{block:!0,"w-[0.75em]":!0,"aspect-[1/1]":!0},repeater__moveUpIcon:{block:!0,"w-[0.75em]":!0,"aspect-[1/1]":!0},repeater__removeIcon:{block:!0,"w-[1.25em]":!0,"aspect-[1/1]":!0},repeater__addIcon:{block:!0,"w-[1.25em]":!0,"aspect-[1/1]":!0},slider__outer:{group:!0,"max-w-none":!0,"min-w-0":!0,grow:!0,"mb-4":!0,"data-[disabled]:select-none":!0,"data-[disabled]:opacity-50":!0,"text-sm":!0,"data-[disabled]:pointer-events-none":!0},slider__help:{"text-zinc-500":!0,"text-[11px]":!0,"[line-height:1em]":!0,"dark:text-zinc-400":!0,"-mt-0.5":!0,"mb-1.5":!0},slider__sliderInner:{flex:!0,"items-center":!0,"[&>[data-type=number]]:mb-0":!0,"[&>[data-type=number]]:ml-2.5":!0,"[&>[data-type=number]]:shrink":!0,"[&>[data-type=number]]:grow-0":!0,"[&[data-has-mark-labels=true]_[id^=track]]:mb-5":!0},slider__track:{grow:!0,relative:!0,"z-20":!0,"py-2.5":!0,"select-none":!0},slider__trackWrapper:{"px-[2px]":!0,"rounded-full":!0,"bg-zinc-300":!0,"dark:bg-zinc-500":!0},slider__trackInner:{"h-1.5":!0,"mx-0.5":!0,relative:!0},slider__prefixIcon:{flex:!0,"items-center":!0,"-ml-1":!0,"mr-2":!0,"text-sm":!0,"h-[1em]":!0,"w-[1em]":!0,"shrink-0":!0,"[&>svg]:w-full":!0,"text-zinc-600":!0,"dark:text-zinc-300":!0},slider__suffixIcon:{flex:!0,"items-center":!0,"-mr-1":!0,"ml-2":!0,"text-sm":!0,"h-[1em]":!0,"w-[1em]":!0,"shrink-0":!0,"[&>svg]:w-full":!0,"text-zinc-600":!0,"dark:text-zinc-300":!0},slider__fill:{"h-full":!0,"rounded-full":!0,absolute:!0,"top-0":!0,"-mx-1":!0,"bg-accent-500":!0,"group-data-[disabled]:bg-zinc-500":!0},slider__marks:{absolute:!0,"pointer-events-none":!0,"inset-0":!0},slider__mark:{absolute:!0,"top-1/2":!0,"w-[3px]":!0,"h-[3px]":!0,"rounded-full":!0,"-translate-x-1/2":!0,"-translate-y-1/2":!0,"bg-zinc-400":!0,"data-[active=true]:bg-white":!0},slider__markLabel:{absolute:!0,"top-[calc(100%+0.5em)]":!0,"left-1/2":!0,"text-zinc-400":!0,"text-[11px]":!0,"[line-height:1em]":!0,"-translate-x-1/2":!0},slider__handles:{"m-0":!0,"p-0":!0,"list-none":!0},slider__handle:{group:!0,"select-none":!0,"w-4":!0,"h-4":!0,"rounded-full":!0,"bg-white":!0,absolute:!0,"top-1/2":!0,"left-0":!0,"z-30":!0,"-translate-x-1/2":!0,"-translate-y-1/2":!0,"shadow-[inset_0_0_0_1px_rgba(0,0,0,0.1),0_1px_2px_0_rgba(0,0,0,0.5)]":!0,"focus-visible:outline-0":!0,"focus-visible:ring-2":!0,"ring-accent-500":!0,"data-[is-target=true]:z-20":!0,"dark:bg-zinc-200":!0},slider__tooltip:{absolute:!0,"bottom-full":!0,"left-1/2":!0,"-translate-x-1/2":!0,"-translate-y-[4px]":!0,"bg-accent-500":!0,"text-white":!0,"py-1":!0,"px-1.5":!0,"text-xs":!0,"leading-none":!0,"whitespace-nowrap":!0,"rounded-sm":!0,"opacity-0":!0,"pointer-events-none":!0,"transition-opacity":!0,'after:content-[""]':!0,"after:absolute":!0,"after:top-full":!0,"after:left-1/2":!0,"after:-translate-x-1/2":!0,"after:-translate-y-[1px]":!0,"after:border-4":!0,"after:border-transparent":!0,"after:border-t-accent-500":!0,"group-hover:opacity-100":!0,"group-focus-visible:opacity-100":!0,"group-data-[show-tooltip=true]:opacity-100":!0},slider__linkedValues:{flex:!0,"items-start":!0,"justify-between":!0},slider__minValue:{grow:!0,"!max-w-[45%]":!0,"mb-0":!0,"[&>div>div]:relative":!0,'[&>div>div::after]:content-[""]':!0,"[&>div>div::after]:absolute":!0,"[&>div>div::after]:top-1/2":!0,"[&>div>div::after]:left-[105.5%]":!0,"[&>div>div::after]:w-[12%]":!0,"[&>div>div::after]:h-[1px]":!0,"[&>div>div::after]:bg-zinc-300":!0,"dark:[&>div>div::after]:bg-zinc-700":!0},slider__maxValue:{grow:!0,"!max-w-[45%]":!0,"mb-0":!0,relative:!0},slider__chart:{relative:!0,"z-20":!0,"mb-2":!0,flex:!0,"justify-between":!0,"items-center":!0,"w-full":!0,"aspect-[3/1]":!0},slider__chartBar:{absolute:!0,"bottom-0":!0,"h-full":!0,"bg-zinc-400":!0,"data-[active=false]:bg-zinc-300":!0,"dark:bg-zinc-500":!0,"dark:data-[active=false]:bg-zinc-600":!0},taglist__inner:{"py-2":!0,"pr-0":!0,"pl-0":!0},taglist__tags:{"pl-3":!0},taglist__tagWrapper:{"[&.formkit-dropZone_.formkit-tag]:opacity-25":!0,"[&.formkit-touchDropZone_.formkit-tag]:opacity-25":!0},taglist__input:{"appearance-none":!0,"[color-scheme:light]":!0,"dark:[color-scheme:dark]":!0,"selection:bg-accent-100":!0,"selection:text-zinc-700":!0,"group-data-[has-overlay]:selection:!text-transparent":!0,"!p-0":!0,"!w-[0%]":!0,"min-w-[1em]":!0,"inline-block":!0,"-mt-1":!0,"first:mt-0":!0,"first:mb-1":!0},taglist__listboxButton:{"ml-auto":!0,"shrink-0":!0},toggle__outer:{group:!0,"min-w-0":!0,grow:!0,"mb-4":!0,"data-[disabled]:select-none":!0,"data-[disabled]:opacity-50":!0,"text-sm":!0,"max-w-none":!0},toggle__altLabel:{block:!0,"w-full":!0,"mb-1.5":!0,"font-bold":!0,"text-[11px]":!0,"[line-height:1em]":!0,"text-zinc-700":!0,"dark:text-zinc-300":!0},toggle__inner:{peer:!0,"inline-block":!0,"mr-2":!0},toggle__input:{"appearance-none":!0,"[color-scheme:light]":!0,"dark:[color-scheme:dark]":!0,"selection:bg-accent-100":!0,"selection:text-zinc-700":!0,"group-data-[has-overlay]:selection:!text-transparent":!0,peer:!0,absolute:!0,"opacity-0":!0,"w-0":!0,"h-0":!0},toggle__label:{block:!0,"text-zinc-700":!0,"text-xs":!0,"font-bold":!0,"mb-1":!0,"dark:text-zinc-300":!0,"peer-first:font-normal":!0,"peer-first:mb-0":!0},toggle__innerLabel:{absolute:!0,"text-zinc-200":!0,"text-[10px]":!0,"font-bold":!0,"select-none":!0,"left-full":!0,"top-1/2":!0,"-translate-x-full":!0,"-translate-y-1/2":!0,"px-1":!0},toggle__thumb:{relative:!0,"p-0.5":!0,"left-0":!0,"aspect-[1/1]":!0,"rounded-full":!0,"transition-all":!0,"w-[1.25em]":!0,"bg-zinc-50":!0,"text-zinc-600":!0,"shadow-base":!0},toggle__track:{"p-0.5":!0,"min-w-[3em]":!0,relative:!0,"cursor-pointer":!0,"select-none":!0,"rounded-full":!0,"transition-all":!0,"bg-zinc-400":!0,"peer-checked:bg-accent-500":!0,"peer-checked:[&>div:last-child]:left-full":!0,"peer-checked:[&>div:last-child]:-translate-x-full":!0,"peer-checked:[&>div:first-child:not(:last-child)]:left-0":!0,"peer-checked:[&>div:first-child:not(:last-child)]:translate-x-0":!0,"shadow-none":!0,"peer-focus-visible:ring-2":!0,"peer-focus-visible:ring-accent-400":!0,"peer-focus-visible:ring-offset-2":!0,"dark:bg-zinc-500":!0},toggle__valueLabel:{"font-bold":!0,"text-[11px]":!0,"[line-height:1em]":!0,"text-zinc-700":!0,"dark:text-zinc-300":!0},toggle__wrapper:{flex:!0,"flex-wrap":!0,"items-center":!0,"mb-1.5":!0},togglebuttons__wrapper:{"mb-1.5":!0},togglebuttons__options:{"group/options":!0,"inline-flex":!0,"data-[vertical=true]:flex-col":!0},togglebuttons__option:{"group/option":!0},togglebuttons__input:{"appearance-none":!0,"[color-scheme:light]":!0,"dark:[color-scheme:dark]":!0,"selection:bg-accent-100":!0,"selection:text-zinc-700":!0,"group-data-[has-overlay]:selection:!text-transparent":!0,"!px-4":!0,"!mb-0":!0,relative:!0,"focus:z-10":!0,"group-data-[vertical=true]/options:w-full":!0,"justify-center":!0,"bg-accent-50":!0,"disabled:opacity-50":!0,"disabled:cursor-not-allowed":!0,"group-data-[disabled]:disabled:opacity-100":!0,"dark:bg-transparent":!0,"dark:disabled:bg-transparent":!0,"dark:disabled:text-accent-500":!0,"dark:text-accent-500":!0,"aria-[pressed=true]:bg-accent-500":!0,"aria-[pressed=true]:text-white":!0,"dark:aria-[pressed=true]:bg-accent-500":!0,"dark:aria-[pressed=true]:text-white":!0,"group-[&]/option:!rounded-none":!0,"group-data-[vertical=false]/options:group-first/option:!rounded-sm":!0,"group-data-[vertical=true]/options:group-first/option:!rounded-sm":!0,"group-data-[vertical=false]/options:group-first/option:!rounded-tr-none":!0,"group-data-[vertical=false]/options:group-first/option:!rounded-br-none":!0,"group-data-[vertical=true]/options:group-first/option:!rounded-bl-none":!0,"group-data-[vertical=true]/options:group-first/option:!rounded-br-none":!0,"group-data-[vertical=false]/options:group-last/option:!rounded-sm":!0,"group-data-[vertical=true]/options:group-last/option:!rounded-sm":!0,"group-data-[vertical=false]/options:group-last/option:!rounded-tl-none":!0,"group-data-[vertical=false]/options:group-last/option:!rounded-bl-none":!0,"group-data-[vertical=true]/options:group-last/option:!rounded-tl-none":!0,"group-data-[vertical=true]/options:group-last/option:!rounded-tr-none":!0,"group-data-[vertical=false]/options:group-[&]/option:!border-r-0":!0,"group-data-[vertical=false]/options:group-last/option:!border-r":!0,"group-data-[vertical=false]/options:group-[&]/option:aria-[pressed=true]:border-x-accent-500":!0,"group-data-[vertical=false]/options:group-first/option:aria-[pressed=true]:border-l-accent-500":!0,"group-data-[vertical=false]/options:group-last/option:aria-[pressed=true]:border-r-accent-500":!0,"dark:group-data-[vertical=false]/options:group-[&]/option:aria-[pressed=true]:border-x-accent-500":!0,"dark:group-data-[vertical=false]/options:group-first/option:aria-[pressed=true]:border-l-accent-500":!0,"dark:group-data-[vertical=false]/options:group-last/option:aria-[pressed=true]:border-r-accent-500":!0,"group-data-[vertical=true]/options:group-[&]/option:!border-b-0":!0,"group-data-[vertical=true]/options:group-last/option:!border-b":!0,"group-data-[vertical=true]/options:group-[&]/option:aria-[pressed=true]:border-y-accent-500":!0,"group-data-[vertical=true]/options:group-first/option:aria-[pressed=true]:border-t-accent-500":!0,"group-data-[vertical=true]/options:group-last/option:aria-[pressed=true]:border-b-accent-500":!0,"dark:group-data-[vertical=true]/options:group-[&]/option:aria-[pressed=true]:border-y-accent-500":!0,"dark:group-data-[vertical=true]/options:group-first/option:aria-[pressed=true]:border-t-accent-500":!0,"dark:group-data-[vertical=true]/options:group-last/option:aria-[pressed=true]:border-b-accent-500":!0},transferlist__outer:{group:!0,"min-w-0":!0,grow:!0,"mb-4":!0,"data-[disabled]:select-none":!0,"data-[disabled]:opacity-50":!0,"text-sm":!0,"max-w-none":!0,"[&_.dnd-placeholder]:bg-accent-500":!0,"[&_.dnd-placeholder]:text-white":!0},transferlist__wrapper:{flex:!0,"flex-col":!0,"sm:flex-row":!0,"justify-between":!0,"w-full":!0,"max-w-none":!0},transferlist__help:{"text-zinc-500":!0,"text-[11px]":!0,"[line-height:1em]":!0,"dark:text-zinc-400":!0,"pb-2":!0},transferlist__transferlist:{grow:!0,shrink:!0,"min-w-0":!0,"shadow-none":!0,"group-[&]/repeater:shadow-none":!0,"group-[&]/multistep:shadow-none":!0,"aspect-[4/5]":!0,flex:!0,"flex-col":!0,"h-[350px]":!0,border:!0,"border-zinc-200":!0,"rounded-sm":!0,"overflow-hidden":!0,"select-none":!0,"[&:has(:focus-visible)]:ring-1":!0,"[&:has(:focus-visible)]:ring-accent-400":!0,"dark:border-zinc-800":!0,"dark:bg-zinc-900/50":!0},transferlist__transferlistHeader:{flex:!0,"bg-zinc-100":!0,"text-zinc-600":!0,"text-xs":!0,"justify-between":!0,"items-center":!0,"border-b":!0,"border-zinc-200":!0,"py-2":!0,"px-2.5":!0,"dark:bg-zinc-700":!0,"dark:border-zinc-800":!0,"dark:text-zinc-400":!0},transferlist__transferlistHeaderItemCount:{"ml-auto":!0,"text-xs":!0,"min-w-[1.5em]":!0,"[line-height:1.5em]":!0,"px-2":!0,"text-center":!0,"rounded-lg":!0,"bg-zinc-200":!0,"text-zinc-700":!0,"dark:bg-zinc-500":!0,"dark:text-zinc-300":!0},transferlist__transferlistListItems:{"list-none":!0,"bg-white":!0,"h-full":!0,"overflow-x-hidden":!0,"overflow-y-auto":!0,"dark:bg-transparent":!0,"outline-hidden":!0},transferlist__transferlistListItem:{"py-2":!0,"px-2":!0,"text-zinc-700":!0,"ring-1":!0,"ring-zinc-200":!0,"aria-selected:bg-accent-100":!0,"data-[is-active=true]:bg-accent-100":!0,"data-[is-active=true]:ring-accent-200":!0,"aria-selected:ring-accent-200":!0,relative:!0,flex:!0,"cursor-pointer":!0,"items-center":!0,"bg-white":!0,"pl-[1.5em]":!0,"first:-mt-px":!0,"first:border-t":!0,"aria-selected:z-[2]":!0,"aria-selected:border-transparent":!0,"aria-selected:ring-1":!0,"data-[is-active=true]:z-[2]":!0,"data-[is-active=true]:border-transparent":!0,"data-[is-active=true]:ring-1":!0,"group-data-[is-max=true]:cursor-not-allowed":!0,"dark:bg-zinc-800":!0,"dark:text-zinc-300":!0,"dark:data-[is-active=true]:bg-accent-800":!0,"dark:aria-selected:bg-accent-800":!0,"dark:ring-zinc-700":!0,"dark:data-[is-active=true]:ring-accent-600":!0,"dark:aria-selected:ring-accent-600":!0,"[&.formkit-dropZone]:bg-accent-100":!0,"[&.formkit-selectionDropZone]:bg-accent-100":!0,"[&.formkit-touchDropZone]:bg-accent-100":!0,"[&.formkit-touchSelectionDropZone]:bg-accent-100":!0,"[&.formkit-longTouch]:bg-accent-100":!0,"dark:[&.formkit-dropZone]:bg-accent-900":!0,"dark:[&.formkit-selectionDropZone]:bg-accent-900":!0,"dark:[&.formkit-touchDropZone]:bg-accent-900":!0,"dark:[&.formkit-touchSelectionDropZone]:bg-accent-900":!0,"dark:[&.formkit-longTouch]:bg-accent-900":!0},transferlist__transferlistOption:{"text-xs":!0},transferlist__transferControls:{"inline-flex":!0,"grow-0":!0,shrink:!0,border:!0,"border-zinc-200":!0,"flex-row":!0,"sm:flex-col":!0,"justify-center":!0,"my-2":!0,"sm:my-auto":!0,"mx-auto":!0,"sm:mx-2":!0,"rounded-sm":!0,"overflow-clip":!0,"shadow-none":!0,"group-[&]/repeater:shadow-none":!0,"group-[&]/multistep:shadow-none":!0,"dark:border-zinc-800":!0},transferlist__sourceEmptyMessage:{"appearance-none":!0,"border-none":!0,"w-full":!0,"my-2":!0,"text-center":!0,"text-zinc-500":!0,italic:!0},transferlist__sourceListItems:{"group-data-[is-max=true]:opacity-50":!0},transferlist__targetEmptyMessage:{"appearance-none":!0,"border-none":!0,"w-full":!0,"my-2":!0,"text-center":!0,"text-zinc-500":!0,italic:!0},transferlist__emptyMessageInner:{flex:!0,"items-center":!0,"justify-center":!0,"p-2":!0,"text-sm":!0},transferlist__transferlistControls:{"bg-white":!0,"p-2":!0,"border-b":!0,"border-zinc-200":!0,"dark:bg-zinc-700":!0,"dark:border-zinc-700":!0},transferlist__transferlistSearch:{flex:!0,border:!0,"border-zinc-200":!0,"rounded-sm":!0,"items-center":!0,"text-zinc-700":!0,"selection:bg-accent-100":!0,"dark:border-zinc-800":!0,"dark:text-zinc-300":!0,"dark:selection:bg-accent-100":!0,"dark:selection:text-zinc-700":!0,"dark:bg-zinc-800":!0},transferlist__transferlistSearchInput:{"border-none":!0,"px-2":!0,"py-1.5":!0,"w-full":!0,"bg-transparent":!0,"outline-hidden":!0,"text-xs":!0},transferlist__transferlistSearchClear:{flex:!0,"w-[0.75em]":!0,"mr-2":!0,"[&_svg]:w-full":!0},transferlist__controlLabel:{absolute:!0,"opacity-0":!0,"pointer-events-none":!0,"text-[0px]":!0},transferlist__selectedIcon:{"w-[0.75em]":!0,absolute:!0,"left-[0.5em]":!0,"select-none":!0,"text-accent-500":!0,"dark:text-accent-400":!0},transferlist__transferlistButton:{"sm:w-5":!0,relative:!0,flex:!0,"justify-center":!0,"text-sm":!0,"shrink-0":!0,"box-content":!0,"text-zinc-700":!0,"disabled:bg-zinc-200":!0,"disabled:!text-zinc-400":!0,"bg-zinc-50":!0,"hover:text-accent-500":!0,"cursor-pointer":!0,"appearance-none":!0,"border-none":!0,"p-2.5":!0,"hover:z-10":!0,"disabled:cursor-not-allowed":!0,"disabled:opacity-50":!0,"disabled:hover:text-current":!0,"disabled:hover:outline-hidden":!0,"focus-visible:ring-1":!0,"focus-visible:ring-accent-400":!0,"focus-visible:z-10":!0,"dark:bg-zinc-800":!0,"dark:text-zinc-400":!0,"dark:disabled:!text-zinc-600":!0,"dark:disabled:bg-zinc-900":!0,"dark:disabled:hover:text-current":!0,"dark:disabled:hover:outline-hidden":!0,"dark:hover:text-accent-400":!0},transferlist__fastForwardIcon:{"w-4":!0,flex:!0,"select-none":!0,"[&>svg]:m-auto":!0,"[&>svg]:w-full":!0,"[&>svg]:max-w-[1rem]":!0,"[&>svg]:max-h-[1rem]":!0,"rotate-90":!0,"sm:rotate-0":!0},transferlist__moveRightIcon:{"w-4":!0,flex:!0,"select-none":!0,"[&>svg]:m-auto":!0,"[&>svg]:w-full":!0,"[&>svg]:max-w-[1rem]":!0,"[&>svg]:max-h-[1rem]":!0,"rotate-90":!0,"sm:rotate-0":!0},transferlist__moveLeftIcon:{"w-4":!0,flex:!0,"select-none":!0,"[&>svg]:m-auto":!0,"[&>svg]:w-full":!0,"[&>svg]:max-w-[1rem]":!0,"[&>svg]:max-h-[1rem]":!0,"rotate-90":!0,"sm:rotate-0":!0},transferlist__rewindIcon:{"w-4":!0,flex:!0,"select-none":!0,"[&>svg]:m-auto":!0,"[&>svg]:w-full":!0,"[&>svg]:max-w-[1rem]":!0,"[&>svg]:max-h-[1rem]":!0,"rotate-90":!0,"sm:rotate-0":!0},transferlist__messages:{"mt-2":!0},barcode__barcodeIcon:{"w-[1.5em]":!0,"text-zinc-700":!0,"cursor-pointer":!0,"dark:text-zinc-300":!0},barcode__dialog:{"border-none":!0,"outline-hidden":!0,"overflow-clip":!0,"p-0":!0,"bg-black":!0,"rounded-sm":!0,"w-[100%-2rem]":!0,"max-w-[30rem]":!0,"[&::backdrop]:bg-zinc-800/50":!0},barcode__video:{"w-full":!0,"aspect-[1/1]":!0,"object-cover":!0,block:!0,"pointer-events-none":!0},barcode__closeIcon:{"cursor-pointer":!0,absolute:!0,"bg-white":!0,"color-zinc-700":!0,"w-[1.5em]":!0,"h-[1.5em]":!0,"rounded-sm":!0,flex:!0,"top-2":!0,"right-2":!0,"z-20":!0,"[&>svg]:w-[1.25em]":!0,"[&>svg]:h-[1.25em]":!0,"[&>svg]:m-auto":!0},barcode__overlay:{"text-zinc-700":!0,"dark:text-zinc-300":!0,absolute:!0,"top-1/2":!0,"left-1/2":!0,"w-[min(20em,75%)]":!0,"aspect-[1/1]":!0,"-translate-x-1/2":!0,"-translate-y-1/2":!0,"rounded-sm":!0,"pointer-events-none":!0,"shadow-[0_0_0_999em_rgba(0,0,0,0.5)]":!0},barcode__overlayDecorators:{absolute:!0,"inset-0":!0,"z-10":!0},barcode__overlayDecoratorTopLeft:{absolute:!0,"w-[1.5rem]":!0,"h-[1.5rem]":!0,"rounded-sm":!0,"top-0":!0,"left-0":!0,"border-l-4":!0,"border-t-4":!0,"rounded-tr-none":!0,"rounded-bl-none":!0},barcode__overlayDecoratorTopRight:{absolute:!0,"w-[1.5rem]":!0,"h-[1.5rem]":!0,"rounded-sm":!0,"top-0":!0,"right-0":!0,"border-r-4":!0,"border-t-4":!0,"rounded-tl-none":!0,"rounded-br-none":!0},barcode__overlayDecoratorBottomRight:{absolute:!0,"w-[1.5rem]":!0,"h-[1.5rem]":!0,"rounded-sm":!0,"bottom-0":!0,"right-0":!0,"border-r-4":!0,"border-b-4":!0,"rounded-tr-none":!0,"rounded-bl-none":!0},barcode__overlayDecoratorBottomLeft:{absolute:!0,"w-[1.5rem]":!0,"h-[1.5rem]":!0,"rounded-sm":!0,"bottom-0":!0,"left-0":!0,"border-l-4":!0,"border-b-4":!0,"rounded-tl-none":!0,"rounded-br-none":!0},"multi-step__outer":{group:!0,"min-w-0":!0,grow:!0,"mb-4":!0,"data-[disabled]:select-none":!0,"data-[disabled]:opacity-50":!0,"text-sm":!0,"group/multistep":!0,"max-w-[32rem]":!0},"multi-step__wrapper":{"group/wrapper":!0,"data-[tab-style=tab]:shadow-none":!0,"data-[tab-style=tab]:rounded-sm":!0},"multi-step__tabs":{flex:!0,"items-center":!0,"group-data-[tab-style=tab]/wrapper:overflow-auto":!0,"group-data-[tab-style=tab]/wrapper:border":!0,"group-data-[tab-style=tab]/wrapper:border-b-0":!0,"group-data-[tab-style=tab]/wrapper:border-zinc-200":!0,"group-data-[tab-style=tab]/wrapper:rounded-sm":!0,"group-data-[tab-style=tab]/wrapper:rounded-bl-none":!0,"group-data-[tab-style=tab]/wrapper:rounded-br-none":!0,"dark:group-data-[tab-style=tab]/wrapper:border-zinc-800":!0,"group-data-[tab-style=progress]/wrapper:my-6":!0,"group-data-[tab-style=progress]/wrapper:justify-around":!0,"group-data-[tab-style=progress]/wrapper:overflow-visible":!0,"group-data-[tab-style=progress]/wrapper:group-data-[hide-labels=true]/wrapper:mb-3.5":!0},"multi-step__tab":{"group/tab":!0,"group-data-[tab-style=tab]/wrapper:relative":!0,"group-data-[tab-style=tab]/wrapper:flex":!0,"group-data-[tab-style=tab]/wrapper:grow":!0,"group-data-[tab-style=tab]/wrapper:text-xs":!0,"group-data-[tab-style=tab]/wrapper:items-center":!0,"group-data-[tab-style=tab]/wrapper:justify-center":!0,"group-data-[tab-style=tab]/wrapper:cursor-pointer":!0,"group-data-[tab-style=tab]/wrapper:text-zinc-700":!0,"group-data-[tab-style=tab]/wrapper:bg-zinc-100":!0,"group-data-[tab-style=tab]/wrapper:py-3.5":!0,"group-data-[tab-style=tab]/wrapper:px-4":!0,"group-data-[tab-style=tab]/wrapper:border-r":!0,"group-data-[tab-style=tab]/wrapper:border-b":!0,"group-data-[tab-style=tab]/wrapper:border-zinc-200":!0,"group-data-[tab-style=tab]/wrapper:last:border-r-0":!0,"group-data-[tab-style=tab]/wrapper:shadow-[inset_0_-0.5em_0.5em_-0.5em_rgba(0,0,0,0.1)]":!0,"group-data-[tab-style=tab]/wrapper:data-[active=true]:bg-white":!0,"group-data-[tab-style=tab]/wrapper:data-[active=true]:font-bold":!0,"group-data-[tab-style=tab]/wrapper:data-[active=true]:border-b-white":!0,"group-data-[tab-style=tab]/wrapper:data-[active=true]:z-10":!0,"group-data-[tab-style=tab]/wrapper:data-[active=true]:shadow-[0_0_0.5em_0_rgba(0,0,0,0.1)]":!0,"dark:group-data-[tab-style=tab]/wrapper:text-zinc-300":!0,"dark:group-data-[tab-style=tab]/wrapper:bg-zinc-950/20":!0,"dark:group-data-[tab-style=tab]/wrapper:data-[active=true]:bg-transparent":!0,"dark:group-data-[tab-style=tab]/wrapper:data-[active=true]:border-b-transparent":!0,"dark:group-data-[tab-style=tab]/wrapper:border-zinc-800":!0,"group-data-[tab-style=progress]/wrapper:flex":!0,"group-data-[tab-style=progress]/wrapper:flex-col":!0,"group-data-[tab-style=progress]/wrapper:items-center":!0,"group-data-[tab-style=progress]/wrapper:grow":!0,"group-data-[tab-style=progress]/wrapper:shrink-0":!0,"group-data-[tab-style=progress]/wrapper:relative":!0,"group-data-[tab-style=progress]/wrapper:before:block":!0,"group-data-[tab-style=progress]/wrapper:before:text-xs":!0,"group-data-[tab-style=progress]/wrapper:before:w-[1.25rem]":!0,"group-data-[tab-style=progress]/wrapper:before:h-[1.25rem]":!0,"group-data-[tab-style=progress]/wrapper:before:border-4":!0,"group-data-[tab-style=progress]/wrapper:before:border-zinc-300":!0,"group-data-[tab-style=progress]/wrapper:before:rounded-full":!0,"group-data-[tab-style=progress]/wrapper:before:bg-white":!0,"group-data-[tab-style=progress]/wrapper:before:z-10":!0,"dark:group-data-[tab-style=progress]/wrapper:before:border-zinc-800":!0,"dark:group-data-[tab-style=progress]/wrapper:before:bg-zinc-950":!0,"group-data-[tab-style=progress]/wrapper:after:block":!0,"group-data-[tab-style=progress]/wrapper:after:h-1":!0,"group-data-[tab-style=progress]/wrapper:after:w-full":!0,"group-data-[tab-style=progress]/wrapper:after:absolute":!0,"group-data-[tab-style=progress]/wrapper:after:top-[0.5em]":!0,"group-data-[tab-style=progress]/wrapper:after:left-[calc(50%+0.5em)]":!0,"group-data-[tab-style=progress]/wrapper:after:bg-zinc-300":!0,"group-data-[tab-style=progress]/wrapper:data-[valid=true]:data-[visited=true]:after:bg-accent-500":!0,"group-data-[tab-style=progress]/wrapper:last:after:hidden":!0,"dark:group-data-[tab-style=progress]/wrapper:after:bg-zinc-800":!0,"dark:group-data-[tab-style=progress]/wrapper:data-[valid=true]:data-[visited=true]:after:bg-accent-500":!0},"multi-step__tabLabel":{"group-data-[tab-style=progress]/wrapper:absolute":!0,"group-data-[tab-style=progress]/wrapper:text-zinc-800":!0,"group-data-[tab-style=progress]/wrapper:top-full":!0,"group-data-[tab-style=progress]/wrapper:w-full":!0,"group-data-[tab-style=progress]/wrapper:whitespace-nowrap":!0,"group-data-[tab-style=progress]/wrapper:text-[11px]":!0,"[line-height:1em]":!0,"dark:group-data-[tab-style=progress]/wrapper:text-zinc-300":!0},"multi-step__badge":{"bg-red-500":!0,absolute:!0,"font-mono":!0,"font-bold":!0,flex:!0,"items-center":!0,"justify-center":!0,"aspect-[1/1]":!0,"[line-height:1.25rem]":!0,"text-white":!0,"rounded-full":!0,"group-data-[valid=true]/tab:bg-accent-500":!0,"group-data-[tab-style=tab]/wrapper:text-[0.66rem]":!0,"group-data-[tab-style=tab]/wrapper:p-1.5":!0,"group-data-[tab-style=tab]/wrapper:w-5":!0,"group-data-[tab-style=tab]/wrapper:h-5":!0,"group-data-[tab-style=tab]/wrapper:top-1.5":!0,"group-data-[tab-style=tab]/wrapper:right-1.5":!0,"group-data-[tab-style=progress]/wrapper:w-[1.25rem]":!0,"group-data-[tab-style=progress]/wrapper:h-[1.25rem]":!0,"group-data-[tab-style=progress]/wrapper:p-1":!0,"group-data-[tab-style=progress]/wrapper:text-[10px]":!0,"group-data-[tab-style=progress]/wrapper:[line-height:0]":!0,"group-data-[tab-style=progress]/wrapper:z-10":!0},"multi-step__validStepIcon":{"w-full":!0,"h-full":!0,"mt-0.5":!0},"multi-step__steps":{"px-10":!0,"pt-8":!0,"pb-4":!0,"bg-white":!0,border:!0,"border-zinc-200":!0,"rounded-sm":!0,"dark:bg-transparent":!0,"dark:border-zinc-800":!0,"group-data-[tab-style=tab]/wrapper:border-t-0":!0,"group-data-[tab-style=tab]/wrapper:rounded-tl-none":!0,"group-data-[tab-style=tab]/wrapper:rounded-tr-none":!0,"group-data-[tab-style=progress]/wrapper:shadow-none":!0,"[&_[data-type]]:max-w-none":!0},step__stepActions:{flex:!0,"justify-between":!0,"[&>*]:grow-0":!0},step__stepPrevious:{"mr-1.5":!0},step__stepNext:{"ml-auto":!0}},yo={outer:{group:!0,"max-w-none":!0,"min-w-0":!0,grow:!0,"mb-4":!0,"data-[disabled]:select-none":!0,"data-[disabled]:opacity-50":!0,"text-sm":!0},label:{block:!0,"text-zinc-700":!0,"text-xs":!0,"font-bold":!0,"mb-1":!0,"dark:text-zinc-300":!0},legend:{block:!0,"text-zinc-700":!0,"text-xs":!0,"font-bold":!0,"dark:text-zinc-300":!0},input:{"appearance-none":!0,"[color-scheme:light]":!0,"dark:[color-scheme:dark]":!0,"selection:bg-accent-100":!0,"selection:text-zinc-700":!0,"group-data-[has-overlay]:selection:!text-transparent":!0},prefixIcon:{flex:!0,"items-center":!0,"-ml-1":!0,"mr-2":!0,"text-sm":!0,"h-[1em]":!0,"w-[1em]":!0,"shrink-0":!0,"[&>svg]:w-full":!0},suffixIcon:{flex:!0,"items-center":!0,"-mr-1":!0,"ml-2":!0,"text-sm":!0,"h-[1em]":!0,"w-[1em]":!0,"shrink-0":!0,"[&>svg]:w-full":!0},loaderIcon:{"animate-spin":!0,flex:!0,"items-center":!0,"my-auto":!0,"ml-2":!0,"text-sm":!0,"text-zinc-500":!0,"h-[1em]":!0,"w-[1em]":!0,"shrink-0":!0,"[&>svg]:w-full":!0},loadMoreInner:{flex:!0,"text-xs":!0,"text-zinc-500":!0,"p-2":!0,"items-center":!0,"justify-center":!0,"[&>span]:mr-2":!0},help:{"text-zinc-500":!0,"text-[11px]":!0,"[line-height:1em]":!0,"dark:text-zinc-400":!0},message:{"text-red-500":!0,"mb-1.5":!0,"text-[11px]":!0,"[line-height:1em]":!0,"dark:text-red-400":!0},overlay:{"text-zinc-700":!0,"dark:text-zinc-300":!0},overlayPlaceholder:{"text-zinc-400":!0,"dark:text-zinc-400/50":!0},overlayLiteral:{"text-zinc-700":!0,"dark:text-zinc-300":!0},overlayChar:{"text-zinc-700":!0,"dark:text-zinc-300":!0},overlayEnum:{"text-zinc-700":!0,"dark:text-zinc-300":!0},searchInput__input:{"w-full":!0,"bg-transparent":!0,border:!0,"border-zinc-200":!0,"dark:border-zinc-700":!0,"rounded-lg":!0,"focus:outline-none":!0,"focus:ring-2":!0,"focus:ring-accent-500/30":!0,"focus:border-accent-500":!0,"dark:focus:border-accent-400":!0,"transition-all":!0,"placeholder:text-zinc-400":!0,"disabled:opacity-50":!0,"disabled:cursor-not-allowed":!0,"pl-9":!0,"pr-9":!0,"py-2":!0,"text-sm":!0},"searchInput__input--sm":{"pl-7":!0,"pr-7":!0,"py-1.5":!0,"text-xs":!0},searchInput__icon:{absolute:!0,"left-3":!0,"top-1/2":!0,"-translate-y-1/2":!0,"text-zinc-400":!0,"w-4":!0,"h-4":!0},"searchInput__icon--sm":{"left-2":!0,"w-3.5":!0,"h-3.5":!0},searchInput__clearButton:{absolute:!0,"right-2.5":!0,"top-1/2":!0,"-translate-y-1/2":!0,"p-1":!0,"rounded-md":!0,"hover:bg-zinc-100":!0,"dark:hover:bg-zinc-800":!0,"transition-colors":!0},searchInput__clearIcon:{"w-3.5":!0,"h-3.5":!0,"text-zinc-400":!0,"hover:text-zinc-600":!0,"dark:hover:text-zinc-300":!0},selectSearch__button:{"w-full":!0,"min-w-[200px]":!0,"px-3":!0,"py-2":!0,"text-left":!0,"rounded-lg":!0,"focus:outline-none":!0,"focus:ring-2":!0,"focus:ring-accent-500/30":!0,"bg-transparent":!0,"disabled:opacity-50":!0,"disabled:cursor-not-allowed":!0,"text-sm":!0,"overflow-hidden":!0,"transition-colors":!0,border:!0,"border-zinc-200":!0,"dark:border-zinc-700":!0,"focus:border-accent-500":!0,"dark:focus:border-accent-400":!0}};function ko(t){const n=String(t.value||"");return n?/^[a-z][a-z0-9_]*$/.test(n):!0}function wo(t){const n=t.value;if(n===""||n===null||n===void 0)return!0;const a=Number(n);return a>0&&Number.isInteger(a)}function _o(t){const n=t.value;return n===""||n===null||n===void 0?!0:Number(n)>=0}function $o(t){const n=String(t.value||"");if(!n.trim())return!0;try{return JSON.parse(n),!0}catch{return!1}}function Co(t){const n=String(t.value||"");if(!n)return!0;try{return new URL(n),!0}catch{return!1}}function So(t){const n=String(t.value||"");return n?n.length>=10&&!/\s/.test(n):!0}const Io={snakeCase:ko,positiveInteger:wo,nonNegative:_o,validJson:$o,validUrl:Co,apiKey:So},To={snakeCase({name:t}){return`${t} must be in snake_case format (lowercase letters, numbers, and underscores, starting with a letter).`},positiveInteger({name:t}){return`${t} must be a positive whole number.`},nonNegative({name:t}){return`${t} must be zero or greater.`},validJson({name:t}){return`${t} must be valid JSON.`},validUrl({name:t}){return`${t} must be a valid URL.`},apiKey({name:t}){return`${t} must be at least 10 characters with no spaces.`}},Wt=Ce({__name:"DropShadow",props:{offsetX:{default:8},offsetY:{default:8},intensity:{default:.5},pattern:{default:"crosshatch"}},setup(t){const n=t,a=m(),s=m(),l=m(),u=m(0),i=(h,g,y,_,v,d)=>{h.beginPath(),h.moveTo(g+d,y),h.lineTo(g+_-d,y),h.quadraticCurveTo(g+_,y,g+_,y+d),h.lineTo(g+_,y+v-d),h.quadraticCurveTo(g+_,y+v,g+_-d,y+v),h.lineTo(g+d,y+v),h.quadraticCurveTo(g,y+v,g,y+v-d),h.lineTo(g,y+d),h.quadraticCurveTo(g,y,g+d,y),h.closePath()},p=async()=>{if(await Ne(),!a.value||!s.value||!l.value)return;const h=a.value.getContext("2d");if(!h)return;const g=l.value.getBoundingClientRect(),y=l.value.firstElementChild;if(y){const b=getComputedStyle(y);u.value=parseFloat(b.borderRadius)||0}const _=g.width+n.offsetX+4,v=g.height+n.offsetY+4;a.value.width=_,a.value.height=v,a.value.style.width=`${_}px`,a.value.style.height=`${v}px`,h.clearRect(0,0,a.value.width,a.value.height);const d=document.documentElement.classList.contains("dark");if(h.fillStyle=d?"#6b7280":"black",h.globalAlpha=n.intensity,h.save(),i(h,n.offsetX,n.offsetY,g.width,g.height,u.value),h.clip(),n.pattern==="crosshatch"){const b=d?4:3;h.lineWidth=1,h.strokeStyle=d?"#6b7280":"black";for(let c=-g.height;c<g.width;c+=b)h.beginPath(),h.moveTo(n.offsetX+c,n.offsetY),h.lineTo(n.offsetX+c+g.height,n.offsetY+g.height),h.stroke();for(let c=0;c<g.width+g.height;c+=b)h.beginPath(),h.moveTo(n.offsetX+c,n.offsetY+g.height),h.lineTo(n.offsetX+c-g.height,n.offsetY),h.stroke()}else if(n.pattern==="dots"){const c=d?3:2,f=[[0,8,2,10],[12,4,14,6],[3,11,1,9],[15,7,13,5]];for(let $=0;$<g.width;$+=c)for(let N=0;N<g.height;N+=c){const E=Math.floor($/c)%4,L=Math.floor(N/c)%4;f[L][E]/16<n.intensity&&h.fillRect(n.offsetX+$,n.offsetY+N,1,1)}}else if(n.pattern==="diagonal"){const b=d?5:4;h.lineWidth=1,h.strokeStyle=d?"#6b7280":"black";for(let c=-g.height;c<g.width;c+=b)h.beginPath(),h.moveTo(n.offsetX+c,n.offsetY),h.lineTo(n.offsetX+c+g.height,n.offsetY+g.height),h.stroke()}h.restore()};let x=null,k=null;return qe(()=>{x=new ResizeObserver(()=>{p()}),l.value&&x.observe(l.value),p(),k=new MutationObserver(()=>{p()}),k.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]})}),ut(()=>{l.value&&x&&x.unobserve(l.value),k&&k.disconnect()}),Ee(()=>[n.offsetX,n.offsetY,n.intensity,n.pattern],()=>{p()}),(h,g)=>(r(),o("div",{ref_key:"container",ref:s,class:"relative",style:yt({paddingRight:`${t.offsetX}px`,paddingBottom:`${t.offsetY}px`})},[e("canvas",{ref_key:"canvas",ref:a,class:"absolute top-0 left-0 pointer-events-none"},null,512),e("div",{ref_key:"contentEl",ref:l,class:"relative"},[We(h.$slots,"default")],512)],4))}}),Mo={class:"prompt-input-container relative"},zo=["contenteditable","data-placeholder"],Vo={class:"bg-white dark:bg-zinc-900 border border-zinc-300 dark:border-zinc-700 rounded-sm overflow-hidden min-w-[240px] max-w-[320px]"},Eo={key:0,class:"p-3 text-sm text-neutral-500"},Lo={key:1,class:"p-3 text-sm text-neutral-500"},Ao={key:2,class:"max-h-[220px] overflow-y-auto"},Po=["onClick"],jo={class:"font-medium flex items-center gap-2"},Ro=["title"],Oo={key:0,class:"text-xs text-neutral-500 dark:text-neutral-400 mt-0.5"},Do={key:1,class:"text-xs text-red-600 dark:text-red-400 mt-1"},Uo={class:"text-xs mt-1"},Bo=Ce({__name:"PromptInput",props:{modelValue:{},search:{},placeholder:{default:"Type @ to insert variables, env, or prompts..."},disabled:{type:Boolean,default:!1},maxLength:{},allowedTypes:{default:()=>["variable","env","prompt"]},editorClass:{}},emits:["update:modelValue","segment-click"],setup(t,{emit:n}){const a=t,s=n,l=m(),u=m(),i=nn({segments:a.modelValue&&a.modelValue.length?a.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),x=H=>H.type==="string"?"":`@${H.type==="variable"?H.label||H.value:H.type==="env"?H.label||H.property:H.label||H.id}`,k=H=>{const ve=H._uid||(H._uid=p()),X=x(H),D=H.type==="variable"?{type:"variable",value:H.value,label:H.label,schema:H.schema,meta:H.meta}:H.type==="env"?{type:"env",property:H.property,label:H.label,meta:H.meta}:{type:"prompt",id:H.id,label:H.label,schema:H.schema,meta:H.meta},W=encodeURIComponent(JSON.stringify(D)),me=(H.type==="prompt"||H.type==="env")&&H.meta&&!H.meta.isValid,ue=me?`<span class="prompt-tag-warning" title="${(H.meta?.validationMessage||"").replace(/"/g,"&quot;")}">⚠️</span>`:"";return`<span class="prompt-tag prompt-tag-clickable${me?" prompt-tag-invalid":""}" contenteditable="false" data-segment-uid="${ve}" data-segment="${W}">${X}${ue}</span>`},h=H=>{const ve=document.createRange();ve.selectNode(H);const X=window.getSelection();X.removeAllRanges(),X.addRange(ve),document.execCommand("delete")},g=()=>{if(!l.value)return;const H=i.segments.map(ve=>ve.type==="string"?(ve.value||"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/\n/g,"<br>")||"":k(ve)).join("");l.value.innerHTML=H||"<br>"},y=()=>{const H=[];for(const ve of i.segments)ve.type==="string"&&H.length>0&&H[H.length-1].type==="string"?H[H.length-1].value+=ve.value:H.push(ve);i.segments=H.length?H:[{type:"string",value:""}]},_=H=>{const ve=H.dataset.segmentUid;let X=i.segments.find(D=>D._uid===ve);if(!X){const D=H.dataset.segment;if(D)try{const W=JSON.parse(decodeURIComponent(D));W&&(W.type==="variable"||W.type==="prompt"||W.type==="env")&&(X=W.type==="variable"?{type:"variable",value:W.value,label:W.label,schema:W.schema,meta:W.meta,_uid:ve}:W.type==="env"?{type:"env",property:W.property,label:W.label,meta:W.meta,_uid:ve}:{type:"prompt",id:W.id,label:W.label,schema:W.schema,meta:W.meta,_uid:ve})}catch{}}return X||null},v=H=>{const ve=H.target;if(ve.classList?.contains("prompt-tag")){const X=_(ve);X&&s("segment-click",X,H)}},d=H=>{if(i.isComposing)return;const ve=H.target,X=[];let D="";const W=()=>{D.length>0&&(X.push({type:"string",value:D}),D="")},me=ae=>{if(ae.nodeType===Node.TEXT_NODE){const ye=(ae.textContent||"").replace(/\u00A0/g," ");D+=ye;return}if(ae.nodeType===Node.ELEMENT_NODE){const ye=ae;if(ye.classList?.contains("prompt-tag")){W();const ne=_(ye);ne&&X.push(ne);return}if(ye.tagName==="BR"){D+=`
2
- `;return}const Te=Array.from(ye.childNodes);for(const ne of Te)me(ne);(ye.tagName==="DIV"||ye.tagName==="P"||ye.tagName==="LI")&&ye.nextSibling&&(D+=`
3
- `);return}},ue=Array.from(ve.childNodes);for(const ae of ue)me(ae);W();const Y=X.some(ae=>ae.type!=="string")?X:[{type:"string",value:(ve.innerText||"").replace(/\r\n/g,`
4
- `)}];i.segments=Y.length?Y:[{type:"string",value:""}],y(),b(),ie()},b=()=>{const H=window.getSelection();if(!H||!H.rangeCount||!l.value)return;const ve=H.getRangeAt(0);if(ve.startContainer.nodeType!==Node.TEXT_NODE){i.dialogOpen&&f();return}const D=ve.startContainer.textContent||"",W=ve.startOffset;if(W>0&&D[W-1]==="@")i.atTriggerIndex=W-1,i.searchQuery="",c(),E("");else if(i.dialogOpen&&i.atTriggerIndex>=0)if(ve.startContainer.nodeType===Node.TEXT_NODE){const me=ve.startContainer.textContent||"",ue=ve.startOffset;if(ue<=i.atTriggerIndex){f();return}const te=me.substring(0,ue);if(te.length>i.atTriggerIndex&&te[i.atTriggerIndex]==="@"){const Y=te.substring(i.atTriggerIndex+1);Y.includes(" ")||Y.includes(`
5
- `)||Y.length>i.searchQuery.length+5?f():(i.searchQuery=Y,E(Y))}else f()}else f()},c=async()=>{i.dialogOpen=!0,i.selectedIndex=0,await Ne(),$()},f=()=>{i.dialogOpen=!1,i.searchResults=[],i.searchQuery="",i.atTriggerIndex=-1,i.isSearching=!1},$=()=>{if(!u.value||!l.value)return;const H=window.getSelection();if(!H||!H.rangeCount)return;const X=H.getRangeAt(0).getBoundingClientRect(),D=l.value.getBoundingClientRect();i.dialogPosition={x:X.left-D.left,y:X.bottom-D.top+4}};let N=null;const E=async H=>{if(!a.search){i.searchResults=[];return}N&&clearTimeout(N),i.isSearching=!0,N=setTimeout(async()=>{try{const ve=await a.search(H);i.searchResults=(ve||[]).filter(X=>a.allowedTypes?.includes(X.type))}catch(ve){console.error("Search error:",ve),i.searchResults=[]}finally{i.isSearching=!1}},200)},L=H=>H.type==="variable"?{type:"variable",value:H.value??H.id??"",label:H.label,schema:H.schema,_uid:p(),meta:H.meta}:H.type==="env"?{type:"env",property:H.value??H.id??"",label:H.label,_uid:p(),meta:H.meta}:{type:"prompt",id:H.id??H.value??"",label:H.label,schema:H.schema,_uid:p(),meta:H.meta},V=H=>{if(i.atTriggerIndex<0||!l.value)return;const ve=window.getSelection();if(!ve||!ve.rangeCount)return;const X=ve.getRangeAt(0);if(X.startContainer.nodeType!==Node.TEXT_NODE)return;const D=X.startContainer,W=X.startOffset,me=document.createRange();me.setStart(D,i.atTriggerIndex),me.setEnd(D,W),ve.removeAllRanges(),ve.addRange(me);const ue=L(H),te=k(ue);f(),document.execCommand("insertHTML",!1,te),l.value.focus()},A=H=>{if((H.key==="ArrowLeft"||H.key==="ArrowRight")&&setTimeout(()=>b(),0),i.dialogOpen)H.key==="ArrowDown"?(H.preventDefault(),i.selectedIndex=Math.min(i.selectedIndex+1,i.searchResults.length-1)):H.key==="ArrowUp"?(H.preventDefault(),i.selectedIndex=Math.max(i.selectedIndex-1,0)):H.key==="Enter"?(H.preventDefault(),i.searchResults[i.selectedIndex]&&V(i.searchResults[i.selectedIndex])):(H.key==="Escape"||H.key==="Esc")&&(H.preventDefault(),f());else if(H.key==="Backspace"||H.key==="Delete"){const ve=window.getSelection();if(!ve||!ve.rangeCount||!l.value)return;const X=ve.getRangeAt(0);if(!X.collapsed)return;if(H.key==="Backspace"){if(X.startContainer===l.value){const D=X.startOffset-1;if(D>=0){const W=l.value.childNodes[D];if(W&&W.nodeType===Node.ELEMENT_NODE&&W.classList?.contains("prompt-tag")){H.preventDefault(),h(W);return}}}if(X.startContainer.nodeType===Node.TEXT_NODE&&X.startOffset===0){let D=X.startContainer;for(;D&&D!==l.value;){const W=D.previousSibling;if(W&&W.nodeType===Node.ELEMENT_NODE&&W.classList?.contains("prompt-tag")){H.preventDefault(),h(W);return}D=D.parentNode}}}else{if(X.startContainer===l.value){const D=l.value.childNodes[X.startOffset];if(D&&D.nodeType===Node.ELEMENT_NODE&&D.classList?.contains("prompt-tag")){H.preventDefault(),h(D);return}}if(X.startContainer.nodeType===Node.TEXT_NODE&&X.startOffset===(X.startContainer.textContent?.length??0)){let D=X.startContainer;for(;D&&D!==l.value;){const W=D.nextSibling;if(W&&W.nodeType===Node.ELEMENT_NODE&&W.classList?.contains("prompt-tag")){H.preventDefault(),h(W);return}D=D.parentNode}}}}},G=H=>{H.preventDefault();const ve=H.clipboardData?.getData("text/plain")||"";document.execCommand("insertText",!1,ve)},ee=H=>{if(!i.dialogOpen)return;const ve=u.value;ve&&(ve.contains(H.target)||f())},ie=()=>{i.ignoreNextWatch=!0;const H=i.segments.map(ve=>{const{_uid:X,...D}=ve||{};return D});s("update:modelValue",H)},be=()=>{const H=window.getSelection();if(!H||!l.value)return;const ve=H.anchorNode;ve&&l.value.contains(ve)&&b()},Q=H=>{(H.key==="Escape"||H.key==="Esc")&&i.dialogOpen&&(H.preventDefault(),f())};qe(()=>{a.modelValue&&a.modelValue.length&&(i.segments=JSON.parse(JSON.stringify(a.modelValue))),g(),document.addEventListener("mousedown",ee),document.addEventListener("selectionchange",be),document.addEventListener("keydown",Q,!0)}),ut(()=>{document.removeEventListener("mousedown",ee),document.removeEventListener("selectionchange",be),document.removeEventListener("keydown",Q,!0)});const U=(H,ve)=>{if(H.length!==ve.length)return!1;for(let X=0;X<H.length;X++){const D=H[X],W=ve[X];if(D.type!==W.type)return!1;if(D.type==="string"&&W.type==="string"){if(D.value!==W.value)return!1}else if(D.type==="prompt"&&W.type==="prompt"){if(D.id!==W.id)return!1}else if(D.type==="env"&&W.type==="env"){if(D.property!==W.property)return!1}else if(D.type==="variable"&&W.type==="variable"&&D.value!==W.value)return!1}return!0},R=()=>{if(!l.value)return;l.value.querySelectorAll(".prompt-tag").forEach(ve=>{const X=ve.dataset.segmentUid,D=i.segments.find(te=>te._uid===X);if(!D)return;const W=(D.type==="prompt"||D.type==="env")&&D.meta&&!D.meta.isValid;ve.classList.toggle("prompt-tag-invalid",!!W);const me=ve.querySelector(".prompt-tag-warning");if(W&&!me){const te=document.createElement("span");te.className="prompt-tag-warning",te.textContent="⚠️",te.title=D.meta?.validationMessage||"Validation error",ve.appendChild(te)}else!W&&me?me.remove():W&&me&&(me.title=D.meta?.validationMessage||"Validation error");const ue=D.type==="variable"?{type:"variable",value:D.value,label:D.label,schema:D.schema,meta:D.meta}:D.type==="env"?{type:"env",property:D.property,label:D.label,meta:D.meta}:{type:"prompt",id:D.id,label:D.label,schema:D.schema,meta:D.meta};ve.dataset.segment=encodeURIComponent(JSON.stringify(ue))})};Ee(()=>a.modelValue,H=>{if(i.ignoreNextWatch){i.ignoreNextWatch=!1;return}if(H){const ve=!U(H,i.segments);i.segments=JSON.parse(JSON.stringify(H)),ve?g():R()}},{deep:!0});const K=q(()=>{const H=["prompt-input-editor","min-h-[100px]",a.disabled?"opacity-50 cursor-not-allowed":""];return a.editorClass?[...H,a.editorClass,"!h-auto"]:[...H,"py-2 px-3","rounded-sm","border border-zinc-300 dark:border-zinc-700","bg-white dark:bg-transparent","text-sm text-zinc-700 dark:text-zinc-300","focus:outline-none focus:ring-1 focus:ring-accent-400 focus:border-accent-400"]});return(H,ve)=>(r(),o("div",Mo,[e("div",{ref_key:"editorRef",ref:l,contenteditable:!t.disabled,onInput:d,onKeydown:A,onPaste:G,onClick:v,onKeyup:ve[0]||(ve[0]=X=>{X.key==="Escape"?(X.preventDefault(),f()):(X.key==="ArrowLeft"||X.key==="ArrowRight")&&b()}),onCompositionstart:ve[1]||(ve[1]=X=>i.isComposing=!0),onCompositionend:ve[2]||(ve[2]=X=>i.isComposing=!1),class:ce(K.value),"data-placeholder":t.placeholder},[He(e("div",null,[We(H.$slots,"segment",{segment:null},void 0,!0)],512),[[dt,!1]])],42,zo),i.dialogOpen?(r(),o("div",{key:0,ref_key:"dialogRef",ref:u,class:"absolute z-50",style:yt({left:`${i.dialogPosition.x}px`,top:`${i.dialogPosition.y}px`})},[w(Wt,{"offset-x":4,"offset-y":4,intensity:.3},{default:F(()=>[e("div",Vo,[i.isSearching?(r(),o("div",Eo," Searching... ")):i.searchResults.length===0?(r(),o("div",Lo," No results found ")):(r(),o("div",Ao,[(r(!0),o(we,null,Ae(i.searchResults,(X,D)=>(r(),o("button",{key:X.id||X.value||D,type:"button",onClick:W=>V(X),class:ce(["w-full px-3 py-2 text-left text-sm","hover:bg-neutral-100 dark:hover:bg-neutral-900","focus:bg-neutral-100 dark:focus:bg-neutral-900 focus:outline-none",i.selectedIndex===D?"bg-neutral-100 dark:bg-neutral-900":""])},[e("div",jo,[de(C(X.label||X.id||X.value)+" ",1),X.type==="prompt"&&X.meta&&!X.meta.isValid?(r(),o("span",{key:0,title:X.meta.validationMessage,class:"text-red-500"},"⚠️",8,Ro)):S("",!0)]),X.description?(r(),o("div",Oo,C(X.description),1)):S("",!0),X.type==="prompt"&&X.meta&&!X.meta.isValid?(r(),o("div",Do,C(X.meta.validationMessage),1)):S("",!0),e("div",Uo,[e("span",{class:ce(["inline-block px-1.5 py-0.5 rounded",X.type==="variable"?"bg-blue-100 dark:bg-blue-900 text-blue-700 dark:text-blue-300":X.type==="env"?"bg-emerald-100 dark:bg-emerald-900 text-emerald-700 dark:text-emerald-300":"bg-purple-100 dark:bg-purple-900 text-purple-700 dark:text-purple-300"])},C(X.type),3)])],10,Po))),128))]))])]),_:1})],4)):S("",!0)]))}}),ct=(t,n)=>{const a=t.__vccOpts||t;for(const[s,l]of n)a[s]=l;return a},Mr=ct(Bo,[["__scopeId","data-v-88db0e55"]]),No=Ce({__name:"PromptInputWrapper",props:{context:{}},emits:["segment-click"],setup(t,{emit:n}){const a=t,s=(_,v)=>{const d=a.context;return d[_]!==void 0?d[_]:d.attrs?.[_]!==void 0?d.attrs[_]:v},l=q(()=>a.context.classes??{}),u=q(()=>a.context._value??[]),i=_=>{a.context.node.input(_)},p=q(()=>s("search",void 0)),x=q(()=>s("placeholder","Type @ to insert variables or prompts...")),k=q(()=>s("maxLength",void 0)),h=q(()=>s("allowedTypes",["variable","prompt"])),g=q(()=>a.context.disabled??!1),y=(_,v)=>{const d=a.context;d.attrs?.["onSegment-click"]&&d.attrs["onSegment-click"](_,v)};return(_,v)=>(r(),J(Mr,{"model-value":u.value,search:p.value,placeholder:x.value,disabled:g.value,"max-length":k.value,"allowed-types":h.value,"editor-class":l.value.inner,"onUpdate:modelValue":i,onSegmentClick:y},null,8,["model-value","search","placeholder","disabled","max-length","allowed-types","editor-class"]))}}),qo={type:"input",family:"text",props:["search","placeholder","maxLength","allowedTypes"],schema:()=>[{$el:"label",if:"$label",attrs:{class:"$classes.label",for:"$id"},children:"$label"},{$el:"p",if:"$help",attrs:{class:"$classes.help"},children:"$help"},{$cmp:De(No),props:{context:"$node.context"}}]},Fo={class:"inline-flex items-center justify-center"},Be=Ce({__name:"Loader",props:{size:{default:"md"}},setup(t){const n=t,a=q(()=>{switch(n.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(s,l)=>(r(),o("div",Fo,[e("div",{class:ce([a.value,"border-black/20 dark:border-white/20 border-t-black dark:border-t-white rounded-full animate-spin"])},null,2)]))}}),Ho=["type","disabled"],Wo="inline-flex items-center justify-center gap-2 font-medium rounded transition-all disabled:opacity-50 disabled:cursor-not-allowed",Je=Ce({__name:"UiButton",props:{variant:{default:"primary"},size:{default:"md"},disabled:{type:Boolean,default:!1},loading:{type:Boolean,default:!1},iconLeft:{},iconRight:{},fullWidth:{type:Boolean,default:!1},type:{default:"button"}},emits:["click"],setup(t,{emit:n}){const a=t,s=n,l=q(()=>{switch(a.variant){case"primary":return"bg-black text-white dark:bg-white dark:text-black hover:opacity-90";case"secondary":return"border-2 border-black dark:border-neutral-300 bg-white dark:bg-black text-black dark:text-white hover:bg-neutral-50 dark:hover:bg-neutral-900";case"ghost":return"border border-black dark:border-white hover:bg-black/5 dark:hover:bg-white/10";case"danger":return"border-2 border-red-600 bg-red-600 text-white hover:bg-red-700 hover:border-red-700";case"link":return"text-accent-600 dark:text-accent-400 hover:underline p-0";default:return""}}),u=q(()=>{if(a.variant==="link")return"text-sm";switch(a.size){case"xs":return"px-2 py-1 text-xs";case"sm":return"px-3 py-1.5 text-sm";case"md":return"px-4 py-2 text-sm";case"lg":return"px-6 py-3 text-base";default:return""}}),i=q(()=>a.size==="xs"||a.size==="sm"?"xs":"sm"),p=x=>{!a.disabled&&!a.loading&&s("click",x)};return(x,k)=>(r(),o("button",{type:t.type,disabled:t.disabled||t.loading,class:ce([Wo,l.value,u.value,t.fullWidth?"w-full":""]),onClick:p},[t.loading?(r(),J(Be,{key:0,size:i.value},null,8,["size"])):t.iconLeft?(r(),J(Qe(t.iconLeft),{key:1,class:"w-4 h-4"})):S("",!0),We(x.$slots,"default"),t.iconRight&&!t.loading?(r(),J(Qe(t.iconRight),{key:2,class:"w-4 h-4"})):S("",!0)],10,Ho))}}),Ko=["disabled","aria-label","title"],Jo="inline-flex items-center justify-center rounded transition-colors disabled:opacity-50 disabled:cursor-not-allowed",za=Ce({__name:"UiIconButton",props:{icon:{},label:{},size:{default:"sm"},variant:{default:"default"},disabled:{type:Boolean,default:!1},loading:{type:Boolean,default:!1}},emits:["click"],setup(t,{emit:n}){const a=t,s=n,l=q(()=>{switch(a.variant){case"default":return"hover:bg-black/10 dark:hover:bg-white/10";case"ghost":return"hover:bg-black/5 dark:hover:bg-white/5";case"danger":return"text-red-600 hover:bg-red-50 dark:hover:bg-red-900/20";default:return""}}),u=q(()=>{switch(a.size){case"xs":return"p-0.5";case"sm":return"p-1";case"md":return"p-1.5";default:return""}}),i=q(()=>{switch(a.size){case"xs":return"w-3.5 h-3.5";case"sm":return"w-4 h-4";case"md":return"w-5 h-5";default:return""}}),p=x=>{!a.disabled&&!a.loading&&s("click",x)};return(x,k)=>(r(),o("button",{type:"button",disabled:t.disabled||t.loading,"aria-label":t.label,title:t.label,class:ce([Jo,l.value,u.value]),onClick:p},[t.loading?(r(),J(Be,{key:0,size:"xs"})):(r(),J(Qe(t.icon),{key:1,class:ce(i.value)},null,8,["class"]))],10,Ko))}}),Go=["for"],Yo={key:0,class:"text-red-500 ml-0.5"},Va=Ce({__name:"UiLabel",props:{required:{type:Boolean,default:!1},htmlFor:{}},setup(t){return(n,a)=>(r(),o("label",{for:t.htmlFor,class:"block text-sm font-medium text-neutral-700 dark:text-neutral-300"},[We(n.$slots,"default"),t.required?(r(),o("span",Yo,"*")):S("",!0)],8,Go))}}),Zo={class:"text-xs text-red-500 dark:text-red-400"},kt=Ce({__name:"UiErrorText",setup(t){return(n,a)=>(r(),o("p",Zo,[We(n.$slots,"default")]))}}),Xo={class:"text-xs text-neutral-500 dark:text-neutral-400"},Ue=Ce({__name:"UiHelpText",setup(t){return(n,a)=>(r(),o("p",Xo,[We(n.$slots,"default")]))}}),Qo={class:"space-y-1.5"},Vt=Ce({__name:"UiFormField",props:{label:{},error:{},helpText:{},required:{type:Boolean,default:!1},htmlFor:{}},setup(t){return(n,a)=>(r(),o("div",Qo,[We(n.$slots,"label",{},()=>[t.label?(r(),J(Va,{key:0,"html-for":t.htmlFor,required:t.required},{default:F(()=>[de(C(t.label),1)]),_:1},8,["html-for","required"])):S("",!0)]),We(n.$slots,"default"),We(n.$slots,"error",{},()=>[t.error?(r(),J(kt,{key:0},{default:F(()=>[de(C(t.error),1)]),_:1})):S("",!0)]),We(n.$slots,"help",{},()=>[t.helpText&&!t.error?(r(),J(Ue,{key:0},{default:F(()=>[de(C(t.helpText),1)]),_:1})):S("",!0)])]))}}),el={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function tl(t,n){return r(),o("svg",el,[...n[0]||(n[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 ir=De({name:"lucide-x",render:tl}),rl={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function al(t,n){return r(),o("svg",rl,[...n[0]||(n[0]=[e("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[e("circle",{cx:"12",cy:"12",r:"10"}),e("path",{d:"M12 16v-4m0-4h.01"})],-1)])])}De({name:"lucide-info",render:al});const nl={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function ol(t,n){return r(),o("svg",nl,[...n[0]||(n[0]=[e("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[e("circle",{cx:"12",cy:"12",r:"10"}),e("path",{d:"m9 12l2 2l4-4"})],-1)])])}De({name:"lucide-circle-check",render:ol});const ll={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function sl(t,n){return r(),o("svg",ll,[...n[0]||(n[0]=[e("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"m21.73 18l-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3M12 9v4m0 4h.01"},null,-1)])])}const Hr=De({name:"lucide-triangle-alert",render:sl}),il={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function ul(t,n){return r(),o("svg",il,[...n[0]||(n[0]=[e("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[e("circle",{cx:"12",cy:"12",r:"10"}),e("path",{d:"m15 9l-6 6m0-6l6 6"})],-1)])])}De({name:"lucide-circle-x",render:ul});const Pt=Ce({__name:"UiBadge",props:{variant:{default:"default"},size:{default:"sm"},pill:{type:Boolean,default:!1}},setup(t){const n=t,a=q(()=>{switch(n.variant){case"default":return"bg-neutral-100 dark:bg-neutral-800 text-neutral-700 dark:text-neutral-300";case"primary":return"bg-black dark:bg-white text-white dark:text-black";case"secondary":return"bg-neutral-200 dark:bg-neutral-700 text-neutral-600 dark:text-neutral-300";case"success":return"bg-green-100 dark:bg-green-900/30 text-green-700 dark:text-green-300";case"warning":return"bg-yellow-100 dark:bg-yellow-900/30 text-yellow-700 dark:text-yellow-300";case"error":return"bg-red-100 dark:bg-red-900/30 text-red-700 dark:text-red-300";case"accent":return"bg-accent-100 dark:bg-accent-900/30 text-accent-700 dark:text-accent-300";default:return""}}),s=q(()=>{switch(n.size){case"sm":return"px-2 py-0.5 text-xs";case"md":return"px-2.5 py-1 text-sm";default:return""}});return(l,u)=>(r(),o("span",{class:ce(["inline-flex items-center font-medium",a.value,s.value,t.pill?"rounded-full":"rounded"])},[We(l.$slots,"default")],2))}}),dl={key:0,class:"border-b border-neutral-200 dark:border-neutral-700"},cl={key:1,class:"border-t border-neutral-200 dark:border-neutral-700"},ur=Ce({__name:"UiDropdownPanel",props:{width:{},maxHeight:{},shadow:{type:[Boolean,Object],default:!0}},setup(t){const n=t,a=q(()=>n.shadow===!0?{offsetX:6,offsetY:6,intensity:.4}:n.shadow&&typeof n.shadow=="object"?n.shadow:null),s=q(()=>!!n.shadow),l=q(()=>["bg-white dark:bg-neutral-900 border border-neutral-300 dark:border-neutral-600 rounded-lg overflow-hidden",n.width]),u=q(()=>[n.maxHeight?"overflow-y-auto":"",n.maxHeight]);return(i,p)=>(r(),J(Qe(s.value?Wt:"template"),on(ln(s.value?a.value:{})),{default:F(()=>[e("div",{class:ce(l.value)},[i.$slots.header?(r(),o("div",dl,[We(i.$slots,"header")])):S("",!0),e("div",{class:ce(u.value)},[We(i.$slots,"default")],2),i.$slots.footer?(r(),o("div",cl,[We(i.$slots,"footer")])):S("",!0)],2)]),_:3},16))}}),pl={class:"flex items-start gap-3"},ml={class:"flex-1 text-sm"},at=Ce({__name:"UiAlertBox",props:{variant:{default:"info"},showIcon:{type:Boolean,default:!0}},setup(t){const n=t,a=q(()=>{switch(n.variant){case"warning":return"bg-amber-50 dark:bg-amber-900/20 border-amber-200 dark:border-amber-800 text-amber-800 dark:text-amber-300";case"success":return"bg-emerald-50 dark:bg-emerald-900/20 border-emerald-200 dark:border-emerald-800 text-emerald-800 dark:text-emerald-300";case"error":return"bg-red-50 dark:bg-red-900/20 border-red-200 dark:border-red-800 text-red-800 dark:text-red-300";case"info":default:return"bg-neutral-50 dark:bg-neutral-900/50 border-neutral-200 dark:border-neutral-700 text-neutral-700 dark:text-neutral-300"}}),s=q(()=>{switch(n.variant){case"warning":return Xt;case"success":return un;case"error":return sn;case"info":default:return ca}}),l=q(()=>{switch(n.variant){case"warning":return"text-amber-500 dark:text-amber-400";case"success":return"text-emerald-500 dark:text-emerald-400";case"error":return"text-red-500 dark:text-red-400";case"info":default:return"text-neutral-500 dark:text-neutral-400"}});return(u,i)=>(r(),o("div",{class:ce(["px-4 py-3 border rounded-lg",a.value])},[e("div",pl,[t.showIcon?(r(),J(Qe(s.value),{key:0,class:ce(["w-5 h-5 mt-0.5 flex-shrink-0",l.value])},null,8,["class"])):S("",!0),e("div",ml,[We(u.$slots,"default")])])],2))}}),Wr=Ce({__name:"UiMenuItem",props:{active:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},as:{default:"button"}},emits:["click"],setup(t,{emit:n}){const a=t,s=n;function l(u){a.disabled||s("click",u)}return(u,i)=>(r(),J(Qe(t.as),{type:t.as==="button"?"button":void 0,disabled:t.as==="button"?t.disabled:void 0,onClick:l,class:ce(["w-full flex items-center gap-2 px-3 py-2 text-sm text-left transition-colors",[t.disabled?"opacity-50 cursor-not-allowed":"hover:bg-neutral-100 dark:hover:bg-neutral-800 cursor-pointer",t.active?"bg-accent-50 dark:bg-accent-950/30":""]])},{default:F(()=>[We(u.$slots,"default")]),_:3},8,["type","disabled","class"]))}}),vl={class:"relative inline-flex group"},Kr=Ce({__name:"UiTooltip",props:{content:{},position:{default:"top"}},setup(t){const n=t,a=q(()=>{switch(n.position){case"bottom":return"top-full mt-2 left-1/2 -translate-x-1/2";case"left":return"right-full mr-2 top-1/2 -translate-y-1/2";case"right":return"left-full ml-2 top-1/2 -translate-y-1/2";case"top":default:return"bottom-full mb-2 left-1/2 -translate-x-1/2"}}),s=q(()=>{switch(n.position){case"bottom":return"bottom-full left-1/2 -translate-x-1/2 border-b-black dark:border-b-white border-t-transparent border-l-transparent border-r-transparent";case"left":return"left-full top-1/2 -translate-y-1/2 border-l-black dark:border-l-white border-t-transparent border-b-transparent border-r-transparent";case"right":return"right-full top-1/2 -translate-y-1/2 border-r-black dark:border-r-white border-t-transparent border-b-transparent border-l-transparent";case"top":default:return"top-full left-1/2 -translate-x-1/2 border-t-black dark:border-t-white border-b-transparent border-l-transparent border-r-transparent"}});return(l,u)=>(r(),o("div",vl,[We(l.$slots,"default"),e("div",{class:ce(["absolute z-50 px-3 py-2 text-xs whitespace-nowrap bg-black dark:bg-white text-white dark:text-black rounded opacity-0 invisible group-hover:opacity-100 group-hover:visible group-focus-within:opacity-100 group-focus-within:visible transition-opacity pointer-events-none",a.value]),role:"tooltip"},[de(C(t.content)+" ",1),e("div",{class:ce(["absolute border-4",s.value])},null,2)],2)]))}}),Ea=Ce({__name:"UiCodeBlock",props:{inline:{type:Boolean,default:!0}},setup(t){return(n,a)=>(r(),J(Qe(t.inline?"code":"pre"),{class:ce(["font-mono text-xs bg-neutral-100 dark:bg-neutral-800 rounded",t.inline?"px-1.5 py-0.5":"px-3 py-2 overflow-x-auto"])},{default:F(()=>[We(n.$slots,"default")]),_:3},8,["class"]))}}),fl={key:0,class:"block text-zinc-700 dark:text-zinc-300 text-xs font-bold mb-1"},gl={key:0,class:"text-red-500"},hl=["disabled","aria-expanded"],bl={key:0,class:"flex items-center gap-2 text-zinc-400 flex-1 min-w-0"},xl=["src","alt"],yl={class:"block truncate"},kl={key:2,class:"block truncate text-zinc-400 flex-1 min-w-0"},wl=["placeholder"],_l=["onClick","onMouseenter"],$l=["src","alt"],Cl={key:1,class:"w-full h-full bg-zinc-200 dark:bg-zinc-700 rounded"},Sl={class:"flex-1 min-w-0"},pt=Ce({__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},triggerClass:{},size:{default:"md"},activeHighlight:{type:Boolean,default:!1}},emits:["update:modelValue"],setup(t,{emit:n}){const a=t,s=n,l=m(!1),u=m(""),i=m(),p=m(),x=m(),k=m(),h=m(-1),g=q(()=>a.options.find(G=>G.value===a.modelValue)),y=q(()=>{const G=a.activeHighlight&&g.value,ee=a.size==="sm"?"!text-xs !py-1 !px-2":"",ie=G?"!border-accent-500 !bg-accent-50 dark:!bg-accent-950/50 !text-accent-700 dark:!text-accent-300":"";return a.triggerClass?[a.triggerClass,"text-left cursor-pointer",ee,ie,a.error?"!border-red-500 dark:!border-red-400":""]:["w-full min-w-[200px] px-3 py-2 text-left rounded-lg focus:outline-none focus:ring-2 focus:ring-accent-500/30 bg-transparent disabled:opacity-50 disabled:cursor-not-allowed text-sm overflow-hidden transition-colors",ee,ie,a.error?"border border-red-500 dark:border-red-400 focus:border-red-500 dark:focus:border-red-400":"border border-zinc-200 dark:border-zinc-700 focus:border-accent-500 dark:focus:border-accent-400"]}),_=q(()=>{if(!u.value)return a.options;const G=u.value.toLowerCase();return a.options.filter(ee=>ee.label.toLowerCase().includes(G)||ee.value.toLowerCase().includes(G)||ee.description&&ee.description.toLowerCase().includes(G))});Ee(_,()=>{h.value=-1});const v=()=>{a.disabled||(l.value?c():(l.value=!0,u.value="",h.value=-1,Ne(()=>{if(k.value&&(k.value.setAttribute("popover","auto"),k.value.addEventListener("toggle",V),"showPopover"in k.value))try{k.value.showPopover()}catch{}f(),setTimeout(()=>i.value?.focus(),0)})))},d=G=>{s("update:modelValue",G.value),c(),u.value="",h.value=-1},b=G=>{G.stopPropagation(),s("update:modelValue","")},c=()=>{if(k.value){if("hidePopover"in k.value)try{k.value.hidePopover()}catch{}k.value.removeEventListener("toggle",V)}l.value=!1,h.value=-1},f=()=>{if(!x.value||!k.value)return;const G=x.value.getBoundingClientRect(),ee=window.innerWidth;k.value.style.position="fixed",k.value.style.top=`${G.bottom+8}px`,k.value.style.left=`${G.left}px`,k.value.style.margin="0",k.value.style.width="max-content";const ie=k.value.offsetWidth,be=G.width,Q=Math.min(400,ee-G.left-16),U=Math.max(be,Math.min(ie,Q));k.value.style.width=`${U}px`},$=G=>{p.value&&!p.value.contains(G.target)&&k.value&&!k.value.contains(G.target)&&c()},N=G=>{G.key==="Escape"&&l.value&&(c(),x.value?.focus())},E=G=>{if(!l.value)return;const ee=_.value;if(ee.length!==0)switch(G.key){case"ArrowDown":G.preventDefault(),h.value=h.value<ee.length-1?h.value+1:0,L();break;case"ArrowUp":G.preventDefault(),h.value=h.value>0?h.value-1:ee.length-1,L();break;case"Enter":G.preventDefault(),h.value>=0&&h.value<ee.length&&d(ee[h.value]);break}},L=()=>{Ne(()=>{const G=k.value?.querySelector(".highlighted-option");G&&G.scrollIntoView({block:"nearest",behavior:"smooth"})})},V=G=>{G.target===k.value&&(l.value=G.newState==="open",l.value&&f())},A=()=>{l.value&&f()};return qe(()=>{document.addEventListener("click",$),document.addEventListener("keydown",N),window.addEventListener("resize",A),window.addEventListener("scroll",A,!0)}),ut(()=>{document.removeEventListener("click",$),document.removeEventListener("keydown",N),window.removeEventListener("resize",A),window.removeEventListener("scroll",A,!0)}),(G,ee)=>(r(),o("div",{ref_key:"dropdownRef",ref:p,class:"relative"},[t.label?(r(),o("label",fl,[de(C(t.label)+" ",1),t.required?(r(),o("span",gl,"*")):S("",!0)])):S("",!0),e("button",{ref_key:"buttonRef",ref:x,type:"button",onClick:v,disabled:t.disabled,"aria-expanded":l.value,"aria-haspopup":!0,class:ce(y.value)},[e("div",{class:ce(["flex items-center gap-1 w-full",t.size==="sm"?"min-h-[1.25em]":"min-h-[1.5em]"])},[t.loading?(r(),o("span",bl,[w(Be,{size:"xs"}),ee[1]||(ee[1]=de(" Loading... ",-1))])):g.value?(r(),o("span",{key:1,class:ce(["flex items-center flex-1 min-w-0",t.size==="sm"?"gap-1.5":"gap-2"])},[g.value.icon?(r(),o("img",{key:0,src:g.value.icon,alt:g.value.label,class:ce(["flex-shrink-0",[t.size==="sm"?"w-4 h-4":"w-5 h-5",g.value.icon.startsWith("data:image/svg+xml")?"dark:invert":""]])},null,10,xl)):S("",!0),e("span",yl,C(g.value.label),1)],2)):(r(),o("span",kl,C(t.placeholder),1)),g.value&&!t.disabled?(r(),o("button",{key:3,type:"button",onClick:b,class:"flex-shrink-0 p-0.5 hover:bg-zinc-100 dark:hover:bg-zinc-800 rounded transition-colors","aria-label":"Clear selection"},[(r(),o("svg",{class:ce(["text-zinc-400 hover:text-zinc-600 dark:hover:text-zinc-300",t.size==="sm"?"h-3 w-3":"h-4 w-4"]),xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor"},[...ee[2]||(ee[2]=[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"},null,-1)])],2))])):S("",!0),(r(),o("svg",{class:ce(["text-zinc-400 flex-shrink-0",t.size==="sm"?"h-3.5 w-3.5":"h-5 w-5"]),xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor"},[...ee[3]||(ee[3]=[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"},null,-1)])],2))],2)],10,hl),l.value?(r(),o("div",{key:1,ref_key:"popoverRef",ref:k,class:"dropdown-popover z-[9999]"},[w(I(ur),{"max-height":t.size==="sm"?"max-h-48":"max-h-60",shadow:{offsetX:4,offsetY:4,intensity:.3}},{header:F(()=>[e("div",{class:ce(t.size==="sm"?"p-1.5":"p-2")},[He(e("input",{ref_key:"searchInput",ref:i,"onUpdate:modelValue":ee[0]||(ee[0]=ie=>u.value=ie),type:"text",placeholder:t.searchPlaceholder,onKeydown:E,class:ce(["w-full border border-zinc-300 dark:border-zinc-600 rounded-sm focus:outline-none focus:ring-1 focus:ring-accent-400 focus:border-accent-400 bg-transparent text-zinc-700 dark:text-zinc-200 placeholder:text-zinc-400 dark:placeholder:text-zinc-500",t.size==="sm"?"px-2 py-1 text-xs":"px-3 py-1.5 text-sm"])},null,42,wl),[[ht,u.value]])],2)]),default:F(()=>[_.value.length===0?(r(),o("div",{key:0,class:ce(["text-zinc-500 dark:text-zinc-400",t.size==="sm"?"px-3 py-2 text-xs":"px-4 py-3 text-sm"])}," No options found ",2)):S("",!0),(r(!0),o(we,null,Ae(_.value,(ie,be)=>(r(),o("button",{key:ie.value,type:"button",onClick:Q=>d(ie),onMouseenter:Q=>h.value=be,class:ce(["w-full text-left hover:bg-zinc-100 dark:hover:bg-zinc-800 focus:bg-zinc-100 dark:focus:bg-zinc-800 focus:outline-none flex items-start",[t.size==="sm"?"px-2.5 py-1.5 gap-2":"px-4 py-2 gap-3",{"bg-zinc-50 dark:bg-zinc-900":ie.value===t.modelValue,"bg-zinc-100 dark:bg-zinc-800 highlighted-option":be===h.value}]])},[e("div",{class:ce(["flex-shrink-0 mt-0.5",t.size==="sm"?"w-4 h-4":"w-5 h-5"])},[ie.icon?(r(),o("img",{key:0,src:ie.icon,alt:ie.label,class:ce(["w-full h-full",ie.icon.startsWith("data:image/svg+xml")?"dark:invert":""])},null,10,$l)):(r(),o("div",Cl))],2),e("div",Sl,[e("div",{class:ce(["font-medium text-black dark:text-white",t.size==="sm"?"text-xs":"text-sm"])},C(ie.label),3),ie.description?(r(),o("div",{key:0,class:ce(["text-zinc-500 dark:text-zinc-400 mt-0.5",t.size==="sm"?"text-[10px]":"text-xs"])},C(ie.description),3)):S("",!0)])],42,_l))),128))]),_:1},8,["max-height"])],512)):S("",!0),t.error?(r(),J(I(kt),{key:2,class:"mt-1"},{default:F(()=>[de(C(t.error),1)]),_:1})):S("",!0)],512))}}),Il=["type","value","placeholder","disabled"],St=Ce({__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:n,emit:a}){const s=t,l=a,u=m(null),i=q(()=>["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",s.error?"border-red-500 dark:border-red-400":"border-neutral-300 dark:border-neutral-800",s.disabled?"opacity-50 cursor-not-allowed":""]),p=h=>{const g=h.target;l("update:modelValue",g.value)},x=h=>{l("focus",h)},k=h=>{l("click",h)};return n({inputRef:u}),(h,g)=>(r(),J(I(Vt),{label:t.label,error:t.error,required:t.required},{default:F(()=>[e("input",{ref_key:"inputRef",ref:u,type:t.type,value:t.modelValue,placeholder:t.placeholder,disabled:t.disabled,class:ce(i.value),onInput:p,onFocus:x,onClick:k},null,42,Il)]),_:1},8,["label","error","required"]))}}),Tl=["data-property-id","data-nested-property-id"],Ml={class:"p-3 space-y-3"},zl={class:"flex items-start gap-2"},Vl={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"},El={class:"flex-1 grid grid-cols-1 md:grid-cols-3 gap-2"},Ll={class:"flex items-center gap-2 mt-2"},Al=["disabled"],Pl={key:0},jl={key:0,class:"p-3 bg-neutral-50 dark:bg-neutral-900 rounded-lg space-y-2"},Rl={class:"flex items-center justify-between mb-2"},Ol=["disabled"],Dl={key:0,class:"space-y-1"},Ul=["onClick","disabled"],Bl={key:1,class:"p-3 bg-neutral-50 dark:bg-neutral-900 rounded-lg"},Nl={class:"text-xs font-medium text-neutral-600 dark:text-neutral-400 mb-2"},ql={class:"space-y-2"},Fl={class:"flex items-center justify-between"},Hl=["disabled"],Wl={class:"space-y-2"},Kl={key:2,class:"p-3 bg-neutral-50 dark:bg-neutral-900 rounded-lg"},Jl={key:0,class:"mb-2"},Gl=["disabled"],Yl={key:1,class:"space-y-2"},Zl=Ce({__name:"PropertyEditor",props:mt({propertyId:{},isNested:{type:Boolean,default:!1},parentId:{},disabled:{type:Boolean,default:!1},enableDrag:{type:Boolean,default:!0}},{modelValue:{required:!0},modelModifiers:{}}),emits:mt(["remove","description-keydown","add-top-level"],["update:modelValue"]),setup(t,{emit:n}){const a=t,s=n,l=It(t,"modelValue"),u=m(["object","array","enum","anyOf"].includes(l.value.type));m();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=q(()=>["object","array","enum","anyOf"].includes(l.value.type));Ee(()=>l.value.type,async(v,d)=>{if(["object","array","enum","anyOf"].includes(v)&&(u.value=!0,v==="anyOf"&&!l.value.anyOf&&(l.value.anyOf=[]),v==="object"&&!l.value.properties&&(l.value.properties=[{id:crypto.randomUUID(),name:"property1",type:"string",description:""}]),v==="array"&&!l.value.items&&(l.value.items={id:crypto.randomUUID(),name:"",type:"string",description:""}),v==="enum"&&!l.value.enum&&(l.value.enum=["value1"])),d!==void 0){await Ne();const b=a.isNested?`[data-nested-property-id="${a.propertyId}"] input[placeholder="Description"]`:`[data-property-id="${a.propertyId}"] input[placeholder="Description"]`,c=document.querySelector(b);c&&c.focus()}},{immediate:!0,flush:"sync"});const x=v=>{v.shiftKey&&l.value.type==="object"&&l.value.properties?y():s("add-top-level")},k=()=>{l.value.items||(l.value.items={id:crypto.randomUUID(),name:"",type:"string",description:""})},h=()=>{l.value.enum||(l.value.enum=[]),l.value.enum.push(`value${l.value.enum.length+1}`)},g=v=>{l.value.enum&&l.value.enum.splice(v,1)},y=async()=>{const v={id:crypto.randomUUID(),name:l.value.type==="anyOf"?"":`property${(l.value.properties?.length||l.value.anyOf?.length||0)+1}`,type:"string",description:""};l.value.type==="anyOf"?(l.value.anyOf||(l.value.anyOf=[]),l.value.anyOf.push(v)):(l.value.properties||(l.value.properties=[]),l.value.properties.push(v)),await Ne();const d=document.querySelector(`[data-nested-property-id="${v.id}"] input[placeholder="Property name"]`);d&&(d.focus(),d.select())},_=v=>{l.value.type==="anyOf"&&l.value.anyOf?l.value.anyOf=l.value.anyOf.filter(d=>d.id!==v):l.value.properties&&(l.value.properties=l.value.properties.filter(d=>d.id!==v))};return(v,d)=>{const b=tt("PropertyEditor",!0);return r(),o("div",{"data-property-id":t.isNested?void 0:t.propertyId,"data-nested-property-id":t.isNested?t.propertyId:void 0,class:ce(["border rounded-lg",t.isNested?"border-neutral-100 dark:border-neutral-900":"border-neutral-200 dark:border-neutral-800"])},[e("div",Ml,[e("div",zl,[t.enableDrag?(r(),o("div",Vl,[...d[10]||(d[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)])])):S("",!0),e("div",El,[w(St,{modelValue:l.value.name,"onUpdate:modelValue":d[0]||(d[0]=c=>l.value.name=c),placeholder:"Property name",disabled:t.disabled},null,8,["modelValue","disabled"]),w(pt,{modelValue:l.value.type,"onUpdate:modelValue":d[1]||(d[1]=c=>l.value.type=c),options:i,disabled:t.disabled},null,8,["modelValue","disabled"]),w(St,{modelValue:l.value.description,"onUpdate:modelValue":d[2]||(d[2]=c=>l.value.description=c),placeholder:"Description",disabled:t.disabled,onKeydown:d[3]||(d[3]=dn(Ge(c=>x(c),["prevent"]),["enter"]))},null,8,["modelValue","disabled"])]),e("div",Ll,[p.value?(r(),o("button",{key:0,onClick:d[4]||(d[4]=c=>u.value=!u.value),type:"button",class:"p-1 hover:bg-neutral-100 dark:hover:bg-neutral-800 rounded transition-colors"},[(r(),o("svg",{class:ce(["w-4 h-4 transition-transform",u.value?"rotate-90":""]),fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[...d[11]||(d[11]=[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M9 5l7 7-7 7"},null,-1)])],2))])):S("",!0),e("button",{onClick:d[5]||(d[5]=c=>v.$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"},[...d[12]||(d[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,Al)])]),u.value&&p.value?(r(),o("div",Pl,[l.value.type==="enum"?(r(),o("div",jl,[e("div",Rl,[d[13]||(d[13]=e("h4",{class:"text-xs font-medium text-neutral-600 dark:text-neutral-400"}," Enum Values ",-1)),e("button",{onClick:h,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,Ol)]),l.value.enum?(r(),o("div",Dl,[(r(!0),o(we,null,Ae(l.value.enum,(c,f)=>(r(),o("div",{key:f,class:"flex items-center gap-2"},[w(St,{modelValue:l.value.enum[f],"onUpdate:modelValue":$=>l.value.enum[f]=$,placeholder:"Enum value",disabled:t.disabled,class:"flex-1"},null,8,["modelValue","onUpdate:modelValue","disabled"]),e("button",{onClick:$=>g(f),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"},[...d[14]||(d[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,Ul)]))),128))])):S("",!0)])):S("",!0),l.value.type==="object"||l.value.type==="anyOf"?(r(),o("div",Bl,[e("h4",Nl,C(l.value.type==="anyOf"?"Type Options":"Nested Properties"),1),e("div",ql,[e("div",Fl,[e("button",{onClick:y,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(l.value.type==="anyOf"?"Type Option":"Property"),9,Hl)]),e("div",Wl,[(r(!0),o(we,null,Ae(l.value.type==="anyOf"?l.value.anyOf:l.value.properties,(c,f)=>(r(),J(b,{key:c.id,modelValue:(l.value.type==="anyOf"?l.value.anyOf:l.value.properties)[f],"onUpdate:modelValue":$=>(l.value.type==="anyOf"?l.value.anyOf:l.value.properties)[f]=$,"property-id":c.id,"is-nested":!0,"parent-id":t.propertyId,disabled:t.disabled,"enable-drag":!1,onRemove:$=>_(c.id),onAddTopLevel:d[6]||(d[6]=$=>s("add-top-level"))},null,8,["modelValue","onUpdate:modelValue","property-id","parent-id","disabled","onRemove"]))),128))])])])):S("",!0),l.value.type==="array"?(r(),o("div",Kl,[d[15]||(d[15]=e("h4",{class:"text-xs font-medium text-neutral-600 dark:text-neutral-400 mb-2"}," Array Item Type ",-1)),l.value.items?S("",!0):(r(),o("div",Jl,[e("button",{onClick:k,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,Gl)])),l.value.items?(r(),o("div",Yl,[(r(),J(b,{key:`${l.value.items.id}-${l.value.items.type}`,modelValue:l.value.items,"onUpdate:modelValue":d[7]||(d[7]=c=>l.value.items=c),"property-id":l.value.items.id,"is-nested":!0,"parent-id":t.propertyId,disabled:t.disabled,"enable-drag":!1,onRemove:d[8]||(d[8]=c=>l.value.items=null),onAddTopLevel:d[9]||(d[9]=c=>s("add-top-level"))},null,8,["modelValue","property-id","parent-id","disabled"]))])):S("",!0)])):S("",!0)])):S("",!0)])],10,Tl)}}}),Xl={class:"space-y-2"},Ql=["disabled"],es=Ce({__name:"PropertyList",props:mt({disabled:{type:Boolean,default:!1},parentId:{},isNested:{type:Boolean,default:!1}},{modelValue:{required:!0,default:()=>[]},modelModifiers:{}}),emits:mt(["add-property","description-keydown"],["update:modelValue"]),setup(t,{expose:n,emit:a}){const s=t,l=a,u=It(t,"modelValue"),i=m();let p=!1;qe(async()=>{}),ut(()=>{});const x=async()=>{if(p)return;p=!0;const h={id:crypto.randomUUID(),name:`property${u.value.length+1}`,type:"string",description:"",required:!1};u.value=[...u.value,h],await Ne();const g=s.parentId?`[data-nested-property-id="${h.id}"]`:`[data-property-id="${h.id}"]`,y=document.querySelector(`${g} input[placeholder="Property name"]`);y&&(y.focus(),y.select()),l("add-property"),p=!1},k=h=>{u.value=u.value.filter(g=>g.id!==h)};return n({addProperty:x}),(h,g)=>(r(),o("div",Xl,[e("div",{ref_key:"dragAreaRef",ref:i,class:"space-y-2"},[(r(!0),o(we,null,Ae(u.value,y=>(r(),J(Zl,{key:y.id,modelValue:u.value[u.value.indexOf(y)],"onUpdate:modelValue":_=>u.value[u.value.indexOf(y)]=_,"property-id":y.id,"is-nested":t.isNested,"parent-id":t.parentId,disabled:t.disabled,"enable-drag":!t.isNested,onRemove:_=>k(y.id),onAddTopLevel:g[0]||(g[0]=_=>h.$emit("add-property"))},null,8,["modelValue","onUpdate:modelValue","property-id","is-nested","parent-id","disabled","enable-drag","onRemove"]))),128))],512),e("div",{class:ce(t.isNested?"mt-2":"mt-3 pt-3 border-t border-neutral-200 dark:border-neutral-800")},[e("button",{onClick:x,type:"button",disabled:t.disabled,class:ce(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")},[...g[1]||(g[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"})]),de(" Add Property ")],-1)])],10,Ql)],2)]))}}),ts={class:"space-y-4"},rs={key:0,class:"flex items-center justify-between"},as={class:"text-sm font-medium"},ns={key:0,class:"text-red-500"},os={class:"space-y-2 border border-neutral-200 dark:border-neutral-800 rounded-lg p-4"},ls={key:0,class:"flex items-center justify-between mb-2"},ss={key:1,class:"text-center py-12"},is=["disabled"],us={class:"mt-4 text-center"},ds={key:3,class:"mt-4"},cs={class:"bg-neutral-50 dark:bg-neutral-900 border border-neutral-200 dark:border-neutral-800 rounded-lg p-4 overflow-x-auto"},ps={class:"text-xs leading-relaxed"},ms=["innerHTML"],La=Ce({__name:"JSONSchemaInput",props:mt({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 n=It(t,"modelValue"),a=m([]),s=m(),l=m(!1),u=()=>{if(n.value?.properties){const v=[];n.value.required;for(const[d,b]of Object.entries(n.value.properties)){const c=b,f={id:crypto.randomUUID(),name:d,type:c.type||"string",description:c.description||""};c.enum&&(f.enum=c.enum),c.anyOf&&(f.type="anyOf",f.anyOf=i(c.anyOf)),c.type==="array"&&c.items&&(f.items=p(c.items)),c.type==="object"&&c.properties&&(f.properties=x(c.properties,c.required||[])),v.push(f)}a.value=v}},i=v=>v.map(d=>typeof d=="object"&&d.type?{id:crypto.randomUUID(),name:"",type:d.type,description:d.description||"",properties:d.properties?x(d.properties,d.required||[]):void 0,items:d.items?p(d.items):void 0,enum:d.enum}:{id:crypto.randomUUID(),name:"",type:"string",description:""}),p=v=>{const d={id:crypto.randomUUID(),name:"",type:v.type||"string",description:v.description||""};return v.enum&&(d.enum=v.enum),v.anyOf&&(d.type="anyOf",d.anyOf=i(v.anyOf)),v.type==="array"&&v.items&&(d.items=p(v.items)),v.type==="object"&&v.properties&&(d.properties=x(v.properties,v.required||[])),d},x=(v,d)=>{const b=[];for(const[c,f]of Object.entries(v)){const $=f,N={id:crypto.randomUUID(),name:c,type:$.type||"string",description:$.description||""};$.enum&&(N.enum=$.enum),$.anyOf&&(N.type="anyOf",N.anyOf=i($.anyOf)),$.type==="array"&&$.items&&(N.items=p($.items)),$.type==="object"&&$.properties&&(N.properties=x($.properties,$.required||[])),b.push(N)}return b};u();const k=()=>{const v={type:"object",properties:{},required:[],additionalProperties:!1},{properties:d}=g(a.value);v.properties=d,v.required=Object.keys(d),n.value=v},h=v=>{const d={type:v.type==="anyOf"?void 0:v.type,description:v.description};if(v.type==="enum"&&v.enum&&(d.enum=v.enum,d.type="string"),v.type==="anyOf"&&v.anyOf&&(delete d.type,d.anyOf=v.anyOf.map(h)),v.type==="object"&&v.properties){const{properties:b}=g(v.properties);d.properties=b,d.required=Object.keys(b),d.additionalProperties=!1}return v.type==="array"&&v.items&&(d.items=h(v.items)),d},g=v=>{const d={},b=[];for(const c of v){const f={type:c.type==="anyOf"?void 0:c.type,description:c.description};if(b.push(c.name),c.type==="enum"&&c.enum&&(f.enum=c.enum,f.type="string"),c.type==="anyOf"&&c.anyOf&&c.anyOf.length>0&&(delete f.type,f.anyOf=c.anyOf.map(h)),c.type==="array"&&c.items&&(f.items=h(c.items)),c.type==="object"&&c.properties){const{properties:$}=g(c.properties);f.properties=$,f.required=Object.keys($),f.additionalProperties=!1}d[c.name]=f}return{properties:d,required:b}};Ee(a,()=>{k()},{deep:!0}),k();const y=q(()=>JSON.stringify(n.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>')),_=async()=>{if(a.value.length===0){const v={id:crypto.randomUUID(),name:"property1",type:"string",description:""};a.value.push(v),await Ne();const d=document.querySelector(`[data-property-id="${v.id}"] input[placeholder="Property name"]`);d&&(d.focus(),d.select())}else s.value&&s.value.addProperty()};return(v,d)=>(r(),o("div",ts,[t.label?(r(),o("div",rs,[e("label",as,[de(C(t.label)+" ",1),t.required?(r(),o("span",ns,"*")):S("",!0)])])):S("",!0),e("div",os,[a.value.length>0?(r(),o("div",ls,[...d[2]||(d[2]=[e("h3",{class:"text-sm font-medium text-neutral-700 dark:text-neutral-300"}," Properties ",-1)])])):S("",!0),a.value.length===0?(r(),o("div",ss,[d[4]||(d[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)),d[5]||(d[5]=e("p",{class:"text-neutral-500 dark:text-neutral-400 text-sm mb-4"}," No properties defined ",-1)),e("button",{onClick:_,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"},[...d[3]||(d[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"})]),de(" Add Property ")],-1)])],8,is)])):S("",!0),a.value.length>0?(r(),J(es,{key:2,ref_key:"propertyListRef",ref:s,modelValue:a.value,"onUpdate:modelValue":d[0]||(d[0]=b=>a.value=b),disabled:t.disabled,onAddProperty:_},null,8,["modelValue","disabled"])):S("",!0),e("div",us,[e("button",{onClick:d[1]||(d[1]=b=>l.value=!l.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(l.value?"Hide":"Show")+" JSON Schema ",1)]),l.value?(r(),o("div",ds,[e("div",cs,[e("pre",ps,[e("code",{class:"font-mono",innerHTML:y.value},null,8,ms)])])])):S("",!0)])]))}}),vs=Rt(De(La),{props:["label","disabled","required"],family:"text",features:[]}),fs={class:"space-y-2"},gs={key:0,class:"space-y-2"},hs={key:0,class:"block text-sm font-medium"},bs={key:0,class:"text-red-500"},xs=["src","alt"],ys={class:"flex-1 text-sm"},ks={key:0,class:"text-xs text-neutral-500 dark:text-neutral-400 ml-1"},ws=["onClick","aria-label"],jt=Ce({__name:"MultipleSelectionsInput",props:mt({label:{},placeholder:{default:"Select an option"},searchPlaceholder:{default:"Search..."},error:{},required:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},options:{},addLabel:{default:"Add another"},loading:{type:Boolean,default:!1}},{modelValue:{required:!0,default:()=>[]},modelModifiers:{}}),emits:mt(["removeItem"],["update:modelValue"]),setup(t,{emit:n}){const a=t,s=n,l=It(t,"modelValue"),u=m();pa(async()=>{u.value,await Ne(),await ma({parent:u,values:l,dragHandle:".drag-handle"})});const i=q(()=>Array.isArray(l.value)?l.value.length>0&&typeof l.value[0]=="object"?l.value:l.value.map(h=>{const g=a.options.find(y=>y.value===h);return{id:h,label:g?.label||h,description:g?.description,icon:g?.icon}}):[]),p=q(()=>{const h=i.value.map(g=>g.id);return a.options.filter(g=>!h.includes(g.value))}),x=h=>{if(!h)return;const g=a.options.find(y=>y.value===h);if(g)if(l.value.length===0||typeof l.value[0]=="string")l.value=[...l.value,h];else{const y={id:h,label:g.label,description:g.description,icon:g.icon};l.value=[...l.value,y]}},k=h=>{typeof l.value[0]=="string"?l.value=l.value.filter(g=>g!==h):l.value=l.value.filter(g=>g.id!==h),s("removeItem",h)};return(h,g)=>(r(),o("div",fs,[i.value.length>0?(r(),o("div",gs,[t.label?(r(),o("label",hs,[de(C(t.label)+" ",1),t.required?(r(),o("span",bs,"*")):S("",!0)])):S("",!0),e("div",{class:"space-y-1",ref_key:"dragAreaRef",ref:u},[(r(!0),o(we,null,Ae(i.value,y=>(r(),o("div",{key:y.id,class:ce(["flex items-center gap-2 px-3 py-2 bg-neutral-50 dark:bg-neutral-900 rounded border","border-neutral-200 dark:border-neutral-800",t.disabled?"opacity-50":""])},[g[1]||(g[1]=e("div",{class:"drag-handle cursor-move text-neutral-400 hover:text-neutral-600 dark:text-neutral-600 dark:hover:text-neutral-400"},[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)),y.icon?(r(),o("img",{key:0,src:y.icon,alt:y.label,class:"w-4 h-4 flex-shrink-0"},null,8,xs)):S("",!0),e("span",ys,[de(C(y.label)+" ",1),y.description?(r(),o("span",ks," ("+C(y.description)+") ",1)):S("",!0)]),t.disabled?S("",!0):(r(),o("button",{key:1,onClick:_=>k(y.id),type:"button",class:"p-1 hover:bg-neutral-200 dark:hover:bg-neutral-800 rounded transition-colors","aria-label":`Remove ${y.label}`},[...g[0]||(g[0]=[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,ws))],2))),128))],512)])):S("",!0),w(pt,{"model-value":"","onUpdate:modelValue":x,label:i.value.length>0?t.addLabel:t.label,options:p.value,placeholder:t.placeholder,"search-placeholder":t.searchPlaceholder,disabled:t.disabled||p.value.length===0,loading:t.loading},null,8,["label","options","placeholder","search-placeholder","disabled","loading"]),t.error?(r(),J(I(kt),{key:1},{default:F(()=>[de(C(t.error),1)]),_:1})):S("",!0)]))}});function Aa(){return window.__AGENTBUILDER_CONFIG__||{mountPoint:"/agentbuilder"}}function Kt(){return Aa().mountPoint}function dr(){return Aa().devMode===!0}function Ve(t){const n=Kt(),a=t.startsWith("/")?t:`/${t}`;return n==="/"?a:`${n}${a}`}const _s=Ce({__name:"ModelSelectorInput",props:mt({label:{},placeholder:{default:"Select a model"},error:{},required:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},allowMultiple:{type:Boolean,default:!1}},{modelValue:{required:!0},modelModifiers:{}}),emits:["update:modelValue"],setup(t){const n=t,a=It(t,"modelValue"),s=m([]),l=m(!1),u=q(()=>s.value.map(x=>({value:x.id,label:x.name,description:x.provider_id||x.provider,icon:x.iconId}))),i=async()=>{l.value=!0;try{const x=await fetch(Ve("/api/models"));if(x.ok){const k=await x.json();s.value=k.models||[]}}catch(x){console.error("Error fetching models:",x)}finally{l.value=!1}},p=x=>{};return qe(()=>{i()}),Ee(()=>n.allowMultiple,()=>{n.allowMultiple&&typeof a.value=="string"?a.value=a.value?[a.value]:[]:!n.allowMultiple&&Array.isArray(a.value)&&(a.value=a.value[0]||"")}),(x,k)=>(r(),o(we,null,[t.allowMultiple?(r(),J(jt,{key:0,modelValue:a.value,"onUpdate:modelValue":k[0]||(k[0]=h=>a.value=h),label:t.label,placeholder:t.placeholder,"search-placeholder":"Search models...",error:t.error,required:t.required,disabled:t.disabled,options:u.value,loading:l.value,"add-label":"Add another model",onRemoveItem:p},null,8,["modelValue","label","placeholder","error","required","disabled","options","loading"])):(r(),J(pt,{key:1,modelValue:a.value,"onUpdate:modelValue":k[1]||(k[1]=h=>a.value=h),label:t.label,placeholder:t.placeholder,"search-placeholder":"Search models...",options:u.value,disabled:t.disabled,loading:l.value},null,8,["modelValue","label","placeholder","options","disabled","loading"])),!t.allowMultiple&&t.error?(r(),J(I(kt),{key:2,class:"mt-1"},{default:F(()=>[de(C(t.error),1)]),_:1})):S("",!0)],64))}}),$s=Ce({__name:"AgentSelectorInput",props:mt({label:{default:"Handoff Agents"},placeholder:{default:"Select an agent"},error:{},required:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},allowMultiple:{type:Boolean,default:!0},agentType:{default:"ai_human"}},{modelValue:{required:!0,default:()=>[]},modelModifiers:{}}),emits:["update:modelValue"],setup(t){const n=t,a=It(t,"modelValue"),s=m([]),l=m(!1),u=q(()=>s.value.map(x=>({value:x.id,label:x.title,description:x.tool_description||`Handoff to ${x.title} agent`}))),i=async()=>{l.value=!0;try{const x=Ve(`/api/agents${n.agentType?`?type=${n.agentType}`:""}`),k=await fetch(x);if(k.ok){const h=await k.json();s.value=h.agents||[]}}catch(x){console.error("Error fetching agents:",x)}finally{l.value=!1}},p=x=>{};return qe(()=>{i()}),Ee(()=>n.allowMultiple,()=>{n.allowMultiple&&typeof a.value=="string"?a.value=a.value?[a.value]:[]:!n.allowMultiple&&Array.isArray(a.value)&&(a.value=a.value[0]||"")},{immediate:!0}),(x,k)=>(r(),o(we,null,[t.allowMultiple?(r(),J(jt,{key:0,modelValue:a.value,"onUpdate:modelValue":k[0]||(k[0]=h=>a.value=h),label:t.label,placeholder:t.placeholder,"search-placeholder":"Search agents...",error:t.error,required:t.required,disabled:t.disabled,options:u.value,loading:l.value,"add-label":"Add another agent",onRemoveItem:p},null,8,["modelValue","label","placeholder","error","required","disabled","options","loading"])):(r(),J(pt,{key:1,modelValue:a.value,"onUpdate:modelValue":k[1]||(k[1]=h=>a.value=h),label:t.label,placeholder:t.placeholder,"search-placeholder":"Search agents...",options:u.value,disabled:t.disabled,loading:l.value},null,8,["modelValue","label","placeholder","options","disabled","loading"])),!t.allowMultiple&&t.error?(r(),J(I(kt),{key:2,class:"mt-1"},{default:F(()=>[de(C(t.error),1)]),_:1})):S("",!0)],64))}}),Cs=Ce({__name:"ToolSelectorInput",props:mt({label:{default:"Available Tools"},placeholder:{default:"Select a tool"},error:{},required:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},allowMultiple:{type:Boolean,default:!0}},{modelValue:{required:!0,default:()=>[]},modelModifiers:{}}),emits:["update:modelValue"],setup(t){const n=t,a=It(t,"modelValue"),s=m([]),l=m(!1),u=q(()=>s.value.map(x=>{let k=x.name;return x.type==="prompt"?k=`${x.name} (prompt)`:x.type==="mcp"&&(k=`${x.name} (mcp)`),{value:x.name,label:k,description:x.description}})),i=async()=>{l.value=!0;try{const x=await fetch(Ve("/api/tools"));if(x.ok){const k=await x.json();s.value=Object.entries(k).map(([h,g])=>({name:h,description:g.description||"",type:g.type,model:g.model}))}}catch(x){console.error("Error fetching tools:",x)}finally{l.value=!1}},p=x=>{};return qe(()=>{i()}),Ee(()=>n.allowMultiple,()=>{n.allowMultiple&&typeof a.value=="string"?a.value=a.value?[a.value]:[]:!n.allowMultiple&&Array.isArray(a.value)&&(a.value=a.value[0]||"")},{immediate:!0}),(x,k)=>(r(),o(we,null,[t.allowMultiple?(r(),J(jt,{key:0,modelValue:a.value,"onUpdate:modelValue":k[0]||(k[0]=h=>a.value=h),label:t.label,placeholder:t.placeholder,"search-placeholder":"Search tools...",error:t.error,required:t.required,disabled:t.disabled,options:u.value,loading:l.value,"add-label":"Add another tool",onRemoveItem:p},null,8,["modelValue","label","placeholder","error","required","disabled","options","loading"])):(r(),J(pt,{key:1,modelValue:a.value,"onUpdate:modelValue":k[1]||(k[1]=h=>a.value=h),label:t.label,placeholder:t.placeholder,"search-placeholder":"Search tools...",options:u.value,disabled:t.disabled,loading:l.value},null,8,["modelValue","label","placeholder","options","disabled","loading"])),!t.allowMultiple&&t.error?(r(),J(I(kt),{key:2,class:"mt-1"},{default:F(()=>[de(C(t.error),1)]),_:1})):S("",!0)],64))}}),Ss=Rt(De(_s),{props:["label","placeholder","error","required","disabled","allowMultiple"],family:"dropdown",features:[]}),Is=Rt(De($s),{props:["label","placeholder","error","required","disabled","allowMultiple","agentType"],family:"dropdown",features:[]}),Ts=Rt(De(Cs),{props:["label","placeholder","error","required","disabled","allowMultiple"],family:"dropdown",features:[]}),Ms={class:"space-y-4"},zs={class:"flex items-start gap-2"},Vs={class:"flex-1"},Es=["onClick","disabled","title"],Ls={key:0,class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},As={key:1,class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},Ps={key:0,class:"text-xs text-neutral-400 dark:text-neutral-500 mt-1"},js={key:0,class:"text-amber-500 dark:text-amber-400 ml-1"},Rs={class:"flex-1"},Os={class:"flex-1"},Ds=["onClick","disabled"],Us=["disabled"],Bs=Ce({__name:"TenvPropertyList",props:{modelValue:{},inherited:{default:()=>[]},allowCustom:{type:Boolean,default:!0},disabled:{type:Boolean,default:!1}},emits:["update:modelValue"],setup(t,{emit:n}){const a=t,s=n,l=m(new Set),u=m([]),i=q(()=>new Set(a.inherited.map(d=>d.name)));Ee(()=>a.modelValue,d=>{const b=Object.keys(d).filter(f=>!i.value.has(f)),c=new Set(u.value.map(f=>f.name));for(const f of b)c.has(f)||u.value.push({id:crypto.randomUUID(),name:f,value:String(d[f]??"")})},{immediate:!0,deep:!0});const p=d=>{if(l.value.has(d)){l.value.delete(d);const b=a.inherited.find(c=>c.name===d);b&&x(d,b.value)}else l.value.add(d)},x=(d,b)=>{const c={...a.modelValue};b===void 0||b===""?delete c[d]:c[d]=b,s("update:modelValue",c)},k=d=>a.modelValue[d.name]!==void 0?String(a.modelValue[d.name]):d.value!==void 0?String(d.value):"",h=(d,b)=>{x(d.name,b||void 0)},g=()=>{u.value.push({id:crypto.randomUUID(),name:"",value:""})},y=d=>{const b=u.value.find(c=>c.id===d);if(b&&b.name){const c={...a.modelValue};delete c[b.name],s("update:modelValue",c)}u.value=u.value.filter(c=>c.id!==d)},_=(d,b,c)=>{const f=u.value.find(N=>N.id===d);if(!f)return;f.name=c;const $={...a.modelValue};b&&delete $[b],c&&f.value&&($[c]=f.value),s("update:modelValue",$)},v=(d,b)=>{const c=u.value.find(f=>f.id===d);c&&(c.value=b,c.name&&x(c.name,b||void 0))};return(d,b)=>(r(),o("div",Ms,[(r(!0),o(we,null,Ae(t.inherited,c=>(r(),o("div",{key:c.name,class:"relative"},[e("div",zs,[e("div",Vs,[w(St,{"model-value":k(c),label:c.name,placeholder:c.description||"Enter value...",disabled:t.disabled||!l.value.has(c.name),required:c.required,"onUpdate:modelValue":f=>h(c,f)},null,8,["model-value","label","placeholder","disabled","required","onUpdate:modelValue"])]),e("button",{type:"button",onClick:f=>p(c.name),disabled:t.disabled,class:"mt-7 p-2 text-neutral-400 hover:text-neutral-600 dark:hover:text-neutral-300 transition-colors disabled:opacity-50",title:l.value.has(c.name)?"Lock (use inherited value)":"Unlock to override"},[l.value.has(c.name)?(r(),o("svg",As,[...b[1]||(b[1]=[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M8 11V7a4 4 0 118 0m-4 8v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2z"},null,-1)])])):(r(),o("svg",Ls,[...b[0]||(b[0]=[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 15v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2zm10-10V7a4 4 0 00-8 0v4h8z"},null,-1)])]))],8,Es)]),c.source?(r(),o("p",Ps,[de(" From: "+C(c.source)+" ",1),c.required?(r(),o("span",js,"(required)")):S("",!0)])):S("",!0)]))),128)),(r(!0),o(we,null,Ae(u.value,c=>(r(),o("div",{key:c.id,class:"flex items-start gap-2"},[e("div",Rs,[w(St,{"model-value":c.name,label:"Name",placeholder:"Variable name",disabled:t.disabled,"onUpdate:modelValue":f=>_(c.id,c.name,f)},null,8,["model-value","disabled","onUpdate:modelValue"])]),e("div",Os,[w(St,{"model-value":c.value,label:"Value",placeholder:"Variable value",disabled:t.disabled,"onUpdate:modelValue":f=>v(c.id,f)},null,8,["model-value","disabled","onUpdate:modelValue"])]),e("button",{type:"button",onClick:f=>y(c.id),disabled:t.disabled,class:"mt-7 p-2 text-red-400 hover:text-red-600 dark:hover:text-red-300 transition-colors disabled:opacity-50",title:"Remove"},[...b[2]||(b[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:"M6 18L18 6M6 6l12 12"})],-1)])],8,Ds)]))),128)),t.allowCustom?(r(),o("button",{key:0,type:"button",onClick:g,disabled:t.disabled,class:"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"},[...b[3]||(b[3]=[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"})]),de(" Add custom variable ")],-1)])],8,Us)):S("",!0)]))}}),Ns=Rt(De(Bs),{props:["inherited","allowCustom","disabled"],family:"text",features:[]}),qs={class:"space-y-3 mt-3 pt-3 border-t border-neutral-200 dark:border-neutral-700"},Fs={class:"space-y-2 pl-4 border-l-2 border-accent-200 dark:border-accent-700"},Hs={key:0,class:"space-y-2 pl-4 border-l-2 border-neutral-200 dark:border-neutral-700"},Ws={key:1,class:"space-y-3 pl-4 border-l-2 border-neutral-200 dark:border-neutral-700"},Ks={key:2,class:"space-y-3 pl-4 border-l-2 border-neutral-200 dark:border-neutral-700"},Js={key:0,class:"grid grid-cols-1 gap-3"},Gs={key:3,class:"space-y-3 pl-4 border-l-2 border-neutral-200 dark:border-neutral-700"},Ys={key:0,class:"grid grid-cols-1 gap-3"},Zs=Ce({__name:"PromptToolOptions",props:{toolName:{},toolConfig:{},toolType:{default:"prompt"},disabled:{type:Boolean},availableEnvVariables:{default:()=>[]}},emits:["update:option"],setup(t,{emit:n}){const a=t,s=n,l=m(null),u=m(!0),i=m([]),p=m(!1),x=q(()=>l.value?.properties?Object.entries(l.value.properties).map(([Q,U])=>({value:Q,label:Q,attrs:{description:U.description||U.type||""}})):[]),k=q(()=>a.toolType==="prompt"),h=q(()=>a.toolType==="subagent"),g=[{value:"side_a",label:"Side A",attrs:{description:"Queue parent messages as user messages in the child thread."}},{value:"side_b",label:"Side B",attrs:{description:"Queue parent messages as assistant messages in the child thread."}}],y=[{value:"implicit",label:"Implicit",attrs:{description:"Child completion is automatically queued back to the parent."}},{value:"explicit",label:"Explicit",attrs:{description:"Child stays quiet unless tools or hooks call state.notifyParent()."}}],_=q(()=>a.toolConfig.immediate!==void 0&&a.toolConfig.immediate!==!1),v=q(()=>!!a.toolConfig.resumable&&a.toolConfig.resumable!==!1),d=q(()=>(a.toolConfig.immediate&&typeof a.toolConfig.immediate=="object"?a.toolConfig.immediate.name_env:"")||""),b=q(()=>(a.toolConfig.immediate&&typeof a.toolConfig.immediate=="object"?a.toolConfig.immediate.description_env:"")||""),c=q(()=>!a.toolConfig.immediate||typeof a.toolConfig.immediate!="object"?[]:Array.isArray(a.toolConfig.immediate.scoped_env)?a.toolConfig.immediate.scoped_env:[]),f=(Q,U)=>({value:Q,label:Q||"Not set",attrs:{description:U}}),$=q(()=>{const Q=new Map,U=(R,K)=>{const H=R.trim();H&&(Q.has(H)||Q.set(H,new Set),Q.get(H).add(K))};for(const R of a.availableEnvVariables)U(R,"Parent prompt env");for(const R of i.value){const K=["Subagent variable"];R.description&&K.push(R.description),R.required&&K.push("required"),R.scoped&&K.push("declared scoped"),U(R.property,K.join(" • "))}for(const R of[a.toolConfig.optional||"",d.value,b.value])R&&U(R,"Currently selected");return[f("","Not set"),...Array.from(Q.entries()).sort(([R],[K])=>R.localeCompare(K)).map(([R,K])=>f(R,Array.from(K).join(" | ")))]}),N=q(()=>{const Q=new Map;for(const U of i.value){const R=[];U.description&&R.push(U.description),U.required&&R.push("required"),U.scoped&&R.push("declared scoped"),Q.set(U.property,R.length>0?R.join(" • "):"Subagent variable")}for(const U of c.value)Q.has(U)||Q.set(U,"Currently selected");return Array.from(Q.entries()).sort(([U],[R])=>U.localeCompare(R)).map(([U,R])=>f(U,R))}),E=async()=>{try{let Q=a.toolName;if(a.toolType==="handoff"||a.toolType==="subagent"){const R=await fetch(Ve(`/api/agents/${encodeURIComponent(a.toolName)}`));if(R.ok){if(Q=(await R.json())?.agent?.side_a_agent_prompt,!Q){u.value=!1;return}}else{u.value=!1;return}}const U=await fetch(Ve(`/api/prompts/${encodeURIComponent(Q)}`));if(U.ok){const R=await U.json();R?.prompt?.required_schema&&(l.value=R.prompt.required_schema)}}catch(Q){console.error("Error fetching prompt schema:",Q)}finally{u.value=!1}},L=async()=>{if(a.toolType!=="subagent"){i.value=[];return}p.value=!0;try{const Q=await fetch(Ve(`/api/variables/agents/${encodeURIComponent(a.toolName)}`));if(!Q.ok){i.value=[];return}const U=await Q.json();i.value=Array.isArray(U?.variables)?U.variables.filter(R=>R&&typeof R.property=="string").map(R=>({property:R.property,description:R.description||"",required:!!R.required,scoped:!!R.scoped})):[]}catch(Q){console.error("Error fetching subagent variables:",Q),i.value=[]}finally{p.value=!1}};qe(()=>{E(),L()});const V=(Q,U)=>{s("update:option",Q,U)},A=(Q={})=>{const U=a.toolConfig.immediate&&typeof a.toolConfig.immediate=="object"?a.toolConfig.immediate:{},R={name_env:U.name_env||null,description_env:U.description_env||null,scoped_env:U.scoped_env||[],...Q};return!R.name_env&&!R.description_env&&(!R.scoped_env||R.scoped_env.length===0)?!0:R},G=Q=>{if(!Q){V("immediate",void 0);return}V("immediate",A())},ee=(Q,U)=>{const R=A({[Q]:U});V("immediate",R)},ie=Q=>{if(!Q){V("resumable",void 0);return}const U=a.toolConfig.resumable&&a.toolConfig.resumable!==!1?a.toolConfig.resumable:null;V("resumable",{receives_messages:U?.receives_messages||"side_a",max_instances:U?.max_instances??null,parent_communication:U?.parent_communication||"implicit"})},be=(Q,U)=>{const R=a.toolConfig.resumable&&a.toolConfig.resumable!==!1?a.toolConfig.resumable:{receives_messages:"side_a",max_instances:null,parent_communication:"implicit"};V("resumable",{receives_messages:R.receives_messages,max_instances:R.max_instances??null,parent_communication:R.parent_communication||"implicit",[Q]:U})};return(Q,U)=>{const R=tt("FormKit");return r(),o("div",qs,[e("div",Fs,[U[16]||(U[16]=e("p",{class:"text-xs font-medium text-neutral-600 dark:text-neutral-400 mb-2"}," Initialization Options: ",-1)),w(R,{type:"selectSearch",value:t.toolConfig.init_user_message_property||"",onInput:U[0]||(U[0]=K=>V("init_user_message_property",K||null)),label:"User message property",placeholder:"Don't inject a user message",options:x.value,disabled:t.disabled||u.value||x.value.length===0,loading:u.value,help:"Select which argument property should be used as the most recent user message for this sub-prompt. If not set no additional user message will be injected.","outer-class":"$reset mb-2"},null,8,["value","options","disabled","loading"]),w(R,{type:"selectSearch",value:t.toolConfig.init_attachments_property||"",onInput:U[1]||(U[1]=K=>V("init_attachments_property",K||null)),label:"Attachments property",placeholder:"Don't attach files",options:x.value,disabled:t.disabled||u.value||x.value.length===0,loading:u.value,help:"Select which argument contains attachment path(s). Accepts a single path string or an array of paths.","outer-class":"$reset mb-0"},null,8,["value","options","disabled","loading"]),h.value?(r(),J(R,{key:0,type:"selectSearch",value:t.toolConfig.init_agent_name_property||"",onInput:U[2]||(U[2]=K=>V("init_agent_name_property",K||null)),label:"Agent name property",placeholder:"Don't map a child thread name",options:x.value,disabled:t.disabled||u.value||x.value.length===0,loading:u.value,help:"Select which argument property should be used to name each spawned child thread.","outer-class":"$reset mb-0"},null,8,["value","options","disabled","loading"])):S("",!0)]),k.value?(r(),o("div",Hs,[U[17]||(U[17]=e("p",{class:"text-xs font-medium text-neutral-600 dark:text-neutral-400 mb-2"}," Sub-Prompt Response Options: ",-1)),w(R,{type:"checkbox",value:t.toolConfig.include_text_response,onInput:U[3]||(U[3]=K=>V("include_text_response",K)),label:"Include text response",help:"Include the final text content from the sub-prompt",disabled:t.disabled,"outer-class":"$reset mb-1"},null,8,["value","disabled"]),w(R,{type:"checkbox",value:t.toolConfig.include_tool_calls,onInput:U[4]||(U[4]=K=>V("include_tool_calls",K)),label:"Include tool calls and responses",help:"Include tool calls executed by the sub-prompt and their responses",disabled:t.disabled,"outer-class":"$reset mb-1"},null,8,["value","disabled"]),w(R,{type:"checkbox",value:t.toolConfig.include_errors,onInput:U[5]||(U[5]=K=>V("include_errors",K)),label:"Include errors",help:"Include error information if the sub-prompt fails",disabled:t.disabled,"outer-class":"$reset mb-0"},null,8,["value","disabled"])])):S("",!0),h.value?(r(),o("div",Ws,[U[18]||(U[18]=e("p",{class:"text-xs font-medium text-neutral-600 dark:text-neutral-400 mb-2"}," Relationship Options: ",-1)),w(R,{type:"checkbox",value:t.toolConfig.blocking??!0,onInput:U[6]||(U[6]=K=>V("blocking",K)),label:"Blocking",help:"When enabled, the parent waits for this child to finish before continuing. Turn this off for background watchers or long-running workers.",disabled:t.disabled,"outer-class":"$reset mb-1"},null,8,["value","disabled"]),w(R,{type:"selectSearch",value:t.toolConfig.optional||"",onInput:U[7]||(U[7]=K=>V("optional",K||null)),label:"Enable this subagent when",placeholder:"Don't gate this subagent","search-placeholder":"Search env variables...",options:$.value,help:"Pick an env variable that gates this branch. Example: ENABLE_GMAIL. This subagent only appears and runs when that env resolves to true, 1, or yes on the parent thread. Leave this empty to keep the subagent always enabled.",disabled:t.disabled||p.value,"outer-class":"$reset mb-0"},null,8,["value","options","disabled"])])):S("",!0),h.value?(r(),o("div",Ks,[U[19]||(U[19]=e("p",{class:"text-xs font-medium text-neutral-600 dark:text-neutral-400 mb-2"}," Immediate Bootstrap: ",-1)),w(R,{type:"checkbox",value:_.value,onInput:U[8]||(U[8]=K=>G(!!K)),label:"Run immediately",disabled:t.disabled,help:"Boot this subagent as soon as the prompt becomes active, before the parent takes its first normal LLM step.","outer-class":"$reset mb-0"},null,8,["value","disabled"]),_.value?(r(),o("div",Js,[w(R,{type:"select",value:d.value,onInput:U[9]||(U[9]=K=>ee("name_env",K||null)),label:"Name env",placeholder:"Don't use a name env",options:$.value,help:"Optional safe env whose value can be used to name each immediate child instance. This is one of the few env values the runtime may expose during bootstrap.",disabled:t.disabled||p.value,"outer-class":"$reset mb-0"},null,8,["value","options","disabled"]),w(R,{type:"select",value:b.value,onInput:U[10]||(U[10]=K=>ee("description_env",K||null)),label:"Description env",placeholder:"Don't use a description env",options:$.value,help:"Optional safe env whose value can describe what this instance is for. The runtime may use it as bootstrap context when starting the child.",disabled:t.disabled||p.value,"outer-class":"$reset mb-0"},null,8,["value","options","disabled"]),w(R,{type:"taglist",value:c.value,onInput:U[11]||(U[11]=K=>ee("scoped_env",Array.isArray(K)?K:[])),label:"Scoped env",placeholder:"Pick subagent envs",options:N.value,"open-on-click":"","close-on-select":"false","selection-appearance":"tags","empty-message":"No subagent variables available.",help:"Pick the subagent variables that belong to each instance. These values are copied into the child thread env and stay hidden from the model unless you also selected them as Name env or Description env.",disabled:t.disabled||p.value,"outer-class":"$reset mb-0"},null,8,["value","options","disabled"])])):S("",!0)])):S("",!0),h.value?(r(),o("div",Gs,[U[20]||(U[20]=e("p",{class:"text-xs font-medium text-neutral-600 dark:text-neutral-400 mb-2"}," Resumable Mode: ",-1)),w(R,{type:"checkbox",value:v.value,onInput:U[12]||(U[12]=K=>ie(K)),label:"Enable resumable child threads",help:"Keep child instances alive and addressable in the parent registry so the parent can message or reuse them later instead of always spawning a new thread.",disabled:t.disabled,"outer-class":"$reset mb-0"},null,8,["value","disabled"]),v.value?(r(),o("div",Ys,[w(R,{type:"select",value:t.toolConfig.resumable&&t.toolConfig.resumable!==!1?t.toolConfig.resumable.receives_messages:"side_a",onInput:U[13]||(U[13]=K=>be("receives_messages",K||"side_a")),label:"Receives messages",options:g,disabled:t.disabled,help:"Choose which side receives parent messages. Side A queues them as user messages in the child; Side B queues them as assistant messages.","outer-class":"$reset mb-0"},null,8,["value","disabled"]),w(R,{type:"number",value:t.toolConfig.resumable&&t.toolConfig.resumable!==!1?t.toolConfig.resumable.max_instances??"":"",onInput:U[14]||(U[14]=K=>be("max_instances",K===""||K===null?null:Number(K))),label:"Max instances",min:"1",step:"1",placeholder:"Unlimited",help:"Cap how many resumable instances of this subagent can exist at once. Leave empty for unlimited.",disabled:t.disabled,"outer-class":"$reset mb-0"},null,8,["value","disabled"]),w(R,{type:"select",value:t.toolConfig.resumable&&t.toolConfig.resumable!==!1&&t.toolConfig.resumable.parent_communication||"implicit",onInput:U[15]||(U[15]=K=>be("parent_communication",K||"implicit")),label:"Parent communication",options:y,disabled:t.disabled,help:"Implicit mode automatically forwards child completion back to the parent. Explicit mode keeps the child quiet until your code calls state.notifyParent() or updates status deliberately.","outer-class":"$reset mb-0"},null,8,["value","disabled"])])):S("",!0)])):S("",!0)])}}});async function lt(t,n={}){const a=localStorage.getItem("auth_token"),s={"Content-Type":"application/json",...n.headers};a&&(s.Authorization=`Bearer ${a}`);const l=t.startsWith("/")?t:`/${t}`,u=await fetch(Ve(`/api${l}`),{...n,headers:s});if(u.status===401)throw localStorage.removeItem("auth_token"),window.location.href=Ve("/login"),new Error("Unauthorized");return u}const Xs={class:"space-y-4"},Qs={class:"block text-sm font-medium mb-2"},ei={key:0,class:"text-red-500"},ti={class:"flex items-start justify-between"},ri={class:"flex items-center gap-2 flex-1"},ai={class:"flex-1"},ni={key:0,class:"text-xs text-neutral-500 dark:text-neutral-400 font-normal"},oi={key:1,class:"text-xs text-neutral-500 dark:text-neutral-400 font-normal"},li={key:2,class:"text-xs text-neutral-500 dark:text-neutral-400 font-normal"},si={key:3,class:"text-xs text-neutral-500 dark:text-neutral-400 font-normal"},ii={key:4,class:"text-xs text-neutral-500 dark:text-neutral-400 font-normal"},ui={key:0,class:"text-xs text-neutral-600 dark:text-neutral-400 mt-1"},di={key:1,class:"text-xs text-amber-600 dark:text-amber-400 mt-1 flex items-center gap-1"},ci=["onClick","disabled","aria-label"],pi={key:0,class:"mt-3 pt-3 border-t border-neutral-200 dark:border-neutral-700"},mi={class:"space-y-2"},vi={key:0,class:"text-xs text-amber-500 dark:text-amber-400 whitespace-nowrap",title:"Required at agent or thread level"},fi={key:0,class:"text-center py-8 text-sm text-neutral-500 dark:text-neutral-400 border border-dashed border-neutral-300 dark:border-neutral-600 rounded-lg"},Pa=Ce({__name:"ToolSelectorWithOptions",props:mt({label:{default:"Available Tools"},placeholder:{default:"Select a tool"},error:{},required:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},modelId:{},providerId:{},availableEnvVariables:{default:()=>[]}},{modelValue:{required:!0,default:()=>[]},modelModifiers:{}}),emits:mt(["unavailable-tools"],["update:modelValue"]),setup(t,{expose:n,emit:a}){const s=t,l=It(t,"modelValue"),u=m([]),i=m([]),p=m(!1),x=m(!1),k=m(),h=m(""),g=q(()=>[...u.value,...i.value]),y=q(()=>new Set(g.value.map(Q=>b(Q)))),_=Q=>(Q.startsWith("provider:"),y.value.has(Q)),v=q(()=>l.value.filter(Q=>!_(Q.name)).map(Q=>Q.name)),d=a;Ee(v,Q=>{Q.length>0&&d("unavailable-tools",Q)},{immediate:!0}),pa(async()=>{k.value,await Ne(),k.value&&l.value.length>0&&await ma({parent:k,values:l,dragHandle:".drag-handle"})});const b=Q=>Q.type==="provider"?`provider:${Q.name}`:Q.type==="mcp"?`mcp:${Q.name}`:Q.name,c=Q=>Q.startsWith("provider:")?Q.slice(9):Q.startsWith("mcp:")?Q.slice(4):Q,f=Q=>Q.startsWith("provider:")?"provider":Q.startsWith("mcp:")?"mcp":"tool",$=q(()=>{const Q=new Set(l.value.map(U=>U.name));return g.value.filter(U=>!Q.has(b(U))).map(U=>{let R=U.name;return U.type==="prompt"?R=`${U.name} (prompt)`:U.type==="mcp"?R=`${U.name} (mcp)`:U.type==="provider"?R=`${U.name} (provider)`:U.type==="handoff"?R=`${U.name} (handoff agent)`:U.type==="subagent"&&(R=`${U.name} (subagent)`),{value:b(U),label:R,attrs:{description:U.description}}})}),N=async()=>{p.value=!0;try{const Q=await lt("/tools");if(Q.ok){const U=await Q.json();u.value=Object.entries(U).map(([R,K])=>({name:R,description:K.description||"",type:K.type,model:K.model}))}}catch(Q){console.error("Error fetching tools:",Q)}finally{p.value=!1}},E=async()=>{if(!s.providerId||!s.modelId){i.value=[];return}x.value=!0;try{const Q=await lt(`/providers/${s.providerId}/tools?model=${encodeURIComponent(s.modelId)}`);if(Q.ok){const U=await Q.json();i.value=(U.tools||[]).map(R=>({name:R.name,description:R.description||"",type:"provider",tenvs:R.tenvs||[]}))}else i.value=[]}catch(Q){console.error("Error fetching provider tools:",Q),i.value=[]}finally{x.value=!1}};Ee([()=>s.providerId,()=>s.modelId],async([Q,U])=>{Q&&U?await E():i.value=[]},{immediate:!0});const L=Q=>{if(!Q||l.value.find(K=>K.name===Q))return;const U=A(Q),R={};if(U?.tenvs&&U.tenvs.length>0)for(const K of U.tenvs)R[K.name]="";l.value=[...l.value,{name:Q,include_text_response:!0,include_tool_calls:!0,include_errors:!0,init_user_message_property:null,init_attachments_property:null,init_agent_name_property:null,optional:null,...Object.keys(R).length>0?{tenvs:R}:{}}],Ne(()=>{h.value=""})},V=Q=>{l.value=l.value.filter(U=>U.name!==Q)},A=Q=>{const U=g.value.find(R=>b(R)===Q);return U||g.value.find(R=>R.name===Q)},G=(Q,U,R)=>{l.value=l.value.map(K=>{if(K.name===Q){const H={...K.tenvs||{},[U]:R||void 0};for(const ve of Object.keys(H))H[ve]||delete H[ve];return{...K,tenvs:Object.keys(H).length>0?H:void 0}}return K})},ee=(Q,U,R)=>{l.value=l.value.map(K=>K.name===Q?{...K,[U]:R}:K)};return n({removeUnavailableTools:()=>{l.value=l.value.filter(Q=>_(Q.name))},getAvailableToolsOnly:()=>l.value.filter(Q=>_(Q.name)),unavailableTools:v}),qe(()=>{N()}),(Q,U)=>{const R=tt("FormKit");return r(),o("div",Xs,[e("div",null,[e("label",Qs,[de(C(t.label)+" ",1),t.required?(r(),o("span",ei,"*")):S("",!0)]),l.value.length>0?(r(),o("div",{key:0,class:"space-y-3 mb-4",ref_key:"dragAreaRef",ref:k},[(r(!0),o(we,null,Ae(l.value,K=>(r(),o("div",{key:K.name,class:ce(["border rounded-lg p-4 transition-colors",_(K.name)?"border-neutral-300 dark:border-neutral-600":"border-amber-300 dark:border-amber-700 bg-amber-50 dark:bg-amber-900/20 opacity-75"])},[e("div",ti,[e("div",ri,[e("div",{class:ce(["drag-handle",_(K.name)?"cursor-move text-neutral-400 hover:text-neutral-600 dark:text-neutral-600 dark:hover:text-neutral-400":"cursor-not-allowed text-neutral-300 dark:text-neutral-700"])},[...U[1]||(U[1]=[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)])],2),e("div",ai,[e("h4",{class:ce(["font-medium text-sm",!_(K.name)&&"text-neutral-500 dark:text-neutral-400"])},[de(C(c(K.name))+" ",1),f(K.name)==="provider"?(r(),o("span",ni,"(provider)")):f(K.name)==="mcp"?(r(),o("span",oi,"(mcp)")):A(K.name)?.type==="prompt"?(r(),o("span",li,"(prompt)")):A(K.name)?.type==="handoff"?(r(),o("span",si,"(handoff agent)")):A(K.name)?.type==="subagent"?(r(),o("span",ii,"(subagent)")):S("",!0)],2),A(K.name)?.description?(r(),o("p",ui,C(A(K.name)?.description),1)):S("",!0),_(K.name)?S("",!0):(r(),o("p",di,[...U[2]||(U[2]=[e("svg",{class:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})],-1),de(" Not available for selected model - will be removed on save ",-1)])]))])]),e("button",{onClick:H=>V(K.name),type:"button",disabled:t.disabled,class:"p-1 hover:bg-neutral-200 dark:hover:bg-neutral-800 rounded transition-colors text-neutral-500 hover:text-red-500","aria-label":`Remove ${c(K.name)}`},[...U[3]||(U[3]=[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,ci)]),A(K.name)?.type==="provider"&&A(K.name)?.tenvs?.length?(r(),o("div",pi,[U[4]||(U[4]=e("p",{class:"text-xs text-neutral-500 dark:text-neutral-400 mb-2 font-medium"},[de(" Environment Variables "),e("span",{class:"text-neutral-400"},"(optional at prompt level)")],-1)),e("div",mi,[(r(!0),o(we,null,Ae(A(K.name)?.tenvs,H=>(r(),o("div",{key:H.name,class:"flex items-center gap-2"},[w(R,{type:"text",value:K.tenvs?.[H.name]||"",onInput:ve=>G(K.name,H.name,ve),label:H.name,placeholder:H.description||"Enter value...",disabled:t.disabled,"outer-class":"$reset flex-1 mb-0"},null,8,["value","onInput","label","placeholder","disabled"]),H.required?(r(),o("span",vi," required* ")):S("",!0)]))),128))])])):S("",!0),A(K.name)?.type==="prompt"||A(K.name)?.type==="handoff"||A(K.name)?.type==="subagent"?(r(),J(Zs,{key:1,"tool-name":K.name,"tool-config":K,"tool-type":A(K.name)?.type,disabled:t.disabled,"available-env-variables":t.availableEnvVariables,"onUpdate:option":(H,ve)=>ee(K.name,H,ve)},null,8,["tool-name","tool-config","tool-type","disabled","available-env-variables","onUpdate:option"])):S("",!0)],2))),128))],512)):S("",!0),w(R,{type:"selectSearch",modelValue:h.value,"onUpdate:modelValue":U[0]||(U[0]=K=>h.value=K),onInput:L,placeholder:l.value.length>0?"Add another tool...":t.placeholder,"search-placeholder":"Search tools...",options:$.value,disabled:t.disabled||p.value||$.value.length===0,loading:p.value,"outer-class":"$reset"},null,8,["modelValue","placeholder","options","disabled","loading"]),t.error?(r(),J(I(kt),{key:1,class:"mt-1"},{default:F(()=>[de(C(t.error),1)]),_:1})):S("",!0)]),l.value.length===0&&!p.value&&$.value.length===0?(r(),o("div",fi," No tools available. Create tools in your agentbuilder/tools directory. ")):S("",!0)])}}}),gi=Rt(De(Pa),{props:["label","placeholder","error","required","disabled","modelId","providerId"],family:"dropdown",features:[]}),hi=Ce({__name:"SelectInputWrapper",props:{context:{}},setup(t){const n=t,a=(_,v)=>{const d=n.context;return d[_]!==void 0?d[_]:d.attrs?.[_]!==void 0?d.attrs[_]:v},s=q(()=>n.context.classes??{}),l=q(()=>{const _=a("options",[]);if(typeof _=="function"){const v=_();return Array.isArray(v)?v:[]}return Array.isArray(_)?_:[]}),u=q(()=>n.context._value??""),i=_=>{n.context.node.input(_)},p=q(()=>a("placeholder","Select an option")),x=q(()=>a("searchPlaceholder","Search...")),k=q(()=>a("loading",!1)),h=q(()=>n.context.disabled??!1),g=q(()=>a("size","md")),y=q(()=>a("activeHighlight",!1));return(_,v)=>(r(),J(pt,{"model-value":u.value,options:l.value,placeholder:p.value,"search-placeholder":x.value,loading:k.value,disabled:h.value,"trigger-class":s.value.inner,size:g.value,"active-highlight":y.value,"onUpdate:modelValue":i},null,8,["model-value","options","placeholder","search-placeholder","loading","disabled","trigger-class","size","active-highlight"]))}}),bi={type:"input",family:"dropdown",props:["options","placeholder","searchPlaceholder","loading","size","activeHighlight"],schema:()=>[{$el:"label",if:"$label",attrs:{class:"$classes.label",for:"$id"},children:"$label"},{$cmp:De(hi),props:{context:"$node.context"}}]},xi={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function yi(t,n){return r(),o("svg",xi,[...n[0]||(n[0]=[e("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[e("path",{d:"m21 21l-4.34-4.34"}),e("circle",{cx:"11",cy:"11",r:"8"})],-1)])])}const ki=De({name:"lucide-search",render:yi}),wi=["data-suffix-icon"],_i=["id","value","placeholder","disabled"],$i=Ce({__name:"SearchInputWrapper",props:{context:{}},setup(t){const n=t,a=(k,h)=>{const g=n.context;return g[k]!==void 0?g[k]:g.attrs?.[k]!==void 0?g.attrs[k]:h},s=q(()=>n.context.classes??{}),l=q(()=>n.context._value??""),u=k=>{const h=k.target.value;n.context.node.input(h)},i=()=>{n.context.node.input("")},p=q(()=>a("placeholder","Search...")),x=q(()=>n.context.disabled??!1);return(k,h)=>(r(),o("div",{class:ce(s.value.inner),"data-prefix-icon":"true","data-suffix-icon":!!l.value},[e("span",{class:ce(s.value.prefixIcon)},[w(I(ki))],2),e("input",{type:"text",id:t.context.id,value:l.value,onInput:u,placeholder:p.value,disabled:x.value,class:ce(s.value.input)},null,42,_i),l.value?(r(),o("button",{key:0,type:"button",onClick:i,class:ce([s.value.suffixIcon,"hover:text-zinc-600 dark:hover:text-zinc-300 cursor-pointer"])},[w(I(ir))],2)):S("",!0)],10,wi))}}),Ci={type:"input",family:"text",props:["placeholder","size"],schema:()=>[{$el:"label",if:"$label",attrs:{class:"$classes.label",for:"$id"},children:"$label"},{$cmp:De($i),props:{context:"$node.context"}}]},Si=Ce({__name:"SortableMultiSelectWrapper",props:{context:{}},setup(t){const n=t,a=q(()=>n.context.options??[]),s=q(()=>n.context.placeholder??"Select an option"),l=q(()=>n.context.searchPlaceholder??"Search..."),u=q(()=>n.context.addLabel??"Add another"),i=q(()=>n.context.loading??!1),p=q(()=>n.context.disabled??!1),x=q({get:()=>n.context._value??[],set:k=>n.context.node.input(k)});return(k,h)=>(r(),J(jt,{modelValue:x.value,"onUpdate:modelValue":h[0]||(h[0]=g=>x.value=g),options:a.value,placeholder:s.value,"search-placeholder":l.value,"add-label":u.value,loading:i.value,disabled:p.value},null,8,["modelValue","options","placeholder","search-placeholder","add-label","loading","disabled"]))}}),Ii={type:"input",family:"dropdown",props:["options","placeholder","searchPlaceholder","addLabel","loading"],schema:()=>[{$el:"label",if:"$label",attrs:{class:"$classes.label",for:"$id"},children:"$label"},{$cmp:De(Si),props:{context:"$node.context"}}]},Ti={class:"flex items-center gap-2 py-1 pl-2 pr-1"},Mi={class:"flex-1 grid grid-cols-1 md:grid-cols-3 gap-2"},zi={class:"flex items-center gap-0.5 shrink-0"},Vi={key:1,class:"w-7"},Ei={class:"pl-2 pb-1"},Li={key:0},Ai={class:"space-y-1.5"},Pi=["onClick"],ji=["onClick"],Ri={key:1},Oi=["onClick"],Di={key:2},Ui=["onClick"],Bi={key:3},Ni={class:"flex items-center gap-2 py-1 pl-2 pr-1"},qi={class:"flex-1 grid grid-cols-1 md:grid-cols-2 gap-2"},Fi={class:"flex items-center gap-0.5 shrink-0"},Hi={key:1,class:"w-7"},Wi={class:"pl-2 pb-1"},Ki={key:0},Ji={class:"space-y-1.5"},Gi=["onClick"],Yi=["onClick"],Zi={key:1},Xi=["onClick"],Qi={key:2},eu=["onClick"],tu={key:3},ru=["onClick"],au=Ce({__name:"SchemaPropertyRow",props:{typeOptions:{},depth:{},index:{}},emits:["remove"],setup(t){const n=t,a=m(!1),s=m("string"),l=m("string"),u=m(!1),i=v=>{s.value=v,k(v)&&(a.value=!0)},p=v=>{l.value=v,k(v)&&(u.value=!0)},x=v=>{v.value?.type&&(l.value=v.value.type,k(l.value)&&(u.value=!0)),v.on("input",({payload:d})=>{d?.type&&d.type!==l.value&&p(d.type)})},k=v=>["object","array","enum","anyOf"].includes(v),h=["#3b82f6","#8b5cf6","#ec4899","#f97316","#10b981"],g=q(()=>n.depth||0),y=v=>h[v%h.length],_=q(()=>y(g.value));return(v,d)=>{const b=tt("FormKit"),c=tt("SchemaPropertyRow",!0);return r(),J(b,{type:"group",index:t.index,onNode:d[3]||(d[3]=f=>{f.value?.type&&(s.value=f.value.type,k(s.value)&&(a.value=!0)),f.on("input",({payload:$})=>{$?.type&&$.type!==s.value&&i($.type)})})},{default:F(({value:f})=>[e("div",{class:ce(["schema-row",g.value>0?"border-l-[3px] ml-2":""]),style:yt(g.value>0?{borderColor:_.value}:{})},[e("div",Ti,[e("div",Mi,[w(b,{type:"text",name:"name",placeholder:"Property name","outer-class":"$reset"}),w(b,{type:"selectSearch",name:"type",options:t.typeOptions,placeholder:"Type","outer-class":"$reset",onInput:i},null,8,["options"]),w(b,{type:"text",name:"description",placeholder:"Description","outer-class":"$reset"})]),e("div",zi,[k(s.value)?(r(),o("button",{key:0,onClick:d[0]||(d[0]=$=>a.value=!a.value),type:"button",class:"p-1.5 text-neutral-500 dark:text-white/70 hover:text-neutral-700 dark:hover:text-white hover:bg-neutral-100 dark:hover:bg-neutral-700 rounded transition-colors"},[(r(),o("svg",{class:ce(["w-4 h-4 transition-transform duration-150",a.value?"rotate-90":""]),fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[...d[4]||(d[4]=[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M9 5l7 7-7 7"},null,-1)])],2))])):(r(),o("div",Vi)),e("button",{onClick:d[1]||(d[1]=$=>v.$emit("remove")),type:"button",class:"p-1.5 text-neutral-500 dark:text-white/70 hover:text-red-500 dark:hover:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/30 rounded transition-colors"},[...d[5]||(d[5]=[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)])])])]),He(e("div",Ei,[s.value==="enum"?(r(),o("div",Li,[d[7]||(d[7]=e("div",{class:"text-[11px] font-medium text-neutral-400 uppercase tracking-wider mb-2"}," Enum Values ",-1)),w(b,{type:"list",name:"enumValues",dynamic:""},{default:F(({items:$,value:N,node:E})=>[e("div",Ai,[(r(!0),o(we,null,Ae($,(L,V)=>(r(),o("div",{key:L,class:"flex items-center gap-2"},[w(b,{type:"group",index:V},{default:F(()=>[w(b,{type:"text",name:"value",placeholder:"Value","outer-class":"$reset flex-1"})]),_:1},8,["index"]),e("button",{onClick:A=>E.input(N.filter((G,ee)=>ee!==V)),type:"button",class:"p-1 text-neutral-500 dark:text-white/70 hover:text-red-500 dark:hover:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/30 rounded"},[...d[6]||(d[6]=[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,Pi)]))),128))]),e("button",{onClick:L=>E.input((N||[]).concat({value:""})),type:"button",class:"mt-2 px-3 py-1.5 text-xs font-medium text-neutral-600 dark:text-neutral-400 bg-neutral-100 dark:bg-neutral-800 hover:bg-neutral-200 dark:hover:bg-neutral-700 rounded transition-colors"}," + Add Value ",8,ji)]),_:1})])):S("",!0),s.value==="object"?(r(),o("div",Ri,[w(b,{type:"list",name:"properties",dynamic:""},{default:F(({items:$,value:N,node:E})=>[e("div",null,[(r(!0),o(we,null,Ae($,(L,V)=>(r(),J(c,{key:L,index:V,"type-options":t.typeOptions,depth:g.value+1,onRemove:A=>E.input(N.filter((G,ee)=>ee!==V))},null,8,["index","type-options","depth","onRemove"]))),128))]),e("button",{onClick:L=>E.input((N||[]).concat({name:"",type:"string",description:""})),type:"button",class:"mt-2 px-3 py-1.5 text-xs font-medium text-neutral-600 dark:text-neutral-400 bg-neutral-100 dark:bg-neutral-800 hover:bg-neutral-200 dark:hover:bg-neutral-700 rounded transition-colors"}," + Add Nested Property ",8,Oi)]),_:1})])):S("",!0),s.value==="anyOf"?(r(),o("div",Di,[d[8]||(d[8]=e("div",{class:"text-[11px] font-medium text-neutral-400 uppercase tracking-wider mb-2"}," Type Options ",-1)),w(b,{type:"list",name:"anyOfTypes",dynamic:""},{default:F(({items:$,value:N,node:E})=>[e("div",null,[(r(!0),o(we,null,Ae($,(L,V)=>(r(),J(c,{key:L,index:V,"type-options":t.typeOptions,depth:g.value+1,onRemove:A=>E.input(N.filter((G,ee)=>ee!==V))},null,8,["index","type-options","depth","onRemove"]))),128))]),e("button",{onClick:L=>E.input((N||[]).concat({name:"",type:"string",description:""})),type:"button",class:"mt-2 px-3 py-1.5 text-xs font-medium text-neutral-600 dark:text-neutral-400 bg-neutral-100 dark:bg-neutral-800 hover:bg-neutral-200 dark:hover:bg-neutral-700 rounded transition-colors"}," + Add Type ",8,Ui)]),_:1})])):S("",!0),s.value==="array"?(r(),o("div",Bi,[d[14]||(d[14]=e("div",{class:"text-[11px] font-medium text-neutral-400 uppercase tracking-wider mb-2"}," Array Item Type ",-1)),w(b,{type:"group",name:"items",onNode:x},{default:F(({value:$,node:N})=>[e("div",{class:"schema-row border-l-[3px] ml-2",style:yt({borderColor:y(g.value+1)})},[e("div",Ni,[e("div",qi,[w(b,{type:"selectSearch",name:"type",options:t.typeOptions,placeholder:"Item type","outer-class":"$reset",onInput:p},null,8,["options"]),w(b,{type:"text",name:"description",placeholder:"Description","outer-class":"$reset"})]),e("div",Fi,[k(l.value)?(r(),o("button",{key:0,onClick:d[2]||(d[2]=E=>u.value=!u.value),type:"button",class:"p-1.5 text-neutral-500 dark:text-white/70 hover:text-neutral-700 dark:hover:text-white hover:bg-neutral-100 dark:hover:bg-neutral-700 rounded transition-colors"},[(r(),o("svg",{class:ce(["w-4 h-4 transition-transform duration-150",u.value?"rotate-90":""]),fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[...d[9]||(d[9]=[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M9 5l7 7-7 7"},null,-1)])],2))])):(r(),o("div",Hi))])]),He(e("div",Wi,[l.value==="enum"?(r(),o("div",Ki,[d[11]||(d[11]=e("div",{class:"text-[11px] font-medium text-neutral-400 uppercase tracking-wider mb-2"}," Enum Values ",-1)),w(b,{type:"list",name:"enumValues",dynamic:""},{default:F(({items:E,value:L,node:V})=>[e("div",Ji,[(r(!0),o(we,null,Ae(E,(A,G)=>(r(),o("div",{key:A,class:"flex items-center gap-2"},[w(b,{type:"group",index:G},{default:F(()=>[w(b,{type:"text",name:"value",placeholder:"Value","outer-class":"$reset flex-1"})]),_:1},8,["index"]),e("button",{onClick:ee=>V.input(L.filter((ie,be)=>be!==G)),type:"button",class:"p-1 text-neutral-500 dark:text-white/70 hover:text-red-500 dark:hover:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/30 rounded"},[...d[10]||(d[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:"M6 18L18 6M6 6l12 12"})],-1)])],8,Gi)]))),128))]),e("button",{onClick:A=>V.input((L||[]).concat({value:""})),type:"button",class:"mt-2 px-3 py-1.5 text-xs font-medium text-neutral-600 dark:text-neutral-400 bg-neutral-100 dark:bg-neutral-800 hover:bg-neutral-200 dark:hover:bg-neutral-700 rounded transition-colors"}," + Add Value ",8,Yi)]),_:1})])):S("",!0),l.value==="object"?(r(),o("div",Zi,[w(b,{type:"list",name:"properties",dynamic:""},{default:F(({items:E,value:L,node:V})=>[e("div",null,[(r(!0),o(we,null,Ae(E,(A,G)=>(r(),J(c,{key:A,index:G,"type-options":t.typeOptions,depth:g.value+2,onRemove:ee=>V.input(L.filter((ie,be)=>be!==G))},null,8,["index","type-options","depth","onRemove"]))),128))]),e("button",{onClick:A=>V.input((L||[]).concat({name:"",type:"string",description:""})),type:"button",class:"mt-2 px-3 py-1.5 text-xs font-medium text-neutral-600 dark:text-neutral-400 bg-neutral-100 dark:bg-neutral-800 hover:bg-neutral-200 dark:hover:bg-neutral-700 rounded transition-colors"}," + Add Nested Property ",8,Xi)]),_:1})])):S("",!0),l.value==="anyOf"?(r(),o("div",Qi,[d[12]||(d[12]=e("div",{class:"text-[11px] font-medium text-neutral-400 uppercase tracking-wider mb-2"}," Type Options ",-1)),w(b,{type:"list",name:"anyOfTypes",dynamic:""},{default:F(({items:E,value:L,node:V})=>[e("div",null,[(r(!0),o(we,null,Ae(E,(A,G)=>(r(),J(c,{key:A,index:G,"type-options":t.typeOptions,depth:g.value+2,onRemove:ee=>V.input(L.filter((ie,be)=>be!==G))},null,8,["index","type-options","depth","onRemove"]))),128))]),e("button",{onClick:A=>V.input((L||[]).concat({name:"",type:"string",description:""})),type:"button",class:"mt-2 px-3 py-1.5 text-xs font-medium text-neutral-600 dark:text-neutral-400 bg-neutral-100 dark:bg-neutral-800 hover:bg-neutral-200 dark:hover:bg-neutral-700 rounded transition-colors"}," + Add Type ",8,eu)]),_:1})])):S("",!0),l.value==="array"?(r(),o("div",tu,[d[13]||(d[13]=e("div",{class:"text-[11px] font-medium text-neutral-400 uppercase tracking-wider mb-2"}," Nested Array Item Type ",-1)),w(b,{type:"list",name:"items",dynamic:""},{default:F(({items:E,value:L,node:V})=>[e("div",null,[(r(!0),o(we,null,Ae(E,(A,G)=>(r(),J(c,{key:A,index:G,"type-options":t.typeOptions,depth:g.value+2,onRemove:ee=>V.input(L.filter((ie,be)=>be!==G))},null,8,["index","type-options","depth","onRemove"]))),128))]),e("button",{onClick:A=>V.input((L||[]).concat({type:"string",description:""})),type:"button",class:"mt-2 px-3 py-1.5 text-xs font-medium text-neutral-600 dark:text-neutral-400 bg-neutral-100 dark:bg-neutral-800 hover:bg-neutral-200 dark:hover:bg-neutral-700 rounded transition-colors"}," + Define Nested Item ",8,ru)]),_:1})])):S("",!0)],512),[[dt,u.value&&k(l.value)]])],4)]),_:1})])):S("",!0)],512),[[dt,a.value&&k(s.value)]])],6)]),_:1},8,["index"])}}}),nu=ct(au,[["__scopeId","data-v-a52ecd3f"]]),ou={"data-schema-editor":"",class:"space-y-4"},lu={class:"space-y-2 border border-neutral-200 dark:border-neutral-800 rounded-lg p-4"},su={key:0,class:"flex items-center justify-between mb-2"},iu={key:1,class:"text-center py-12"},uu={class:"divide-y divide-neutral-100 dark:divide-neutral-800"},du={class:"mt-3 pt-3 border-t border-neutral-200 dark:border-neutral-800"},cu=["onClick"],pu={class:"mt-4 text-center"},mu={key:3,class:"mt-4"},vu={class:"bg-neutral-50 dark:bg-neutral-900 border border-neutral-200 dark:border-neutral-800 rounded-lg p-4 overflow-x-auto"},fu={class:"text-xs leading-relaxed"},gu=["innerHTML"],hu=Ce({__name:"FormKitSchemaEditor",props:{context:{}},setup(t){const n=[{value:"string",label:"String",icon:"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' 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' 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' 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' 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' 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' 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",icon:"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' 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"}],a=t,s=m(!1),l=k=>k?.properties?Object.entries(k.properties).map(([h,g])=>{const y={name:h,type:g.enum?"enum":g.anyOf?"anyOf":g.type||"string",description:g.description||""};return g.enum&&(y.enumValues=g.enum.map(_=>({value:_}))),g.anyOf&&(y.anyOfTypes=g.anyOf.map(_=>({type:_.type||"string",description:_.description||""}))),g.type==="object"&&g.properties&&(y.properties=l(g)),g.type==="array"&&g.items&&(y.items={type:g.items.type||"string",description:g.items.description||""},g.items.properties&&(y.items.properties=l(g.items))),y}):[],u=k=>{const h={type:"object",properties:{},required:[],additionalProperties:!1};for(const g of k||[]){if(!g.name)continue;const y={type:g.type==="enum"||g.type==="anyOf"?void 0:g.type,description:g.description||void 0};if(g.type==="enum"&&g.enumValues&&(y.type="string",y.enum=g.enumValues.map(_=>_.value)),g.type==="anyOf"&&g.anyOfTypes&&(y.anyOf=g.anyOfTypes.map(_=>({type:_.type,description:_.description||void 0}))),g.type==="object"&&g.properties){const _=u(g.properties);y.properties=_.properties,y.required=_.required,y.additionalProperties=!1}if(g.type==="array"&&g.items&&(y.items={type:g.items.type,description:g.items.description||void 0},g.items.properties)){const _=u(g.items.properties);y.items.properties=_.properties,y.items.required=_.required}Object.keys(y).forEach(_=>y[_]===void 0&&delete y[_]),h.properties[g.name]=y,h.required.push(g.name)}return h},i=q({get:()=>{const k=a.context._value;return l(k)},set:k=>{const h=u(k);a.context.node.input(h)}}),p=q(()=>{const k=a.context._value||{type:"object",properties:{},required:[]};return JSON.stringify(k,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>')}),x=()=>{i.value=[{name:"property1",type:"string",description:""}]};return(k,h)=>{const g=tt("FormKit");return r(),o("div",ou,[e("div",lu,[i.value.length>0?(r(),o("div",su,[...h[3]||(h[3]=[e("h3",{class:"text-sm font-medium text-neutral-700 dark:text-neutral-300"}," Properties ",-1)])])):S("",!0),i.value.length===0?(r(),o("div",iu,[h[5]||(h[5]=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[6]||(h[6]=e("p",{class:"text-neutral-500 dark:text-neutral-400 text-sm mb-4"}," No properties defined ",-1)),e("button",{onClick:h[0]||(h[0]=y=>x()),type:"button",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 font-medium text-sm"},[...h[4]||(h[4]=[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"})]),de(" Add Property ")],-1)])])])):S("",!0),i.value.length>0?(r(),J(g,{key:2,type:"list",value:i.value,onInput:h[1]||(h[1]=y=>i.value=y),dynamic:""},{default:F(({items:y,value:_,node:v})=>[e("div",uu,[(r(!0),o(we,null,Ae(y,(d,b)=>(r(),J(nu,{key:d,index:b,"type-options":n,depth:0,onRemove:c=>v.input(_.filter((f,$)=>$!==b))},null,8,["index","onRemove"]))),128))]),e("div",du,[e("button",{onClick:d=>v.input(_.concat({name:`property${_.length+1}`,type:"string",description:""})),type:"button",class:"px-3 py-1.5 text-xs font-medium text-neutral-700 dark:text-neutral-300 bg-white dark:bg-neutral-800 border border-neutral-300 dark:border-neutral-600 rounded-md hover:bg-neutral-50 dark:hover:bg-neutral-700 transition-colors shadow-sm"}," + Add Property ",8,cu)])]),_:1},8,["value"])):S("",!0),e("div",pu,[e("button",{onClick:h[2]||(h[2]=y=>s.value=!s.value),type:"button",class:"text-xs font-medium text-neutral-600 dark:text-neutral-400 hover:text-neutral-900 dark:hover:text-neutral-100 underline underline-offset-2 transition-colors"},C(s.value?"Hide":"Show")+" JSON Schema ",1)]),s.value?(r(),o("div",mu,[e("div",vu,[e("pre",fu,[e("code",{class:"font-mono",innerHTML:p.value},null,8,gu)])])])):S("",!0)])])}}}),bu={type:"input",family:"text",props:["label","disabled","required"],schema:()=>[{$el:"label",if:"$label",attrs:{class:"$classes.label",for:"$id"},children:"$label"},{$cmp:De(hu),props:{context:"$node.context"}}]},xu={promptInput:qo,jsonSchema:vs,modelSelector:Ss,agentSelector:Is,toolSelector:Ts,tenvPropertyList:Ns,toolSelectorWithOptions:gi,selectSearch:bi,searchInput:Ci,sortableMultiSelect:Ii,schemaEditor:bu},yu=Dn("fk-2d3e4e0bb",Bn),ku={config:{rootClasses:xo},plugins:[yu],rules:Io,messages:{en:To},inputs:xu,icons:{...Un}},wu={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function _u(t,n){return r(),o("svg",wu,[...n[0]||(n[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 At=De({name:"lucide-bot",render:_u}),$u={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Cu(t,n){return r(),o("svg",$u,[...n[0]||(n[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 or=De({name:"lucide-message-square",render:Cu}),Su={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Iu(t,n){return r(),o("svg",Su,[...n[0]||(n[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 Tu=De({name:"lucide-cpu",render:Iu}),Mu={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function zu(t,n){return r(),o("svg",Mu,[...n[0]||(n[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 Vu=De({name:"lucide-server",render:zu}),Eu={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Lu(t,n){return r(),o("svg",Eu,[...n[0]||(n[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 _r=De({name:"lucide-wrench",render:Lu}),Au={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Pu(t,n){return r(),o("svg",Au,[...n[0]||(n[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 qt=De({name:"lucide-settings",render:Pu}),ju={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Ru(t,n){return r(),o("svg",ju,[...n[0]||(n[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 ja=De({name:"lucide-chevron-left",render:Ru}),Ou={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Du(t,n){return r(),o("svg",Ou,[...n[0]||(n[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 Uu=De({name:"lucide-sun",render:Du}),Bu={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Nu(t,n){return r(),o("svg",Bu,[...n[0]||(n[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 qu=De({name:"lucide-moon",render:Nu}),Fu={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Hu(t,n){return r(),o("svg",Fu,[...n[0]||(n[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 Wu=De({name:"lucide-activity",render:Hu}),Ku={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Ju(t,n){return r(),o("svg",Ku,[...n[0]||(n[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 Gu=De({name:"lucide-function-square",render:Ju}),Yu={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Zu(t,n){return r(),o("svg",Yu,[...n[0]||(n[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 Xu=De({name:"lucide-log-out",render:Zu}),Qu={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function ed(t,n){return r(),o("svg",Qu,[...n[0]||(n[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 td=De({name:"lucide-users",render:ed}),rd={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function ad(t,n){return r(),o("svg",rd,[...n[0]||(n[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 nd=De({name:"lucide-key",render:ad}),od={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function ld(t,n){return r(),o("svg",od,[...n[0]||(n[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 sd=De({name:"lucide-book-open",render:ld}),id={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function ud(t,n){return r(),o("svg",id,[...n[0]||(n[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 dd=De({name:"lucide-external-link",render:ud}),Ra="agentbuilder-accent-theme",Oa=["amber","lime","emerald","sky","blue","indigo","purple","fuchsia","pink","white"],$r=m("purple");let Jr=!1;function Da(t){typeof document>"u"||(t==="purple"?delete document.documentElement.dataset.accent:document.documentElement.dataset.accent=t)}function cd(t){try{localStorage.setItem(Ra,t)}catch{}}function pd(){try{const t=localStorage.getItem(Ra);if(t&&Oa.includes(t))return t}catch{}return"purple"}function Ua(){if(Jr)return;Jr=!0;const t=pd();$r.value=t,Da(t)}function md(){Ua();function t(n){$r.value=n,Da(n),cd(n)}return{theme:$r,themes:Oa,setTheme:t}}const Ba="/agents/assets/img/agent-builder-logo-light.svg",Na="/agents/assets/img/agent-builder-logo-dark.svg",vd="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",fd="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",gd=["src"],hd=["src"],bd={class:"flex-1 flex flex-col justify-between pt-2 pb-4"},xd={class:"flex flex-col gap-1 px-2"},yd={key:0},kd=["onClick","title"],wd={key:0,class:"flex-1 whitespace-nowrap overflow-hidden text-ellipsis text-left"},_d={key:0,class:"ml-4 space-y-0.5"},$d=["onClick"],Cd={class:"whitespace-nowrap overflow-hidden text-ellipsis"},Sd=["onClick","title"],Id={key:0,class:"whitespace-nowrap overflow-hidden text-ellipsis"},Td={class:"flex flex-col gap-1 px-2"},Md=["title"],zd={key:0,class:"flex-1 whitespace-nowrap overflow-hidden text-ellipsis"},Vd={class:"relative settings-menu-container"},Ed={key:0,class:"absolute bottom-full mb-2 left-0 z-50"},Ld={class:"px-4 py-3 border-b border-neutral-200 dark:border-neutral-700"},Ad=["title"],Pd={class:"relative z-10 flex items-center justify-center w-8 h-full"},jd={class:"relative z-10 flex items-center justify-center w-8 h-full"},Rd={class:"px-4 pt-3 pb-4 border-b border-neutral-200 dark:border-neutral-700"},Od={class:"grid grid-cols-5 gap-3"},Dd=["onClick","title"],Ud={key:0,class:"w-2 h-2 rounded-full bg-white shadow-sm"},Bd={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"},Nd=Ce({__name:"Sidebar",props:{isCollapsed:{type:Boolean},isDark:{type:Boolean}},emits:["toggle-sidebar","toggle-theme"],setup(t,{emit:n}){function a(ie){if(ie.startsWith("/src/")||ie.startsWith("data:"))return ie;const be=Kt();return be==="/"?ie.replace("/agents/","/"):ie.replace("/agents/",`${be}/`)}const s=a(Ba),l=a(Na),u=a(vd),i=a(fd),p=t,x=Tt(),k=Ot(),h=q(()=>x.name);function g(ie){const be=x.path;return be===ie.path||be.startsWith(ie.path+"/")}const y=q(()=>p.isDark?l:s),_=q(()=>p.isDark?i:u),v=[{id:"threads",label:"Threads",icon:Wu,path:"/threads"},{id:"agents",label:"Agents",icon:At,path:"/agents"},{id:"prompts",label:"Prompts",icon:or,path:"/prompts"},{id:"tools",label:"Tools",icon:_r,path:"/tools",hasSubnav:!0,subnav:[{id:"tools-functions",label:"Functions",icon:Gu,path:"/tools#functions"},{id:"tools-prompts",label:"Prompts",icon:or,path:"/tools#prompts"},{id:"tools-agents",label:"Agents",icon:At,path:"/tools#agents"}]},{id:"models",label:"Models",icon:Tu,path:"/models"},{id:"providers",label:"Providers",icon:Vu,path:"/providers"}],d=ie=>{k.push(ie)},b=ie=>{k.push(ie),f.value=!1},c=q(()=>typeof h.value=="string"&&(h.value==="tools"||h.value.startsWith("tools-"))),f=m(!1),{theme:$,themes:N,setTheme:E}=md(),L={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"},V=q(()=>h.value==="users"||h.value==="api-keys"),A=()=>{f.value=!f.value},G=()=>{localStorage.removeItem("auth_token"),k.push("/login")},ee=ie=>{const be=ie.target;f.value&&!be.closest(".settings-menu-container")&&(f.value=!1)};return qe(()=>{document.addEventListener("click",ee)}),ut(()=>{document.removeEventListener("click",ee)}),(ie,be)=>(r(),o("aside",{class:ce(["flex flex-col transition-all duration-300 pt-2.5",t.isCollapsed?"w-16":"w-60"])},[e("div",{class:ce(`flex items-center justify-between ${t.isCollapsed?"px-2 py-4":"p-4"}`)},[t.isCollapsed?S("",!0):(r(),o("img",{key:0,src:y.value,alt:"AgentBuilder",class:"h-8 mr-2 mt-0.5"},null,8,gd)),e("button",{onClick:be[0]||(be[0]=Q=>ie.$emit("toggle-sidebar")),class:ce(`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?(r(),o("img",{key:1,src:_.value,alt:"AgentBuilder",class:"w-7 h-7 m-auto"},null,8,hd)):(r(),J(I(ja),{key:0,class:"w-5 h-5"}))],2)],2),e("nav",bd,[e("div",xd,[(r(),o(we,null,Ae(v,Q=>(r(),o(we,{key:Q.id},[Q.hasSubnav?(r(),o("div",yd,[e("button",{onClick:U=>d(Q.path),class:ce(["flex items-center gap-3 px-3 py-3 rounded text-sm font-medium transition-all w-full",c.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?Q.label:void 0},[(r(),J(Qe(Q.icon),{class:"w-5 h-5 flex-shrink-0"})),t.isCollapsed?S("",!0):(r(),o("span",wd,C(Q.label),1))],10,kd),!t.isCollapsed&&Q.subnav?(r(),o("div",_d,[(r(!0),o(we,null,Ae(Q.subnav,U=>(r(),o("button",{key:U.id,onClick:R=>d(U.path),class:ce(["flex items-center gap-3 px-3 py-1.5 text-sm transition-all w-full",h.value===U.id?"bg-black text-white dark:bg-white dark:text-black rounded":"hover:underline"])},[(r(),J(Qe(U.icon),{class:"w-4 h-4 flex-shrink-0"})),e("span",Cd,C(U.label),1)],10,$d))),128))])):S("",!0)])):(r(),o("button",{key:1,onClick:U=>d(Q.path),class:ce(["flex items-center gap-3 px-3 py-3 rounded text-sm font-medium transition-all",g(Q)?"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?Q.label:void 0},[(r(),J(Qe(Q.icon),{class:"w-5 h-5 flex-shrink-0"})),t.isCollapsed?S("",!0):(r(),o("span",Id,C(Q.label),1))],10,Sd))],64))),64))]),e("div",Td,[e("a",{href:"https://docs.standardagentbuilder.com/",target:"_blank",rel:"noopener noreferrer",class:ce(["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},[w(I(sd),{class:"w-5 h-5 flex-shrink-0"}),t.isCollapsed?S("",!0):(r(),o("span",zd," Docs ")),t.isCollapsed?S("",!0):(r(),J(I(dd),{key:1,class:"w-3 h-3 flex-shrink-0 opacity-50"}))],10,Md),e("div",{class:ce(["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",Vd,[e("button",{onClick:Ge(A,["stop"]),class:ce(["p-2 rounded transition-colors flex items-center",f.value||V.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"},[w(I(qt),{class:"w-5 h-5 flex-shrink-0"})],2),f.value?(r(),o("div",Ed,[w(I(ur),{width:"min-w-[200px]",shadow:{offsetX:6,offsetY:6,intensity:.4}},{default:F(()=>[e("div",Ld,[be[4]||(be[4]=e("div",{class:"text-xs font-bold text-neutral-600 dark:text-neutral-400 pb-3"}," Appearance ",-1)),e("button",{onClick:be[1]||(be[1]=Ge(Q=>ie.$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:ce(["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",Pd,[w(I(Uu),{class:ce(["w-4 h-4",t.isDark?"text-neutral-500":"text-black"])},null,8,["class"])]),e("span",jd,[w(I(qu),{class:ce(["w-4 h-4",t.isDark?"text-white":"text-neutral-400"])},null,8,["class"])])],8,Ad)]),e("div",Rd,[be[5]||(be[5]=e("div",{class:"text-xs font-bold text-neutral-600 dark:text-neutral-400 pb-3"}," Accent Color ",-1)),e("div",Od,[(r(!0),o(we,null,Ae(I(N),Q=>(r(),o("button",{key:Q,onClick:Ge(U=>I(E)(Q),["stop"]),class:ce(["w-6 h-6 rounded-full transition-all flex items-center justify-center ring-1 ring-black/10 dark:ring-white/10",[L[Q],I($)===Q?"ring-2 ring-black/50 dark:ring-white/50":"hover:scale-110"]]),title:Q.charAt(0).toUpperCase()+Q.slice(1)},[I($)===Q?(r(),o("span",Ud)):S("",!0)],10,Dd))),128))])]),e("button",{onClick:be[2]||(be[2]=Q=>b("/settings/users")),class:ce(["flex items-center gap-3 px-4 py-2 text-sm transition-all w-full text-left",h.value==="users"?"bg-black text-white dark:bg-white dark:text-black":"hover:bg-black/5 dark:hover:bg-white/10"])},[w(I(td),{class:"w-4 h-4 flex-shrink-0"}),be[6]||(be[6]=e("span",{class:"whitespace-nowrap"},"Users",-1))],2),e("button",{onClick:be[3]||(be[3]=Q=>b("/settings/api-keys")),class:ce(["flex items-center gap-3 px-4 py-2 text-sm transition-all w-full text-left",h.value==="api-keys"?"bg-black text-white dark:bg-white dark:text-black":"hover:bg-black/5 dark:hover:bg-white/10"])},[w(I(nd),{class:"w-4 h-4 flex-shrink-0"}),be[7]||(be[7]=e("span",{class:"whitespace-nowrap"},"API Keys",-1))],2)]),_:1})])):S("",!0)]),e("button",{onClick:G,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"},[w(I(Xu),{class:"w-5 h-5 flex-shrink-0"}),t.isCollapsed?S("",!0):(r(),o("span",Bd,"Logout"))])],2)])])],2))}}),qd={class:"warning-banner-container"},Fd={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"},Hd={class:"flex items-center gap-2"},Wd=["onClick"],Kd=Ce({__name:"WarningBanner",setup(t){const n=m([]),a=m(new Set),s=async()=>{if(localStorage.getItem("auth_token"))try{const x=await fetch(Ve("/api/diagnostics"));if(x.ok){const k=await x.json();n.value=k.warnings||[]}}catch{}},l=p=>{const x=`${p.type}:${p.details?.name||p.message}`;a.value.add(x)},u=p=>{const x=`${p.type}:${p.details?.name||p.message}`;return!a.value.has(x)},i=p=>{if(p.type==="duplicate_tool_name"){const x=p.details?.sources?.join(" and ")||"multiple sources";return`Duplicate tool name "${p.details?.name}" (defined as both ${x}). This may cause unexpected behavior.`}return p.message};return qe(()=>{s()}),(p,x)=>(r(),o("div",qd,[(r(!0),o(we,null,Ae(n.value,k=>(r(),o(we,{key:`${k.type}:${k.details?.name}`},[u(k)?(r(),o("div",Fd,[e("div",Hd,[x[0]||(x[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(k)),1)]),e("button",{onClick:h=>l(k),class:"text-amber-600 dark:text-amber-400 hover:text-amber-800 dark:hover:text-amber-200 p-1",title:"Dismiss"},[...x[1]||(x[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,Wd)])):S("",!0)],64))),128))]))}}),Jd={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"},Gd={class:"flex-1 overflow-auto"},Yd=Ce({__name:"App",setup(t){Ua();const n=Tt(),a=m(!1),s=m(!1),l=q(()=>n.name!=="login"),u=()=>{a.value=!a.value},i=()=>{s.value=!s.value,s.value?(document.documentElement.classList.add("dark"),localStorage.setItem("theme","dark")):(document.documentElement.classList.remove("dark"),localStorage.setItem("theme","light"))};return qe(()=>{const p=localStorage.getItem("theme");(p==="dark"||!p&&window.matchMedia("(prefers-color-scheme: dark)").matches)&&(s.value=!0,document.documentElement.classList.add("dark"))}),(p,x)=>(r(),o("div",{class:ce(["app-container relative flex h-screen font-sans bg-neutral-50/80 text-black dark:bg-black dark:text-white",{"is-dark":s.value}])},[l.value?(r(),J(Nd,{key:0,"is-collapsed":a.value,"is-dark":s.value,onToggleSidebar:u,onToggleTheme:i},null,8,["is-collapsed","is-dark"])):S("",!0),l.value?(r(),o("main",Jd,[w(Kd),e("div",Gd,[w(I(Ar))])])):(r(),J(I(Ar),{key:1}))],2))}}),Zd=ct(Yd,[["__scopeId","data-v-2125e5d3"]]),Xd={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Qd(t,n){return r(),o("svg",Xd,[...n[0]||(n[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 ec=De({name:"lucide-trash-2",render:Qd}),tc={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function rc(t,n){return r(),o("svg",tc,[...n[0]||(n[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 ac=De({name:"lucide-edit",render:rc}),nc={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function oc(t,n){return r(),o("svg",nc,[...n[0]||(n[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 Cr=De({name:"lucide-eye",render:oc}),lc={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function sc(t,n){return r(),o("svg",lc,[...n[0]||(n[0]=[e("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"m18 15l-6-6l-6 6"},null,-1)])])}const ic=De({name:"lucide-chevron-up",render:sc}),uc={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function dc(t,n){return r(),o("svg",uc,[...n[0]||(n[0]=[e("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"m6 9l6 6l6-6"},null,-1)])])}const cc=De({name:"lucide-chevron-down",render:dc}),pc={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function mc(t,n){return r(),o("svg",pc,[...n[0]||(n[0]=[e("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"m7 15l5 5l5-5M7 9l5-5l5 5"},null,-1)])])}const vc=De({name:"lucide-chevrons-up-down",render:mc}),fc={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function gc(t,n){return r(),o("svg",fc,[...n[0]||(n[0]=[e("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[e("path",{d:"M22 12h-6l-2 3h-4l-2-3H2"}),e("path",{d:"M5.45 5.11L2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11"})],-1)])])}const hc=De({name:"lucide-inbox",render:gc}),bc={key:0,class:"w-full max-w-md"},xc={class:"flex items-center justify-between p-4 border-b border-red-200 dark:border-red-900 flex-shrink-0"},yc={class:"text-xl font-bold text-red-600"},kc={class:"p-6"},wc={class:"text-neutral-700 dark:text-neutral-300 mb-6"},_c={class:"flex justify-end gap-3"},zr=Ce({__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:n}){const a=t,s=n,l=()=>{s("update:modelValue",!1)},u=()=>{s("confirm"),l()},i=()=>{s("cancel"),l()},p=x=>{x.key==="Escape"&&a.modelValue&&i()};return Ee(()=>a.modelValue,x=>{x?(document.addEventListener("keydown",p),document.body.style.overflow="hidden"):(document.removeEventListener("keydown",p),document.body.style.overflow="")}),(x,k)=>(r(),J(Ht,{to:"body"},[w(bt,{"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:F(()=>[t.modelValue?(r(),o("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},[w(bt,{"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:F(()=>[t.modelValue?(r(),o("div",bc,[w(Wt,{"offset-x":8,"offset-y":8,intensity:.35},{default:F(()=>[e("div",{class:"bg-white dark:bg-neutral-900 border border-red-400 dark:border-red-500 rounded-lg flex flex-col",onClick:k[0]||(k[0]=Ge(()=>{},["stop"]))},[e("div",xc,[e("h2",yc,C(t.title),1),w(I(za),{icon:I(ir),label:"Close dialog",variant:"danger",onClick:i},null,8,["icon"])]),e("div",kc,[e("p",wc,C(t.message),1),e("div",_c,[w(I(Je),{variant:"secondary",onClick:i},{default:F(()=>[de(C(t.cancelText),1)]),_:1}),w(I(Je),{variant:"danger",onClick:u},{default:F(()=>[de(C(t.confirmText),1)]),_:1})])])])]),_:1})])):S("",!0)]),_:1})])):S("",!0)]),_:1})]))}}),$c={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Cc(t,n){return r(),o("svg",$c,[...n[0]||(n[0]=[e("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"m9 18l6-6l-6-6"},null,-1)])])}const Sc=De({name:"lucide-chevron-right",render:Cc}),Ic={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Tc(t,n){return r(),o("svg",Ic,[...n[0]||(n[0]=[e("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"m11 17l-5-5l5-5m7 10l-5-5l5-5"},null,-1)])])}const Mc=De({name:"lucide-chevrons-left",render:Tc}),zc={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Vc(t,n){return r(),o("svg",zc,[...n[0]||(n[0]=[e("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"m6 17l5-5l-5-5m7 10l5-5l-5-5"},null,-1)])])}const Ec=De({name:"lucide-chevrons-right",render:Vc}),Lc={key:0,class:"flex flex-wrap items-center justify-between gap-4 px-4 py-2.5 text-sm bg-neutral-50 dark:bg-neutral-800/50 border-t border-neutral-300 dark:border-neutral-700"},Ac={class:"text-neutral-500 dark:text-neutral-400 text-xs font-medium"},Pc={class:"text-neutral-700 dark:text-neutral-300"},jc={class:"text-neutral-700 dark:text-neutral-300"},Rc={class:"text-neutral-700 dark:text-neutral-300"},Oc={class:"flex items-center gap-0.5"},Dc=["disabled"],Uc=["disabled"],Bc={class:"flex items-center gap-0.5 mx-1"},Nc={key:0,class:"px-2 text-neutral-400 dark:text-neutral-500 text-xs"},qc=["onClick"],Fc=["disabled"],Hc=["disabled"],Wc={class:"flex items-center gap-2"},Kc=["value"],Jc=["value"],Gc=Ce({__name:"DataTablePagination",props:{page:{},pageSize:{},totalItems:{},pageSizeOptions:{default:()=>[10,25,50,100]}},emits:["update:page","update:pageSize"],setup(t,{emit:n}){const a=t,s=n,l=q(()=>Math.ceil(a.totalItems/a.pageSize)),u=q(()=>a.totalItems===0?0:(a.page-1)*a.pageSize+1),i=q(()=>Math.min(a.page*a.pageSize,a.totalItems)),p=q(()=>a.page>1),x=q(()=>a.page<l.value),k=q(()=>{const b=[],c=l.value,f=a.page;if(c<=7)for(let $=1;$<=c;$++)b.push($);else{b.push(1),f>3&&b.push("...");const $=Math.max(2,f-1),N=Math.min(c-1,f+1);for(let E=$;E<=N;E++)b.includes(E)||b.push(E);f<c-2&&b.push("..."),b.includes(c)||b.push(c)}return b}),h=b=>{b>=1&&b<=l.value&&s("update:page",b)},g=()=>h(1),y=()=>h(a.page-1),_=()=>h(a.page+1),v=()=>h(l.value),d=b=>{const c=b.target;s("update:pageSize",parseInt(c.value,10)),s("update:page",1)};return(b,c)=>t.totalItems>0?(r(),o("div",Lc,[e("div",Ac,[c[0]||(c[0]=de(" Showing ",-1)),e("span",Pc,C(u.value),1),c[1]||(c[1]=de(" to ",-1)),e("span",jc,C(i.value),1),c[2]||(c[2]=de(" of ",-1)),e("span",Rc,C(t.totalItems),1)]),e("div",Oc,[e("button",{type:"button",onClick:g,disabled:!p.value,class:"p-1.5 rounded-md transition-all duration-150 hover:bg-neutral-200 dark:hover:bg-neutral-700 disabled:opacity-30 disabled:cursor-not-allowed disabled:hover:bg-transparent",title:"First page"},[w(I(Mc),{class:"w-4 h-4 text-neutral-500 dark:text-neutral-400"})],8,Dc),e("button",{type:"button",onClick:y,disabled:!p.value,class:"p-1.5 rounded-md transition-all duration-150 hover:bg-neutral-200 dark:hover:bg-neutral-700 disabled:opacity-30 disabled:cursor-not-allowed disabled:hover:bg-transparent",title:"Previous page"},[w(I(ja),{class:"w-4 h-4 text-neutral-500 dark:text-neutral-400"})],8,Uc),e("div",Bc,[(r(!0),o(we,null,Ae(k.value,(f,$)=>(r(),o(we,{key:$},[f==="..."?(r(),o("span",Nc," ... ")):(r(),o("button",{key:1,type:"button",onClick:N=>h(f),class:ce(["min-w-[1.75rem] px-2 py-1 rounded-md text-xs font-medium transition-all duration-150",f===t.page?"bg-accent-600 text-white shadow-sm":"text-neutral-600 dark:text-neutral-400 hover:bg-neutral-200 dark:hover:bg-neutral-700 hover:text-neutral-900 dark:hover:text-neutral-200"])},C(f),11,qc))],64))),128))]),e("button",{type:"button",onClick:_,disabled:!x.value,class:"p-1.5 rounded-md transition-all duration-150 hover:bg-neutral-200 dark:hover:bg-neutral-700 disabled:opacity-30 disabled:cursor-not-allowed disabled:hover:bg-transparent",title:"Next page"},[w(I(Sc),{class:"w-4 h-4 text-neutral-500 dark:text-neutral-400"})],8,Fc),e("button",{type:"button",onClick:v,disabled:!x.value,class:"p-1.5 rounded-md transition-all duration-150 hover:bg-neutral-200 dark:hover:bg-neutral-700 disabled:opacity-30 disabled:cursor-not-allowed disabled:hover:bg-transparent",title:"Last page"},[w(I(Ec),{class:"w-4 h-4 text-neutral-500 dark:text-neutral-400"})],8,Hc)]),e("div",Wc,[e("select",{value:t.pageSize,onChange:d,class:"px-2 py-1 rounded-md border border-neutral-200 dark:border-neutral-700 bg-white dark:bg-neutral-800 text-xs font-medium text-neutral-700 dark:text-neutral-300 focus:outline-none focus:ring-2 focus:ring-accent-500/30 focus:border-accent-500 dark:focus:border-accent-400 cursor-pointer transition-all"},[(r(!0),o(we,null,Ae(t.pageSizeOptions,f=>(r(),o("option",{key:f,value:f},C(f),9,Jc))),128))],40,Kc),c[3]||(c[3]=e("span",{class:"text-neutral-500 dark:text-neutral-400 text-xs"},"per page",-1))])])):S("",!0)}}),Yc={class:"w-full"},Zc={key:0,class:"flex flex-wrap items-start justify-between gap-4 mb-5"},Xc={class:"flex items-center gap-3"},Qc={class:"flex items-center gap-2"},ep={key:0,class:"text-xl font-bold tracking-tight"},tp={key:1,class:"text-xs font-mono text-neutral-400 dark:text-neutral-500"},rp={key:0,class:"text-sm text-neutral-500 dark:text-neutral-400 mt-0.5"},ap={key:0,class:"flex items-center gap-2"},np={key:1,class:"mb-4"},op={class:"flex flex-wrap items-center gap-3"},lp={key:0,class:"flex-1 min-w-[200px] max-w-md"},sp={key:2,class:"flex items-center gap-2 ml-auto"},ip={class:"text-sm text-neutral-500 dark:text-neutral-400 font-medium"},up={class:"flex items-center gap-1.5"},dp=["onClick"],cp={class:"rounded-xl border border-neutral-300 dark:border-neutral-700 overflow-hidden bg-white dark:bg-transparent"},pp={class:"overflow-x-auto"},mp={class:"w-full"},vp={class:"bg-neutral-50 dark:bg-neutral-800/50 border-b border-neutral-300 dark:border-neutral-700"},fp={key:0,class:"px-4 py-2.5 w-12"},gp={class:"flex items-center justify-center"},hp=["checked","indeterminate"],bp=["onClick"],xp={key:1,class:"px-4 py-2.5 text-right font-medium text-xs uppercase tracking-wide text-neutral-500 dark:text-neutral-400 w-24"},yp={class:"divide-y divide-neutral-200 dark:divide-neutral-800"},kp={key:0},wp=["colspan"],_p={class:"flex flex-col items-center justify-center gap-3 text-neutral-400"},$p={key:1},Cp=["colspan"],Sp={class:"flex flex-col items-center justify-center gap-3 text-neutral-400"},Ip={class:"w-12 h-12 rounded-full bg-neutral-100 dark:bg-neutral-800 flex items-center justify-center"},Tp={class:"text-sm"},Mp=["onClick"],zp={key:0,class:"absolute left-0 top-0 bottom-0 w-0.5 bg-accent-500"},Vp={class:"flex items-center justify-center"},Ep=["checked","onChange"],Lp=["innerHTML"],Ap={class:"inline-flex gap-0.5"},Pp=["disabled","onClick","title"],jp=["disabled","onClick","title"],$t=Ce({__name:"DataTable",props:{columns:{},data:{},actions:{},emptyMessage:{default:"No data available"},loading:{type:Boolean,default:!1},title:{},description:{},primaryAction:{},sortable:{type:Boolean,default:!1},sortKey:{},sortDirection:{default:"asc"},searchable:{type:Boolean,default:!1},searchQuery:{default:""},searchPlaceholder:{default:"Search..."},paginated:{type:Boolean,default:!1},page:{default:1},pageSize:{default:10},totalItems:{default:0},pageSizeOptions:{default:()=>[10,25,50,100]},selectable:{type:Boolean,default:!1},selectedRows:{default:()=>[]},rowKey:{default:"id"},bulkActions:{default:()=>[]}},emits:["update:sortKey","update:sortDirection","sort","update:searchQuery","search","update:page","update:pageSize","page-change","update:selectedRows","selection-change","row-click"],setup(t,{emit:n}){const a=t,s=n,l=m(!1),u=m(""),i=m(null),p=O=>{if(typeof O!="string")return O;switch(O){case"edit":return ac;case"delete":return ec;case"view":return Cr;default:return null}},x=(O,j)=>{const z=O[j.key];return j.formatter?j.formatter(z,O):z??"-"},k=O=>{switch(O){case"center":return"text-center";case"right":return"text-right";default:return"text-left"}},h=(O,j)=>j.cellClass?typeof j.cellClass=="function"?j.cellClass(O):j.cellClass:"",g=async(O,j)=>{if(O.confirm){const z=typeof O.confirmMessage=="function"?O.confirmMessage(j):O.confirmMessage||`Are you sure you want to ${O.label.toLowerCase()}?`;u.value=z,i.value=async()=>{await O.handler(j)},l.value=!0}else await O.handler(j)},y=async()=>{i.value&&(await i.value(),i.value=null),l.value=!1},_=()=>{i.value=null,l.value=!1},v=(O,j)=>O.visible===void 0?!0:typeof O.visible=="function"?O.visible(j):O.visible,d=(O,j)=>O.disabled===void 0?!1:typeof O.disabled=="function"?O.disabled(j):O.disabled,b=m(null),c=m("asc"),f=q(()=>a.sortKey??b.value),$=q(()=>a.sortKey!==void 0?a.sortDirection:c.value),N=O=>a.sortable&&O.sortable===!0,E=O=>{if(!N(O))return;const j=O.key;let z="asc";f.value===j&&(z=$.value==="asc"?"desc":"asc"),b.value=j,c.value=z,s("update:sortKey",j),s("update:sortDirection",z),s("sort",{key:j,direction:z})},L=O=>f.value!==O.key?vc:$.value==="asc"?ic:cc,V=q(()=>{if(!f.value||!a.sortable)return R.value;const O=f.value,j=$.value;return[...R.value].sort((z,M)=>{const P=z[O],re=M[O];if(P==null&&re==null)return 0;if(P==null)return j==="asc"?1:-1;if(re==null)return j==="asc"?-1:1;let se=0;return typeof P=="string"&&typeof re=="string"?se=P.localeCompare(re,void 0,{sensitivity:"base"}):typeof P=="number"&&typeof re=="number"?se=P-re:se=String(P).localeCompare(String(re)),j==="asc"?se:-se})}),A=m(a.searchQuery),G=m({}),ee=va(O=>{s("update:searchQuery",O),s("search",O)},300),ie=O=>{A.value=O,ee(O)},be=()=>{A.value="",s("update:searchQuery",""),s("search","")},Q=q(()=>a.columns.filter(O=>O.filterable===!0).map(O=>{const j=new Map;a.data.forEach(M=>{const P=M[O.key];if(P!=null){const re=O.formatter?O.formatter(P,M):String(P);if(!j.has(re)){const se=O.filterIcon?O.filterIcon(P,M):void 0;j.set(re,{value:re,icon:se})}}});const z=Array.from(j.entries()).sort((M,P)=>M[0].localeCompare(P[0]));return{key:O.key,label:O.label,options:z.map(([M,P])=>({value:M,label:M,icon:P.icon}))}})),U=(O,j)=>{if(j===""){const{[O]:z,...M}=G.value;G.value=M}else G.value={...G.value,[O]:j}},R=q(()=>{let O=a.data;const j=Object.entries(G.value);if(j.length>0&&(O=O.filter(z=>j.every(([M,P])=>{const re=a.columns.find(he=>he.key===M);if(!re)return!0;const se=z[M];return se==null?!1:(re.formatter?re.formatter(se,z):String(se))===P}))),a.searchable&&A.value.trim()){const z=A.value.toLowerCase().trim();O=O.filter(M=>a.columns.some(P=>{if(P.searchable===!1)return!1;const re=M[P.key];return re==null?!1:(P.formatter?P.formatter(re,M):String(re)).toLowerCase().includes(z)}))}return O}),K=q(()=>{let O=0;return A.value&&O++,O+=Object.keys(G.value).length,O}),H=()=>{be(),G.value={}},ve=O=>O[a.rowKey],X=O=>{const j=ve(O);return a.selectedRows.some(z=>z[a.rowKey]===j)},D=q(()=>V.value.length>0&&a.selectedRows.length===V.value.length),W=q(()=>a.selectedRows.length>0&&a.selectedRows.length<V.value.length),me=O=>{const j=ve(O);let z;X(O)?z=a.selectedRows.filter(M=>M[a.rowKey]!==j):z=[...a.selectedRows,O],s("update:selectedRows",z),s("selection-change",z)},ue=()=>{const O=D.value?[]:[...V.value];s("update:selectedRows",O),s("selection-change",O)},te=async O=>{if(O.confirm){const j=O.confirmMessage||`Are you sure you want to ${O.label.toLowerCase()} ${a.selectedRows.length} item(s)?`;u.value=j,i.value=async()=>{await O.handler(a.selectedRows)},l.value=!0}else await O.handler(a.selectedRows)},Y=O=>{s("update:page",O),s("page-change",O)},ae=O=>{s("update:pageSize",O)},ye=q(()=>a.title||a.description||a.primaryAction),Te=q(()=>a.actions&&a.actions.length>0),ne=q(()=>a.actions?.filter(O=>O.variant!=="danger")||[]),ke=q(()=>a.actions?.filter(O=>O.variant==="danger")||[]),_e=q(()=>{let O=a.columns.length;return a.selectable&&O++,Te.value&&O++,O});return(O,j)=>{const z=tt("FormKit");return r(),o("div",Yc,[ye.value?(r(),o("div",Zc,[e("div",Xc,[e("div",null,[e("div",Qc,[t.title?(r(),o("h2",ep,C(t.title),1)):S("",!0),!t.loading&&t.data.length>0?(r(),o("span",tp,[K.value>0&&R.value.length!==t.data.length?(r(),o(we,{key:0},[de(" ("+C(R.value.length)+" of "+C(t.data.length)+") ",1)],64)):(r(),o(we,{key:1},[de(" ("+C(t.data.length)+") ",1)],64))])):S("",!0)]),t.description?(r(),o("p",rp,C(t.description),1)):S("",!0)])]),t.primaryAction?(r(),o("div",ap,[We(O.$slots,"header-actions"),w(I(Je),{onClick:t.primaryAction.handler},{default:F(()=>[t.primaryAction.icon?(r(),J(Qe(t.primaryAction.icon),{key:0,class:"w-4 h-4 mr-2"})):S("",!0),de(" "+C(t.primaryAction.label),1)]),_:1},8,["onClick"])])):S("",!0)])):S("",!0),t.searchable||Q.value.length>0?(r(),o("div",np,[e("div",op,[t.searchable?(r(),o("div",lp,[w(z,{type:"searchInput",value:A.value,placeholder:t.searchPlaceholder,onInput:ie},null,8,["value","placeholder"])])):S("",!0),(r(!0),o(we,null,Ae(Q.value,M=>(r(),o("div",{key:M.key,class:"min-w-[220px]"},[w(z,{type:"selectSearch",value:G.value[M.key]||"",options:M.options,placeholder:`All ${M.label}s`,onInput:P=>U(M.key,P)},null,8,["value","options","placeholder","onInput"])]))),128)),K.value>0?(r(),o("button",{key:1,type:"button",onClick:H,class:"px-3 py-2 text-sm font-medium text-neutral-500 hover:text-neutral-700 dark:text-neutral-400 dark:hover:text-neutral-200 transition-colors"}," Clear filters ")):S("",!0),t.selectable&&t.selectedRows.length>0&&t.bulkActions.length>0?(r(),o("div",sp,[e("span",ip,C(t.selectedRows.length)+" selected ",1),e("div",up,[(r(!0),o(we,null,Ae(t.bulkActions,(M,P)=>(r(),o("button",{key:P,type:"button",onClick:re=>te(M),class:ce(["inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-sm font-medium transition-all duration-150",M.variant==="danger"?"bg-red-100 text-red-700 hover:bg-red-200 dark:bg-red-900/30 dark:text-red-400 dark:hover:bg-red-900/50":"bg-neutral-100 text-neutral-700 hover:bg-neutral-200 dark:bg-neutral-800 dark:text-neutral-300 dark:hover:bg-neutral-700"])},[(r(),J(Qe(M.icon),{class:"w-4 h-4"})),de(" "+C(M.label),1)],10,dp))),128))])])):S("",!0)])])):S("",!0),We(O.$slots,"toolbar"),e("div",cp,[e("div",pp,[e("table",mp,[e("thead",vp,[e("tr",null,[t.selectable?(r(),o("th",fp,[e("div",gp,[e("input",{type:"checkbox",checked:D.value,indeterminate:W.value,onChange:ue,class:"w-4 h-4 rounded border-neutral-300 dark:border-neutral-600 text-accent-600 focus:ring-accent-500 focus:ring-offset-0 cursor-pointer transition-colors"},null,40,hp)])])):S("",!0),(r(!0),o(we,null,Ae(t.columns,M=>(r(),o("th",{key:M.key,class:ce(["px-4 py-2.5 font-medium text-xs uppercase tracking-wide text-neutral-500 dark:text-neutral-400",k(M.align),M.width||"",N(M)?"cursor-pointer select-none group":""]),onClick:P=>E(M)},[e("div",{class:ce(["inline-flex items-center gap-1",M.align==="right"?"flex-row-reverse":"",N(M)?"hover:text-neutral-700 dark:hover:text-neutral-200 transition-colors":""])},[e("span",null,C(M.label),1),N(M)?(r(),o("span",{key:0,class:ce(["inline-flex items-center justify-center w-5 h-5 rounded transition-all duration-150",f.value===M.key?"bg-accent-100 dark:bg-accent-900/50":"group-hover:bg-neutral-200 dark:group-hover:bg-neutral-700"])},[(r(),J(Qe(L(M)),{class:ce(["w-3.5 h-3.5",f.value===M.key?"text-accent-600 dark:text-accent-400":"text-neutral-400 dark:text-neutral-500"])},null,8,["class"]))],2)):S("",!0)],2)],10,bp))),128)),Te.value?(r(),o("th",xp," Actions ")):S("",!0)])]),e("tbody",yp,[t.loading?(r(),o("tr",kp,[e("td",{colspan:_e.value,class:"px-4 py-16"},[We(O.$slots,"loading",{},()=>[e("div",_p,[w(Be,{size:"md"}),j[3]||(j[3]=e("span",{class:"text-sm"},"Loading data...",-1))])])],8,wp)])):V.value.length===0?(r(),o("tr",$p,[e("td",{colspan:_e.value,class:"px-4 py-16"},[We(O.$slots,"empty",{},()=>[e("div",Sp,[e("div",Ip,[w(I(hc),{class:"w-6 h-6"})]),e("p",Tp,C(t.emptyMessage),1),K.value>0?(r(),o("button",{key:0,onClick:H,type:"button",class:"text-xs text-accent-600 dark:text-accent-400 hover:underline font-medium"}," Clear filters ")):S("",!0)])])],8,Cp)])):(r(!0),o(we,{key:2},Ae(V.value,(M,P)=>(r(),o("tr",{key:M[t.rowKey]??P,class:ce(["transition-all duration-150 cursor-pointer relative",X(M)?"bg-accent-50 dark:bg-accent-950/30":"hover:bg-neutral-50 dark:hover:bg-neutral-900/50"]),onClick:re=>s("row-click",M)},[X(M)?(r(),o("div",zp)):S("",!0),t.selectable?(r(),o("td",{key:1,class:"px-4 py-3",onClick:j[0]||(j[0]=Ge(()=>{},["stop"]))},[e("div",Vp,[e("input",{type:"checkbox",checked:X(M),onChange:re=>me(M),class:"w-4 h-4 rounded border-neutral-300 dark:border-neutral-600 text-accent-600 focus:ring-accent-500 focus:ring-offset-0 cursor-pointer transition-colors"},null,40,Ep)])])):S("",!0),(r(!0),o(we,null,Ae(t.columns,re=>(r(),o("td",{key:re.key,class:ce(["px-4 py-3 text-sm",k(re.align),h(M,re),X(M)?"text-accent-900 dark:text-accent-100":"text-neutral-700 dark:text-neutral-300"])},[We(O.$slots,`cell-${re.key}`,{value:M[re.key],row:M,column:re},()=>[re.html?(r(),o("span",{key:0,innerHTML:x(M,re)},null,8,Lp)):(r(),o(we,{key:1},[de(C(x(M,re)),1)],64))])],2))),128)),Te.value?(r(),o("td",{key:2,class:"px-4 py-3 text-right",onClick:j[1]||(j[1]=Ge(()=>{},["stop"]))},[e("div",Ap,[(r(!0),o(we,null,Ae(ne.value,(re,se)=>He((r(),o("button",{key:`non-delete-${se}`,disabled:d(re,M),onClick:Ie=>g(re,M),class:ce(["p-1.5 rounded-md transition-all duration-150",d(re,M)?"opacity-30 cursor-not-allowed":"text-neutral-400 hover:text-neutral-700 hover:bg-neutral-100 dark:hover:text-neutral-200 dark:hover:bg-neutral-800"]),title:re.label},[(r(),J(Qe(p(re.icon)),{class:"w-4 h-4"}))],10,Pp)),[[dt,v(re,M)]])),128)),We(O.$slots,"extra-actions",{row:M}),(r(!0),o(we,null,Ae(ke.value,(re,se)=>He((r(),o("button",{key:`delete-${se}`,disabled:d(re,M),onClick:Ie=>g(re,M),class:ce(["p-1.5 rounded-md transition-all duration-150",d(re,M)?"opacity-30 cursor-not-allowed":"text-neutral-400 hover:text-red-600 hover:bg-red-50 dark:hover:text-red-400 dark:hover:bg-red-900/30"]),title:re.label},[(r(),J(Qe(p(re.icon)),{class:"w-4 h-4"}))],10,jp)),[[dt,v(re,M)]])),128))])])):S("",!0)],10,Mp))),128))])])]),t.paginated?(r(),J(Gc,{key:0,page:t.page,"page-size":t.pageSize,"total-items":t.totalItems,"page-size-options":t.pageSizeOptions,"onUpdate:page":Y,"onUpdate:pageSize":ae},null,8,["page","page-size","total-items","page-size-options"])):S("",!0)]),w(zr,{modelValue:l.value,"onUpdate:modelValue":j[2]||(j[2]=M=>l.value=M),title:"Confirm Action",message:u.value,"confirm-text":"Confirm","cancel-text":"Cancel",onConfirm:y,onCancel:_},null,8,["modelValue","message"])])}}}),Rp={},Op={xmlns:"http://www.w3.org/2000/svg",viewBox:"-12 -12 408 408",width:"1em",height:"1em",fill:"currentColor",stroke:"currentColor","stroke-width":"24","stroke-linejoin":"round","aria-hidden":"true"};function Dp(t,n){return r(),o("svg",Op,[...n[0]||(n[0]=[e("path",{d:"M384,171.75v9.75c-1.68,7.91-4.76,14.74-10.77,20.88l-113.42,115.85c-10.42,10.65-25.58,13.8-39.31,8.04-12.9-5.41-21.53-18.19-21.52-33.02l.03-43.8h-26.55c-32.35.02-67.19,7.63-94.92,24.63s-44.76,42.35-51.3,73.05c-1.42,6.68-5.61,11.51-12.38,12.08-6.37.54-11.26-3.83-13.86-9.7v-46.5c.42-1.2.55-2.61.71-4.61,7.99-103.74,94.18-186.48,198.25-192.75l.08-45.6c.02-14.6,8.87-27.11,21.33-32.38,13.91-5.89,29.05-2.63,39.51,8.05l112.3,114.71c6.23,6.36,9.94,13.03,11.82,21.33ZM211.97,223.41c7.34,0,13.01,5.78,13.01,12.84v56.98c.01,4.38,2.23,7.69,5.66,9.09,4.03,1.65,7.66.72,10.83-2.51l113.71-116.2c3.69-3.77,3.73-9.48.04-13.25l-113.69-116.21c-3.21-3.28-6.81-4.26-11.03-2.51-3.33,1.38-5.52,4.74-5.52,9.15l.03,56.96c0,7.8-5.62,13.53-13.58,13.54-48.85.09-95.31,19.31-130.18,53.54-26.49,26-45.26,59.26-51.99,96.82,34.96-40.83,86.25-56.16,137.95-58.21l44.76-.03Z"},null,-1)])])}const Up=ct(Rp,[["render",Dp]]),Bp={},Np={xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",fill:"currentColor"};function qp(t,n){return r(),o("svg",Np,[...n[0]||(n[0]=[e("path",{d:"M4 4h16v16H4V4zm2 2v12h4v-10h3v10h5V6H6z"},null,-1)])])}const Fp=ct(Bp,[["render",qp]]),Hp={class:"py-1"},Wp=Ce({__name:"ShareDropdown",props:{packageId:{}},emits:["download","publish"],setup(t,{emit:n}){const a=n,s=m(null),l=m(null);function u(){if(!s.value||!l.value)return;const k=s.value.getBoundingClientRect();let g=k.right-160;const y=8;g<y&&(g=y),l.value.style.top=`${k.bottom+4}px`,l.value.style.left=`${g}px`}function i(){l.value&&(l.value.matches(":popover-open")?l.value.hidePopover():(u(),l.value.showPopover()))}function p(k){l.value?.hidePopover(),a(k)}function x(){l.value?.matches(":popover-open")&&u()}return qe(()=>{window.addEventListener("scroll",x,!0),window.addEventListener("resize",x)}),ut(()=>{window.removeEventListener("scroll",x,!0),window.removeEventListener("resize",x)}),(k,h)=>(r(),o(we,null,[e("button",{ref_key:"triggerButton",ref:s,type:"button",onClick:i,class:"p-1.5 rounded-md transition-all duration-150 text-neutral-400 hover:text-neutral-700 hover:bg-neutral-100 dark:hover:text-neutral-200 dark:hover:bg-neutral-800",title:"Share"},[w(Up,{class:"w-4 h-4"})],512),e("div",{ref_key:"popoverEl",ref:l,popover:"auto",class:"w-40 p-0 m-0 border-0 bg-transparent overflow-visible"},[w(I(ur),{width:"w-40",shadow:{offsetX:4,offsetY:4,intensity:.3}},{default:F(()=>[e("div",Hp,[w(I(Wr),{onClick:h[0]||(h[0]=g=>p("download"))},{default:F(()=>[w(I(cn),{class:"w-4 h-4 text-neutral-500"}),h[2]||(h[2]=e("span",null,"Download",-1))]),_:1}),w(I(Wr),{onClick:h[1]||(h[1]=g=>p("publish"))},{default:F(()=>[w(Fp,{class:"w-4 h-4 text-neutral-500"}),h[3]||(h[3]=e("span",null,"Publish",-1))]),_:1})])]),_:1})],512)],64))}}),Kp={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Jp(t,n){return r(),o("svg",Kp,[...n[0]||(n[0]=[e("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[e("path",{d:"M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73zm1 .27V12"}),e("path",{d:"M3.29 7L12 12l8.71-5M7.5 4.27l9 5.15"})],-1)])])}const Gr=De({name:"lucide-package",render:Jp}),Gp={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Yp(t,n){return r(),o("svg",Gp,[...n[0]||(n[0]=[e("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[e("path",{d:"M12 22v-9m3.17-10.79a1.67 1.67 0 0 1 1.63 0L21 4.57a1.93 1.93 0 0 1 0 3.36L8.82 14.79a1.66 1.66 0 0 1-1.64 0L3 12.43a1.93 1.93 0 0 1 0-3.36z"}),e("path",{d:"M20 13v3.87a2.06 2.06 0 0 1-1.11 1.83l-6 3.08a1.93 1.93 0 0 1-1.78 0l-6-3.08A2.06 2.06 0 0 1 4 16.87V13"}),e("path",{d:"M21 12.43a1.93 1.93 0 0 0 0-3.36L8.83 2.2a1.64 1.64 0 0 0-1.63 0L3 4.57a1.93 1.93 0 0 0 0 3.36l12.18 6.86a1.64 1.64 0 0 0 1.63 0z"})],-1)])])}const Zp=De({name:"lucide-package-open",render:Yp}),Xp={class:"flex items-center gap-2"},Qp=Ce({__name:"AgentsDataTable",props:{title:{},description:{},primaryAction:{},readonly:{type:Boolean,default:!1}},emits:["add","edit","delete","pack","unpack","publish"],setup(t,{expose:n,emit:a}){const s=t,l=a,u=m([]),i=m(!1),p=[{key:"title",label:"Title",width:"w-1/5",sortable:!0},{key:"type",label:"Type",width:"w-1/12",sortable:!0,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",sortable:!0,searchable:!1,formatter:d=>d?new Date(d*1e3).toLocaleDateString():"-"}],x=[{icon:Gr,label:"Pack",handler:d=>l("pack",d),visible:d=>!d.packed},{icon:Zp,label:"Unpack",handler:d=>l("unpack",d),visible:d=>!!d.packed},{icon:"edit",label:"Edit",handler:d=>l("edit",d),visible:d=>!d.packed},{icon:"delete",label:"Delete",handler:async d=>{await g(d)},confirm:!0,confirmMessage:"Are you sure you want to delete this agent?",variant:"danger",visible:d=>!d.packed},{icon:"delete",label:"Delete Package",handler:async d=>{await y(d)},confirm:!0,confirmMessage:"Are you sure you want to delete this packed agent and all its contents?",variant:"danger",visible:d=>!!d.packed&&d.source==="local"}],k=q(()=>s.readonly?x.filter(d=>d.variant!=="danger"):x),h=async()=>{i.value=!0;try{const d=await fetch(Ve("/api/agents"));if(d.ok){const b=await d.json();u.value=b.agents||[]}}catch(d){console.error("Error fetching agents:",d)}finally{i.value=!1}},g=async d=>{try{const b=await fetch(Ve(`/api/agents/${encodeURIComponent(d.id)}`),{method:"DELETE"});if(b.ok)await h();else{const c=await b.json();alert(c.error||"Failed to delete agent")}}catch(b){console.error("Error deleting agent:",b),alert("Failed to delete agent")}},y=async d=>{if(d.packageId)try{const b=await fetch(Ve(`/api/pack/${encodeURIComponent(d.packageId)}`),{method:"DELETE"});if(b.ok)await h();else{const c=await b.json();alert(c.error||"Failed to delete packed agent")}}catch(b){console.error("Error deleting packed agent:",b),alert("Failed to delete packed agent")}},_=d=>{d.packageId&&(window.location.href=Ve(`/api/pack/${encodeURIComponent(d.packageId)}/download`))},v=d=>{l("publish",d)};return qe(()=>{h()}),n({refresh:h}),(d,b)=>(r(),o("div",null,[w($t,{title:t.title,description:t.description,"primary-action":t.primaryAction,columns:p,data:u.value,actions:k.value,loading:i.value,sortable:"",searchable:"","search-placeholder":"Search agents...","empty-message":"No agents available. Create your first agent to get started.",onRowClick:b[0]||(b[0]=c=>{c.packed||l("edit",c)})},pn({"cell-title":F(({row:c})=>[e("div",Xp,[c.packed?(r(),J(I(Gr),{key:0,class:"w-4 h-4 text-blue-500 flex-shrink-0",title:`Packed agent from ${c.packageId}`},null,8,["title"])):S("",!0),e("span",null,C(c.title),1)])]),_:2},[t.readonly?void 0:{name:"extra-actions",fn:F(({row:c})=>[c.packed?(r(),J(Wp,{key:0,"package-id":c.packageId,onDownload:f=>_(c),onPublish:f=>v(c)},null,8,["package-id","onDownload","onPublish"])):S("",!0)]),key:"0"}]),1032,["title","description","primary-action","data","actions","loading"])]))}}),e0={class:"flex items-center justify-between p-4 border-b border-neutral-200 dark:border-neutral-700 flex-shrink-0"},t0={class:"text-xl font-bold"},r0={key:0,class:"p-6 border-t border-neutral-200 dark:border-neutral-700 flex-shrink-0"},st=Ce({__name:"Modal",props:{modelValue:{type:Boolean},title:{},width:{default:"max-w-lg"},minHeight:{default:"min-h-[24rem]"},hasChanges:{type:Boolean,default:void 0},contentPadding:{type:Boolean,default:!0}},emits:["update:modelValue","close"],setup(t,{emit:n}){const a=t,s=n,l=m(),u=m(!1),i=m(new Map),p=()=>l.value&&(l.value.querySelector("input")||l.value.querySelector("textarea")||l.value.querySelector("select")||l.value.querySelector("[contenteditable]")||l.value.querySelector(".monaco-editor")),x=()=>{if(!l.value)return;l.value.querySelectorAll(".monaco-editor-container").forEach(E=>{const L=E.__monacoEditor;if(L&&typeof L.getValue=="function"){const V=L.getValue();i.value.set(E,V)}})},k=()=>{if(!l.value)return!1;const N=l.value.querySelectorAll(".monaco-editor-container");for(const E of N){const L=E.__monacoEditor;if(L&&typeof L.getValue=="function"){const V=L.getValue(),A=i.value.get(E);if(A===void 0||(L.getRawOptions?.()||{}).readOnly===!0)continue;if(V!==A)return!0}}return!1},h=N=>{const E=N;return E.type==="checkbox"||E.type==="radio"?E.checked!==E.defaultChecked:(E.tagName==="SELECT",E.value!==E.defaultValue)},g=()=>{if(a.hasChanges!==void 0)return a.hasChanges;if(!l.value)return!1;if(k())return!0;const N=l.value.querySelectorAll("input, textarea, select");for(const E of N)if(h(E))return!0;return!1},y=()=>{p()&&g()?u.value=!0:_()},_=()=>{s("update:modelValue",!1),s("close")},v=()=>{u.value=!1,_()},d=()=>{u.value=!1},b=N=>{N.key==="Escape"&&a.modelValue&&(p()||_())};Ee(()=>a.modelValue,async N=>{N?(document.addEventListener("keydown",b),document.body.style.overflow="hidden",await Ne(),setTimeout(()=>{x()},100)):(document.removeEventListener("keydown",b),document.body.style.overflow="",i.value.clear())});const c=m(!1),f=N=>{c.value=N.target===N.currentTarget},$=N=>{N.target===N.currentTarget&&c.value&&(p()||_()),c.value=!1};return(N,E)=>(r(),J(Ht,{to:"body"},[w(bt,{"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:F(()=>[t.modelValue?(r(),o("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:f,onClick:$},[w(bt,{"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:F(()=>[t.modelValue?(r(),o("div",{key:0,class:ce(["w-full",t.width,"max-h-[85vh] flex flex-col"])},[w(Wt,{"offset-x":8,"offset-y":8,intensity:.35},{default:F(()=>[e("div",{ref_key:"modalRef",ref:l,class:ce(["bg-white dark:bg-neutral-900 border border-neutral-300 dark:border-neutral-600 rounded-lg flex flex-col max-h-[85vh]",t.minHeight])},[e("div",e0,[e("h2",t0,C(t.title),1),w(I(za),{icon:I(ir),label:"Close modal",variant:"ghost",onClick:y},null,8,["icon"])]),e("div",{class:ce(["flex-1 min-h-0",t.contentPadding?"overflow-y-auto p-6":"overflow-hidden flex flex-col"])},[We(N.$slots,"default")],2),N.$slots.footer?(r(),o("div",r0,[We(N.$slots,"footer")])):S("",!0)],2)]),_:3})],2)):S("",!0)]),_:3})],32)):S("",!0)]),_:3}),w(zr,{modelValue:u.value,"onUpdate:modelValue":E[0]||(E[0]=L=>u.value=L),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:v,onCancel:d},null,8,["modelValue"])]))}}),a0=["id"],n0={class:"px-5 py-3 border-b border-neutral-100 dark:border-neutral-800"},o0={class:"text-sm font-semibold text-neutral-900 dark:text-neutral-100 flex items-center gap-2"},l0={class:"p-5"},s0={key:0,class:"px-5 py-3 border-t border-neutral-100 dark:border-neutral-800 bg-neutral-50 dark:bg-neutral-800/50"},ft=Ce({__name:"ModalCard",props:{id:{},title:{},icon:{}},setup(t){return(n,a)=>(r(),o("section",{id:t.id,class:"bg-white dark:bg-neutral-900 rounded-lg border border-neutral-200 dark:border-neutral-700 overflow-hidden"},[e("div",n0,[e("h3",o0,[t.icon?(r(),J(Qe(t.icon),{key:0,class:"w-4 h-4 text-neutral-500"})):S("",!0),de(" "+C(t.title),1)])]),e("div",l0,[We(n.$slots,"default")]),n.$slots.footer?(r(),o("div",s0,[We(n.$slots,"footer")])):S("",!0)],8,a0))}}),i0={class:"flex flex-col gap-1 px-2"},u0=["onClick"],d0={class:"whitespace-nowrap overflow-hidden text-ellipsis"},qa=Ce({__name:"ModalTabs",props:{tabs:{},activeTab:{}},emits:["select"],setup(t,{emit:n}){const a=n;return(s,l)=>(r(),o("div",i0,[(r(!0),o(we,null,Ae(t.tabs,u=>(r(),o("button",{key:u.id,type:"button",onClick:Ge(i=>a("select",u.id),["prevent"]),class:ce(["flex items-center gap-3 px-3 py-2.5 rounded text-sm font-medium transition-all w-full text-left",t.activeTab===u.id?"bg-black text-white dark:bg-white dark:text-black":"text-neutral-600 dark:text-neutral-400 hover:bg-black/5 dark:hover:bg-white/10"])},[(r(),J(Qe(u.icon),{class:"w-4 h-4 flex-shrink-0"})),e("span",d0,C(u.label),1)],10,u0))),128))]))}}),c0={class:"text-sm font-semibold text-neutral-900 dark:text-neutral-100 pl-3 border-l-2 border-neutral-300 dark:border-neutral-600"},Ut=Ce({__name:"ModalSubHeader",props:{title:{}},setup(t){return(n,a)=>(r(),o("h4",c0,C(t.title),1))}});function Fa(t,n){const a=m(n[0]),s=()=>{const u=t.value;if(!u)return;const i=n.filter(g=>document.getElementById(`section-${g}`)!==null);if(i.length===0)return;if(u.scrollHeight-u.scrollTop-u.clientHeight<50){a.value=i[i.length-1];return}const x=u.getBoundingClientRect(),k=x.top+x.height*.3;let h=i[0];for(const g of i)document.getElementById(`section-${g}`).getBoundingClientRect().top<=k&&(h=g);a.value=h},l=u=>{const i=document.getElementById(`section-${u}`);if(i&&t.value){const p=t.value.getBoundingClientRect().top,x=i.getBoundingClientRect().top,k=t.value.scrollTop+(x-p);t.value.scrollTo({top:k,behavior:"smooth"})}};return Ee(t,(u,i)=>{i&&i.removeEventListener("scroll",s),u&&(u.addEventListener("scroll",s),s())}),fa(()=>{t.value?.removeEventListener("scroll",s)}),{activeTab:a,scrollToSection:l}}const p0={class:"space-y-3"},m0=["data-variable-property"],v0={class:"relative"},f0=["disabled","onClick"],g0=["disabled","onClick"],h0={key:1,class:"h-[34px] w-7 justify-self-center"},b0={class:"text-xs text-neutral-400 dark:text-neutral-500 px-1"},x0={key:0,class:"text-xs text-neutral-400 dark:text-neutral-500 px-1"},y0=["data-enabler-property"],k0={class:"text-[11px] text-neutral-500 dark:text-neutral-400"},w0={key:0,class:"text-[11px] text-neutral-500 dark:text-neutral-400"},_0={class:"space-y-2"},$0={class:"flex items-center justify-between"},C0={class:"text-xs text-neutral-500 dark:text-neutral-400"},S0=["disabled","onClick"],I0={class:"grid gap-2 items-start grid-cols-[minmax(180px,1fr)_minmax(220px,1fr)]"},T0={class:"text-xs text-neutral-400 dark:text-neutral-500 px-1"},M0=["disabled","onClick"],z0=["disabled","onClick"],V0=["disabled"],gr="grid-cols-[minmax(180px,1fr)_140px_minmax(220px,1fr)_44px_28px]",Ha=Ce({__name:"VariableScanEditor",props:{modelValue:{},declarations:{default:()=>[]},scanned:{default:()=>[]},allowDeclarationEdit:{type:Boolean,default:!1},allowSecretValues:{type:Boolean,default:!0},allowSecretDeclarations:{type:Boolean,default:!0},requireRequiredValues:{type:Boolean,default:!1},showCustomRows:{type:Boolean,default:!0},disabled:{type:Boolean,default:!1}},emits:["update:modelValue","update:declarations"],setup(t,{emit:n}){const a=t,s=n,l=[{value:"text",label:"text",icon:"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' stroke='currentColor' viewBox='0 0 24 24'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M4 7h16M4 12h10M4 17h16'/%3E%3C/svg%3E"},{value:"secret",label:"secret",icon:"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' stroke='currentColor' viewBox='0 0 24 24'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M7 10V7a5 5 0 1110 0v3m-9 0h8a2 2 0 012 2v6a2 2 0 01-2 2H8a2 2 0 01-2-2v-6a2 2 0 012-2z'/%3E%3C/svg%3E"}],u=T=>T==="secret"&&a.allowSecretDeclarations?"secret":"text",i=T=>({name:T.name||"",type:u(T.type),required:!!T.required,description:T.description||""}),p=T=>T.filter(B=>B.name?.trim()).map(B=>({name:B.name.trim(),type:u(B.type),required:!!B.required,description:B.description||""})),x=T=>JSON.stringify(p(T)),k=T=>!!(a.scanned||[]).some(B=>B.property===T),h=m((a.declarations||[]).map(T=>i(T)).filter(T=>{const B=T.name.trim();return B&&k(B)})),g=m(!1);Ee([()=>a.declarations,()=>a.scanned],([T])=>{const B=(T||[]).map(fe=>i(fe)).filter(fe=>{const pe=fe.name.trim();return pe&&k(pe)});x(B)!==x(h.value)&&(g.value=!0,h.value=B)},{deep:!0,immediate:!0}),Ee(h,T=>{const B=p(T),fe=p((a.declarations||[]).map(Re=>i(Re))),pe=fe.filter(Re=>{const rt=Re.name.trim();return rt&&!k(rt)}),ze=[...B,...pe];if(g.value){if(g.value=!1,x(ze)===x(fe))return}else if(x(ze)===x(fe))return;s("update:declarations",ze)},{deep:!0});const y=q(()=>{const T=new Map;for(const B of a.scanned||[]){const fe=Array.isArray(B.optionalBranches)?B.optionalBranches.map(pe=>{const ze=typeof pe?.gate=="string"?pe.gate.trim():"",Re=typeof pe?.tool=="string"?pe.tool.trim():"";return!ze||!Re?null:{gate:ze,tool:Re,immediate:!!pe.immediate,maxInstances:typeof pe.maxInstances=="number"&&pe.maxInstances>0?pe.maxInstances:void 0}}).filter(pe=>!!pe):[];T.set(B.property,{...B,type:B.type==="secret"?"secret":"text",required:!!B.required,description:B.description||"",optionalOnly:!!B.optionalOnly,optionalBranches:fe.length>0?fe:void 0})}return T}),_=q(()=>{const T=new Map;for(const B of h.value){const fe=B.name?.trim();fe&&T.set(fe,{...B,name:fe,type:u(B.type),required:!!B.required,description:B.description||""})}return T}),v=q(()=>{const T=new Map;for(const[B,fe]of y.value.entries())T.set(B,{...fe});for(const[B,fe]of _.value.entries()){if(!T.has(B)){T.set(B,{property:B,declared:[{type:"prompt",name:"local"}],defined:!1,type:fe.type,required:fe.required,description:fe.description,optionalOnly:!1});continue}const pe=T.get(B);pe.required=pe.required||fe.required,fe.type==="secret"&&(pe.type="secret"),!pe.description&&fe.description&&(pe.description=fe.description)}return Array.from(T.values())}),d=T=>{if(!T.optionalOnly)return null;const B=T.optionalBranches?.[0];return B?.gate?B.gate:null},b=q(()=>{const T=new Map;for(const B of v.value){const fe=d(B);fe&&(T.has(fe)||T.set(fe,[]),T.get(fe).push(B))}for(const B of T.values())B.sort((fe,pe)=>fe.property.localeCompare(pe.property));return T}),c=q(()=>v.value.filter(T=>!d(T))),f=T=>(b.value.get(T)||[]).map(B=>B.property),$=T=>{const B=b.value.get(T)||[],fe=[];for(const pe of B){const ze=pe.optionalBranches||[];for(const Re of ze)Re.gate===T&&typeof Re.maxInstances=="number"&&Re.maxInstances>0&&fe.push(Re.maxInstances)}if(fe.length!==0)return Math.min(...fe)},N=T=>{for(const B of b.value.values())for(const fe of B){const pe=`${fe.property}__`;if(!T.startsWith(pe))continue;const ze=T.slice(pe.length);if(/^\d+$/.test(ze))return!0}return!1},E=(T,B)=>{for(const fe of f(T)){const pe=`${fe}__`;if(!B.startsWith(pe))continue;const ze=B.slice(pe.length);if(/^\d+$/.test(ze))return!0}return!1},L=T=>{const B={};for(const fe of f(T))B[fe]="";return B},V=(T,B,fe)=>{const pe=f(T),ze=$(T),Re=[];if(Array.isArray(B))for(const it of B){const xt=it&&typeof it=="object"?it:{},vt=L(T);for(const Mt of pe){const wt=xt[Mt];vt[Mt]=wt==null?"":String(wt)}Re.push(vt)}const rt=typeof ze=="number"&&ze>0?Re.slice(0,ze):Re;return rt.length===0&&pe.length>0&&rt.push(L(T)),rt},A=(T,B)=>{const fe=f(T);if(fe.length===0)return[];const pe=new Map;for(const Re of fe){const rt=B[Re];rt!=null&&rt!==""&&(pe.has(0)||pe.set(0,L(T)),pe.get(0)[Re]=String(rt));const it=`${Re}__`;for(const[xt,vt]of Object.entries(B||{})){if(!xt.startsWith(it))continue;const Mt=xt.slice(it.length);if(!/^\d+$/.test(Mt))continue;const wt=Number.parseInt(Mt,10);if(!Number.isFinite(wt)||wt<2)continue;const Lt=wt-1;pe.has(Lt)||pe.set(Lt,L(T)),pe.get(Lt)[Re]=vt==null?"":String(vt)}}pe.size>0&&!pe.has(0)&&pe.set(0,L(T));const ze=Array.from(pe.entries()).sort((Re,rt)=>Re[0]-rt[0]).map(Re=>Re[1]);return V(T,ze)},G=T=>K(T)?A(T,a.modelValue||{}):[],ee=(T,B)=>{const fe=f(T);if(fe.length===0)return!1;let pe=!1;for(const ze of Object.keys(B))(fe.includes(ze)||E(T,ze))&&(delete B[ze],pe=!0);return pe},ie=(T,B)=>{const fe=V(T,B),pe=f(T);if(pe.length===0)return;const ze={...a.modelValue};ee(T,ze);for(let Re=0;Re<fe.length;Re++){const rt=fe[Re]||{};for(const it of pe){const xt=rt[it],vt=Re===0?it:`${it}__${Re+1}`;if(Re===0){xt&&(ze[vt]=xt);continue}ze[vt]=xt||""}}W(ze)!==W(a.modelValue||{})&&s("update:modelValue",ze)},be=T=>{const B=G(T),fe=$(T);typeof fe=="number"&&fe>0&&B.length>=fe||ie(T,[...B,L(T)])},Q=(T,B)=>{const fe=[...G(T)];if(fe.length<=1){ie(T,[L(T)]);return}B<0||B>=fe.length||(fe.splice(B,1),ie(T,fe))},U=T=>{if(T==null)return!1;const B=String(T).trim().toLowerCase();return B==="true"||B==="1"||B==="yes"},R=T=>{const B=a.modelValue[T];if(B!=null)return String(B);const fe=y.value.get(T);return fe?.value!==void 0&&fe.value!==null?String(fe.value):""},K=T=>U(R(T)),H=q(()=>new Set(v.value.map(T=>T.property))),ve=T=>({name:T.name||"",value:T.value===void 0||T.value===null?"":String(T.value),type:u(T.type),required:!!T.required}),X=T=>T.map(B=>ve(B)),D=T=>JSON.stringify(X(T).map(B=>({name:B.name,value:B.value,type:B.type,required:B.required}))),W=T=>JSON.stringify(Object.keys(T).sort((B,fe)=>B.localeCompare(fe)).map(B=>[B,T[B]===void 0||T[B]===null?"":String(T[B])])),me=m([]),ue=m(!1),te=T=>{const B=Array.isArray(T)?T:[],fe=X(B);D(fe)!==D(me.value)&&(me.value=fe)},Y=T=>X(T).map(B=>{const fe=B.name.trim();return!fe||k(fe)?null:{name:fe,type:u(B.type),required:!!B.required,description:""}}).filter(B=>!!B);function ae(){const T=new Map;for(const[pe,ze]of Object.entries(a.modelValue||{}))H.value.has(pe)||N(pe)||ze==null||ze===""||T.set(pe,String(ze));const B=new Map;for(const pe of p((a.declarations||[]).map(ze=>i(ze)))){const ze=pe.name.trim();!ze||k(ze)||B.set(ze,{type:u(pe.type),required:!!pe.required})}const fe=[];for(const pe of me.value.map(ze=>ve(ze))){const ze=pe.name.trim();if(!ze){fe.push(pe);continue}if(!H.value.has(ze)){if(B.has(ze)){const Re=B.get(ze);pe.type=Re.type,pe.required=Re.required,B.delete(ze)}T.has(ze)&&(pe.value=T.get(ze)||"",T.delete(ze)),fe.push(pe)}}for(const[pe,ze]of B.entries()){const Re=T.get(pe)||"";T.delete(pe),fe.push({name:pe,value:Re,type:ze.type,required:ze.required})}for(const[pe,ze]of T.entries())fe.push({name:pe,value:ze,type:"text",required:!1});D(fe)!==D(me.value)&&(ue.value=!0,me.value=fe)}Ee([()=>a.modelValue,()=>a.declarations,()=>a.scanned,H],(T,B)=>{const[fe,pe,ze,Re]=T,[rt,it,xt,vt]=B||[],Mt=pe!==it||ze!==xt||Re!==vt,wt=(()=>{if(!rt||typeof rt!="object")return!0;const Lt=fe||{},Lr=rt,Qa=new Set([...Object.keys(Lt),...Object.keys(Lr)]);for(const Jt of Qa){const mr=Lt[Jt],vr=Lr[Jt],en=mr==null?"":String(mr),tn=vr==null?"":String(vr);if(en!==tn&&!(H.value.has(Jt)||N(Jt)))return!0}return!1})();!Mt&&!wt||ae()},{deep:!0,immediate:!0}),Ee(me,T=>{const B=X(T);if(ue.value&&(ue.value=!1,D(B)===D(me.value)))return;if(D(B)!==D(me.value)){ue.value=!0,me.value=B;return}const fe={...a.modelValue};for(const pe of Object.keys(fe))!H.value.has(pe)&&!N(pe)&&delete fe[pe];for(const pe of B){const ze=pe.name.trim();!ze||H.value.has(ze)||!pe.value||(fe[ze]=pe.value)}if(W(fe)!==W(a.modelValue||{})&&s("update:modelValue",fe),a.allowDeclarationEdit){const pe=[...p(h.value),...Y(B)],ze=p((a.declarations||[]).map(Re=>i(Re)));x(pe)!==x(ze)&&s("update:declarations",pe)}},{deep:!0});const ye=m(new Set),Te=m(new Set),ne=T=>{if(Te.value.has(T))return;const B=new Set(Te.value);B.add(T),Te.value=B},ke=T=>{if(!Te.value.has(T))return!1;const B=new Set(Te.value);return B.delete(T),Te.value=B,!0},_e=T=>({outer:"$remove:mb-4 group mb-0",wrapper:"$remove:flex-1 flex-1",inner:T?"!bg-zinc-100 dark:!bg-zinc-700/40 !cursor-not-allowed":""}),O=T=>({outer:"$remove:mb-4 group mb-0",wrapper:"$remove:flex-1 flex-1",inner:[T?.insetRight?"!pr-8":"",T?.requiredHighlight?"!border-amber-400 dark:!border-amber-500":"",T?.disabled?"!bg-zinc-100 dark:!bg-zinc-700/40 !cursor-not-allowed":""].filter(Boolean).join(" ")}),j=T=>a.modelValue[T]!==void 0&&a.modelValue[T]!==null,z=T=>!!T.defined,M=T=>{const B=_.value.get(T.property);return B?u(B.type):T.type==="secret"?"secret":"text"},P=T=>{const B=_.value.get(T.property);return B?u(B.type):T.type==="secret"?"secret":"text"},re=T=>a.requireRequiredValues&&T.required&&!T.defined&&!j(T.property),se=T=>a.disabled||M(T)==="secret"&&!a.allowSecretValues?!1:!!(j(T.property)||!z(T)||ye.value.has(T.property)),Ie=T=>z(T)&&(M(T)!=="secret"||a.allowSecretValues),he=T=>z(T)&&(j(T.property)||ye.value.has(T.property)),ge=T=>a.allowDeclarationEdit&&_.value.has(T.property)&&!y.value.has(T.property)&&!a.disabled,Oe=T=>ge(T),Z=T=>{const B=a.modelValue[T.property];return B!=null?String(B):z(T)&&ye.value.has(T.property)||M(T)==="secret"?"":T.value||""},oe=(T,B)=>{if(!a.allowDeclarationEdit)return;const fe=T.trim();if(!fe)return;let pe=!1;h.value=h.value.map(ze=>ze.name.trim()!==fe?ze:(pe=!0,{...ze,name:fe,type:u(B.type??ze.type),required:B.required??!!ze.required,description:B.description??(ze.description||"")})),pe||(h.value=[...h.value,{name:fe,type:u(B.type??"text"),required:!!B.required,description:B.description||""}])},Le=T=>{const B=T.trim();B&&(h.value=h.value.filter(fe=>fe.name.trim()!==B))},$e=(T,B)=>{oe(T,{type:u(B)})},Ye=(T,B)=>{oe(T,{required:!!B})},et=(T,B)=>{if(ke(T))return;const fe=v.value.find(ze=>ze.property===T);if(fe&&M(fe)==="secret"&&!a.allowSecretValues)return;const pe={...a.modelValue};B?pe[T]=B:delete pe[T],b.value.has(T)&&!U(B)&&ee(T,pe),W(pe)!==W(a.modelValue||{})&&s("update:modelValue",pe)},Se=T=>{if(ye.value.has(T))return;const B=new Set(ye.value);B.add(T),ye.value=B},xe=T=>{if(a.disabled||!Ie(T))return;if(he(T)){Pe(T.property);return}const B={...a.modelValue};delete B[T.property],s("update:modelValue",B),Se(T.property)},Pe=T=>{ne(T);const B={...a.modelValue};if(delete B[T],s("update:modelValue",B),!ye.value.has(T))return;const fe=new Set(ye.value);fe.delete(T),ye.value=fe},Me=T=>{Le(T),Pe(T)},Fe=T=>T.name==="local"?`this ${T.type}`:`the ${T.name} ${T.type}`,Ze=T=>T.length===0?"":T.length===1?T[0]:T.length===2?`${T[0]} and ${T[1]}`:`${T.slice(0,-1).join(", ")}, and ${T[T.length-1]}`,Ke=T=>(T.type==="agent"||T.type==="prompt")&&T.name?`the ${T.name} ${T.type}`:T.type==="thread"?"the thread":T.type==="account"?"the account":T.type==="instance"?"the instance":`the ${T.type}`,nt=T=>{const B=T.required?"Required by":"Requested by",fe=T.declared.length?Ze(T.declared.map(Fe)):"this configuration";return T.defined?`${B} ${fe}, value provided by ${Ke(T.defined)}.`:`${B} ${fe}.`},je=()=>{me.value=[...me.value,{name:"",value:"",type:"text",required:!1}]},le=T=>{if(T<0||T>=me.value.length)return;const B=[...me.value];B.splice(T,1),me.value=B};return(T,B)=>{const fe=tt("FormKit");return r(),o("div",p0,[e("div",{class:ce(["grid gap-2 text-xs font-medium text-neutral-500 dark:text-neutral-400 px-1",gr])},[...B[2]||(B[2]=[e("span",null,"Name",-1),e("span",null,"Type",-1),e("span",null,"Value",-1),e("span",{class:"text-center text-[10px] leading-none tracking-tight self-center"},"Required",-1),e("span",null,null,-1)])]),(r(!0),o(we,null,Ae(c.value,pe=>(r(),o("div",{key:pe.property,class:"space-y-1","data-variable-property":pe.property},[e("div",{class:ce(["grid gap-2 items-start",gr])},[w(fe,{type:"text",value:pe.property,disabled:!0,"outer-class":"$reset",classes:O({disabled:!0})},null,8,["value","classes"]),w(fe,{type:"selectSearch",value:P(pe),options:t.allowSecretDeclarations?l:l.filter(ze=>ze.value!=="secret"),disabled:!ge(pe),"outer-class":"$reset",classes:_e(!ge(pe)),onInput:ze=>$e(pe.property,ze||"text")},null,8,["value","options","disabled","classes","onInput"]),e("div",v0,[w(fe,{type:M(pe)==="secret"?"password":"text","model-value":Z(pe),placeholder:pe.description||"Enter value...",disabled:!se(pe),validation:t.requireRequiredValues&&pe.required&&!pe.defined?"required":"","validation-label":"Value","validation-visibility":"submit","outer-class":"$reset",classes:O({insetRight:Ie(pe),requiredHighlight:re(pe),disabled:!se(pe)}),onInput:ze=>et(pe.property,String(ze??""))},null,8,["type","model-value","placeholder","disabled","validation","classes","onInput"]),Ie(pe)?(r(),o("button",{key:0,type:"button",class:"absolute top-1/2 right-1 -translate-y-1/2 h-6 w-6 flex items-center justify-center rounded text-neutral-400 hover:text-neutral-700 dark:hover:text-neutral-200 hover:bg-neutral-100 dark:hover:bg-neutral-800 transition-colors disabled:opacity-50",disabled:t.disabled,title:"Override value",onMousedown:B[0]||(B[0]=Ge(()=>{},["prevent"])),onClick:ze=>xe(pe)},[...B[3]||(B[3]=[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)])],40,f0)):S("",!0)]),w(fe,{type:"checkbox",value:pe.required,disabled:!ge(pe),classes:{outer:"$remove:mb-4 mb-0 pt-[8px] h-[34px] w-full flex items-center justify-center justify-self-center",wrapper:"$remove:items-center flex items-center justify-center",decorator:"$remove:mr-1.5 mr-0",label:"$remove:hidden",help:"$remove:hidden",messages:"$remove:formkit-messages hidden"},onInput:ze=>Ye(pe.property,!!ze)},null,8,["value","disabled","onInput"]),Oe(pe)?(r(),o("button",{key:0,type:"button",class:"justify-self-center pt-[3px] h-[34px] w-7 flex items-center justify-center text-neutral-500 dark:text-white/70 hover:text-red-500 dark:hover:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/30 rounded transition-colors disabled:opacity-50",disabled:t.disabled,title:"Remove variable",onClick:ze=>Me(pe.property)},[...B[4]||(B[4]=[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,g0)):(r(),o("span",h0))]),e("p",b0,C(nt(pe)),1),M(pe)==="secret"&&!t.allowSecretValues?(r(),o("p",x0," Secret values cannot be set here. ")):S("",!0),(b.value.get(pe.property)||[]).length>0?(r(),J(fe,{key:1,type:"group",name:`optional-group-${pe.property}`,"outer-class":"$reset",classes:{outer:"$remove:mb-4 mb-0"}},{default:F(()=>[K(pe.property)?(r(),o("div",{key:0,class:"ml-5 space-y-2","data-enabler-property":pe.property},[e("p",k0,[B[5]||(B[5]=de(" Optional branch enabled by ",-1)),e("code",null,C(pe.property),1)]),typeof $(pe.property)=="number"?(r(),o("p",w0," Max instances: "+C($(pe.property)),1)):S("",!0),w(fe,{type:"repeater",name:`optional-repeater-${pe.property}`,"model-value":G(pe.property),min:1,max:$(pe.property),"add-button":!1,"insert-control":!1,"up-control":!1,"down-control":!1,"remove-control":!1,"outer-class":"$reset",classes:{outer:"$remove:mb-4 mb-0",wrapper:"$remove",fieldset:"$remove:border-0 p-0 m-0 min-w-0",legend:"$remove:hidden",content:"$remove:p-5 $remove:space-y-2 p-0 space-y-2",item:"$remove:bg-white $remove:border $remove:border-zinc-200 $remove:rounded-sm $remove:dark:border-zinc-700 $remove:dark:bg-transparent $remove:mb-2 mb-0 border border-neutral-200 dark:border-neutral-700 bg-transparent rounded-sm p-2",help:"$remove:hidden",messages:"$remove:formkit-messages hidden"},onInput:ze=>ie(pe.property,ze)},{default:F(({index:ze})=>[e("div",_0,[e("div",$0,[e("p",C0," Instance "+C(Number(ze)+1),1),e("button",{type:"button",class:"h-5 px-1.5 text-[10px] rounded-sm border border-neutral-500/40 dark:border-neutral-600 text-neutral-500 dark:text-neutral-400 hover:text-neutral-200 hover:border-neutral-400 disabled:opacity-50",disabled:t.disabled||G(pe.property).length<=1,onClick:Re=>Q(pe.property,Number(ze))}," Remove ",8,S0)]),(r(!0),o(we,null,Ae(b.value.get(pe.property)||[],Re=>(r(),o("div",{key:`${pe.property}-${Re.property}-${ze}`,class:"space-y-1"},[e("div",I0,[w(fe,{type:"text",value:Re.property,disabled:!0,"outer-class":"$reset",classes:O({disabled:!0})},null,8,["value","classes"]),w(fe,{name:Re.property,type:M(Re)==="secret"?"password":"text",placeholder:Re.description||"Enter value...",disabled:t.disabled||M(Re)==="secret"&&!t.allowSecretValues,validation:t.requireRequiredValues&&Re.required?"required":"","validation-label":"Value","validation-visibility":"submit","outer-class":"$reset",classes:O({disabled:t.disabled||M(Re)==="secret"&&!t.allowSecretValues})},null,8,["name","type","placeholder","disabled","validation","classes"])]),e("p",T0,C(nt(Re)),1)]))),128))])]),_:2},1032,["name","model-value","max","onInput"]),$(pe.property)!==1&&($(pe.property)===void 0||G(pe.property).length<($(pe.property)||0))?(r(),o("button",{key:1,type:"button",class:"inline-flex h-5 px-2 text-[10px] rounded-sm border border-neutral-500/40 dark:border-neutral-600 text-neutral-500 dark:text-neutral-400 hover:text-neutral-200 hover:border-neutral-400 disabled:opacity-50",disabled:t.disabled,onClick:ze=>be(pe.property)}," Add instance ",8,M0)):S("",!0)],8,y0)):S("",!0)]),_:2},1032,["name"])):S("",!0)],8,m0))),128)),t.showCustomRows?(r(),J(fe,{key:0,type:"repeater","model-value":me.value,min:0,"add-button":!1,"insert-control":!1,"up-control":!1,"down-control":!1,"remove-control":!1,"outer-class":"$reset",classes:{outer:"$remove:mb-4 mb-0",wrapper:"$remove",fieldset:"$remove:border-0 p-0 m-0 min-w-0",legend:"$remove:hidden",content:"$remove:p-5 $remove:space-y-2 p-0 space-y-2",item:"$remove:bg-white $remove:border $remove:border-zinc-200 $remove:rounded-sm $remove:dark:border-zinc-700 $remove:dark:bg-transparent $remove:mb-2 mb-0 border-0 bg-transparent rounded-none",controls:"$remove:hidden",help:"$remove:hidden",messages:"$remove:formkit-messages hidden"},onInput:B[1]||(B[1]=pe=>te(pe))},{default:F(({index:pe})=>[e("div",{class:ce(["grid gap-2 items-start pb-1",gr])},[w(fe,{type:"text",name:"name",placeholder:"VARIABLE_NAME",disabled:t.disabled,"outer-class":"$reset",classes:O({disabled:t.disabled})},null,8,["disabled","classes"]),w(fe,{type:"selectSearch",name:"type",options:t.allowSecretDeclarations?l:l.filter(ze=>ze.value!=="secret"),disabled:t.disabled||!t.allowDeclarationEdit||!me.value[pe]?.name?.trim(),"outer-class":"$reset",classes:_e(t.disabled||!t.allowDeclarationEdit||!me.value[pe]?.name?.trim())},null,8,["options","disabled","classes"]),w(fe,{type:me.value[pe]?.type==="secret"?"password":"text",name:"value",placeholder:"Enter value...",disabled:t.disabled||me.value[pe]?.type==="secret"&&!t.allowSecretValues,"outer-class":"$reset",classes:O({disabled:t.disabled||me.value[pe]?.type==="secret"&&!t.allowSecretValues})},null,8,["type","disabled","classes"]),w(fe,{type:"checkbox",name:"required",disabled:t.disabled||!t.allowDeclarationEdit||!me.value[pe]?.name?.trim(),classes:{outer:"$remove:mb-4 mb-0 pt-[8px] h-[34px] w-full flex items-center justify-center justify-self-center",wrapper:"$remove:items-center flex items-center justify-center",decorator:"$remove:mr-1.5 mr-0",label:"$remove:hidden",help:"$remove:hidden",messages:"$remove:formkit-messages hidden"}},null,8,["disabled"]),e("button",{type:"button",class:"justify-self-center pt-[3px] h-[34px] w-7 flex items-center justify-center text-neutral-500 dark:text-white/70 hover:text-red-500 dark:hover:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/30 rounded transition-colors disabled:opacity-50",disabled:t.disabled,title:"Remove variable",onClick:ze=>le(pe)},[...B[6]||(B[6]=[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,z0)])]),_:1},8,["model-value"])):S("",!0),t.showCustomRows?(r(),o("button",{key:1,type:"button",class:"w-full rounded-sm border border-dashed border-neutral-300 dark:border-neutral-700 px-3 py-2 text-sm text-neutral-600 dark:text-neutral-300 hover:bg-neutral-50 dark:hover:bg-neutral-900",disabled:t.disabled,onClick:je}," + Add custom variable ",8,V0)):S("",!0)])}}}),E0={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function L0(t,n){return r(),o("svg",E0,[...n[0]||(n[0]=[e("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[e("path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"}),e("path",{d:"M14 2v4a2 2 0 0 0 2 2h4M10 9H8m8 4H8m8 4H8"})],-1)])])}const lr=De({name:"lucide-file-text",render:L0}),A0={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function P0(t,n){return r(),o("svg",A0,[...n[0]||(n[0]=[e("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[e("path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2"}),e("circle",{cx:"12",cy:"7",r:"4"})],-1)])])}const Yr=De({name:"lucide-user",render:P0}),j0={key:0,class:"min-h-[500px] flex items-center justify-center"},R0={class:"flex flex-1 min-h-0"},O0={class:"w-44 flex-shrink-0 border-r border-neutral-200 dark:border-neutral-700 py-4"},D0={class:"space-y-4"},U0={class:"space-y-5"},B0={class:"grid grid-cols-2 gap-4"},N0={key:0},q0={key:1},F0={key:2},H0={class:"space-y-5"},W0={class:"grid grid-cols-2 gap-4"},K0={class:"space-y-4 pt-4 border-t border-neutral-100 dark:border-neutral-800"},J0={key:0,class:"ml-6 mt-3 space-y-3"},G0={key:2},Y0={class:"grid grid-cols-2 gap-4 pt-4 border-t border-neutral-100 dark:border-neutral-800"},Z0={class:"space-y-5"},X0={class:"grid grid-cols-2 gap-4"},Q0={class:"space-y-4 pt-4 border-t border-neutral-100 dark:border-neutral-800"},em={key:0,class:"ml-6 mt-3 space-y-3"},tm={key:2},rm={class:"grid grid-cols-2 gap-4 pt-4 border-t border-neutral-100 dark:border-neutral-800"},am={class:"space-y-3"},nm={key:0,class:"text-xs text-neutral-500"},om={class:"p-6 border-t border-neutral-200 dark:border-neutral-700 flex-shrink-0"},lm={class:"flex justify-between items-center"},sm={key:0,class:"flex items-center gap-3"},im=Ce({__name:"AgentModal",props:{modelValue:{type:Boolean},editAgent:{},mode:{},apiError:{},readonly:{type:Boolean,default:!1}},emits:["update:modelValue","save"],setup(t,{expose:n,emit:a}){const s=t,l=a,u=q(()=>s.mode==="edit"),i=m(!1),p=m(null),x=["basics","side-a","side-b","variables"],{activeTab:k,scrollToSection:h}=Fa(p,x),g=q(()=>[{id:"basics",label:"Basics",icon:lr},{id:"side-a",label:"Side A",icon:At},{id:"side-b",label:"Side B",icon:d.value==="ai_human"?Yr:At},{id:"variables",label:"Variables",icon:qt}]),y=m(""),_=m(""),v=m(""),d=m("dual_ai"),b=m(!1),c=m(""),f=m(null),$=m(""),N=m(""),E=m(""),L=m(!0),V=m(!1),A=m(""),G=m(""),ee=m(""),ie=m(""),be=m(!1),Q=m(null),U=m(""),R=m(""),K=m(""),H=m(""),ve=m(""),X=m(""),D=m(!0),W=m(!1),me=m(""),ue=m(""),te=m(""),Y=m(""),ae=m(null),ye=m(""),Te=m(""),ne=m(""),ke=m([]),_e=m({}),O=m(!1),{data:j,execute:z}=ot(Ve("/api/prompts"),{immediate:!1}).json(),{data:M,execute:P}=ot(Ve("/api/tools?schema=true"),{immediate:!1}).json(),re=m(null),se=m(!1),Ie=m(null),he=m(!1),ge=m(!1),Oe=q(()=>{if(!j.value)return[{value:"",label:"Select a prompt..."}];const je=j.value?.prompts||[];return[{value:"",label:"None"},...je.map(le=>({value:le.id,label:le.name}))]}),Z=je=>M.value?M.value[je]:null,oe=q(()=>!re.value||!re.value.tools?[{value:"",label:"None"}]:[{value:"",label:"None"},...re.value.tools.map(je=>{const le=typeof je=="string"?je:je.name;return{value:le,label:le}})]),Le=q(()=>!Ie.value||!Ie.value.tools?[{value:"",label:"None"}]:[{value:"",label:"None"},...Ie.value.tools.map(je=>{const le=typeof je=="string"?je:je.name;return{value:le,label:le}})]),$e=q(()=>{if(!A.value)return[];const je=Z(A.value);return!je||!je.schema||!je.schema.properties?[]:Object.keys(je.schema.properties).map(le=>({value:le,label:le}))}),Ye=q(()=>{if(!me.value)return[];const je=Z(me.value);return!je||!je.schema||!je.schema.properties?[]:Object.keys(je.schema.properties).map(le=>({value:le,label:le}))}),et=async()=>{const je=[N.value,d.value==="dual_ai"?ve.value:""].filter(Boolean);if(je.length===0){ke.value=[];return}O.value=!0;try{const le=je.slice(1).map(pe=>({type:"prompt",name:pe})),T=le.length>0?`?include=${encodeURIComponent(JSON.stringify(le))}`:"",B=await lt(`/variables/prompts/${encodeURIComponent(je[0])}${T}`);if(!B.ok){ke.value=[];return}const fe=await B.json();ke.value=fe.variables||[]}catch(le){console.error("Error scanning variables from prompts:",le),ke.value=[]}finally{O.value=!1}},Se=m(null),xe=je=>{Se.value=je};n({formNode:Se});const Pe=[{value:"dual_ai",label:"AI + AI (Subagent)"},{value:"ai_human",label:"AI + Human"}],Me=je=>{let le=je.toLowerCase().replace(/\s+/g,"_").replace(/[^a-z0-9_]/g,"");return!le.endsWith("_agent")&&le.length>0&&(le=le+"_agent"),le},Fe=()=>{_.value="",y.value="",v.value="",d.value="dual_ai",b.value=!1,c.value="",f.value=null,$.value="",N.value="",E.value="",L.value=!0,V.value=!1,A.value="",G.value="",ee.value="",ie.value="",be.value=!1,Q.value=null,U.value="",R.value="",K.value="",re.value=null,H.value="",ve.value="",X.value="",D.value=!0,W.value=!1,me.value="",ue.value="",te.value="",Y.value="",ae.value=null,ye.value="",Te.value="",ne.value="",Ie.value=null,ke.value=[],_e.value={}},Ze=async()=>{if(s.editAgent?.id){i.value=!0,ge.value=!0;try{const je=await fetch(Ve(`/api/agents/${encodeURIComponent(s.editAgent.id)}`));if(je.ok){const le=await je.json(),T=le.agent||le;_.value=T.name||"",y.value=T.name||"",v.value=T.title||"",d.value=T.type||"dual_ai",b.value=T.expose_as_tool||!1,c.value=T.tool_description||"",f.value=T.max_session_turns;const B=T.side_a_stop_tool||"",fe=T.side_a_stop_tool_response_property||"",pe=T.side_b_stop_tool||"",ze=T.side_b_stop_tool_response_property||"",Re=T.side_a_end_conversation_tool||"",rt=T.side_b_end_conversation_tool||"";$.value=T.side_a_label||"",H.value=T.side_b_label||"",N.value=T.side_a_agent_prompt||"",ve.value=T.side_b_agent_prompt||"",L.value=!!T.side_a_stop_on_response,V.value=!!T.side_a_stop_tool,be.value=!!T.side_a_manual_stop_condition,Q.value=T.side_a_max_steps,D.value=!!T.side_b_stop_on_response,W.value=!!T.side_b_stop_tool,ae.value=T.side_b_max_steps,await Ne(),A.value=B,ee.value=fe,me.value=pe,te.value=ze,R.value=Re,Te.value=rt;const it=(T.env&&typeof T.env=="object"?T.env:null)||(T.tenvs&&typeof T.tenvs=="object"?T.tenvs:null);_e.value=it||{},await et()}}catch(je){console.error("Error loading agent data:",je)}finally{i.value=!1,ge.value=!1}}},Ke=async()=>{E.value="",G.value="",ie.value="",U.value="",K.value="",X.value="",ue.value="",Y.value="",ye.value="",ne.value="";let je=!1;const le=_.value,T=L.value||A.value,B=d.value==="ai_human"&&be.value;if(!T&&!B&&(E.value="At least one stop condition is required (or check manual stop condition for ai_human agents)",je=!0),A.value&&!ee.value&&(ie.value="Response property required when using stop tool",je=!0),Q.value!==null&&Q.value<=0&&(U.value="Max steps must be a positive number",je=!0),d.value==="dual_ai"&&!R.value&&!Te.value&&(K.value="At least one side must have an end conversation tool",ne.value="At least one side must have an end conversation tool",je=!0),d.value==="dual_ai"&&(me.value&&!te.value&&(Y.value="Response property required when using stop tool",je=!0),ae.value!==null&&ae.value<=0&&(ye.value="Max steps must be a positive number",je=!0)),je)return;const fe={name:le,title:v.value||null,type:d.value,expose_as_tool:b.value,tool_description:b.value?c.value:null,max_session_turns:d.value==="dual_ai"?f.value:null,side_a_label:$.value||null,side_a_agent_prompt:N.value,side_a_stop_on_response:L.value,side_a_stop_tool:A.value||null,side_a_stop_tool_response_property:ee.value||null,side_a_manual_stop_condition:be.value,side_a_max_steps:Q.value,side_a_end_conversation_tool:R.value||null};d.value==="dual_ai"&&(fe.side_b_label=H.value||null,fe.side_b_agent_prompt=ve.value,fe.side_b_stop_on_response=D.value,fe.side_b_stop_tool=me.value||null,fe.side_b_stop_tool_response_property=te.value||null,fe.side_b_max_steps=ae.value,fe.side_b_end_conversation_tool=Te.value||null),fe.env=_e.value,u.value&&s.editAgent?.id&&(fe.id=s.editAgent.id),l("save",fe)},nt=()=>{Fe(),l("update:modelValue",!1)};return Ee(N,async je=>{if(ge.value||(A.value="",ee.value=""),!je){re.value=null;return}se.value=!0;try{const le=await fetch(Ve(`/api/prompts/${encodeURIComponent(je)}`));if(le.ok){const T=await le.json();re.value=T.prompt||T}}catch(le){console.error("Error fetching Side A prompt:",le)}finally{se.value=!1}ge.value||await et()}),Ee(ve,async je=>{if(ge.value||(me.value="",te.value=""),!je){Ie.value=null;return}he.value=!0;try{const le=await fetch(Ve(`/api/prompts/${encodeURIComponent(je)}`));if(le.ok){const T=await le.json();Ie.value=T.prompt||T}}catch(le){console.error("Error fetching Side B prompt:",le)}finally{he.value=!1}ge.value||await et()}),Ee(V,je=>{je||(A.value="",ee.value="")}),Ee(W,je=>{je||(me.value="",te.value="")}),Ee(d,async()=>{!s.modelValue||ge.value||await et()}),Ee(()=>s.modelValue,async je=>{je?(await Promise.all([z(),P()]),u.value?(Fe(),await Ze()):Fe()):Fe()}),(je,le)=>{const T=tt("FormKit");return r(),J(st,{"model-value":t.modelValue,"onUpdate:modelValue":le[26]||(le[26]=B=>je.$emit("update:modelValue",B)),title:u.value?"Edit Agent":"Create Agent",width:"max-w-5xl","content-padding":!1},{default:F(()=>[i.value?(r(),o("div",j0,[...le[27]||(le[27]=[e("span",{class:"text-neutral-500"},"Loading agent data...",-1)])])):(r(),J(T,{key:1,type:"form",id:"agent-form",actions:!1,disabled:t.readonly,onSubmit:Ke,onNode:xe,"form-class":"$reset flex-1 min-h-0 flex flex-col"},{default:F(()=>[e("div",R0,[e("nav",O0,[w(I(qa),{tabs:g.value,"active-tab":I(k),onSelect:I(h)},null,8,["tabs","active-tab","onSelect"])]),e("div",{ref_key:"contentRef",ref:p,class:"flex-1 overflow-y-auto p-5 bg-neutral-100 dark:bg-neutral-950"},[e("div",D0,[t.apiError?(r(),J(I(at),{key:0,variant:"error"},{default:F(()=>[de(C(t.apiError),1)]),_:1})):S("",!0),w(I(ft),{id:"section-basics",title:"Basics",icon:I(lr)},{default:F(()=>[e("div",U0,[e("div",null,[w(T,{type:"text",name:"name",modelValue:_.value,"onUpdate:modelValue":le[0]||(le[0]=B=>_.value=B),label:"Agent Name",disabled:u.value,validation:"required|matches:/^[a-z][a-z0-9_]*_agent$/","validation-visibility":"submit","validation-messages":{required:"Name is required",matches:"Must start with a letter and end with _agent (e.g., research_agent)"},"outer-class":"$reset",onBlur:le[1]||(le[1]=B=>_.value=Me(_.value))},null,8,["modelValue","disabled"]),u.value?(r(),J(I(Ue),{key:1,class:"mt-1"},{default:F(()=>[...le[29]||(le[29]=[de(" Agent names cannot be changed after creation (used as foreign key for threads) ",-1)])]),_:1})):(r(),J(I(Ue),{key:0,class:"mt-1"},{default:F(()=>[...le[28]||(le[28]=[de(" Automatically formatted to snake_case with _agent suffix (e.g., research_agent) ",-1)])]),_:1}))]),e("div",B0,[e("div",null,[w(T,{type:"text",name:"title",modelValue:v.value,"onUpdate:modelValue":le[2]||(le[2]=B=>v.value=B),label:"Display Title (Optional)","outer-class":"$reset"},null,8,["modelValue"]),w(I(Ue),{class:"mt-1"},{default:F(()=>[...le[30]||(le[30]=[de(" Human-readable title shown in the UI ",-1)])]),_:1})]),e("div",null,[w(T,{type:"selectSearch",name:"type",modelValue:d.value,"onUpdate:modelValue":le[3]||(le[3]=B=>d.value=B),label:"Agent Type",options:Pe,"outer-class":"$reset"},null,8,["modelValue"]),w(I(Ue),{class:"mt-1"},{default:F(()=>[...le[31]||(le[31]=[de(" AI + AI or AI + Human conversation ",-1)])]),_:1})])]),d.value==="dual_ai"?(r(),o("div",N0,[w(T,{type:"checkbox",modelValue:b.value,"onUpdate:modelValue":le[4]||(le[4]=B=>b.value=B),label:"Expose as Tool","outer-class":"$reset"},null,8,["modelValue"]),w(I(Ue),{class:"mt-1"},{default:F(()=>[...le[32]||(le[32]=[de(" Make this subagent available as a tool that can be called by other prompts or agents ",-1)])]),_:1})])):S("",!0),b.value&&d.value==="dual_ai"?(r(),o("div",q0,[w(T,{type:"textarea",name:"tool_description",modelValue:c.value,"onUpdate:modelValue":le[5]||(le[5]=B=>c.value=B),label:"Tool Description",placeholder:"Describe what this agent does when called as a tool",rows:3,"outer-class":"$reset"},null,8,["modelValue"]),w(I(Ue),{class:"mt-1"},{default:F(()=>[...le[33]||(le[33]=[de(" This description helps other agents understand when to use this agent ",-1)])]),_:1})])):S("",!0),d.value==="dual_ai"?(r(),o("div",F0,[w(T,{type:"number",name:"max_session_turns",modelValue:f.value,"onUpdate:modelValue":le[6]||(le[6]=B=>f.value=B),label:"Max Session Turns",placeholder:"Unlimited","outer-class":"$reset"},null,8,["modelValue"]),w(I(Ue),{class:"mt-1"},{default:F(()=>[...le[34]||(le[34]=[de(" Maximum number of back-and-forth exchanges between the two agents before the conversation ends ",-1)])]),_:1})])):S("",!0)])]),_:1},8,["icon"]),w(I(ft),{id:"section-side-a",title:"Side A (AI)",icon:I(At)},{default:F(()=>[e("div",H0,[e("div",W0,[e("div",null,[w(T,{type:"text",modelValue:$.value,"onUpdate:modelValue":le[7]||(le[7]=B=>$.value=B),label:"Side Label (Optional)",placeholder:"e.g., ATC, Pilot, Customer","outer-class":"$reset"},null,8,["modelValue"]),w(I(Ue),{class:"mt-1"},{default:F(()=>[...le[35]||(le[35]=[de(" Custom label for this side ",-1)])]),_:1})]),e("div",null,[w(T,{type:"selectSearch",name:"side_a_agent_prompt",modelValue:N.value,"onUpdate:modelValue":le[8]||(le[8]=B=>N.value=B),label:"Agent Prompt",options:Oe.value,validation:"required","validation-visibility":"submit","validation-messages":{required:"Please select an agent prompt"},"outer-class":"$reset"},null,8,["modelValue","options"]),E.value?(r(),J(I(Ue),{key:0,class:"mt-1 text-red-600 dark:text-red-400"},{default:F(()=>[de(C(E.value),1)]),_:1})):(r(),J(I(Ue),{key:1,class:"mt-1"},{default:F(()=>[...le[36]||(le[36]=[de(" Defines this agent's behavior ",-1)])]),_:1}))])]),e("div",K0,[w(I(Ut),{title:"Stop Conditions"}),w(I(Ue),null,{default:F(()=>[...le[37]||(le[37]=[de(" Optional. If no stop conditions are set, the agent will continue until programmatically stopped or end conversation tool is called. ",-1)])]),_:1}),e("div",null,[w(T,{type:"checkbox",modelValue:L.value,"onUpdate:modelValue":le[9]||(le[9]=B=>L.value=B),label:"Stop when agent returns content","outer-class":"$reset"},null,8,["modelValue"]),w(I(Ue),{class:"ml-6"},{default:F(()=>[...le[38]||(le[38]=[de(" Agent stops when it returns a response without calling tools ",-1)])]),_:1})]),e("div",null,[w(T,{type:"checkbox",modelValue:V.value,"onUpdate:modelValue":le[10]||(le[10]=B=>V.value=B),label:"Stop on specific tool call","outer-class":"$reset"},null,8,["modelValue"]),V.value?(r(),o("div",J0,[w(T,{type:"selectSearch",modelValue:A.value,"onUpdate:modelValue":le[11]||(le[11]=B=>A.value=B),label:"Stop Tool",options:oe.value,placeholder:"Select a tool...",disabled:se.value||!N.value,"outer-class":"$reset"},null,8,["modelValue","options","disabled"]),G.value?(r(),J(I(Ue),{key:0,class:"text-red-600 dark:text-red-400"},{default:F(()=>[de(C(G.value),1)]),_:1})):(r(),J(I(Ue),{key:1},{default:F(()=>[...le[39]||(le[39]=[de(" Agent stops when this tool is called ",-1)])]),_:1})),A.value?(r(),o("div",G0,[w(T,{type:"selectSearch",modelValue:ee.value,"onUpdate:modelValue":le[12]||(le[12]=B=>ee.value=B),label:"Response Property",options:$e.value,placeholder:"Select property...","outer-class":"$reset"},null,8,["modelValue","options"]),ie.value?(r(),J(I(Ue),{key:0,class:"mt-1 text-red-600 dark:text-red-400"},{default:F(()=>[de(C(ie.value),1)]),_:1})):(r(),J(I(Ue),{key:1,class:"mt-1"},{default:F(()=>[...le[40]||(le[40]=[de(" Property from tool arguments to return as final response ",-1)])]),_:1}))])):S("",!0)])):S("",!0)]),d.value==="ai_human"&&!L.value&&!V.value?(r(),J(I(at),{key:0,variant:"warning",class:"mt-3"},{default:F(()=>[w(T,{type:"checkbox",modelValue:be.value,"onUpdate:modelValue":le[13]||(le[13]=B=>be.value=B),label:"I have manually implemented a stop condition","outer-class":"$reset"},null,8,["modelValue"]),le[41]||(le[41]=e("p",{class:"mt-2 text-xs"}," 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))]),_:1})):S("",!0)]),e("div",Y0,[e("div",null,[w(T,{type:"number",name:"side_a_max_steps",modelValue:Q.value,"onUpdate:modelValue":le[14]||(le[14]=B=>Q.value=B),label:"Max Steps",placeholder:"Unlimited","outer-class":"$reset"},null,8,["modelValue"]),U.value?(r(),J(I(Ue),{key:0,class:"mt-1 text-red-600 dark:text-red-400"},{default:F(()=>[de(C(U.value),1)]),_:1})):(r(),J(I(Ue),{key:1,class:"mt-1"},{default:F(()=>[...le[42]||(le[42]=[de(" Safety limit before yielding ",-1)])]),_:1}))]),e("div",null,[w(T,{type:"selectSearch",modelValue:R.value,"onUpdate:modelValue":le[15]||(le[15]=B=>R.value=B),label:"End Conversation Tool",options:oe.value,placeholder:"Select a tool...",disabled:se.value||!N.value,"outer-class":"$reset"},null,8,["modelValue","options","disabled"]),K.value?(r(),J(I(Ue),{key:0,class:"mt-1 text-red-600 dark:text-red-400"},{default:F(()=>[de(C(K.value),1)]),_:1})):(r(),J(I(Ue),{key:1,class:"mt-1"},{default:F(()=>[...le[43]||(le[43]=[de(" Ends entire conversation when called ",-1)])]),_:1}))])])])]),_:1},8,["icon"]),w(I(ft),{id:"section-side-b",title:d.value==="ai_human"?"Side B (Human)":"Side B (AI)",icon:d.value==="ai_human"?I(Yr):I(At)},{default:F(()=>[e("div",Z0,[d.value==="ai_human"?(r(),o(we,{key:0},[e("div",null,[w(T,{type:"text",modelValue:H.value,"onUpdate:modelValue":le[16]||(le[16]=B=>H.value=B),label:"Side Label (Optional)",placeholder:"e.g., Customer, User","outer-class":"$reset"},null,8,["modelValue"]),w(I(Ue),{class:"mt-1"},{default:F(()=>[...le[44]||(le[44]=[de(" Custom label for this side ",-1)])]),_:1})]),le[45]||(le[45]=e("div",{class:"flex flex-col items-center justify-center py-8 bg-neutral-50 dark:bg-neutral-800/50 rounded-lg"},[e("svg",{class:"w-16 h-16 mb-4 text-neutral-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[e("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"1.5",d:"M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z"})]),e("h5",{class:"font-medium text-lg mb-2 text-neutral-700 dark:text-neutral-300"},"Human User"),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))],64)):(r(),o(we,{key:1},[e("div",X0,[e("div",null,[w(T,{type:"text",modelValue:H.value,"onUpdate:modelValue":le[17]||(le[17]=B=>H.value=B),label:"Side Label (Optional)",placeholder:"e.g., ATC, Pilot, Customer","outer-class":"$reset"},null,8,["modelValue"]),w(I(Ue),{class:"mt-1"},{default:F(()=>[...le[46]||(le[46]=[de(" Custom label for this side ",-1)])]),_:1})]),e("div",null,[w(T,{type:"selectSearch",name:"side_b_agent_prompt",modelValue:ve.value,"onUpdate:modelValue":le[18]||(le[18]=B=>ve.value=B),label:"Agent Prompt",options:Oe.value,validation:"required","validation-visibility":"submit","validation-messages":{required:"Please select an agent prompt"},"outer-class":"$reset"},null,8,["modelValue","options"]),X.value?(r(),J(I(Ue),{key:0,class:"mt-1 text-red-600 dark:text-red-400"},{default:F(()=>[de(C(X.value),1)]),_:1})):(r(),J(I(Ue),{key:1,class:"mt-1"},{default:F(()=>[...le[47]||(le[47]=[de(" Defines this agent's behavior ",-1)])]),_:1}))])]),e("div",Q0,[w(I(Ut),{title:"Stop Conditions"}),w(I(Ue),null,{default:F(()=>[...le[48]||(le[48]=[de(" Optional. If no stop conditions are set, the agent will continue until programmatically stopped or end conversation tool is called. ",-1)])]),_:1}),e("div",null,[w(T,{type:"checkbox",modelValue:D.value,"onUpdate:modelValue":le[19]||(le[19]=B=>D.value=B),label:"Stop when agent returns content","outer-class":"$reset"},null,8,["modelValue"]),w(I(Ue),{class:"ml-6"},{default:F(()=>[...le[49]||(le[49]=[de(" Agent stops when it returns a response without calling tools ",-1)])]),_:1})]),e("div",null,[w(T,{type:"checkbox",modelValue:W.value,"onUpdate:modelValue":le[20]||(le[20]=B=>W.value=B),label:"Stop on specific tool call","outer-class":"$reset"},null,8,["modelValue"]),W.value?(r(),o("div",em,[w(T,{type:"selectSearch",modelValue:me.value,"onUpdate:modelValue":le[21]||(le[21]=B=>me.value=B),label:"Stop Tool",options:Le.value,placeholder:"Select a tool...",disabled:he.value||!ve.value,"outer-class":"$reset"},null,8,["modelValue","options","disabled"]),ue.value?(r(),J(I(Ue),{key:0,class:"text-red-600 dark:text-red-400"},{default:F(()=>[de(C(ue.value),1)]),_:1})):(r(),J(I(Ue),{key:1},{default:F(()=>[...le[50]||(le[50]=[de(" Agent stops when this tool is called ",-1)])]),_:1})),me.value?(r(),o("div",tm,[w(T,{type:"selectSearch",modelValue:te.value,"onUpdate:modelValue":le[22]||(le[22]=B=>te.value=B),label:"Response Property",options:Ye.value,placeholder:"Select property...","outer-class":"$reset"},null,8,["modelValue","options"]),Y.value?(r(),J(I(Ue),{key:0,class:"mt-1 text-red-600 dark:text-red-400"},{default:F(()=>[de(C(Y.value),1)]),_:1})):(r(),J(I(Ue),{key:1,class:"mt-1"},{default:F(()=>[...le[51]||(le[51]=[de(" Property from tool arguments to return as final response ",-1)])]),_:1}))])):S("",!0)])):S("",!0)])]),e("div",rm,[e("div",null,[w(T,{type:"number",name:"side_b_max_steps",modelValue:ae.value,"onUpdate:modelValue":le[23]||(le[23]=B=>ae.value=B),label:"Max Steps",placeholder:"Unlimited","outer-class":"$reset"},null,8,["modelValue"]),ye.value?(r(),J(I(Ue),{key:0,class:"mt-1 text-red-600 dark:text-red-400"},{default:F(()=>[de(C(ye.value),1)]),_:1})):(r(),J(I(Ue),{key:1,class:"mt-1"},{default:F(()=>[...le[52]||(le[52]=[de(" Safety limit before yielding ",-1)])]),_:1}))]),e("div",null,[w(T,{type:"selectSearch",modelValue:Te.value,"onUpdate:modelValue":le[24]||(le[24]=B=>Te.value=B),label:"End Conversation Tool",options:Le.value,placeholder:"Select a tool...",disabled:he.value||!ve.value,"outer-class":"$reset"},null,8,["modelValue","options","disabled"]),ne.value?(r(),J(I(Ue),{key:0,class:"mt-1 text-red-600 dark:text-red-400"},{default:F(()=>[de(C(ne.value),1)]),_:1})):(r(),J(I(Ue),{key:1,class:"mt-1"},{default:F(()=>[...le[53]||(le[53]=[de(" Ends entire conversation when called ",-1)])]),_:1}))])])],64))])]),_:1},8,["title","icon"]),w(I(ft),{id:"section-variables",title:"Variables",icon:I(qt)},{default:F(()=>[e("div",am,[le[54]||(le[54]=e("p",{class:"text-sm text-neutral-500 dark:text-neutral-400"}," Set optional agent-level overrides for declared variables used by this agent's prompts and tools. ",-1)),O.value?(r(),o("span",nm,"Scanning variables...")):S("",!0),w(Ha,{modelValue:_e.value,"onUpdate:modelValue":le[25]||(le[25]=B=>_e.value=B),scanned:ke.value,"allow-declaration-edit":!1,"allow-secret-values":!1,"allow-secret-declarations":!0,"require-required-values":!1,disabled:t.readonly||i.value},null,8,["modelValue","scanned","disabled"])])]),_:1},8,["icon"])])],512)]),e("div",om,[e("div",lm,[w(I(Je),{variant:"ghost",size:"sm",onClick:nt},{default:F(()=>[de(C(t.readonly?"Close":"Cancel"),1)]),_:1}),t.readonly?S("",!0):(r(),o("div",sm,[w(I(Sr),{node:Se.value||void 0},null,8,["node"]),w(I(Je),{variant:"primary",size:"sm",disabled:i.value,loading:i.value,type:"submit",form:"agent-form"},{default:F(()=>[de(C(u.value?"Update Agent":"Create Agent"),1)]),_:1},8,["disabled","loading"])]))])])]),_:1},8,["disabled"]))]),_:1},8,["model-value","title"])}}}),Wa=Ce({__name:"ExtractCopyToggle",props:{value:{},disabled:{type:Boolean}},emits:["update:value"],setup(t,{emit:n}){const a=n,s=l=>{a("update:value",l)};return(l,u)=>{const i=tt("FormKit");return r(),J(i,{type:"toggle",value:t.value,"on-value":"extract","off-value":"copy","on-value-label":"extract","off-value-label":"copy",disabled:t.disabled,classes:{outer:"$remove:mb-4",wrapper:"$remove:items-center flex-row-reverse justify-end items-center",inner:"h-5",track:"h-5 w-10 rounded-full",thumb:"h-4 w-4",valueLabel:"text-xs text-neutral-600 dark:text-neutral-400 mr-2 flex items-center font-normal"},onInput:s},null,8,["value","disabled"])}}}),um={class:"font-mono text-sm"},dm={class:"flex items-center gap-2 py-1.5"},cm={class:"text-neutral-600 dark:text-neutral-400"},pm={class:"ml-auto"},Ka=Ce({name:"TreeChildren",props:{children:{type:Array,required:!0},getSelection:{type:Function,required:!0},setSelection:{type:Function,required:!0},isShared:{type:Function,required:!0},getTypeColor:{type:Function,required:!0}},setup(t){return()=>t.children.length===0?null:Xe("div",{class:"ml-4"},t.children.map((n,a)=>Xe("div",{class:"relative",key:n.uid},[a<t.children.length-1?Xe("div",{class:"absolute left-0 top-0 bottom-0 border-l border-neutral-300 dark:border-neutral-700"}):Xe("div",{class:"absolute left-0 top-0 h-3 border-l border-neutral-300 dark:border-neutral-700"}),Xe("div",{class:"absolute left-0 top-3 w-4 border-t border-neutral-300 dark:border-neutral-700"}),Xe("div",{class:"pl-5"},[Xe("div",{class:"flex items-center gap-2 py-1.5"},[Xe("span",{class:"text-neutral-600 dark:text-neutral-400"},n.name),Xe(Pt,{variant:t.getTypeColor(n.type),size:"sm"},()=>n.type),t.isShared(n)?Xe("span",{class:"text-xs text-amber-600 dark:text-amber-400",title:`Used by: ${n.sharedWith.join(", ")}`},`(used in ${n.sharedWith.length} other${n.sharedWith.length>1?"s":""})`):null,n.isDuplicate?null:Xe("div",{class:"ml-auto"},[Xe(Wa,{value:t.getSelection(n),disabled:t.isShared(n),"onUpdate:value":s=>t.setSelection(n,s),title:t.isShared(n)?"Cannot extract items shared with other agents":""})])]),n.children.length>0?Xe(Ka,{children:n.children,getSelection:t.getSelection,setSelection:t.setSelection,isShared:t.isShared,getTypeColor:t.getTypeColor}):null])])))}}),mm=Ce({__name:"DependencyTree",props:{analysis:{},selections:{}},emits:["update:selection"],setup(t,{emit:n}){const a=t,s=n,l=q(()=>{const h=a.analysis,g=[];let y=0;const _=($,N)=>{for(const E of $){const L=`${N}:${E.name}`;g.push({...E,type:N,uid:`${L}:${y++}`})}};_(h.constituents.agents,"agent"),_(h.constituents.prompts,"prompt"),_(h.constituents.tools,"tool"),_(h.constituents.models,"model"),_(h.constituents.hooks,"hook");const v=new Map,d=`agent:${h.agent}`;for(const $ of g){const N=$.parentKey||d;`${$.type}:${$.name}`===d&&!$.parentKey||(v.has(N)||v.set(N,[]),v.get(N).push($))}const b=new Set,c=$=>{const N=`${$.type}:${$.name}`,E=b.has(N);b.add(N);const L=[],V=v.get(N)||[];for(const A of V)L.push(c(A));return{name:$.name,type:$.type,filePath:$.filePath,sharedWith:$.sharedWith,discoveredVia:$.discoveredVia,children:L,uid:$.uid,isDuplicate:E}},f=g.find($=>$.type==="agent"&&$.name===h.agent&&!$.parentKey);return f?c(f):{name:h.agent,type:"agent",filePath:"",sharedWith:[],discoveredVia:"static",children:[],uid:"root",isDuplicate:!1}}),u=h=>`${h.type}:${h.name}`,i=h=>a.selections.get(u(h))||"extract",p=(h,g)=>{s("update:selection",u(h),g)},x=h=>h.sharedWith.length>0,k=h=>{switch(h){case"agent":return"accent";case"prompt":return"secondary";case"tool":return"success";case"model":return"warning";case"hook":return"default"}};return(h,g)=>(r(),o("div",um,[e("div",dm,[e("span",cm,C(l.value.name),1),w(I(Pt),{variant:k(l.value.type),size:"sm"},{default:F(()=>[de(C(l.value.type),1)]),_:1},8,["variant"]),e("div",pm,[w(Wa,{value:i(l.value),"onUpdate:value":g[0]||(g[0]=y=>p(l.value,y))},null,8,["value"])])]),(r(),J(Qe(I(Ka)),{children:l.value.children,"get-selection":i,"set-selection":p,"is-shared":x,"get-type-color":k},null,8,["children"]))]))}}),vm={key:0,class:"flex items-center justify-center py-12"},fm={key:1,class:"py-4"},gm={key:2,class:"py-4 space-y-4"},hm={class:"space-y-2"},bm={class:"text-sm opacity-80"},xm={class:"text-sm opacity-80"},ym={key:3,class:"space-y-6"},km={class:"space-y-4"},wm={class:"grid grid-cols-2 gap-4"},_m={class:"col-span-2"},$m=["value"],Cm={class:"col-span-2"},Sm={class:"col-span-2"},Im={key:0,class:"mt-3 space-y-3"},Tm={class:"flex gap-2 border-b border-neutral-200 dark:border-neutral-700"},Mm={key:0},zm=["innerHTML"],Vm={class:"space-y-4"},Em={class:"list-disc list-inside space-y-1"},Lm={class:"border border-neutral-200 dark:border-neutral-700 rounded-lg p-4 bg-neutral-50 dark:bg-neutral-900/50"},Am={class:"flex justify-between"},Pm=Ce({__name:"PackModal",props:{modelValue:{type:Boolean},agent:{}},emits:["update:modelValue","packed"],setup(t,{emit:n}){ar.setOptions({gfm:!0,breaks:!0});const a=[{value:"MIT",label:"MIT"},{value:"Apache-2.0",label:"Apache 2.0"},{value:"ISC",label:"ISC"},{value:"GPL-3.0",label:"GPL 3.0"},{value:"BSD-3-Clause",label:"BSD 3-Clause"},{value:"Unlicensed",label:"Unlicensed / Proprietary"}],s=t,l=n,u=q({get:()=>s.modelValue,set:X=>l("update:modelValue",X)}),i=m(null),p=m(!1),x=m(!1),k=m(null),h=m(null),g=m(""),y=m("1.0.0"),_=m("MIT"),v=m(""),d=m(""),b=m("edit"),c=m(!1),f=m(null),$=m(null),N=q(()=>d.value?ar(d.value):""),E=m(new Map);Ee(()=>s.modelValue,async X=>{X&&s.agent?await Promise.all([V(),A()]):L()});const L=()=>{i.value=null,k.value=null,h.value=null,E.value=new Map,g.value="",y.value="1.0.0",_.value="MIT",v.value="",d.value="",b.value="edit",c.value=!1,f.value=null,$.value=null},V=async()=>{if(s.agent){p.value=!0,k.value=null;try{const X=await fetch(Ve(`/api/pack/${s.agent.id}/analyze`)),D=await X.json();if(!X.ok){k.value=D.error||"Failed to analyze agent";return}if(i.value=D,D.generatedReadme)d.value=D.generatedReadme;else{const W=G(s.agent?.id||"agent");d.value=ee(W,s.agent?.id||"agent",D.agentDescription)}be(D)}catch(X){k.value=X instanceof Error?X.message:"Failed to analyze agent"}finally{p.value=!1}}},A=async()=>{if(s.agent)try{const X=await fetch(Ve(`/api/pack/${s.agent.id}/metadata`));if(X.ok){const D=await X.json();g.value=D.packageName,y.value=ie(D.version),_.value=D.license||"MIT",v.value=D.licenseOwner||""}else g.value=G(s.agent.id),y.value="1.0.0",_.value="MIT",v.value=""}catch{g.value=G(s.agent?.id||"agent"),y.value="1.0.0",_.value="MIT",v.value=""}},G=X=>`standardagent-${X.toLowerCase().replace(/_/g,"-")}`,ee=(X,D,W)=>`# ${X}
1
+ import{d as Se,i as xa,c as F,t as pn,r as p,w as Ve,o as He,a as ct,p as mn,b as o,e as r,n as _t,f as t,g as Ye,h as Fe,j as vn,k as S,l as Je,m as pe,q as k,s as W,F as $e,u as Le,v as ve,x as C,y as pt,z as Y,A as je,B as rt,C as fn,D as gn,I as ya,E as hn,G as bn,T as ar,H as Xe,J as I,K as yt,L as gt,M as zt,N as at,O as xn,P as Nt,Q as ka,R as wa,S as Vt,U as qt,V as Br,W as Yt,X as kt,Y as _a,Z as yn,_ as kn,$ as $a,a0 as it,a1 as Er,a2 as tt,a3 as Ca,a4 as xt,a5 as St,a6 as Lr,a7 as Nr,a8 as wn,a9 as Ar,aa as _n,ab as Sa,ac as $n,ad as Ia,ae as or,af as lr,ag as Ta,ah as Ma,ai as qr,aj as sr,ak as Fr,al as Cn,am as Sn,an as In,ao as Tn,ap as Mn,aq as zn,ar as Vn,as as En,at as Ln,au as An,av as Pn,aw as On,ax as za,ay as Rn,az as jn,aA as Dn,aB as Un,aC as Bn,aD as Nn,aE as qn,aF as Fn,aG as Hn,aH as Wn,aI as Kn}from"./vue.js";import{a6 as Jn,a7 as Gn,a8 as Yn,a9 as ir,aa as Zn,r as Ir}from"./vendor.js";import{W as Xn,a as Qn,e as Hr}from"./monaco.js";(function(){const n=document.createElement("link").relList;if(n&&n.supports&&n.supports("modulepreload"))return;for(const l of document.querySelectorAll('link[rel="modulepreload"]'))s(l);new MutationObserver(l=>{for(const u of l)if(u.type==="childList")for(const i of u.addedNodes)i.tagName==="LINK"&&i.rel==="modulepreload"&&s(i)}).observe(document,{childList:!0,subtree:!0});function a(l){const u={};return l.integrity&&(u.integrity=l.integrity),l.referrerPolicy&&(u.referrerPolicy=l.referrerPolicy),l.crossOrigin==="use-credentials"?u.credentials="include":l.crossOrigin==="anonymous"?u.credentials="omit":u.credentials="same-origin",u}function s(l){if(l.ep)return;l.ep=!0;const u=a(l);fetch(l.href,u)}})();var Va=class{endpoint;token;constructor(e){this.endpoint=e.replace(/\/$/,""),this.token=typeof localStorage<"u"?localStorage.getItem("agentbuilder_auth_token"):null}getEndpoint(){return this.endpoint}async createThread(e){const n=await fetch(`${this.endpoint}/threads`,{method:"POST",headers:{...this.getHeaders(),"Content-Type":"application/json"},body:JSON.stringify(e)});if(!n.ok)throw new Error(`Failed to create thread: ${n.statusText}`);return n.json()}async getThread(e){const n=await fetch(`${this.endpoint}/threads/${e}`,{method:"GET",headers:this.getHeaders()});if(!n.ok)throw new Error(`Failed to get thread: ${n.statusText}`);return n.json()}async getMessages(e,n={}){const a=new URLSearchParams;n.limit!==void 0&&a.set("limit",String(n.limit)),n.offset!==void 0&&a.set("offset",String(n.offset)),n.depth!==void 0&&a.set("depth",String(n.depth)),n.includeSilent!==void 0&&a.set("includeSilent",String(n.includeSilent));const s=a.toString(),l=`${this.endpoint}/threads/${e}/messages${s?`?${s}`:""}`,u=await fetch(l,{method:"GET",headers:this.getHeaders()});if(!u.ok)throw new Error(`Failed to get messages: ${u.statusText}`);return(await u.json()).messages||[]}async sendMessage(e,n){const a=await fetch(`${this.endpoint}/threads/${e}/messages`,{method:"POST",headers:{...this.getHeaders(),"Content-Type":"application/json"},body:JSON.stringify(n)});if(!a.ok)throw new Error(`Failed to send message: ${a.statusText}`);return a.json()}async stopExecution(e){const n=await fetch(`${this.endpoint}/threads/${e}/stop`,{method:"POST",headers:this.getHeaders()});if(!n.ok)throw new Error(`Failed to stop execution: ${n.statusText}`);await n.json()}async deleteMessage(e,n){const a=await fetch(`${this.endpoint}/threads/${e}/messages/${n}`,{method:"DELETE",headers:this.getHeaders()});if(!a.ok)throw new Error(`Failed to delete message: ${a.statusText}`);return a.json()}async uploadFile(e,n,a){const s=encodeURIComponent(n.name),l=`${this.endpoint}/threads/${e}/fs/${s}`;if(a?.thumbnail){const i=await this.fileToBase64(n),c=await fetch(l,{method:"POST",headers:{...this.getHeaders(),"Content-Type":"application/json"},body:JSON.stringify({data:i,mimeType:n.type,thumbnail:a.thumbnail,metadata:{width:a.width,height:a.height}})});if(!c.ok)throw new Error(`Failed to upload file: ${c.statusText}`);return c.json()}const u=await fetch(l,{method:"POST",headers:{...this.getHeaders(),"Content-Type":n.type},body:n});if(!u.ok)throw new Error(`Failed to upload file: ${u.statusText}`);return u.json()}fileToBase64(e){return new Promise((n,a)=>{const s=new FileReader;s.onload=()=>{const u=s.result.split(",")[1];n(u)},s.onerror=()=>a(new Error("Failed to read file")),s.readAsDataURL(e)})}getFileUrl(e,n){const s=(n.startsWith("/")?n.slice(1):n).split("/").map(l=>encodeURIComponent(l)).join("/");return`${this.endpoint}/threads/${e}/fs/${s}`}getThumbnailUrl(e,n){return`${this.getFileUrl(e,n)}?thumbnail=true`}async listFiles(e){const n=await fetch(`${this.endpoint}/threads/${e}/fs?find=**/*&type=file`,{method:"GET",headers:this.getHeaders()});if(!n.ok)throw new Error(`Failed to list files: ${n.statusText}`);return(await n.json()).files||[]}connectMessageWebSocket(e,n={},a={}){const s=new URLSearchParams;this.token&&s.set("token",this.token),a.includeSilent!==void 0&&s.set("includeSilent",String(a.includeSilent)),a.depth!==void 0&&s.set("depth",String(a.depth));const l=this.endpoint.startsWith("https")?"wss":"ws",i=`${this.endpoint.replace(/^https?/,l)}/threads/${e}/stream?${s.toString()}`,c=new WebSocket(i);return c.onopen=()=>{n.onOpen?.()},c.onmessage=f=>{try{if(typeof f.data=="string"&&f.data==="pong")return;const h=JSON.parse(f.data);switch(h.type){case"message_data":n.onMessage?.(h);break;case"message_chunk":n.onChunk?.(h);break;case"event":n.onEvent?.(h);break;case"error":n.onError?.(h);break}}catch(h){console.error("Failed to parse WebSocket message:",h)}},c.onerror=f=>{console.error("WebSocket error:",f),n.onError?.({type:"error",error:"WebSocket connection error"})},c.onclose=f=>{console.log(`[AgentBuilderClient] Message WebSocket closed - code: ${f.code}, reason: ${f.reason||"none"}, wasClean: ${f.wasClean}`),n.onClose?.()},c}connectLogWebSocket(e,n={}){const a=new URLSearchParams;this.token&&a.set("token",this.token);const s=this.endpoint.startsWith("https")?"wss":"ws",u=`${this.endpoint.replace(/^https?/,s)}/threads/${e}?${a.toString()}`,i=new WebSocket(u);return i.onopen=()=>{n.onOpen?.()},i.onmessage=c=>{try{if(typeof c.data=="string"&&c.data==="pong")return;const f=JSON.parse(c.data);switch(f.type){case"log_data":n.onLog?.(f);break;case"custom":n.onCustom?.(f);break;case"stopped_by_user":n.onStopped?.(f);break}}catch(f){console.error("Failed to parse WebSocket message:",f)}},i.onerror=c=>{console.error("WebSocket error:",c)},i.onclose=()=>{n.onClose?.()},i}getHeaders(){const e={};return this.token&&(e.Authorization=`Bearer ${this.token}`),e}},eo=class{client;threadId;callbacks;options;ws=null;status="disconnected";reconnectAttempts=0;reconnectTimeout=null;heartbeatInterval=null;isReconnecting=!1;shouldReconnect=!0;constructor(e,n,a={},s={}){this.client=e,this.threadId=n,this.callbacks=a,this.options={depth:s.depth??0,includeSilent:s.includeSilent??!1,heartbeatInterval:s.heartbeatInterval??3e4,maxReconnectDelay:s.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:e=>{this.callbacks.onMessage?.(e)},onChunk:e=>{this.callbacks.onChunk?.(e)},onEvent:e=>{this.callbacks.onEvent?.(e)},onError:e=>{this.callbacks.onError?.(e)},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(e){this.callbacks={...this.callbacks,...e}}updateOptions(e){this.options={...this.options,...e}}setStatus(e){this.status!==e&&(this.status=e,this.callbacks.onStatusChange?.(e))}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 e=Math.min(1e3*Math.pow(2,this.reconnectAttempts),this.options.maxReconnectDelay);this.reconnectAttempts++,this.reconnectTimeout=setTimeout(()=>{this.shouldReconnect&&this.connect()},e)}};function Wr(e){return e.toLowerCase().startsWith("image/")}var Kr=256;function to(e){return new Promise((n,a)=>{const s=new Image,l=URL.createObjectURL(e);s.onload=()=>{URL.revokeObjectURL(l),n(s)},s.onerror=()=>{URL.revokeObjectURL(l),a(new Error("Failed to load image"))},s.src=l})}function ro(e){const{width:n,height:a}=e,s=n/a;let l,u;s>1?(l=Math.min(Kr,n),u=Math.floor(l/s)):(u=Math.min(Kr,a),l=Math.floor(u*s));const i=document.createElement("canvas");i.width=l,i.height=u;const c=i.getContext("2d");if(!c)throw new Error("Failed to get canvas context");return c.drawImage(e,0,0,l,u),i.toDataURL("image/webp",.8).split(",")[1]}async function ao(e){const n=await to(e);return{thumbnail:ro(n),width:n.width,height:n.height}}function no(){return`pending-${Date.now()}-${Math.random().toString(36).substr(2,9)}`}function oo(e){return new Promise((n,a)=>{const s=new FileReader;s.onload=()=>n(s.result),s.onerror=a,s.readAsDataURL(e)})}var lo=class{createPendingFile(e){return{id:no(),name:e.name,mimeType:e.type,size:e.size,isImage:Wr(e.type),localPreviewUrl:null,status:"uploading"}}queueFiles(e){return Array.from(e).map(n=>({pending:this.createPendingFile(n),file:n}))}async executeUpload(e,n,a,s,l,u={}){const{generateThumbnail:i=!0,generatePreview:c=!0}=u,f=Wr(n.type);f&&c&&oo(n).then(h=>l({localPreviewUrl:h})).catch(h=>console.error("Failed to generate preview:",h));try{let h;if(f&&i)try{const b=await ao(n);h={thumbnail:b.thumbnail,width:b.width,height:b.height}}catch(b){console.warn("Failed to generate thumbnail:",b)}const x=await s.uploadFile(e,n,h);return l({id:x.id,status:"ready",path:x.path,width:x.width,height:x.height}),x}catch(h){throw l({status:"error",error:h instanceof Error?h.message:"Failed to upload file"}),h}}async executeUploads(e,n,a,s,l={}){const u=n.map(({pending:i,file:c})=>this.executeUpload(e,c,i.id,a,f=>s(i.id,f),l).catch(f=>f instanceof Error?f:new Error(String(f))));return Promise.all(u)}};function Ea(e){if(e.length===0)return[];const n=[];let a=0;for(;a<e.length;){const s=e[a];if(s.role==="assistant"&&s.tool_calls){let l;try{l=JSON.parse(s.tool_calls)}catch{n.push(s),a++;continue}const u=[],i=[];let c=s.reasoning_content||null,f="completed";const h=s.id,x=s.created_at,b=s.depth;s.status==="pending"?f="pending":s.status==="failed"&&(f="failed"),s.content&&i.push(s.content);for(const m of l)u.push({id:m.id||s.id,type:"tool_call",name:m.function?.name,content:m.function?.arguments||null,status:null,tool_call_id:m.id});let y=a+1;for(;y<e.length;){const m=e[y];if(m.role==="tool"){const v=m.tool_status||"pending";u.push({id:m.id,type:"tool_result",name:m.name||void 0,content:m.content,status:v,tool_call_id:m.tool_call_id||void 0}),y++}else if(m.role==="assistant"&&m.tool_calls){let v;try{v=JSON.parse(m.tool_calls)}catch{break}m.status==="pending"?f="pending":m.status==="failed"&&f!=="pending"&&(f="failed"),m.content&&i.push(m.content),!c&&m.reasoning_content&&(c=m.reasoning_content);for(const _ of v)u.push({id:_.id||m.id,type:"tool_call",name:_.function?.name,content:_.function?.arguments||null,status:null,tool_call_id:_.id});y++}else break}const $=new Set(u.filter(m=>m.type==="tool_call").map(m=>m.tool_call_id)),g=u.filter(m=>m.type==="tool_result"&&m.tool_call_id&&!$.has(m.tool_call_id));for(const m of g){const v=u.indexOf(m),_=m.content?.match(/Tool not found: (\w+)/)?.[1]||"unknown_tool",P={id:`synthetic-${m.tool_call_id}`,type:"tool_call",name:_,content:null,status:m.status,tool_call_id:m.tool_call_id};u.splice(v,0,P)}for(const m of u)if(m.type==="tool_call"&&m.tool_call_id&&m.status===null){const v=u.find(_=>_.type==="tool_result"&&_.tool_call_id===m.tool_call_id);v?m.status=v.status:m.status="pending"}const d=i.length>0?i.join(""):null,w={id:h,type:"workblock",content:d,reasoning_content:c,workItems:u,status:f,created_at:x,depth:b};n.push(w),a=y}else n.push(s),a++}return n}var pr=new Set(["subagent_create","subagent_message","send_to_agent"]),so=/subagent/i;function xr(e){return e.type==="workblock"}function Jr(e){return e.type==="status"}function Tt(e){if(typeof e!="string")return null;const n=e.trim();return n.length>0?n:null}function Gr(e,n){return!e.metadata||typeof e.metadata!="object"?null:Tt(e.metadata[n])}function La(e){if(!e)return null;const n=e.match(/Reference:\s*([0-9a-fA-F-]{36})/);if(n?.[1])return n[1].toLowerCase();const a=e.match(/reference:\s*([0-9a-fA-F-]{36})/i);return a?.[1]?a[1].toLowerCase():null}function Aa(e){const n=Tt(e.subagent_status);if(n)return n;const a=e.content||"";return/was initiated successfully/i.test(a)||/Message sent to subagent/i.test(a)?"running":/has returned the following result/i.test(a)?"idle":/has reported a failure/i.test(a)||/execution stopped before completion/i.test(a)?"terminated":null}function Tr(e){if(e.role!=="system")return null;const n=Gr(e,"status_kind");if(n==="execution_stopped"||n==="subagent_started"||n==="subagent_event")return n;if(Gr(e,"subagent_event")==="parent_handoff")return"subagent_event";const a=(e.content||"").trim();return/execution\s+stopped/i.test(a)?"execution_stopped":/subagents?\s+started:/i.test(a)?"subagent_started":null}function Yr(e){const n=Tr(e)??void 0;return{id:`status:${e.id}`,type:"status",role:"system",content:e.content||"Execution stopped by user",created_at:e.created_at,depth:e.depth,silent:!1,status_kind:n}}function io(e){if(e.role==="tool"&&Tt(e.subagent_id)||e.role==="tool"&&e.name&&pr.has(e.name))return!0;const n=e.content||"";return!!(/subagent\s*\(reference:/i.test(n)||/the subagent was initiated successfully/i.test(n)||/message sent to subagent/i.test(n))}function Ft(e){const n=Tt(e.subagent_id);if(n)return n;const a=e.metadata;if(a&&typeof a=="object"){const s=Tt(a.subagent_id);if(s)return s;const l=Tt(a.subagentId);if(l)return l}return La(e.content)}function uo(e){if(!e)return{};try{const n=JSON.parse(e);return n&&typeof n=="object"?n:{}}catch{return{}}}function co(e){return e?pr.has(e)?!0:so.test(e):!1}function Pa(e){const n=uo(e.content);return Tt(n.name)}function po(e,n){if(e.tool_call_id){const a=n.get(e.tool_call_id);if(a)return a}return La(e.content)}function mo(e,n){const a=Aa(n);return{id:`subagent:${e}`,type:"subagent_block",subagent_id:e,subagent_name:n.subagent_name??null,subagent_title:n.subagent_title??null,subagent_description:n.subagent_description??null,subagent_status:a??null,subagent_resumable:n.subagent_resumable??null,subagent_blocking:n.subagent_blocking??null,subagent_thread_name:n.subagent_thread_name??null,subagent_spawn_group_id:n.subagent_spawn_group_id??null,messages:[n],created_at:n.created_at,updated_at:n.created_at,depth:n.depth}}function vo(e,n){e.messages.push(n),e.updated_at=Math.max(e.updated_at,n.created_at),e.created_at=Math.min(e.created_at,n.created_at),e.depth=n.depth??e.depth,n.subagent_name!==void 0&&(e.subagent_name=n.subagent_name??e.subagent_name??null),n.subagent_title!==void 0&&(e.subagent_title=n.subagent_title??e.subagent_title??null),n.subagent_description!==void 0&&(e.subagent_description=n.subagent_description??e.subagent_description??null);const a=Aa(n);a!==null&&(e.subagent_status=a),n.subagent_resumable!==void 0&&(e.subagent_resumable=n.subagent_resumable??e.subagent_resumable??null),n.subagent_blocking!==void 0&&(e.subagent_blocking=n.subagent_blocking??e.subagent_blocking??null),n.subagent_thread_name!==void 0&&(e.subagent_thread_name=n.subagent_thread_name??e.subagent_thread_name??null),n.subagent_spawn_group_id!==void 0&&(e.subagent_spawn_group_id=n.subagent_spawn_group_id??e.subagent_spawn_group_id??null)}function fo(e,n){const a=e.workItems.filter(s=>s.type==="tool_call");return a.length===0||!a.every(s=>s.name&&pr.has(s.name))?!1:n.size>0}function go(e,n){if(!n)return null;const a=e.workItems.find(l=>l.type==="tool_result"&&l.tool_call_id===n);if(!a||a.status!=="success")return null;const s=(a.content||"").toLowerCase();return s.includes("was initiated successfully")||s.includes("results will be delivered when complete")?!1:s.length>0?!0:null}function ho(e,n,a,s){const l=Tt(n.name)??"Subagent",u=n.tool_call_id?`pending:${n.tool_call_id}`:`pending:${e.id}:${a}`,i=e.created_at+a,c=!!n.name&&pr.has(n.name);return{id:`subagent:${u}`,type:"subagent_block",subagent_id:u,subagent_name:l,subagent_title:l,subagent_description:null,subagent_status:s,subagent_resumable:!!c,subagent_blocking:c?null:!0,subagent_thread_name:Pa(n),subagent_spawn_group_id:e.id,messages:[],created_at:i,updated_at:i,depth:e.depth}}function bo(e){if(e.startIndex===void 0||e.displayIndex===void 0||e.startIndex===e.displayIndex)return null;const n=e.blocks.map(u=>u.subagent_thread_name||u.subagent_title||u.subagent_name||"Subagent").filter((u,i,c)=>c.indexOf(u)===i);let a;n.length<=1?a=`Subagent started: ${n[0]||"Subagent"}`:n.length<=3?a=`Subagents started: ${n.join(", ")}`:a=`Subagents started: ${n.length} subagents`;const s=Math.min(...e.blocks.map(u=>u.created_at))||Date.now()*1e3,l=e.blocks[0]?.depth;return{id:`subagent-start:${e.groupKey}`,type:"status",role:"system",content:a,created_at:s,status_kind:"subagent_started",silent:!1,depth:l}}function xo(e){return e?.subagent_thread_name||e?.subagent_title||e?.subagent_name||"Subagent"}function yo(e,n){if(!e.content)return null;const a=e.content,s=xo(n);let l=null;return/has returned the following result/i.test(a)?l=`Subagent replied: ${s}`:(/has reported a failure/i.test(a)||/execution stopped before completion/i.test(a))&&(l=`Subagent failed: ${s}`),l?{id:`status:subagent-event:${e.id}`,type:"status",role:"system",content:l,created_at:e.created_at,depth:e.depth,silent:!1,status_kind:"subagent_event",subagent_id:n?.subagent_id??e.subagent_id??null}:null}function ko(e){if(e.blocks.length===1)return e.blocks[0];const n=[...e.blocks].sort((a,s)=>{const l=(a.subagent_thread_name||a.subagent_title||a.subagent_name||"").toLowerCase(),u=(s.subagent_thread_name||s.subagent_title||s.subagent_name||"").toLowerCase();return l!==u?l.localeCompare(u):a.created_at-s.created_at});return{id:`subagent-group:${e.groupKey}`,type:"subagent_group_block",group_id:e.groupKey,subagents:n,created_at:Math.min(...n.map(a=>a.created_at)),updated_at:Math.max(...n.map(a=>a.updated_at)),depth:n[0]?.depth}}function wo(e,n={}){if(e.length===0)return[];const s=n.includeWorkblocks??!1?Ea(e):e,l=new Map;for(const V of e){if(V.role!=="tool"||!V.tool_call_id)continue;const E=Ft(V);E&&l.set(V.tool_call_id,E)}const u=new Map,i=new Map,c=new Map,f=[],h=new Set,x=new Map;s.forEach((V,E)=>{if(x.set(V.id,E),!xr(V))return;const z=new Set,A=V.workItems.filter(ne=>ne.type==="tool_call"),oe=[];for(const ne of A){if(!co(ne.name))continue;const fe=po(ne,l);if(!fe){ne.status==="pending"&&oe.push(ne);continue}z.add(fe),u.has(fe)||u.set(fe,E);const ye=Pa(ne);ye&&!i.has(fe)&&i.set(fe,ye);const te=c.get(fe)??{resumable:null,blocking:null};if((ne.name==="subagent_create"||ne.name==="subagent_message"||ne.name==="send_to_agent")&&(te.resumable=!0),ne.name==="subagent_create"){const q=go(V,ne.tool_call_id);q!==null&&(te.blocking=q)}c.set(fe,te)}oe.length>0&&oe.forEach((ne,fe)=>{const te=ho(V,ne,fe,fe===0?"running":"pending");f.push({block:te,startIndex:E,displayIndex:E,groupKey:`start:${E}`})}),fo(V,z)&&h.add(E)});const b=new Map,y=new Set;for(const V of e){const E=Ft(V);E&&io(V)&&y.add(E)}for(const V of e){const E=Ft(V);if(!E||!y.has(E))continue;const z=b.get(E);z?vo(z,V):b.set(E,mo(E,V))}if(b.size===0&&f.length===0)return s.map(V=>{if(Jr(V)||xr(V))return V;const E=V;return Tr(E)?Yr(E):E});const $=[],g=[];for(const[V,E]of b){const z=i.get(V);!E.subagent_thread_name&&z&&(E.subagent_thread_name=z);const A=c.get(V);E.subagent_resumable===null&&A?.resumable!==null&&A?.resumable!==void 0&&(E.subagent_resumable=A.resumable),E.subagent_blocking===null&&A?.blocking!==null&&A?.blocking!==void 0&&(E.subagent_blocking=A.blocking);let oe=u.get(V),ne;for(const ye of E.messages){const te=x.get(ye.id);te!==void 0&&(ne===void 0||te>ne)&&(ne=te)}if(oe===void 0&&E.subagent_spawn_group_id&&(oe=x.get(E.subagent_spawn_group_id)),ne===void 0&&(oe!==void 0?ne=oe:E.subagent_spawn_group_id&&(ne=x.get(E.subagent_spawn_group_id))),oe===void 0&&ne!==void 0&&(oe=ne),ne===void 0){g.push(E);continue}const fe=E.subagent_spawn_group_id?`spawn:${E.subagent_spawn_group_id}`:oe!==void 0?`start:${oe}`:`subagent:${V}`;$.push({block:E,startIndex:oe,displayIndex:ne,groupKey:fe})}for(const V of f)$.push(V);const d=new Map;for(const V of $){const E=d.get(V.groupKey);if(!E){d.set(V.groupKey,{groupKey:V.groupKey,startIndex:V.startIndex,displayIndex:V.displayIndex,blocks:[V.block]});continue}E.startIndex===void 0&&(E.startIndex=V.startIndex),V.startIndex!==void 0&&E.startIndex!==void 0&&(E.startIndex=Math.min(E.startIndex,V.startIndex)),E.displayIndex===void 0&&(E.displayIndex=V.displayIndex),V.displayIndex!==void 0&&E.displayIndex!==void 0&&(E.displayIndex=Math.max(E.displayIndex,V.displayIndex)),E.blocks.push(V.block)}const w=new Map,m=new Map,v=new Map;for(const V of d.values()){const E=ko(V);if(V.displayIndex!==void 0){const A=w.get(V.displayIndex)??[];A.push(E),w.set(V.displayIndex,A)}const z=bo(V);if(z&&V.startIndex!==void 0){const A=m.get(V.startIndex)??[];A.push(z),m.set(V.startIndex,A)}}for(const V of e){const E=Ft(V);if(!E)continue;const z=x.get(V.id);if(z===void 0)continue;const A=b.get(E),oe=yo(V,A);if(!oe)continue;const ne=v.get(z)??[];ne.push(oe),v.set(z,ne)}for(const[V,E]of w)E.sort((z,A)=>z.created_at-A.created_at),w.set(V,E);for(const[V,E]of m)E.sort((z,A)=>z.created_at-A.created_at),m.set(V,E);for(const[V,E]of v)E.sort((z,A)=>z.created_at-A.created_at),v.set(V,E);g.sort((V,E)=>V.created_at-E.created_at);const _=[],P=new Set;for(let V=0;V<s.length;V++){const E=m.get(V)??[];for(const fe of E)_.push(fe);const z=v.get(V)??[];for(const fe of z)_.push(fe);const A=w.get(V)??[];for(const fe of A)if(fe.type==="subagent_group_block"){const ye=fe;for(const te of ye.subagents)P.add(te.subagent_id);_.push(ye)}else{const ye=fe;P.has(ye.subagent_id)||(_.push(ye),P.add(ye.subagent_id))}const oe=s[V];if(Jr(oe)){_.push(oe);continue}if(xr(oe)){if(h.has(V))continue;_.push(oe);continue}const ne=oe;if(Tr(ne)){_.push(Yr(ne));continue}Ft(ne)||_.push(ne)}for(const V of g)P.has(V.subagent_id)||(_.push(V),P.add(V.subagent_id));return _}var Oa=Symbol("StandardAgents"),Ra=Symbol("Thread"),_o={install(e,n){if(!n?.endpoint)throw new Error("StandardAgentsPlugin requires an endpoint option");const s={client:new Va(n.endpoint),endpoint:n.endpoint};e.provide(Oa,s)}};function $o(){const e=xa(Oa);if(!e)throw new Error("useStandardAgents must be used within a component where StandardAgentsPlugin is installed");return e}var Zr=new lo;function Co(e){return new Promise((n,a)=>{const s=new FileReader;s.onload=()=>{const u=s.result.split(",")[1];n(u)},s.onerror=()=>a(new Error("Failed to read file")),s.readAsDataURL(e)})}function So(e,n={}){const{preload:a=!0,live:s=!0,useWorkblocks:l=!1,useSubagentBlocks:u=!1,depth:i=0,includeSilent:c=!1,endpoint:f}=n,h=F(()=>pn(e)),x=$o(),b=f?new Va(f):x.client,y={preload:a,live:s,useWorkblocks:l,useSubagentBlocks:u,depth:i,includeSilent:c},$=p([]),g=p("disconnected"),d=p(a),w=p(null),m=p([]),v=p([]),_=p([]),P=F(()=>{const X=new Set(v.value.map(be=>be.path));return[...m.value.filter(be=>!be.path||!X.has(be.path)),...v.value]}),V=new Map;let E=null;const z=F(()=>l?Ea($.value):$.value),A=F(()=>u?wo($.value,{includeWorkblocks:l}):$.value),oe=F(()=>u?A.value:l?z.value:$.value);async function ne(){d.value=!0,w.value=null;try{const X=await b.getMessages(h.value,{depth:i,includeSilent:c});$.value=X}catch(X){w.value=X instanceof Error?X:new Error(String(X))}finally{d.value=!1}}async function fe(){try{const X=await b.listFiles(h.value);v.value=X.filter(he=>!he.isDirectory).map(he=>({id:he.path,name:he.name,path:he.path,mimeType:he.mimeType,size:he.size,isImage:he.mimeType.startsWith("image/"),status:"committed",localPreviewUrl:null}))}catch(X){console.error("Failed to load files:",X)}}function ye(X){if(X.file.isDirectory)return;const he={id:X.path,name:X.file.name,path:X.path,mimeType:X.file.mimeType,size:X.file.size,isImage:X.file.mimeType?.startsWith("image/")||!1,status:"committed",localPreviewUrl:null},be=v.value.findIndex(B=>B.path===X.path);be>=0?v.value[be]=he:v.value=[...v.value,he]}function te(X){if(X.file.isDirectory)return;const he={id:X.path,name:X.file.name,path:X.path,mimeType:X.file.mimeType,size:X.file.size,isImage:X.file.mimeType?.startsWith("image/")||!1,status:"committed",localPreviewUrl:null},be=v.value.findIndex(B=>B.path===X.path);be>=0?v.value[be]=he:v.value=[...v.value,he]}function q(X){v.value=v.value.filter(he=>he.path!==X.path)}function j(){s&&(E=new eo(b,h.value,{onStatusChange:X=>{g.value=X},onMessage:X=>{if(X.type==="message_data"){const he=$.value.findIndex(be=>be.id===X.data.id);he>=0?$.value[he]=X.data:$.value=[...$.value,X.data]}},onChunk:X=>{const he=$.value.findIndex(be=>be.id===X.message_id);if(he>=0){const be=$.value[he];$.value[he]={...be,content:(be.content||"")+X.chunk}}},onEvent:X=>{X.eventType==="file_created"?ye(X.data):X.eventType==="file_updated"?te(X.data):X.eventType==="file_deleted"&&q(X.data);const he=V.get(X.eventType);he&&he.forEach(be=>{try{be(X.data)}catch(B){console.error(`Error in event listener for "${X.eventType}":`,B)}})},onError:X=>{w.value=X instanceof Error?X:new Error(String(X))}},{depth:i,includeSilent:c}),E.connect())}async function J(X){const he=`optimistic-${crypto.randomUUID()}`,be=_.value.map(M=>({id:M.id,type:"file",path:"",name:M.name,mimeType:M.mimeType,size:M.size,width:M.width,height:M.height,localPreviewUrl:M.previewUrl||void 0})),B={id:he,role:X.role,content:X.content,attachments:be.length>0?JSON.stringify(be):null,created_at:Date.now()*1e3,status:"pending"};$.value=[...$.value,B];const D=[..._.value];_.value=[];try{const M=await Promise.all(D.map(async L=>({name:L.name,mimeType:L.mimeType,data:await Co(L.file),width:L.width,height:L.height}))),T=await b.sendMessage(h.value,{...X,attachments:M.length>0?M:void 0});return $.value=$.value.filter(L=>L.id!==he),D.forEach(L=>{L.previewUrl&&URL.revokeObjectURL(L.previewUrl)}),T}catch(M){throw _.value=D,$.value=$.value.filter(T=>T.id!==he),w.value=M instanceof Error?M:new Error(String(M)),M}}async function H(){try{await b.stopExecution(h.value)}catch(X){throw w.value=X instanceof Error?X:new Error(String(X)),X}}async function ce(X){const he=[...$.value];$.value=$.value.filter(be=>be.id!==X);try{await b.deleteMessage(h.value,X)}catch(be){throw $.value=he,w.value=be instanceof Error?be:new Error(String(be)),be}}function Z(X){const he=Zr.queueFiles(X);m.value=[...m.value,...he.map(be=>be.pending)];for(const{pending:be,file:B}of he)Zr.executeUpload(h.value,B,be.id,b,D=>{m.value=m.value.map(M=>M.id===be.id?{...M,...D}:M)}).catch(()=>{})}function U(X){m.value=m.value.filter(he=>he.id!==X)}function K(X){return X.path?b.getFileUrl(h.value,X.path):""}function me(X){return X.path?b.getThumbnailUrl(h.value,X.path):""}function ue(X){return X.isImage?X.localPreviewUrl?X.localPreviewUrl:X.path?me(X):null:null}function Q(X){const be=(X instanceof FileList?Array.from(X):Array.isArray(X)?X:[X]).map(B=>{const D=B.type.startsWith("image/");return{id:crypto.randomUUID(),file:B,name:B.name,mimeType:B.type,size:B.size,isImage:D,previewUrl:D?URL.createObjectURL(B):null}});_.value=[..._.value,...be]}function G(X){const he=_.value.find(be=>be.id===X);he?.previewUrl&&URL.revokeObjectURL(he.previewUrl),_.value=_.value.filter(be=>be.id!==X)}function ae(){_.value.forEach(X=>{X.previewUrl&&URL.revokeObjectURL(X.previewUrl)}),_.value=[]}function ie(X,he){return V.has(X)||V.set(X,new Set),V.get(X).add(he),()=>{const be=V.get(X);be&&(be.delete(he),be.size===0&&V.delete(X))}}function xe(){E?.disconnect(),E=null,g.value="disconnected"}return Ve(h,(X,he)=>{X!==he&&(xe(),$.value=[],w.value=null,m.value=[],v.value=[],_.value.forEach(be=>{be.previewUrl&&URL.revokeObjectURL(be.previewUrl)}),_.value=[],a&&ne(),fe(),j())}),He(()=>{a&&ne(),fe(),j()}),ct(()=>{E?.disconnect(),V.clear(),_.value.forEach(X=>{X.previewUrl&&URL.revokeObjectURL(X.previewUrl)})}),{threadId:h,options:y,messages:$,workblocks:z,subagentBlocks:A,groupedMessages:oe,status:g,connectionStatus:g,isLoading:d,loading:d,error:w,sendMessage:J,stopExecution:H,deleteMessage:ce,onEvent:ie,subscribeToEvent:ie,files:P,addFiles:Z,removeFile:U,getFileUrl:K,getThumbnailUrl:me,getPreviewUrl:ue,attachments:_,addAttachment:Q,removeAttachment:G,clearAttachments:ae}}var Io=Se({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},useSubagentBlocks:{type:Boolean,default:void 0},depth:{type:Number,default:void 0},includeSilent:{type:Boolean,default:void 0},endpoint:{type:String,default:void 0}},setup(e,{slots:n}){const a={};e.preload!==void 0&&(a.preload=e.preload),e.live!==void 0&&(a.live=e.live),e.useWorkblocks!==void 0&&(a.useWorkblocks=e.useWorkblocks),e.useSubagentBlocks!==void 0&&(a.useSubagentBlocks=e.useSubagentBlocks),e.depth!==void 0&&(a.depth=e.depth),e.includeSilent!==void 0&&(a.includeSilent=e.includeSilent),e.endpoint!==void 0&&(a.endpoint=e.endpoint);const s=So(()=>e.threadId,a);return mn(Ra,s),()=>n.default?.()}});function ja(){const e=xa(Ra);if(!e)throw new Error('useThread must be used within a <ThreadProvider>. Wrap your component with <ThreadProvider threadId="...">.');return e}function To(e,n){const a=`${n.props.type}__${e}`,s=`formkit-${e}`,l=n.props.family?`family:${n.props.family}__${e}`:"",u=`${a}__${l}`;if(!(u in Lt)){const i=Lt[a]??Mo[e]??{};i[s]=!0,l in Lt?Lt[u]={...Lt[l],...i}:Lt[u]=i}return Lt[u]??{[s]:!0}}const Lt={"family:button__wrapper":{"group-data-[disabled=true]:grayscale":!0},"family:button__input":{"appearance-none":!0,"[color-scheme:light]":!0,"dark:[color-scheme:dark]":!0,"selection:bg-accent-100":!0,"selection:text-zinc-700":!0,"group-data-[has-overlay]:selection:!text-transparent":!0,"font-bold":!0,"rounded-sm":!0,"outline-hidden":!0,flex:!0,"!text-xs":!0,"px-7":!0,"py-3":!0,"items-center":!0,"mb-1.5":!0,"text-xs":!0,"ring-accent-400":!0,"focus-visible:ring-2":!0,"focus-visible:ring-offset-2":!0,"group-data-[disabled]:!cursor-not-allowed":!0,"shadow-none":!0,"group-data-[prefix-icon]:pl-5":!0,"group-data-[suffix-icon]:pr-5":!0,border:!0,"border-accent-500":!0,"text-accent-500":!0,"group-[&]/repeater:shadow-none":!0,"group-[&]/multistep:shadow-none":!0,"dark:border-accent-500":!0},"family:box__wrapper":{"inline-flex":!0,"items-center":!0,"mb-1":!0,"group-data-[multiple]:mb-0":!0},"family:box__legend":{block:!0,"text-zinc-700":!0,"text-xs":!0,"font-bold":!0,"dark:text-zinc-300":!0,"mb-2":!0},"family:box__input":{"appearance-none":!0,"[color-scheme:light]":!0,"dark:[color-scheme:dark]":!0,"selection:bg-accent-100":!0,"selection:text-zinc-700":!0,"group-data-[has-overlay]:selection:!text-transparent":!0,peer:!0,"pointer-events-none":!0,absolute:!0,"h-0":!0,"w-0":!0,"overflow-hidden":!0,"opacity-0":!0},"family:box__decorator":{"mr-1.5":!0,"bg-white":!0,"ring-accent-400":!0,"peer-checked:border-accent-500":!0,relative:!0,block:!0,"text-base":!0,"w-[1em]":!0,"aspect-[1/1]":!0,border:!0,"border-zinc-300":!0,"text-transparent":!0,"peer-checked:bg-accent-50":!0,"peer-checked:text-accent-500":!0,"peer-focus-visible:ring-2":!0,"peer-focus-visible:ring-offset-1":!0,"select-none":!0,"group-data-[disabled]:!cursor-not-allowed":!0,"peer-disabled:bg-zinc-100":!0,"group-data-[disabled]:grayscale":!0,"shadow-none":!0,"peer-disabled:cursor-not-allowed":!0,"group-[&]/repeater:shadow-none":!0,"group-[&]/multistep:shadow-none":!0,"dark:border-zinc-700":!0,"dark:bg-transparent":!0,"dark:ring-offset-accent-400":!0,"dark:peer-focus-visible:ring-1":!0,"dark:peer-disabled:bg-zinc-600/50":!0,"dark:peer-checked:bg-accent-800":!0,"dark:peer-checked:text-accent-300":!0},"family:box__decoratorIcon":{absolute:!0,"left-1/2":!0,"top-1/2":!0,flex:!0,"h-full":!0,"w-full":!0,"-translate-x-1/2":!0,"-translate-y-1/2":!0},"family:box__option":{"mb-1.5":!0,"last:mb-0":!0,"data-[disabled]:opacity-50":!0,"data-[disabled]:select-none":!0,"group-data-[disabled]:data-[disabled]:opacity-100":!0},"family:box__label":{block:!0,"text-zinc-700":!0,"text-xs":!0,"font-bold":!0,"mb-1":!0,"!mb-0":!0,"!font-normal":!0,"!text-sm":!0,"dark:text-zinc-300":!0},"family:box__optionHelp":{"text-zinc-500":!0,"text-[11px]":!0,"[line-height:1em]":!0,"-mt-1":!0,"mb-1.5":!0,"ml-[min(2em,1.7rem)]":!0,relative:!0,"left-px":!0},"family:box__help":{"text-zinc-500":!0,"text-[11px]":!0,"[line-height:1em]":!0,"dark:text-zinc-400":!0,"mb-1":!0,"group-data-[multiple]:mb-2":!0,"group-data-[multiple]:-mt-1.5":!0},"family:text__wrapper":{flex:!0,"flex-col":!0,"items-start":!0,"justify-start":!0,"mb-1.5":!0,"last:mb-0":!0},"family:text__label":{block:!0,"text-zinc-700":!0,"text-xs":!0,"font-bold":!0,"dark:text-zinc-300":!0,"!inline-flex":!0,"mb-1":!0},"family:text__inner":{"text-sm":!0,flex:!0,"items-center":!0,"w-full":!0,"py-2":!0,"px-3":!0,"rounded-sm":!0,border:!0,"border-zinc-300":!0,"bg-white":!0,"focus-within:ring-1":!0,"focus-within:!ring-accent-400":!0,"focus-within:!border-accent-400":!0,"group-data-[invalid]:border-red-400":!0,"group-data-[invalid]:ring-1":!0,"group-data-[invalid]:ring-red-400":!0,"group-data-[disabled]:bg-zinc-100":!0,"group-data-[disabled]:!cursor-not-allowed":!0,"shadow-none":!0,"group-[&]/repeater:shadow-none":!0,"group-[&]/multistep:shadow-none":!0,"dark:bg-transparent":!0,"dark:border-zinc-700":!0,"dark:group-data-[disabled]:bg-zinc-800/5":!0,"dark:group-data-[invalid]:border-red-400":!0,"dark:group-data-[invalid]:ring-red-400":!0},"family:text__input":{"appearance-none":!0,"[color-scheme:light]":!0,"dark:[color-scheme:dark]":!0,"selection:text-zinc-700":!0,"group-data-[has-overlay]:selection:!text-transparent":!0,"text-sm":!0,"text-zinc-700":!0,"min-w-0":!0,"min-h-[1.5em]":!0,grow:!0,"outline-hidden":!0,"bg-transparent":!0,"selection:bg-accent-100":!0,"placeholder:text-zinc-400":!0,"group-data-[disabled]:!cursor-not-allowed":!0,"dark:placeholder-zinc-400/50":!0,"dark:text-zinc-300":!0,"border-none":!0,"p-0":!0,"focus:ring-0":!0},"family:text__prefixIcon":{flex:!0,"items-center":!0,"-ml-1":!0,"mr-2":!0,"text-sm":!0,"h-[1em]":!0,"w-[1em]":!0,"shrink-0":!0,"[&>svg]:w-full":!0,"text-zinc-600":!0,"dark:text-zinc-300":!0},"family:text__suffixIcon":{flex:!0,"items-center":!0,"-mr-1":!0,"ml-2":!0,"text-sm":!0,"h-[1em]":!0,"w-[1em]":!0,"shrink-0":!0,"[&>svg]:w-full":!0,"text-zinc-600":!0,"dark:text-zinc-300":!0},"family:dropdown__wrapper":{"mb-1.5":!0},"family:dropdown__inner":{relative:!0,flex:!0,"items-center":!0,"w-full":!0,"py-2":!0,"px-3":!0,"text-sm":!0,"bg-white":!0,border:!0,"border-zinc-300":!0,"rounded-sm":!0,"group-data-[is-multiline]:!rounded-sm":!0,"focus-within:ring-1":!0,"focus-within:!ring-accent-400":!0,"focus-within:!border-accent-400":!0,"group-data-[invalid]:border-red-400":!0,"group-data-[invalid]:ring-1":!0,"group-data-[invalid]:ring-red-400":!0,"group-data-[disabled]:bg-zinc-100":!0,"group-data-[disabled]:!cursor-not-allowed":!0,"shadow-none":!0,"group-[&]/repeater:shadow-none":!0,"group-[&]/multistep:shadow-none":!0,"dark:bg-transparent":!0,"dark:border-zinc-700":!0,"dark:group-data-[disabled]:bg-zinc-700/40":!0,"dark:group-data-[invalid]:border-red-400":!0,"dark:group-data-[invalid]:ring-red-400":!0},"family:dropdown__input":{"appearance-none":!0,"[color-scheme:light]":!0,"dark:[color-scheme:dark]":!0,"selection:text-zinc-700":!0,"group-data-[has-overlay]:selection:!text-transparent":!0,grow:!0,"p-0":!0,"text-sm":!0,"text-zinc-700":!0,"text-ellipsis":!0,"min-w-0":!0,"outline-hidden":!0,"bg-transparent":!0,"group-data-[disabled]:!cursor-not-allowed":!0,"group-data-[prefix-icon]:!pl-0":!0,"group-data-[suffix-icon]:!pr-0":!0,"placeholder:text-zinc-400":!0,"selection:bg-accent-100":!0,"dark:placeholder:text-zinc-500":!0,"dark:text-zinc-300":!0,"border-none":!0,"focus:ring-0":!0,"bg-none":!0},"family:dropdown__listboxButton":{"w-[2.5em]":!0,"self-stretch":!0,"text-sm":!0,flex:!0,"items-center":!0,"text-zinc-700":!0,"z-10":!0,"dark:text-zinc-300":!0,"data-[disabled]:cursor-not-allowed":!0},"family:dropdown__removeSelection":{"w-[2.5em]":!0,"self-stretch":!0,"text-sm":!0,flex:!0,"items-center":!0,"text-zinc-700":!0,"hover:text-red-400":!0,"z-10":!0,"dark:text-zinc-300":!0},"family:dropdown__controlLabel":{absolute:!0,"opacity-0":!0,"pointer-events-none":!0,"text-[0px]":!0},"family:dropdown__selectIcon":{"text-sm":!0,"inline-flex":!0,"justify-center":!0,"w-[2.5em]":!0,relative:!0,"my-auto":!0,"[&>svg]:w-[1em]":!0,"[&>svg]:mx-auto":!0},"family:dropdown__closeIcon":{"text-sm":!0,"w-[0.75em]":!0,relative:!0,"m-auto":!0},"family:dropdown__prefixIcon":{flex:!0,"items-center":!0,"-ml-1":!0,"mr-2":!0,"text-sm":!0,"h-[1em]":!0,"w-[1em]":!0,"shrink-0":!0,"[&>svg]:w-full":!0,"!ml-2":!0,"!mr-0":!0,"text-zinc-600":!0,"dark:text-zinc-300":!0},"family:dropdown__suffixIcon":{flex:!0,"items-center":!0,"-mr-1":!0,"ml-2":!0,"text-sm":!0,"h-[1em]":!0,"w-[1em]":!0,"shrink-0":!0,"[&>svg]:w-full":!0,"!mr-2":!0,"!ml-0":!0,"text-zinc-600":!0,"dark:text-zinc-300":!0},"family:dropdown__dropdownWrapper":{"mt-2":!0,"empty:hidden":!0,"group-data-[expanded]:opacity-100":!0,"bg-white":!0,"rounded-lg":!0,border:!0,"border-zinc-300":!0,"dark:bg-zinc-800":!0,"dark:border-zinc-600":!0},"family:dropdown__listitemGroup":{"group/optgroup":!0,"last:pb-0":!0,"border-t":!0,"border-b":!0,"-mb-px":!0,"border-zinc-200":!0,"dark:border-zinc-700":!0},"family:dropdown__groupLabel":{block:!0,"pt-1.5":!0,"pb-1":!0,"px-2.5":!0,"font-bold":!0,"pointer-events-none":!0,"text-zinc-500":!0,"dark:text-zinc-500":!0},"family:dropdown__listbox":{"empty:hidden":!0},"family:dropdown__listitem":{relative:!0,flex:!0,"items-center":!0,"px-2":!0,"py-1.5":!0,"first:pt-2":!0,"last:pb-2":!0,"first:rounded-t-lg":!0,"last:rounded-b-lg":!0,"text-zinc-700":!0,"text-sm":!0,"data-[is-active]:bg-accent-100":!0,"dark:text-zinc-200":!0,"dark:data-[is-active]:text-zinc-700":!0},"family:dropdown__selectedIcon":{flex:!0,absolute:!0,"items-center":!0,"text-accent-500":!0,"left-2":!0,"text-sm":!0,"h-[1em]":!0,"w-[1em]":!0,"shrink-0":!0,"[&>svg]:w-full":!0},"family:dropdown__option":{"ml-[1.5em]":!0},"family:dropdown__loadMore":{"data-[is-active]:bg-accent-100":!0},"family:dropdown__loadMoreInner":{flex:!0,"text-xs":!0,"text-zinc-500":!0,"p-2":!0,"items-center":!0,"justify-center":!0,"[&>span]:mr-2":!0,"cursor-pointer":!0,"dark:text-zinc-200":!0,"dark:hover:text-accent-400":!0},"family:dropdown__selectionWrapper":{grow:!0,flex:!0,"items-center":!0,"text-zinc-700":!0},"family:dropdown__selection":{grow:!0,"text-zinc-700":!0,"group-data-[multiple]:p-2":!0,"dark:text-zinc-300":!0},"family:dropdown__tagsWrapper":{"w-full":!0},"family:dropdown__tagWrapper":{"group/tag":!0,"rounded-sm":!0,"mr-1":!0,"mb-1":!0,"outline-hidden":!0,"data-[active-selection=true]:ring-2":!0,"data-[active-selection=true]:ring-accent-400":!0},"family:dropdown__tags":{"inline-flex":!0,"flex-wrap":!0,"items-center":!0,"w-full":!0,"-mb-1":!0,"empty:mb-0":!0},"family:dropdown__tag":{flex:!0,"items-center":!0,"cursor-default":!0,"rounded-sm":!0,"text-xs":!0,"px-1.5":!0,"py-0.5":!0,"bg-accent-500":!0,"text-white":!0,"[&>[type=button]]:!w-[0.5em]":!0,"[&>[type=button]]:aspect-[1/1]":!0,"[&>[type=button]]:!text-inherit":!0,"[&>[type=button]]:cursor-pointer":!0,"group-data-[active-selection=true]/tag:bg-accent-300":!0,"group-data-[active-selection=true]/tag:text-zinc-700":!0},"family:dropdown__tagLabel":{"mr-1":!0},"family:dropdown__emptyMessage":{flex:!0,"items-center":!0,"justify-center":!0,"px-4":!0,"py-3":!0,"text-zinc-500":!0,"text-sm":!0,"dark:text-zinc-400":!0},button__input:{"appearance-none":!0,"[color-scheme:light]":!0,"dark:[color-scheme:dark]":!0,"selection:bg-accent-100":!0,"selection:text-zinc-700":!0,"group-data-[has-overlay]:selection:!text-transparent":!0,"bg-accent-50":!0,"hover:bg-accent-100":!0,"dark:text-accent-500":!0,"dark:bg-transparent":!0,"dark:hover:bg-accent-50/5":!0},checkbox__decorator:{"rounded-sm":!0},checkbox__decoratorIcon:{"max-w-[66.66%]":!0},color__inner:{"!w-auto":!0,"!p-1.5":!0,"!inline-flex":!0,"group-data-[prefix-icon]:border":!0,"group-data-[prefix-icon]:border-zinc-300":!0,"group-data-[suffix-icon]:border":!0,"group-data-[suffix-icon]:border-zinc-300":!0,"dark:group-data-[prefix-icon]:border-zinc-700":!0,"dark:group-data-[suffix-icon]:border-zinc-700":!0},color__input:{"appearance-none":!0,"[color-scheme:light]":!0,"dark:[color-scheme:dark]":!0,"selection:bg-accent-100":!0,"selection:text-zinc-700":!0,"group-data-[has-overlay]:selection:!text-transparent":!0,"!w-14":!0,"bg-transparent":!0,"cursor-pointer":!0,"rounded-sm":!0,"overflow-clip":!0,"[&::-webkit-color-swatch-wrapper]:p-0":!0,"[&::-webkit-color-swatch]:border-none":!0,"[&::-moz-color-swatch]:border-none":!0,"group-data-[prefix-icon]:mx-2":!0,"group-data-[suffix-icon]:mx-2":!0},color__prefixIcon:{flex:!0,"items-center":!0,"-ml-1":!0,"mr-2":!0,"text-sm":!0,"h-[1em]":!0,"w-[1em]":!0,"shrink-0":!0,"[&>svg]:w-full":!0,"group-data-[prefix-icon]:m-1.5":!0,"group-data-[prefix-icon]:mr-0":!0},color__suffixIcon:{flex:!0,"items-center":!0,"-mr-1":!0,"ml-2":!0,"text-sm":!0,"h-[1em]":!0,"w-[1em]":!0,"shrink-0":!0,"[&>svg]:w-full":!0,"group-data-[suffix-icon]:m-1.5":!0,"group-data-[prefix-icon]:ml-0":!0},date__input:{"appearance-none":!0,"[color-scheme:light]":!0,"dark:[color-scheme:dark]":!0,"selection:bg-accent-100":!0,"selection:text-zinc-700":!0,"group-data-[has-overlay]:selection:!text-transparent":!0,"focus:[&::-webkit-datetime-edit-day-field]:bg-accent-100":!0,"focus:[&::-webkit-datetime-edit-month-field]:bg-accent-100":!0,"focus:[&::-webkit-datetime-edit-year-field]:bg-accent-100":!0},"datetime-local__input":{"appearance-none":!0,"[color-scheme:light]":!0,"dark:[color-scheme:dark]":!0,"selection:bg-accent-100":!0,"selection:text-zinc-700":!0,"group-data-[has-overlay]:selection:!text-transparent":!0,"focus:[&::-webkit-datetime-edit-day-field]:bg-accent-100":!0,"focus:[&::-webkit-datetime-edit-month-field]:bg-accent-100":!0,"focus:[&::-webkit-datetime-edit-year-field]:bg-accent-100":!0,"focus:[&::-webkit-datetime-edit-hour-field]:bg-accent-100":!0,"focus:[&::-webkit-datetime-edit-minute-field]:bg-accent-100":!0,"focus:[&::-webkit-datetime-edit-ampm-field]:bg-accent-100":!0},file__fileList:{"group/list":!0,peer:!0,"w-full":!0,"min-w-0":!0,"data-[has-multiple]:mb-[1.25em]":!0},file__fileItemIcon:{"h-[1em]":!0,"w-[1em]":!0,"mr-2":!0,"shrink-0":!0},file__fileItem:{flex:!0,"min-w-0":!0,"items-center":!0,"text-zinc-700":!0,"mb-1.5":!0,"last:mb-0":!0,"dark:text-zinc-300":!0},file__fileName:{truncate:!0,"min-w-0":!0,"w-full":!0,shrink:!0,"leading-5":!0,"group-data-[has-multiple]/list:text-xs":!0},file__fileRemove:{"right-2":!0,"ring-accent-400":!0,"rounded-sm":!0,"z-20":!0,flex:!0,"appearance-none":!0,"items-center":!0,"text-[0px]":!0,"outline-hidden":!0,"hover:!text-red-400":!0,"focus-visible:ring-2":!0,"group-data-[disabled]:pointer-events-none":!0,"group-data-[disabled]:!text-zinc-500":!0,"peer-data-[has-multiple]:absolute":!0,"peer-data-[has-multiple]:bottom-[max(0.5em,8px)]":!0,"peer-data-[has-multiple]:left-3":!0,"peer-data-[has-multiple]:text-accent-500":!0,"peer-data-[has-multiple]:text-[11px]":!0,"[line-height:1em]":!0,"peer-data-[has-multiple]:whitespace-nowrap":!0,"group-data-[prefix-icon]:peer-data-[has-multiple]:left-2":!0,"dark:hover:!text-red-400":!0},file__fileRemoveIcon:{block:!0,"text-base":!0,"w-[0.75em]":!0,relative:!0,"z-10":!0},file__inner:{relative:!0,"cursor-pointer":!0,"group-data-[has-multiple]:rounded-sm":!0},file__input:{"appearance-none":!0,"[color-scheme:light]":!0,"dark:[color-scheme:dark]":!0,"selection:bg-accent-100":!0,"selection:text-zinc-700":!0,"group-data-[has-overlay]:selection:!text-transparent":!0,"cursor-pointer":!0,"text-transparent":!0,absolute:!0,"inset-0":!0,"opacity-0":!0,"z-10":!0,"file:pointer-events-none":!0,"file:w-0":!0,"file:h-0":!0,"file:overflow-hidden":!0},file__noFiles:{flex:!0,"w-full":!0,"items-center":!0,"text-zinc-400":!0,"dark:text-zinc-500":!0},file__noFilesIcon:{"w-[1em]":!0,"mr-2":!0},form__form:{"group/form":!0},form__actions:{"":!0},form__summaryInner:{"group/summary":!0,border:!0,"border-zinc-300":!0,"bg-white":!0,"rounded-sm":!0,"py-2":!0,"px-3":!0,"shadow-none":!0,"dark:bg-transparent":!0,"dark:border-zinc-700":!0},form__summaryHeader:{"text-base":!0,"text-zinc-700":!0,"font-bold":!0,"mb-2":!0,"dark:text-zinc-300":!0},form__messages:{"":!0},form__message:{"text-red-500":!0,"mb-1.5":!0,"text-[11px]":!0,"[line-height:1em]":!0,"dark:text-red-400":!0,"group-[&]/summary:text-xs":!0},form__messageLink:{"group-[&]/summary:outline-hidden":!0,"group-[&]/summary:focus-visible:ring-2":!0,"group-[&]/summary:ring-accent-500":!0},month__input:{"appearance-none":!0,"[color-scheme:light]":!0,"dark:[color-scheme:dark]":!0,"selection:bg-accent-100":!0,"selection:text-zinc-700":!0,"group-data-[has-overlay]:selection:!text-transparent":!0,"focus:[&::-webkit-datetime-edit-month-field]:bg-accent-100":!0,"focus:[&::-webkit-datetime-edit-year-field]:bg-accent-100":!0},radio__decorator:{"rounded-full":!0},radio__decoratorIcon:{"max-w-[50%]":!0},range__inner:{relative:!0,"!border-none":!0,"!ring-0":!0,"!px-0":!0,"!bg-transparent":!0,"!shadow-none":!0},range__input:{"appearance-none":!0,"[color-scheme:light]":!0,"dark:[color-scheme:dark]":!0,"selection:bg-accent-100":!0,"selection:text-zinc-700":!0,"group-data-[has-overlay]:selection:!text-transparent":!0,"group/input":!0,"cursor-pointer":!0,"[&::-webkit-slider-runnable-track]:bg-zinc-300/50":!0,"[&::-webkit-slider-runnable-track]:h-[0.25em]":!0,"[&::-webkit-slider-runnable-track]:rounded-sm":!0,"dark:[&::-webkit-slider-runnable-track]:bg-zinc-600/50":!0,"[&::-webkit-slider-thumb]:appearance-none":!0,"[&::-webkit-slider-thumb]:w-[0.85em]":!0,"[&::-webkit-slider-thumb]:aspect-[1/1]":!0,"[&::-webkit-slider-thumb]:bg-accent-500":!0,"[&::-webkit-slider-thumb]:rounded-full":!0,"[&::-webkit-slider-thumb]:relative":!0,"[&::-webkit-slider-thumb]:top-1/2":!0,"[&::-webkit-slider-thumb]:-translate-y-1/2":!0,"[&::-webkit-slider-thumb]:group-data-[disabled]:bg-zinc-500":!0,"[&::-webkit-slider-thumb]:group-data-[disabled]:!ring-zinc-200":!0,"[&::-webkit-slider-thumb]:focus-visible:ring-2":!0,"[&::-webkit-slider-thumb]:focus:!ring-accent-400":!0,"[&::-webkit-slider-thumb]:focus:ring-offset-2":!0,"[&::-webkit-slider-thumb]:shadow-none":!0,"dark:[&::-webkit-slider-thumb]:group-data-[disabled]:!ring-zinc-700":!0,"dark:[&::-webkit-slider-thumb]:focus:ring-offset-zinc-700":!0,"[&::-moz-range-track]:bg-zinc-300/50":!0,"[&::-moz-range-track]:h-[0.25]":!0,"[&::-moz-range-track]:rounded-sm":!0,"dark:[&::-moz-range-track]:bg-zinc-600/50":!0,"[&::-moz-range-thumb]:appearance-none":!0,"[&::-moz-range-thumb]:border-none":!0,"[&::-moz-range-thumb]:w-[0.85em]":!0,"[&::-moz-range-thumb]:h-[0.85em]":!0,"[&::-moz-range-thumb]:bg-accent-500":!0,"[&::-moz-range-thumb]:rounded-full":!0,"[&::-moz-range-thumb]:group-data-[disabled]:bg-zinc-500":!0,"[&::-moz-range-thumb]:group-data-[disabled]:!ring-zinc-300":!0,"[&::-moz-range-thumb]:focus-visible:ring-2":!0,"[&::-moz-range-thumb]:focus:!ring-accent-400":!0,"[&::-moz-range-thumb]:focus:ring-offset-2":!0,"[&::-moz-range-thumb]:shadow-none":!0,"dark:[&::-moz-range-thumb]:group-data-[disabled]:!ring-zinc-500":!0,"dark:[&::-moz-range-thumb]:focus:ring-offset-zinc-700":!0},select__wrapper:{"mb-1.5":!0},select__inner:{relative:!0,flex:!0,"items-center":!0,"bg-white":!0,border:!0,"border-zinc-300":!0,"rounded-sm":!0,"focus-within:ring-1":!0,"focus-within:!ring-accent-400":!0,"focus-within:!border-accent-400":!0,"group-data-[invalid]:border-red-400":!0,"group-data-[invalid]:ring-1":!0,"group-data-[invalid]:ring-red-400":!0,"group-data-[disabled]:bg-zinc-100":!0,"group-data-[disabled]:!cursor-not-allowed":!0,"shadow-none":!0,"group-[&]/repeater:shadow-none":!0,"group-[&]/multistep:shadow-none":!0,"group-data-[multiple]:rounded-sm":!0,"dark:bg-transparent":!0,"dark:border-zinc-700":!0,"dark:group-data-[disabled]:bg-zinc-800/5":!0,"dark:group-data-[invalid]:border-red-400":!0,"dark:group-data-[invalid]:ring-red-400":!0},select__input:{"appearance-none":!0,"[color-scheme:light]":!0,"dark:[color-scheme:dark]":!0,"selection:text-zinc-700":!0,"group-data-[has-overlay]:selection:!text-transparent":!0,grow:!0,"p-2":!0,"py-2":!0,"px-3":!0,"pr-[2em]":!0,"text-sm":!0,"text-zinc-700":!0,"text-ellipsis":!0,"min-w-0":!0,"outline-hidden":!0,"bg-transparent":!0,"group-data-[disabled]:!cursor-not-allowed":!0,"group-data-[prefix-icon]:!pl-0":!0,"group-data-[suffix-icon]:!pr-0":!0,"data-[placeholder]:text-zinc-400":!0,"group-data-[multiple]:!p-0":!0,"selection:bg-accent-100":!0,"dark:data-[placeholder]:text-zinc-400/50":!0,"dark:text-zinc-300":!0,"border-none":!0,"focus:ring-0":!0,"bg-none":!0},select__selectIcon:{absolute:!0,"w-[1em]":!0,"text-zinc-700":!0,"pointer-events-none":!0,"right-2":!0,"group-data-[suffix-icon]:mr-[1.5em]":!0,"dark:text-zinc-300":!0},select__optGroup:{"bg-white":!0,"text-zinc-700":!0,"group/optgroup":!0,"group-data-[multiple]:px-1.5":!0,"pt-1.5":!0,"font-bold":!0,"text-xs":!0,"dark:bg-zinc-800":!0,"dark:text-zinc-300":!0},select__option:{"bg-white":!0,"text-zinc-700":!0,"group-data-[disabled]:opacity-50":!0,"group-data-[disabled]:select-none":!0,"group-data-[multiple]:checked:bg-accent-100":!0,"group-data-[multiple]:focus:bg-accent-100":!0,"group-data-[multiple]:text-xs":!0,"group-data-[multiple]:outline-hidden":!0,"group-data-[multiple]:border-none":!0,"group-data-[multiple]:py-1.5":!0,"group-data-[multiple]:px-2":!0,"dark:bg-zinc-800":!0,"dark:text-zinc-300":!0,"dark:group-data-[multiple]:focus:bg-accent-700":!0,"dark:group-data-[multiple]:checked:bg-accent-700":!0},select__prefixIcon:{flex:!0,"items-center":!0,"mr-2":!0,"text-sm":!0,"h-[1em]":!0,"w-[1em]":!0,"shrink-0":!0,"[&>svg]:w-full":!0,"ml-2":!0,"text-zinc-600":!0,"dark:text-zinc-300":!0},select__suffixIcon:{flex:!0,"items-center":!0,"ml-2":!0,"text-sm":!0,"h-[1em]":!0,"w-[1em]":!0,"shrink-0":!0,"[&>svg]:w-full":!0,"mr-2":!0,"text-zinc-600":!0,"dark:text-zinc-300":!0},submit__outer:{group:!0,"max-w-none":!0,"min-w-0":!0,grow:!0,"mb-4":!0,"data-[disabled]:select-none":!0,"text-sm":!0,"data-[disabled]:opacity-100":!0},submit__input:{"appearance-none":!0,"[color-scheme:light]":!0,"dark:[color-scheme:dark]":!0,"selection:bg-accent-100":!0,"selection:text-zinc-700":!0,"group-data-[has-overlay]:selection:!text-transparent":!0,"bg-accent-500":!0,"!text-white":!0,"active:text-accent-100":!0,"active:bg-accent-600":!0,"hover:bg-accent-600":!0,"disabled:border-zinc-300":!0,"disabled:bg-zinc-400":!0,"disabled:text-zinc-100":!0,"group-data-[disabled]:!cursor-not-allowed":!0,"dark:disabled:border-zinc-100":!0,"dark:disabled:bg-zinc-500":!0,"dark:disabled:text-zinc-200":!0,"dark:text-white":!0,"dark:ring-offset-accent-400":!0,"before:transition-all":!0,"group-data-[loading=true]/form:before:content['']":!0,"group-data-[loading=true]/form:before:block":!0,"group-data-[loading=true]/form:before:animate-spin":!0,"group-data-[loading=true]/form:before:w-5":!0,"group-data-[loading=true]/form:before:h-5":!0,"group-data-[loading=true]/form:before:rounded-full":!0,"group-data-[loading=true]/form:before:mr-3":!0,"group-data-[loading=true]/form:before:-ml-1.5":!0,"group-data-[loading=true]/form:before:border-2":!0,"group-data-[loading=true]/form:before:border-solid":!0,"group-data-[loading=true]/form:before:border-white":!0,"group-data-[loading=true]/form:before:border-r-transparent":!0},submit__prefixIcon:{flex:!0,"items-center":!0,"-ml-1":!0,"mr-2":!0,"text-sm":!0,"h-[1em]":!0,"w-[1em]":!0,"shrink-0":!0,"[&>svg]:w-full":!0,"text-zinc-100":!0},submit__suffixIcon:{flex:!0,"items-center":!0,"-mr-1":!0,"ml-2":!0,"text-sm":!0,"h-[1em]":!0,"w-[1em]":!0,"shrink-0":!0,"[&>svg]:w-full":!0,"text-zinc-100":!0},textarea__inner:{flex:!0,"items-center":!0,"mb-1.5":!0,"bg-white":!0,border:!0,"border-zinc-300":!0,"rounded-sm":!0,"focus-within:ring-1":!0,"focus-within:!ring-accent-400":!0,"focus-within:!border-accent-400":!0,"group-data-[invalid]:border-red-400":!0,"group-data-[invalid]:ring-1":!0,"group-data-[invalid]:ring-red-400":!0,"group-data-[disabled]:bg-zinc-100":!0,"shadow-none":!0,"group-[&]/repeater:shadow-none":!0,"group-[&]/multistep:shadow-none":!0,"dark:border-zinc-700":!0,"dark:group-data-[disabled]:bg-zinc-800/5":!0,"dark:group-data-[invalid]:border-red-400":!0,"dark:group-data-[invalid]:ring-red-400":!0,"dark:bg-transparent":!0},textarea__input:{"appearance-none":!0,"[color-scheme:light]":!0,"dark:[color-scheme:dark]":!0,"selection:text-zinc-700":!0,"group-data-[has-overlay]:selection:!text-transparent":!0,"text-sm":!0,"h-24":!0,"text-zinc-700":!0,"min-w-0":!0,grow:!0,shrink:!0,"!py-2":!0,"!px-3":!0,"outline-hidden":!0,"bg-transparent":!0,"selection:bg-accent-100":!0,"placeholder:text-zinc-400":!0,"group-data-[disabled]:!cursor-not-allowed":!0,"dark:placeholder-zinc-400/50":!0,"dark:text-zinc-300":!0,"p-0":!0,"border-none":!0,"focus:ring-0":!0},textarea__prefixIcon:{flex:!0,"items-center":!0,"-ml-1":!0,"mr-2":!0,"text-sm":!0,"h-[1em]":!0,"w-[1em]":!0,"shrink-0":!0,"[&>svg]:w-full":!0,"!ml-2":!0,"!mr-0":!0,"text-zinc-600":!0,"dark:text-zinc-300":!0},textarea__suffixIcon:{flex:!0,"items-center":!0,"-mr-1":!0,"ml-2":!0,"text-sm":!0,"h-[1em]":!0,"w-[1em]":!0,"shrink-0":!0,"[&>svg]:w-full":!0,"!mr-2":!0,"!ml-0":!0,"text-zinc-600":!0,"dark:text-zinc-300":!0},time__input:{"appearance-none":!0,"[color-scheme:light]":!0,"dark:[color-scheme:dark]":!0,"selection:bg-accent-100":!0,"selection:text-zinc-700":!0,"group-data-[has-overlay]:selection:!text-transparent":!0,"focus:[&::-webkit-datetime-edit-hour-field]:bg-accent-100":!0,"focus:[&::-webkit-datetime-edit-minute-field]:bg-accent-100":!0,"focus:[&::-webkit-datetime-edit-ampm-field]:bg-accent-100":!0},week__input:{"appearance-none":!0,"[color-scheme:light]":!0,"dark:[color-scheme:dark]":!0,"selection:bg-accent-100":!0,"selection:text-zinc-700":!0,"group-data-[has-overlay]:selection:!text-transparent":!0,"focus:[&::-webkit-datetime-edit-week-field]:bg-accent-100":!0,"focus:[&::-webkit-datetime-edit-year-field]:bg-accent-100":!0},autocomplete__selections:{flex:!0,"items-center":!0,absolute:!0,"inset-0":!0,"group-data-[multiple]:static":!0,"group-data-[multiple]:block":!0,"group-data-[empty]:hidden":!0,"group-data-[multiple]:mt-1.5":!0},autocomplete__selectionWrapper:{"w-full":!0,flex:!0,"items-center":!0,"py-2":!0,"px-3":!0,"bg-zinc-100":!0,"rounded-sm":!0,"outline-hidden":!0,"group-data-[multiple]:border":!0,"group-data-[multiple]:border-zinc-200":!0,"group-data-[multiple]:mb-1.5":!0,"data-[active-selection=true]:ring-2":!0,"data-[active-selection=true]:ring-accent-400":!0,"dark:bg-zinc-600":!0,"dark:group-data-[multiple]:border-zinc-700":!0},autocomplete__selection:{grow:!0,"dark:text-zinc-200":!0},autocomplete__selectedIcon:{hidden:!0},autocomplete__option:{"ml-[1.5em]":!1,"ml-0":!0},autocomplete__listitem:{"aria-selected:bg-zinc-100":!0,"dark:aria-selected:bg-zinc-800":!0},colorpicker__outer:{group:!0,"max-w-none":!0,"min-w-0":!0,grow:!0,"mb-4":!0,"data-[disabled]:select-none":!0,"data-[disabled]:opacity-50":!0,"text-sm":!0,"data-[disabled]:cursor-not-allowed":!0,"data-[disabled]:pointer-events-none":!0},colorpicker__help:{"text-zinc-500":!0,"text-[11px]":!0,"[line-height:1em]":!0,"dark:text-zinc-400":!0,"group-data-[inline]:-mt-1":!0,"group-data-[inline]:mb-2":!0},colorpicker__inner:{relative:!0,"inline-flex":!0,"!w-auto":!0,"pl-2":!0,"group-data-[inline]:border-none":!0,"group-data-[inline]:shadow-none":!0,"group-data-[inline]:p-0":!0,"group-data-[inline]:bg-transparent":!0,"group-data-[inline]:outline-hidden":!0,"group-data-[inline]:!ring-0":!0,"group-data-[inline]:!w-full":!0,"group-data-[inline]:rounded-sm":!0},colorpicker__swatchPreview:{"w-full":!0,flex:!0,"justify-start":!0,"items-center":!0,"rounded-sm":!0,"text-sm":!0,"cursor-pointer":!0,"outline-hidden":!0},colorpicker__canvasSwatchPreviewWrapper:{relative:!0,"before:content-['']":!0,"before:absolute":!0,"before:inset-0":!0,"before:rounded-sm":!0,"before:shadow-[inset_0_0_0_1px_rgba(0,0,0,0.2)]":!0,"before:z-[2]":!0},colorpicker__canvasSwatchPreview:{"text-sm":!0,"rounded-sm":!0,"aspect-[1/1]":!0,"shrink-0":!0,grow:!0,"!w-[1.5em]":!0},colorpicker__valueString:{"text-sm":!0,"text-zinc-700":!0,"selection:bg-accent-100":!0,"font-mono":!0,"inline-block":!0,"ml-2":!0,"mr-1.5":!0,"dark:text-zinc-300":!0,"dark:selection:text-zinc-700":!0},colorpicker__panel:{absolute:!0,"left-0":!0,"top-full":!0,"z-[99]":!0,flex:!0,"w-[100vw]":!0,"max-w-[18.5em]":!0,"touch-manipulation":!0,"flex-col":!0,"rounded-sm":!0,border:!0,"bg-white":!0,"p-2":!0,"shadow-xs":!0,"group-data-[inline]:static":!0,"group-data-[inline]:max-w-none":!0,"border-zinc-300":!0,"group-data-[inline]:z-auto":!0,"group-data-[inline]:w-full":!0,"group-data-[inline]:shadow-none":!0,"group-data-[inline]:group-data-[disabled]:!cursor-not-allowed":!0,"group-data-[inline]:group-data-[disabled]:!pointer-events-none":!0,"group-data-[inline]:[&:has([id^=swatches]:first-child:last-child)]:w-auto":!0,"group-data-[inline]:[&:has([id^=swatches]:first-child:last-child)_[id^=swatches]>div]:w-[1.5em]":!0,"dark:bg-zinc-800":!0,"dark:border-zinc-700":!0,"dark:group-data-[inline]:bg-transparent":!0,"[@media(max-width:431px)_and_(hover:none)]:group-[&:not([data-inline])]:!fixed":!0,"[@media(max-width:431px)_and_(hover:none)]:group-[&:not([data-inline])]:top-auto":!0,"[@media(max-width:431px)_and_(hover:none)]:group-[&:not([data-inline])]:max-w-none":!0,"[@media(max-width:431px)_and_(hover:none)]:group-[&:not([data-inline])]:bottom-0":!0,"[@media(max-width:431px)_and_(hover:none)]:group-[&:not([data-inline])]:left-0":!0,"[@media(max-width:431px)_and_(hover:none)]:group-[&:not([data-inline])]:rounded-none":!0},colorpicker__panelClose:{flex:!0,"justify-end":!0,"items-center":!0,"text-zinc-600":!0,"mb-1.5":!0,"-mt-1":!0,"border-none":!0,"bg-none":!0,"border-b":!0,"border-zinc-200":!0,"w-[calc(100%+1rem)]":!0,"-ml-2":!0,"pt-0":!0,"pr-2":!0,"pb-1.5":!0,"pl-2":!0,"dark:border-zinc-800":!0},colorpicker__closeIcon:{"w-[2rem]":!0,"aspect-[1/1]":!0,"p-1":!0,"rounded-sm":!0,border:!0,"[&>svg]:w-full":!0,"[&>svg]:aspect-[1/1]":!0,"[&>svg]:max-w-none":!0,"[&>svg]:max-h-none":!0},colorpicker__controlGroup:{grid:!0,"[grid-template-areas:'a_a_a'_'b_c_e'_'b_d_e']":!0,"mb-2":!0},colorpicker__LS:{"[grid-area:a]":!0,relative:!0,"mb-2":!0},colorpicker__canvas:{block:!0,"w-full":!0},colorpicker__canvasLS:{"aspect-[2/1]":!0,"cursor-pointer":!0,"rounded-xs":!0},colorpicker__canvasHue:{"rounded-xs":!0},colorpicker__canvasAlpha:{"rounded-xs":!0},colorpicker__preview:{"rounded-sm":!0,"after:rounded-sm":!0,relative:!0,"inline-flex":!0,"aspect-[1/1]":!0,"overflow-hidden":!0,"[grid-area:b]":!0,"mr-2":!0,"after:absolute":!0,"after:left-0":!0,"after:top-0":!0,"after:h-full":!0,"after:w-full":!0,"after:shadow-[inset_0_0_0_1px_rgba(0,0,0,0.2)]":!0,"after:content-['']":!0,"w-[2em]":!0,"dark:after:shadow-[inset_0_0_0_1px_rgba(255,255,255,0.25)]":!0},colorpicker__hue:{"[grid-area:c]":!0,relative:!0,"inline-flex":!0,"h-3/4":!0},colorpicker__alpha:{"[grid-area:d]":!0,relative:!0,"inline-flex":!0,"h-3/4":!0},colorpicker__eyeDropper:{"[grid-area:e]":!0,"w-[2em]":!0,"ml-2":!0,"inline-flex":!0,"self-center":!0,"justify-center":!0,"justify-self-center":!0,"aspect-[1/1]":!0,"rounded-sm":!0,border:!0,"border-zinc-200":!0,"cursor-pointer":!0,"content-center":!0,"items-center":!0,"text-zinc-600":!0,"dark:border-zinc-800":!0},colorpicker__eyeDropperIcon:{"w-auto":!0,"[&>svg]:w-[1em]":!0,"dark:text-zinc-400":!0},colorpicker__control:{absolute:!0,"bg-white":!0,"shadow-[0_0_0_2px_rgba(255,255,255,1),0_0_0_3px_rgba(0,0,0,0.2)]":!0,"-translate-y-1/2":!0,"-translate-x-1/2":!0,"pointer-events-none":!0,"data-[prevent-focus-style]:shadow-[0_0_0_2px_rgba(255,255,255,1),0_0_0_3px_rgba(0,0,0,0.2)]":!0,"focus-visible:outline-hidden":!0,"focus-visible:ring-2":!0,"focus-visible:ring-offset-2":!0,"focus-visible:ring-accent-400":!0},colorpicker__controlLS:{"w-[10px]":!0,"h-[10px]":!0,"rounded-full":!0},colorpicker__controlHue:{"w-[4px]":!0,"h-[calc(100%-2px)]":!0,"top-1/2":!0,"rounded-sm":!0},colorpicker__controlAlpha:{"w-[4px]":!0,"h-[calc(100%-2px)]":!0,"top-1/2":!0,"rounded-sm":!0},colorpicker__formatField:{flex:!0,"items-center":!0,"justify-center":!0,grow:!0},colorpicker__colorField:{"bg-transparent":!0,"text-zinc-700":!0,border:!0,"border-zinc-200":!0,"dark:border-zinc-800":!0,"dark:text-zinc-300":!0,"dark:selection:text-zinc-700":!0},colorpicker__colorInputGroup:{flex:!0,"items-center":!0,"justify-center":!0,grow:!0},colorpicker__fieldGroup:{flex:!0,"flex-col":!0,"items-center":!0,"justify-center":!0,"w-full":!0,"mr-1":!0,"[&>input]:p-1":!0,"[&>input]:text-sm":!0,"[&>input]:text-zinc-700":!0,"[&>input]:selection:bg-accent-100":!0,"[&>input]:m-0":!0,"[&>input]:grow":!0,"[&>input]:shrink":!0,"[&>input]:w-full":!0,"[&>input]:border":!0,"[&>input]:border-zinc-200":!0,"[&>input]:rounded-sm":!0,"[&>input]:text-center":!0,"[&>input]:appearance-none":!0,"[&>input::-webkit-outer-spin-button]:appearance-none":!0,"[&>input::-webkit-inner-spin-button]:appearance-none":!0,"[&>input::-webkit-inner-spin-button]:m-0":!0,"[&>input:focus]:outline-hidden":!0,"[&>input:focus]:ring-1":!0,"[&>input:focus]:ring-accent-500":!0,"[&>input:focus]:border-accent-500":!0,"max-[431px]:[&>input]:text-base":!0},colorpicker__fieldLabel:{"text-xs":!0,"text-zinc-500":!0,"mt-1.5":!0,"dark:text-zinc-400":!0},colorpicker__formatSwitcher:{flex:!0,"justify-end":!0,"self-start":!0,uppercase:!0,"shrink-0":!0,"p-1":!0,"mt-0.5":!0,"text-zinc-600":!0,"rounded-sm":!0,"select-none":!0,"dark:text-zinc-400":!0},colorpicker__switchIcon:{"[&>svg]:w-3":!0},colorpicker__swatches:{"inline-flex":!0,"flex-wrap":!0,"w-full":!0,"justify-self-center":!0,"min-w-0":!0,"mx-auto":!0,"px-[1px]":!0,"pt-2":!0,"pb-2":!0,"mt-2":!0,"-mb-2":!0,"border-t":!0,"border-zinc-200":!0,"overflow-auto":!0,"max-h-[200px]":!0,"select-none":!0,"first:-mt-[3px]":!0,"first:last:-mb-[3px]":!0,"first:last:pb-[2px]":!0,"first:pt-px":!0,"first:border-t-0":!0,"dark:border-zinc-800":!0},colorpicker__swatchGroup:{flex:!0,"flex-wrap":!0,"w-full":!0,"mb-2":!0,"last:mb-0":!0},colorpicker__swatchGroupLabel:{"ml-1":!0,block:!0,"w-full":!0,"text-xs":!0,"text-zinc-500":!0,"dark:text-zinc-400":!0},colorpicker__swatch:{relative:!0,"text-sm":!0,"w-[calc((100%/10)-0.5em)]":!0,"max-w-[22px]":!0,"m-[0.16em]":!0,"cursor-pointer":!0,"before:content-['']":!0,"before:absolute":!0,"before:inset-0":!0,"before:rounded-sm":!0,"before:shadow-[inset_0_0_0_1px_rgba(0,0,0,0.2)]":!0,"before:pointer-events-none":!0,"before:z-[2]":!0,"dark:before:shadow-[inset_0_0_0_1px_rgba(255,255,255,0.25)]":!0,"data-[active=true]:after:content-['']":!0,"data-[active=true]:after:block":!0,"data-[active=true]:after:absolute":!0,"data-[active=true]:after:w-1.5":!0,"data-[active=true]:after:h-1.5":!0,"data-[active=true]:after:top-1/2":!0,"data-[active=true]:after:left-1/2":!0,"data-[active=true]:after:pointer-events-none":!0,"data-[active=true]:after:rounded-full":!0,"data-[active=true]:after:-translate-x-1/2":!0,"data-[active=true]:after:-translate-y-1/2":!0,"data-[active=true]:after:bg-white":!0,"data-[active=true]:after:z-[2]":!0,"data-[active=true]:after:ring-1":!0,"data-[active=true]:after:ring-[rgba(0,0,0,0.33)]":!0,"[&>canvas]:block":!0,"[&>canvas]:w-full":!0,"[&>canvas]:aspect-[1/1]":!0,"[&>canvas]:rounded-sm":!0,"[&>canvas:focus-visible]:outline-hidden":!0,"[&>canvas:focus-visible]:ring-2":!0,"[&>canvas:focus-visible]:ring-accent-400":!0,"[&>canvas:focus-visible]:ring-offset-2":!0,"[&>canvas:focus-visible]:ring-offset-white":!0,"dark:[&>canvas:focus-visible]:ring-offset-zinc-700":!0},datepicker__inner:{relative:!0},datepicker__removeSelection:{"self-stretch":!0,"text-sm":!0,flex:!0,"items-center":!0,"ml-1":!0,"mr-2":!0,"text-zinc-700":!0,"hover:text-red-400":!0,"z-10":!0,"dark:text-zinc-300":!0},datepicker__clearIcon:{"[&>svg]:w-[0.75em]":!0},datepicker__panelWrapper:{"group/panel":!0,absolute:!0,"min-w-[20em]":!0,"top-[calc(100%_+_0.5em)]":!0,"left-0":!0,"shadow-[0_0_1.25em_rgba(0,0,0,.25)]":!0,"rounded-sm":!0,"p-4":!0,"bg-white":!0,"z-10":!0,"dark:bg-zinc-800":!0,"[@media(max-width:431px)_and_(hover:none)]:group-[&:not([data-inline])]:!fixed":!0,"[@media(max-width:431px)_and_(hover:none)]:group-[&:not([data-inline])]:top-auto":!0,"[@media(max-width:431px)_and_(hover:none)]:group-[&:not([data-inline])]:max-w-none":!0,"[@media(max-width:431px)_and_(hover:none)]:group-[&:not([data-inline])]:bottom-0":!0,"[@media(max-width:431px)_and_(hover:none)]:group-[&:not([data-inline])]:left-0":!0,"[@media(max-width:431px)_and_(hover:none)]:group-[&:not([data-inline])]:rounded-none":!0,"[@media(max-width:431px)_and_(hover:none)]:group-[&:not([data-inline])]:w-full":!0},datepicker__panelHeader:{grid:!0,"grid-cols-[2.5em_1fr_2.5em]":!0,"justify-center":!0,"items-center":!0,"border-b-2":!0,"border-zinc-200":!0,"mb-2":!0,"pb-2.5":!0,"dark:border-zinc-700":!0,"[@media(max-width:431px)_and_(hover:none)]:group-[&:not([data-inline])]:grid-cols-[2.5em_1fr_2.5em_2.5em]":!0,"[@media(max-width:431px)_and_(hover:none)]:group-[&:not([data-inline])]:group-data-[panel=time]/panel:grid-cols-[2.5em_1fr_2.5em]":!0,"[@media(max-width:431px)_and_(hover:none)]:group-[&:not([data-inline])]:group-data-[panel=month]/panel:grid-cols-[2.5em_1fr_2.5em]":!0},datepicker__panelClose:{"aspect-[1/1]":!0,border:!0,"border-zinc-200":!0,"rounded-sm":!0,flex:!0,"items-center":!0,"justify-center":!0,"text-zinc-700":!0,"[&_svg]:w-[1.25em]":!0,"dark:text-zinc-300":!0,"dark:border-zinc-800":!0,"[@media(max-width:431px)_and_(hover:none)]:group-data-[panel=time]/panel:col-start-3":!0,"[@media(max-width:431px)_and_(hover:none)]:group-data-[panel=month]/panel:col-start-3":!0},datepicker__panel:{flex:!0,"justify-center":!0},datepicker__input:{"appearance-none":!0,"[color-scheme:light]":!0,"dark:[color-scheme:dark]":!0,"selection:bg-accent-100":!0,"selection:text-zinc-700":!0,"group-data-[has-overlay]:selection:!text-transparent":!0,"placeholder:text-zinc-400":!0},datepicker__monthsHeader:{flex:!0,"items-center":!0,"justify-center":!0,"col-start-2":!0,"col-end-2":!0},datepicker__timeHeader:{flex:!0,"items-center":!0,"justify-center":!0,"col-start-2":!0,"col-end-2":!0},datepicker__months:{grid:!0,"grid-cols-3":!0,"w-full":!0},datepicker__month:{"m-1.5":!0,"p-1.5":!0,"text-center":!0,"text-zinc-700":!0,"rounded-sm":!0,"bg-zinc-200":!0,"aria-selected:!bg-accent-500":!0,"aria-selected:!text-white":!0,"focus:outline":!0,"focus:outline-2":!0,"focus:outline-accent-500":!0,"focus:outline-offset-2":!0,"focus:bg-white":!0,"focus:text-zinc-700":!0,"data-[is-extra=true]:opacity-25":!0,"group-data-[disabled=true]:opacity-50":!0,"group-data-[disabled=true]:cursor-default":!0,"group-data-[disabled=true]:pointer-events-none":!0,"dark:bg-zinc-700":!0,"dark:text-zinc-300":!0},datepicker__yearsHeader:{flex:!0,"items-center":!0,"justify-center":!0,"text-zinc-700":!0,"col-start-2":!0,"col-end-2":!0,"dark:text-zinc-300":!0},datepicker__years:{grid:!0,"grid-cols-5":!0,"w-full":!0},datepicker__year:{"text-sm":!0,"text-center":!0,"text-zinc-700":!0,"items-center":!0,"m-1.5":!0,"p-1.5":!0,"rounded-sm":!0,"bg-zinc-200":!0,"aria-selected:!bg-accent-500":!0,"aria-selected:!text-white":!0,"focus:outline":!0,"focus:outline-2":!0,"focus:outline-accent-500":!0,"focus:outline-offset-2":!0,"focus:bg-white":!0,"data-[is-extra=true]:opacity-25":!0,"group-data-[disabled=true]:opacity-50":!0,"group-data-[disabled=true]:cursor-default":!0,"group-data-[disabled=true]:pointer-events-none":!0,"dark:bg-zinc-700":!0,"dark:text-zinc-300":!0},datepicker__weekDays:{grid:!0,"grid-cols-7":!0},datepicker__weekDay:{"w-[2.25em]":!0,"text-zinc-700":!0,"m-1.5":!0,"rounded-sm":!0,"font-medium":!0,lowercase:!0,"dark:text-zinc-500":!0},datepicker__calendarWeeks:{"":!0},datepicker__week:{grid:!0,"grid-cols-7":!0,"group-data-[disabled=true]:opacity-50":!0,"group-data-[disabled=true]:cursor-default":!0,"group-data-[disabled=true]:pointer-events-none":!0},datepicker__dayCell:{flex:!0,"items-center":!0,"justify-center":!0,"text-center":!0,"text-zinc-700":!0,"w-[2.25em]":!0,"h-[2.25em]":!0,"m-1":!0,"p-2":!0,"rounded-sm":!0,"bg-zinc-200":!0,"aria-selected:bg-accent-500":!0,"aria-selected:text-white":!0,"focus:outline":!0,"focus:outline-2":!0,"focus:outline-accent-500":!0,"focus:outline-offset-2":!0,"focus:bg-white":!0,"data-[is-extra=true]:opacity-25":!0,"data-[disabled=true]:opacity-50":!0,"data-[disabled=true]:cursor-default":!0,"data-[disabled=true]:pointer-events-none":!0,"dark:bg-zinc-600":!0,"dark:text-zinc-300":!0,"dark:aria-selected:bg-accent-500":!0,"dark:aria-selected:text-white":!0,"dark:focus:outline-accent-500":!0,"dark:focus:bg-zinc-200":!0,"dark:focus:text-zinc-700":!0},datepicker__timeInput:{"w-full":!0,"border-2":!0,"[color-scheme:light]":!0,"dark:[color-scheme:dark]":!0,"text-zinc-700":!0,"border-zinc-200":!0,"rounded-sm":!0,"p-1.5":!0,"my-2.5":!0,"focus-visible:outline-accent-500":!0,"dark:text-zinc-300":!0,"dark:bg-transparent":!0,"dark:border-zinc-700":!0},datepicker__daysHeader:{flex:!0,"items-center":!0,"justify-center":!0},datepicker__prev:{"mr-auto":!0,"px-2.5":!0,"py-0.5":!0,"hover:bg-zinc-100":!0,"rounded-sm":!0,"col-start-1":!0,"col-end-1":!0,"focus-visible:outline-hidden":!0,"focus-visible:ring-2":!0,"focus-visible:ring-accent-400":!0,"focus-visible:ring-offset-2":!0},datepicker__prevLabel:{hidden:!0},datepicker__prevIcon:{flex:!0,"w-[0.75em]":!0,"select-none":!0,"text-zinc-700":!0,"[&>svg]:w-full":!0,"dark:text-zinc-300":!0},datepicker__dayButton:{"appearance-none":!0,"text-zinc-700":!0,"cursor-pointer":!0,"px-2.5":!0,"py-0.5":!0,"border-2":!0,"border-zinc-200":!0,"rounded-sm":!0,"mx-1":!0,"hover:border-accent-500":!0,"focus-visible:outline-hidden":!0,"focus-visible:ring-2":!0,"focus-visible:ring-accent-400":!0,"focus-visible:ring-offset-2":!0,"dark:text-zinc-300":!0,"dark:border-zinc-700":!0,"dark:hover:border-accent-400":!0},datepicker__monthButton:{"appearance-none":!0,"text-zinc-700":!0,"cursor-pointer":!0,"px-2.5":!0,"py-0.5":!0,"border-2":!0,"border-zinc-200":!0,"rounded-sm":!0,"mx-1":!0,"hover:border-accent-500":!0,"focus-visible:outline-hidden":!0,"focus-visible:ring-2":!0,"focus-visible:ring-accent-400":!0,"focus-visible:ring-offset-2":!0,"dark:text-zinc-300":!0,"dark:border-zinc-700":!0,"dark:hover:border-accent-400":!0},datepicker__yearButton:{"appearance-none":!0,"text-zinc-700":!0,"cursor-pointer":!0,"px-2.5":!0,"py-0.5":!0,"border-2":!0,"border-zinc-200":!0,"rounded-sm":!0,"mx-1":!0,"hover:border-accent-500":!0,"focus-visible:outline-hidden":!0,"focus-visible:ring-2":!0,"focus-visible:ring-accent-400":!0,"focus-visible:ring-offset-2":!0,"dark:text-zinc-300":!0,"dark:border-zinc-700":!0,"dark:hover:border-accent-400":!0},datepicker__next:{"ml-auto":!0,"px-2.5":!0,"py-0.5":!0,"rounded-sm":!0,"hover:bg-zinc-100":!0,"hover:rounded-sm":!0,"col-start-3":!0,"col-end-3":!0,"focus-visible:outline-hidden":!0,"focus-visible:ring-2":!0,"focus-visible:ring-accent-400":!0,"focus-visible:ring-offset-2":!0},datepicker__nextLabel:{hidden:!0},datepicker__nextIcon:{flex:!0,"w-[0.75em]":!0,"select-none":!0,"text-zinc-700":!0,"[&>svg]:w-full":!0,"dark:text-zinc-300":!0},datepicker__openButton:{"appearance-none":!0,"border-0":!0,"bg-transparent":!0,flex:!0,"p-0":!0,"self-stretch":!0,"cursor-pointer":!0,"focus-visible:outline-hidden":!0,"focus-visible:ring-2":!0,"focus-visible:ring-accent-400":!0,"focus-visible:ring-offset-2":!0,"focus-visible:rounded-sm":!0},datepicker__calendarIcon:{"text-zinc-600":!0,"focus-visible:text-accent-500":!0,flex:!0,"w-[1em]":!0,"grow-0":!0,"shrink-0":!0,"self-stretch":!0,"select-none":!0,"[&>svg]:w-full":!0,"[&>svg]:m-auto":!0,"[&>svg]:max-h-[1em]":!0,"[&>svg]:max-w-[1em]":!0},dropdown__placeholder:{"text-zinc-400":!0,grow:!0,"dark:text-zinc-400/50":!0},dropdown__selector:{flex:!0,grow:!0,"justify-between":!0,"w-full":!0,"py-2":!0,"pl-3":!0,"pr-0":!0,"text-sm":!0,"text-zinc-700":!0,"text-left":!0,"group-data-[disabled]:!cursor-not-allowed":!0,"group-data-[prefix-icon]:!pl-0":!0,"group-data-[suffix-icon]:!pr-0":!0,"data-[placeholder]:text-zinc-400":!0,"selection:bg-accent-100":!0,"dark:data-[placeholder]:text-zinc-400/50":!0,"dark:text-zinc-300":!0},dropdown__selectIcon:{"shrink-0":!0},dropdown__selectionsWrapper:{"w-[85%]":!0,"overflow-hidden":!0},dropdown__selection:{"[&>*]:ml-0":!0},dropdown__selections:{"inline-flex":!0,"items-center":!0},dropdown__selectionsItem:{"whitespace-nowrap":!0,"mr-1":!0},dropdown__tagWrapper:{"[&.formkit-dropZone_.formkit-tag]:opacity-25":!0,"[&.formkit-touchDropZone_.formkit-tag]:opacity-25":!0},dropdown__truncationCount:{flex:!0,"items-center":!0,"justify-center":!0,"h-[1.5em]":!0,"rounded-sm":!0,"bg-zinc-400":!0,"text-white":!0,"whitespace-nowrap":!0,"text-[11px]":!0,"[line-height:1em]":!0,"tracking-tighter":!0,"leading-0":!0,"py-1":!0,"px-1":!0,"shrink-0":!0,"my-auto":!0},mask__inner:{relative:!0},mask__input:{"appearance-none":!0,"[color-scheme:light]":!0,"dark:[color-scheme:dark]":!0,"selection:bg-accent-100":!0,"selection:text-zinc-700":!0,"group-data-[has-overlay]:selection:!text-transparent":!0,"group-data-[has-overlay]:!caret-zinc-700":!0,"dark:group-data-[has-overlay]:!caret-zinc-300":!0},rating__inner:{"text-zinc-300":!0},rating__itemsWrapper:{relative:!0,"inline-flex":!0,"focus:border-accent-500":!0},rating__onItemRow:{"h-full":!0,"w-full":!0},rating__offItemRow:{"h-full":!0,"w-full":!0},rating__onItemWrapper:{"[&>*]:w-full":!0,"[&>*]:h-full":!0,"w-full":!0,"h-full":!0,"text-yellow-400":!0},rating__offItemWrapper:{"text-zinc-300":!0,"w-full":!0,"h-full":!0,"[&>*]:w-full":!0,"[&>*]:h-full":!0,"dark:text-zinc-600":!0},rating__ratingItem:{relative:!0,"focus-within:outline":!0,"focus-within:outline-accent-500":!0,"w-[1.5em]":!0,"h-[1.5em]":!0},rating__itemLabelInner:{"h-px":!0,"w-px":!0,"overflow-hidden":!0,absolute:!0,"white-space-nowrap":!0},rating__itemLabel:{absolute:!0,"h-full":!0},rating__ratingIcon:{"w-[1.5em]":!0,"h-[1.5em]":!0,flex:!0},rating__input:{"appearance-none":!0,"[color-scheme:light]":!0,"dark:[color-scheme:dark]":!0,"selection:bg-accent-100":!0,"selection:text-zinc-700":!0,"group-data-[has-overlay]:selection:!text-transparent":!0,"outline-hidden":!0},rating__messages:{"mt-1.5":!0},repeater__outer:{"min-w-0":!0,grow:!0,"mb-4":!0,"text-sm":!0,"group/repeater":!0,"max-w-full":!0},repeater__fieldset:{"min-w-0":!0},repeater__legend:{block:!0,"text-zinc-700":!0,"text-xs":!0,"font-bold":!0,"dark:text-zinc-300":!0,"mb-2":!0},repeater__content:{"min-w-0":!0,grow:!0,"p-5":!0,flex:!0,"flex-col":!0,"align-center":!0,"[&>div[data-type]]:max-w-none":!0,"[&>div[data-type]:last-child]:mb-0":!0},repeater__addButton:{"!mb-0":!0,"group-data-[disabled]/repeater:pointer-events-none":!0,"group-data-[disabled]/repeater:opacity-50":!0,"group-data-[disabled]/repeater:grayscale":!0},repeater__controlLabel:{absolute:!0,"opacity-0":!0,"pointer-events-none":!0,"text-[0px]":!0},repeater__controls:{flex:!0,"flex-col":!0,"items-center":!0,"justify-center":!0,"bg-zinc-50":!0,"p-2":!0,"[&>li]:aspect-[1/1]":!0,"dark:bg-zinc-800":!0,"rounded-sm":!0,"rounded-tl-none":!0,"rounded-bl-none":!0},repeater__downControl:{"w-[1.5em]":!0,"h-[1.5em]":!0,"my-1.5":!0,"mx-auto":!0,flex:!0,"items-center":!0,"appearance-none":!0,"justify-center":!0,"aspect-[1/1]":!0,"text-zinc-500":!0,"hover:text-accent-500":!0,"disabled:hover:text-inherit":!0,"disabled:opacity-25":!0,"disabled:!text-zinc-500":!0,"dark:text-zinc-300":!0,"dark:disabled:!text-zinc-300":!0,"dark:hover:text-accent-400":!0},repeater__upControl:{"w-[1.5em]":!0,"h-[1.5em]":!0,"my-1.5":!0,"mx-auto":!0,flex:!0,"items-center":!0,"appearance-none":!0,"justify-center":!0,"aspect-[1/1]":!0,"text-zinc-500":!0,"hover:text-accent-500":!0,"disabled:hover:text-inherit":!0,"disabled:opacity-25":!0,"disabled:!text-zinc-500":!0,"dark:text-zinc-300":!0,"dark:disabled:!text-zinc-300":!0,"dark:hover:text-accent-400":!0},repeater__removeControl:{"w-[1.5em]":!0,"h-[1.5em]":!0,"my-1.5":!0,"mx-auto":!0,flex:!0,"items-center":!0,"appearance-none":!0,"justify-center":!0,"aspect-[1/1]":!0,"text-zinc-500":!0,"hover:text-accent-500":!0,"disabled:hover:text-inherit":!0,"disabled:opacity-25":!0,"disabled:!text-zinc-500":!0,"dark:text-zinc-300":!0,"dark:disabled:!text-zinc-300":!0,"dark:hover:text-accent-400":!0},repeater__insertControl:{"w-[1.5em]":!0,"h-[1.5em]":!0,"my-1.5":!0,"mx-auto":!0,flex:!0,"items-center":!0,"appearance-none":!0,"justify-center":!0,"aspect-[1/1]":!0,"text-zinc-500":!0,"hover:text-accent-500":!0,"disabled:hover:text-inherit":!0,"disabled:opacity-25":!0,"disabled:!text-zinc-500":!0,"dark:text-zinc-300":!0,"dark:disabled:!text-zinc-300":!0,"dark:hover:text-accent-400":!0},repeater__help:{"text-zinc-500":!0,"text-[11px]":!0,"[line-height:1em]":!0,"dark:text-zinc-400":!0,"mb-2":!0,"-mt-1":!0},repeater__item:{flex:!0,relative:!0,"w-full":!0,"mb-2":!0,"bg-white":!0,border:!0,"border-zinc-200":!0,"rounded-sm":!0,"shadow-none":!0,"dark:border-zinc-700":!0,"dark:bg-transparent":!0,"[&.formkit-dropZone]:opacity-30":!0,"[&.formkit-dropZone]:blur-[2px]":!0},repeater__dragHandleWrapper:{relative:!0,"w-8":!0,"bg-zinc-50":!0,"rounded-sm":!0,"rounded-tr-none":!0,"rounded-br-none":!0,"dark:bg-zinc-800":!0},repeater__dragHandle:{"w-full":!0,"h-full":!0,flex:!0,absolute:!0,"top-0":!0,"left-0":!0,"cursor-grab":!0,"active:cursor-grabbing":!0},repeater__dragHandleIcon:{"w-2":!0,"m-auto":!0,"text-zinc-400":!0,"dark:text-zinc-600":!0,"[&>svg>path]:fill-current":!0},repeater__moveDownIcon:{block:!0,"w-[0.75em]":!0,"aspect-[1/1]":!0},repeater__moveUpIcon:{block:!0,"w-[0.75em]":!0,"aspect-[1/1]":!0},repeater__removeIcon:{block:!0,"w-[1.25em]":!0,"aspect-[1/1]":!0},repeater__addIcon:{block:!0,"w-[1.25em]":!0,"aspect-[1/1]":!0},slider__outer:{group:!0,"max-w-none":!0,"min-w-0":!0,grow:!0,"mb-4":!0,"data-[disabled]:select-none":!0,"data-[disabled]:opacity-50":!0,"text-sm":!0,"data-[disabled]:pointer-events-none":!0},slider__help:{"text-zinc-500":!0,"text-[11px]":!0,"[line-height:1em]":!0,"dark:text-zinc-400":!0,"-mt-0.5":!0,"mb-1.5":!0},slider__sliderInner:{flex:!0,"items-center":!0,"[&>[data-type=number]]:mb-0":!0,"[&>[data-type=number]]:ml-2.5":!0,"[&>[data-type=number]]:shrink":!0,"[&>[data-type=number]]:grow-0":!0,"[&[data-has-mark-labels=true]_[id^=track]]:mb-5":!0},slider__track:{grow:!0,relative:!0,"z-20":!0,"py-2.5":!0,"select-none":!0},slider__trackWrapper:{"px-[2px]":!0,"rounded-full":!0,"bg-zinc-300":!0,"dark:bg-zinc-500":!0},slider__trackInner:{"h-1.5":!0,"mx-0.5":!0,relative:!0},slider__prefixIcon:{flex:!0,"items-center":!0,"-ml-1":!0,"mr-2":!0,"text-sm":!0,"h-[1em]":!0,"w-[1em]":!0,"shrink-0":!0,"[&>svg]:w-full":!0,"text-zinc-600":!0,"dark:text-zinc-300":!0},slider__suffixIcon:{flex:!0,"items-center":!0,"-mr-1":!0,"ml-2":!0,"text-sm":!0,"h-[1em]":!0,"w-[1em]":!0,"shrink-0":!0,"[&>svg]:w-full":!0,"text-zinc-600":!0,"dark:text-zinc-300":!0},slider__fill:{"h-full":!0,"rounded-full":!0,absolute:!0,"top-0":!0,"-mx-1":!0,"bg-accent-500":!0,"group-data-[disabled]:bg-zinc-500":!0},slider__marks:{absolute:!0,"pointer-events-none":!0,"inset-0":!0},slider__mark:{absolute:!0,"top-1/2":!0,"w-[3px]":!0,"h-[3px]":!0,"rounded-full":!0,"-translate-x-1/2":!0,"-translate-y-1/2":!0,"bg-zinc-400":!0,"data-[active=true]:bg-white":!0},slider__markLabel:{absolute:!0,"top-[calc(100%+0.5em)]":!0,"left-1/2":!0,"text-zinc-400":!0,"text-[11px]":!0,"[line-height:1em]":!0,"-translate-x-1/2":!0},slider__handles:{"m-0":!0,"p-0":!0,"list-none":!0},slider__handle:{group:!0,"select-none":!0,"w-4":!0,"h-4":!0,"rounded-full":!0,"bg-white":!0,absolute:!0,"top-1/2":!0,"left-0":!0,"z-30":!0,"-translate-x-1/2":!0,"-translate-y-1/2":!0,"shadow-[inset_0_0_0_1px_rgba(0,0,0,0.1),0_1px_2px_0_rgba(0,0,0,0.5)]":!0,"focus-visible:outline-0":!0,"focus-visible:ring-2":!0,"ring-accent-500":!0,"data-[is-target=true]:z-20":!0,"dark:bg-zinc-200":!0},slider__tooltip:{absolute:!0,"bottom-full":!0,"left-1/2":!0,"-translate-x-1/2":!0,"-translate-y-[4px]":!0,"bg-accent-500":!0,"text-white":!0,"py-1":!0,"px-1.5":!0,"text-xs":!0,"leading-none":!0,"whitespace-nowrap":!0,"rounded-sm":!0,"opacity-0":!0,"pointer-events-none":!0,"transition-opacity":!0,'after:content-[""]':!0,"after:absolute":!0,"after:top-full":!0,"after:left-1/2":!0,"after:-translate-x-1/2":!0,"after:-translate-y-[1px]":!0,"after:border-4":!0,"after:border-transparent":!0,"after:border-t-accent-500":!0,"group-hover:opacity-100":!0,"group-focus-visible:opacity-100":!0,"group-data-[show-tooltip=true]:opacity-100":!0},slider__linkedValues:{flex:!0,"items-start":!0,"justify-between":!0},slider__minValue:{grow:!0,"!max-w-[45%]":!0,"mb-0":!0,"[&>div>div]:relative":!0,'[&>div>div::after]:content-[""]':!0,"[&>div>div::after]:absolute":!0,"[&>div>div::after]:top-1/2":!0,"[&>div>div::after]:left-[105.5%]":!0,"[&>div>div::after]:w-[12%]":!0,"[&>div>div::after]:h-[1px]":!0,"[&>div>div::after]:bg-zinc-300":!0,"dark:[&>div>div::after]:bg-zinc-700":!0},slider__maxValue:{grow:!0,"!max-w-[45%]":!0,"mb-0":!0,relative:!0},slider__chart:{relative:!0,"z-20":!0,"mb-2":!0,flex:!0,"justify-between":!0,"items-center":!0,"w-full":!0,"aspect-[3/1]":!0},slider__chartBar:{absolute:!0,"bottom-0":!0,"h-full":!0,"bg-zinc-400":!0,"data-[active=false]:bg-zinc-300":!0,"dark:bg-zinc-500":!0,"dark:data-[active=false]:bg-zinc-600":!0},taglist__inner:{"py-2":!0,"pr-0":!0,"pl-0":!0},taglist__tags:{"pl-3":!0},taglist__tagWrapper:{"[&.formkit-dropZone_.formkit-tag]:opacity-25":!0,"[&.formkit-touchDropZone_.formkit-tag]:opacity-25":!0},taglist__input:{"appearance-none":!0,"[color-scheme:light]":!0,"dark:[color-scheme:dark]":!0,"selection:bg-accent-100":!0,"selection:text-zinc-700":!0,"group-data-[has-overlay]:selection:!text-transparent":!0,"!p-0":!0,"!w-[0%]":!0,"min-w-[1em]":!0,"inline-block":!0,"-mt-1":!0,"first:mt-0":!0,"first:mb-1":!0},taglist__listboxButton:{"ml-auto":!0,"shrink-0":!0},toggle__outer:{group:!0,"min-w-0":!0,grow:!0,"mb-4":!0,"data-[disabled]:select-none":!0,"data-[disabled]:opacity-50":!0,"text-sm":!0,"max-w-none":!0},toggle__altLabel:{block:!0,"w-full":!0,"mb-1.5":!0,"font-bold":!0,"text-[11px]":!0,"[line-height:1em]":!0,"text-zinc-700":!0,"dark:text-zinc-300":!0},toggle__inner:{peer:!0,"inline-block":!0,"mr-2":!0},toggle__input:{"appearance-none":!0,"[color-scheme:light]":!0,"dark:[color-scheme:dark]":!0,"selection:bg-accent-100":!0,"selection:text-zinc-700":!0,"group-data-[has-overlay]:selection:!text-transparent":!0,peer:!0,absolute:!0,"opacity-0":!0,"w-0":!0,"h-0":!0},toggle__label:{block:!0,"text-zinc-700":!0,"text-xs":!0,"font-bold":!0,"mb-1":!0,"dark:text-zinc-300":!0,"peer-first:font-normal":!0,"peer-first:mb-0":!0},toggle__innerLabel:{absolute:!0,"text-zinc-200":!0,"text-[10px]":!0,"font-bold":!0,"select-none":!0,"left-full":!0,"top-1/2":!0,"-translate-x-full":!0,"-translate-y-1/2":!0,"px-1":!0},toggle__thumb:{relative:!0,"p-0.5":!0,"left-0":!0,"aspect-[1/1]":!0,"rounded-full":!0,"transition-all":!0,"w-[1.25em]":!0,"bg-zinc-50":!0,"text-zinc-600":!0,"shadow-base":!0},toggle__track:{"p-0.5":!0,"min-w-[3em]":!0,relative:!0,"cursor-pointer":!0,"select-none":!0,"rounded-full":!0,"transition-all":!0,"bg-zinc-400":!0,"peer-checked:bg-accent-500":!0,"peer-checked:[&>div:last-child]:left-full":!0,"peer-checked:[&>div:last-child]:-translate-x-full":!0,"peer-checked:[&>div:first-child:not(:last-child)]:left-0":!0,"peer-checked:[&>div:first-child:not(:last-child)]:translate-x-0":!0,"shadow-none":!0,"peer-focus-visible:ring-2":!0,"peer-focus-visible:ring-accent-400":!0,"peer-focus-visible:ring-offset-2":!0,"dark:bg-zinc-500":!0},toggle__valueLabel:{"font-bold":!0,"text-[11px]":!0,"[line-height:1em]":!0,"text-zinc-700":!0,"dark:text-zinc-300":!0},toggle__wrapper:{flex:!0,"flex-wrap":!0,"items-center":!0,"mb-1.5":!0},togglebuttons__wrapper:{"mb-1.5":!0},togglebuttons__options:{"group/options":!0,"inline-flex":!0,"data-[vertical=true]:flex-col":!0},togglebuttons__option:{"group/option":!0},togglebuttons__input:{"appearance-none":!0,"[color-scheme:light]":!0,"dark:[color-scheme:dark]":!0,"selection:bg-accent-100":!0,"selection:text-zinc-700":!0,"group-data-[has-overlay]:selection:!text-transparent":!0,"!px-4":!0,"!mb-0":!0,relative:!0,"focus:z-10":!0,"group-data-[vertical=true]/options:w-full":!0,"justify-center":!0,"bg-accent-50":!0,"disabled:opacity-50":!0,"disabled:cursor-not-allowed":!0,"group-data-[disabled]:disabled:opacity-100":!0,"dark:bg-transparent":!0,"dark:disabled:bg-transparent":!0,"dark:disabled:text-accent-500":!0,"dark:text-accent-500":!0,"aria-[pressed=true]:bg-accent-500":!0,"aria-[pressed=true]:text-white":!0,"dark:aria-[pressed=true]:bg-accent-500":!0,"dark:aria-[pressed=true]:text-white":!0,"group-[&]/option:!rounded-none":!0,"group-data-[vertical=false]/options:group-first/option:!rounded-sm":!0,"group-data-[vertical=true]/options:group-first/option:!rounded-sm":!0,"group-data-[vertical=false]/options:group-first/option:!rounded-tr-none":!0,"group-data-[vertical=false]/options:group-first/option:!rounded-br-none":!0,"group-data-[vertical=true]/options:group-first/option:!rounded-bl-none":!0,"group-data-[vertical=true]/options:group-first/option:!rounded-br-none":!0,"group-data-[vertical=false]/options:group-last/option:!rounded-sm":!0,"group-data-[vertical=true]/options:group-last/option:!rounded-sm":!0,"group-data-[vertical=false]/options:group-last/option:!rounded-tl-none":!0,"group-data-[vertical=false]/options:group-last/option:!rounded-bl-none":!0,"group-data-[vertical=true]/options:group-last/option:!rounded-tl-none":!0,"group-data-[vertical=true]/options:group-last/option:!rounded-tr-none":!0,"group-data-[vertical=false]/options:group-[&]/option:!border-r-0":!0,"group-data-[vertical=false]/options:group-last/option:!border-r":!0,"group-data-[vertical=false]/options:group-[&]/option:aria-[pressed=true]:border-x-accent-500":!0,"group-data-[vertical=false]/options:group-first/option:aria-[pressed=true]:border-l-accent-500":!0,"group-data-[vertical=false]/options:group-last/option:aria-[pressed=true]:border-r-accent-500":!0,"dark:group-data-[vertical=false]/options:group-[&]/option:aria-[pressed=true]:border-x-accent-500":!0,"dark:group-data-[vertical=false]/options:group-first/option:aria-[pressed=true]:border-l-accent-500":!0,"dark:group-data-[vertical=false]/options:group-last/option:aria-[pressed=true]:border-r-accent-500":!0,"group-data-[vertical=true]/options:group-[&]/option:!border-b-0":!0,"group-data-[vertical=true]/options:group-last/option:!border-b":!0,"group-data-[vertical=true]/options:group-[&]/option:aria-[pressed=true]:border-y-accent-500":!0,"group-data-[vertical=true]/options:group-first/option:aria-[pressed=true]:border-t-accent-500":!0,"group-data-[vertical=true]/options:group-last/option:aria-[pressed=true]:border-b-accent-500":!0,"dark:group-data-[vertical=true]/options:group-[&]/option:aria-[pressed=true]:border-y-accent-500":!0,"dark:group-data-[vertical=true]/options:group-first/option:aria-[pressed=true]:border-t-accent-500":!0,"dark:group-data-[vertical=true]/options:group-last/option:aria-[pressed=true]:border-b-accent-500":!0},transferlist__outer:{group:!0,"min-w-0":!0,grow:!0,"mb-4":!0,"data-[disabled]:select-none":!0,"data-[disabled]:opacity-50":!0,"text-sm":!0,"max-w-none":!0,"[&_.dnd-placeholder]:bg-accent-500":!0,"[&_.dnd-placeholder]:text-white":!0},transferlist__wrapper:{flex:!0,"flex-col":!0,"sm:flex-row":!0,"justify-between":!0,"w-full":!0,"max-w-none":!0},transferlist__help:{"text-zinc-500":!0,"text-[11px]":!0,"[line-height:1em]":!0,"dark:text-zinc-400":!0,"pb-2":!0},transferlist__transferlist:{grow:!0,shrink:!0,"min-w-0":!0,"shadow-none":!0,"group-[&]/repeater:shadow-none":!0,"group-[&]/multistep:shadow-none":!0,"aspect-[4/5]":!0,flex:!0,"flex-col":!0,"h-[350px]":!0,border:!0,"border-zinc-200":!0,"rounded-sm":!0,"overflow-hidden":!0,"select-none":!0,"[&:has(:focus-visible)]:ring-1":!0,"[&:has(:focus-visible)]:ring-accent-400":!0,"dark:border-zinc-800":!0,"dark:bg-zinc-900/50":!0},transferlist__transferlistHeader:{flex:!0,"bg-zinc-100":!0,"text-zinc-600":!0,"text-xs":!0,"justify-between":!0,"items-center":!0,"border-b":!0,"border-zinc-200":!0,"py-2":!0,"px-2.5":!0,"dark:bg-zinc-700":!0,"dark:border-zinc-800":!0,"dark:text-zinc-400":!0},transferlist__transferlistHeaderItemCount:{"ml-auto":!0,"text-xs":!0,"min-w-[1.5em]":!0,"[line-height:1.5em]":!0,"px-2":!0,"text-center":!0,"rounded-lg":!0,"bg-zinc-200":!0,"text-zinc-700":!0,"dark:bg-zinc-500":!0,"dark:text-zinc-300":!0},transferlist__transferlistListItems:{"list-none":!0,"bg-white":!0,"h-full":!0,"overflow-x-hidden":!0,"overflow-y-auto":!0,"dark:bg-transparent":!0,"outline-hidden":!0},transferlist__transferlistListItem:{"py-2":!0,"px-2":!0,"text-zinc-700":!0,"ring-1":!0,"ring-zinc-200":!0,"aria-selected:bg-accent-100":!0,"data-[is-active=true]:bg-accent-100":!0,"data-[is-active=true]:ring-accent-200":!0,"aria-selected:ring-accent-200":!0,relative:!0,flex:!0,"cursor-pointer":!0,"items-center":!0,"bg-white":!0,"pl-[1.5em]":!0,"first:-mt-px":!0,"first:border-t":!0,"aria-selected:z-[2]":!0,"aria-selected:border-transparent":!0,"aria-selected:ring-1":!0,"data-[is-active=true]:z-[2]":!0,"data-[is-active=true]:border-transparent":!0,"data-[is-active=true]:ring-1":!0,"group-data-[is-max=true]:cursor-not-allowed":!0,"dark:bg-zinc-800":!0,"dark:text-zinc-300":!0,"dark:data-[is-active=true]:bg-accent-800":!0,"dark:aria-selected:bg-accent-800":!0,"dark:ring-zinc-700":!0,"dark:data-[is-active=true]:ring-accent-600":!0,"dark:aria-selected:ring-accent-600":!0,"[&.formkit-dropZone]:bg-accent-100":!0,"[&.formkit-selectionDropZone]:bg-accent-100":!0,"[&.formkit-touchDropZone]:bg-accent-100":!0,"[&.formkit-touchSelectionDropZone]:bg-accent-100":!0,"[&.formkit-longTouch]:bg-accent-100":!0,"dark:[&.formkit-dropZone]:bg-accent-900":!0,"dark:[&.formkit-selectionDropZone]:bg-accent-900":!0,"dark:[&.formkit-touchDropZone]:bg-accent-900":!0,"dark:[&.formkit-touchSelectionDropZone]:bg-accent-900":!0,"dark:[&.formkit-longTouch]:bg-accent-900":!0},transferlist__transferlistOption:{"text-xs":!0},transferlist__transferControls:{"inline-flex":!0,"grow-0":!0,shrink:!0,border:!0,"border-zinc-200":!0,"flex-row":!0,"sm:flex-col":!0,"justify-center":!0,"my-2":!0,"sm:my-auto":!0,"mx-auto":!0,"sm:mx-2":!0,"rounded-sm":!0,"overflow-clip":!0,"shadow-none":!0,"group-[&]/repeater:shadow-none":!0,"group-[&]/multistep:shadow-none":!0,"dark:border-zinc-800":!0},transferlist__sourceEmptyMessage:{"appearance-none":!0,"border-none":!0,"w-full":!0,"my-2":!0,"text-center":!0,"text-zinc-500":!0,italic:!0},transferlist__sourceListItems:{"group-data-[is-max=true]:opacity-50":!0},transferlist__targetEmptyMessage:{"appearance-none":!0,"border-none":!0,"w-full":!0,"my-2":!0,"text-center":!0,"text-zinc-500":!0,italic:!0},transferlist__emptyMessageInner:{flex:!0,"items-center":!0,"justify-center":!0,"p-2":!0,"text-sm":!0},transferlist__transferlistControls:{"bg-white":!0,"p-2":!0,"border-b":!0,"border-zinc-200":!0,"dark:bg-zinc-700":!0,"dark:border-zinc-700":!0},transferlist__transferlistSearch:{flex:!0,border:!0,"border-zinc-200":!0,"rounded-sm":!0,"items-center":!0,"text-zinc-700":!0,"selection:bg-accent-100":!0,"dark:border-zinc-800":!0,"dark:text-zinc-300":!0,"dark:selection:bg-accent-100":!0,"dark:selection:text-zinc-700":!0,"dark:bg-zinc-800":!0},transferlist__transferlistSearchInput:{"border-none":!0,"px-2":!0,"py-1.5":!0,"w-full":!0,"bg-transparent":!0,"outline-hidden":!0,"text-xs":!0},transferlist__transferlistSearchClear:{flex:!0,"w-[0.75em]":!0,"mr-2":!0,"[&_svg]:w-full":!0},transferlist__controlLabel:{absolute:!0,"opacity-0":!0,"pointer-events-none":!0,"text-[0px]":!0},transferlist__selectedIcon:{"w-[0.75em]":!0,absolute:!0,"left-[0.5em]":!0,"select-none":!0,"text-accent-500":!0,"dark:text-accent-400":!0},transferlist__transferlistButton:{"sm:w-5":!0,relative:!0,flex:!0,"justify-center":!0,"text-sm":!0,"shrink-0":!0,"box-content":!0,"text-zinc-700":!0,"disabled:bg-zinc-200":!0,"disabled:!text-zinc-400":!0,"bg-zinc-50":!0,"hover:text-accent-500":!0,"cursor-pointer":!0,"appearance-none":!0,"border-none":!0,"p-2.5":!0,"hover:z-10":!0,"disabled:cursor-not-allowed":!0,"disabled:opacity-50":!0,"disabled:hover:text-current":!0,"disabled:hover:outline-hidden":!0,"focus-visible:ring-1":!0,"focus-visible:ring-accent-400":!0,"focus-visible:z-10":!0,"dark:bg-zinc-800":!0,"dark:text-zinc-400":!0,"dark:disabled:!text-zinc-600":!0,"dark:disabled:bg-zinc-900":!0,"dark:disabled:hover:text-current":!0,"dark:disabled:hover:outline-hidden":!0,"dark:hover:text-accent-400":!0},transferlist__fastForwardIcon:{"w-4":!0,flex:!0,"select-none":!0,"[&>svg]:m-auto":!0,"[&>svg]:w-full":!0,"[&>svg]:max-w-[1rem]":!0,"[&>svg]:max-h-[1rem]":!0,"rotate-90":!0,"sm:rotate-0":!0},transferlist__moveRightIcon:{"w-4":!0,flex:!0,"select-none":!0,"[&>svg]:m-auto":!0,"[&>svg]:w-full":!0,"[&>svg]:max-w-[1rem]":!0,"[&>svg]:max-h-[1rem]":!0,"rotate-90":!0,"sm:rotate-0":!0},transferlist__moveLeftIcon:{"w-4":!0,flex:!0,"select-none":!0,"[&>svg]:m-auto":!0,"[&>svg]:w-full":!0,"[&>svg]:max-w-[1rem]":!0,"[&>svg]:max-h-[1rem]":!0,"rotate-90":!0,"sm:rotate-0":!0},transferlist__rewindIcon:{"w-4":!0,flex:!0,"select-none":!0,"[&>svg]:m-auto":!0,"[&>svg]:w-full":!0,"[&>svg]:max-w-[1rem]":!0,"[&>svg]:max-h-[1rem]":!0,"rotate-90":!0,"sm:rotate-0":!0},transferlist__messages:{"mt-2":!0},barcode__barcodeIcon:{"w-[1.5em]":!0,"text-zinc-700":!0,"cursor-pointer":!0,"dark:text-zinc-300":!0},barcode__dialog:{"border-none":!0,"outline-hidden":!0,"overflow-clip":!0,"p-0":!0,"bg-black":!0,"rounded-sm":!0,"w-[100%-2rem]":!0,"max-w-[30rem]":!0,"[&::backdrop]:bg-zinc-800/50":!0},barcode__video:{"w-full":!0,"aspect-[1/1]":!0,"object-cover":!0,block:!0,"pointer-events-none":!0},barcode__closeIcon:{"cursor-pointer":!0,absolute:!0,"bg-white":!0,"color-zinc-700":!0,"w-[1.5em]":!0,"h-[1.5em]":!0,"rounded-sm":!0,flex:!0,"top-2":!0,"right-2":!0,"z-20":!0,"[&>svg]:w-[1.25em]":!0,"[&>svg]:h-[1.25em]":!0,"[&>svg]:m-auto":!0},barcode__overlay:{"text-zinc-700":!0,"dark:text-zinc-300":!0,absolute:!0,"top-1/2":!0,"left-1/2":!0,"w-[min(20em,75%)]":!0,"aspect-[1/1]":!0,"-translate-x-1/2":!0,"-translate-y-1/2":!0,"rounded-sm":!0,"pointer-events-none":!0,"shadow-[0_0_0_999em_rgba(0,0,0,0.5)]":!0},barcode__overlayDecorators:{absolute:!0,"inset-0":!0,"z-10":!0},barcode__overlayDecoratorTopLeft:{absolute:!0,"w-[1.5rem]":!0,"h-[1.5rem]":!0,"rounded-sm":!0,"top-0":!0,"left-0":!0,"border-l-4":!0,"border-t-4":!0,"rounded-tr-none":!0,"rounded-bl-none":!0},barcode__overlayDecoratorTopRight:{absolute:!0,"w-[1.5rem]":!0,"h-[1.5rem]":!0,"rounded-sm":!0,"top-0":!0,"right-0":!0,"border-r-4":!0,"border-t-4":!0,"rounded-tl-none":!0,"rounded-br-none":!0},barcode__overlayDecoratorBottomRight:{absolute:!0,"w-[1.5rem]":!0,"h-[1.5rem]":!0,"rounded-sm":!0,"bottom-0":!0,"right-0":!0,"border-r-4":!0,"border-b-4":!0,"rounded-tr-none":!0,"rounded-bl-none":!0},barcode__overlayDecoratorBottomLeft:{absolute:!0,"w-[1.5rem]":!0,"h-[1.5rem]":!0,"rounded-sm":!0,"bottom-0":!0,"left-0":!0,"border-l-4":!0,"border-b-4":!0,"rounded-tl-none":!0,"rounded-br-none":!0},"multi-step__outer":{group:!0,"min-w-0":!0,grow:!0,"mb-4":!0,"data-[disabled]:select-none":!0,"data-[disabled]:opacity-50":!0,"text-sm":!0,"group/multistep":!0,"max-w-[32rem]":!0},"multi-step__wrapper":{"group/wrapper":!0,"data-[tab-style=tab]:shadow-none":!0,"data-[tab-style=tab]:rounded-sm":!0},"multi-step__tabs":{flex:!0,"items-center":!0,"group-data-[tab-style=tab]/wrapper:overflow-auto":!0,"group-data-[tab-style=tab]/wrapper:border":!0,"group-data-[tab-style=tab]/wrapper:border-b-0":!0,"group-data-[tab-style=tab]/wrapper:border-zinc-200":!0,"group-data-[tab-style=tab]/wrapper:rounded-sm":!0,"group-data-[tab-style=tab]/wrapper:rounded-bl-none":!0,"group-data-[tab-style=tab]/wrapper:rounded-br-none":!0,"dark:group-data-[tab-style=tab]/wrapper:border-zinc-800":!0,"group-data-[tab-style=progress]/wrapper:my-6":!0,"group-data-[tab-style=progress]/wrapper:justify-around":!0,"group-data-[tab-style=progress]/wrapper:overflow-visible":!0,"group-data-[tab-style=progress]/wrapper:group-data-[hide-labels=true]/wrapper:mb-3.5":!0},"multi-step__tab":{"group/tab":!0,"group-data-[tab-style=tab]/wrapper:relative":!0,"group-data-[tab-style=tab]/wrapper:flex":!0,"group-data-[tab-style=tab]/wrapper:grow":!0,"group-data-[tab-style=tab]/wrapper:text-xs":!0,"group-data-[tab-style=tab]/wrapper:items-center":!0,"group-data-[tab-style=tab]/wrapper:justify-center":!0,"group-data-[tab-style=tab]/wrapper:cursor-pointer":!0,"group-data-[tab-style=tab]/wrapper:text-zinc-700":!0,"group-data-[tab-style=tab]/wrapper:bg-zinc-100":!0,"group-data-[tab-style=tab]/wrapper:py-3.5":!0,"group-data-[tab-style=tab]/wrapper:px-4":!0,"group-data-[tab-style=tab]/wrapper:border-r":!0,"group-data-[tab-style=tab]/wrapper:border-b":!0,"group-data-[tab-style=tab]/wrapper:border-zinc-200":!0,"group-data-[tab-style=tab]/wrapper:last:border-r-0":!0,"group-data-[tab-style=tab]/wrapper:shadow-[inset_0_-0.5em_0.5em_-0.5em_rgba(0,0,0,0.1)]":!0,"group-data-[tab-style=tab]/wrapper:data-[active=true]:bg-white":!0,"group-data-[tab-style=tab]/wrapper:data-[active=true]:font-bold":!0,"group-data-[tab-style=tab]/wrapper:data-[active=true]:border-b-white":!0,"group-data-[tab-style=tab]/wrapper:data-[active=true]:z-10":!0,"group-data-[tab-style=tab]/wrapper:data-[active=true]:shadow-[0_0_0.5em_0_rgba(0,0,0,0.1)]":!0,"dark:group-data-[tab-style=tab]/wrapper:text-zinc-300":!0,"dark:group-data-[tab-style=tab]/wrapper:bg-zinc-950/20":!0,"dark:group-data-[tab-style=tab]/wrapper:data-[active=true]:bg-transparent":!0,"dark:group-data-[tab-style=tab]/wrapper:data-[active=true]:border-b-transparent":!0,"dark:group-data-[tab-style=tab]/wrapper:border-zinc-800":!0,"group-data-[tab-style=progress]/wrapper:flex":!0,"group-data-[tab-style=progress]/wrapper:flex-col":!0,"group-data-[tab-style=progress]/wrapper:items-center":!0,"group-data-[tab-style=progress]/wrapper:grow":!0,"group-data-[tab-style=progress]/wrapper:shrink-0":!0,"group-data-[tab-style=progress]/wrapper:relative":!0,"group-data-[tab-style=progress]/wrapper:before:block":!0,"group-data-[tab-style=progress]/wrapper:before:text-xs":!0,"group-data-[tab-style=progress]/wrapper:before:w-[1.25rem]":!0,"group-data-[tab-style=progress]/wrapper:before:h-[1.25rem]":!0,"group-data-[tab-style=progress]/wrapper:before:border-4":!0,"group-data-[tab-style=progress]/wrapper:before:border-zinc-300":!0,"group-data-[tab-style=progress]/wrapper:before:rounded-full":!0,"group-data-[tab-style=progress]/wrapper:before:bg-white":!0,"group-data-[tab-style=progress]/wrapper:before:z-10":!0,"dark:group-data-[tab-style=progress]/wrapper:before:border-zinc-800":!0,"dark:group-data-[tab-style=progress]/wrapper:before:bg-zinc-950":!0,"group-data-[tab-style=progress]/wrapper:after:block":!0,"group-data-[tab-style=progress]/wrapper:after:h-1":!0,"group-data-[tab-style=progress]/wrapper:after:w-full":!0,"group-data-[tab-style=progress]/wrapper:after:absolute":!0,"group-data-[tab-style=progress]/wrapper:after:top-[0.5em]":!0,"group-data-[tab-style=progress]/wrapper:after:left-[calc(50%+0.5em)]":!0,"group-data-[tab-style=progress]/wrapper:after:bg-zinc-300":!0,"group-data-[tab-style=progress]/wrapper:data-[valid=true]:data-[visited=true]:after:bg-accent-500":!0,"group-data-[tab-style=progress]/wrapper:last:after:hidden":!0,"dark:group-data-[tab-style=progress]/wrapper:after:bg-zinc-800":!0,"dark:group-data-[tab-style=progress]/wrapper:data-[valid=true]:data-[visited=true]:after:bg-accent-500":!0},"multi-step__tabLabel":{"group-data-[tab-style=progress]/wrapper:absolute":!0,"group-data-[tab-style=progress]/wrapper:text-zinc-800":!0,"group-data-[tab-style=progress]/wrapper:top-full":!0,"group-data-[tab-style=progress]/wrapper:w-full":!0,"group-data-[tab-style=progress]/wrapper:whitespace-nowrap":!0,"group-data-[tab-style=progress]/wrapper:text-[11px]":!0,"[line-height:1em]":!0,"dark:group-data-[tab-style=progress]/wrapper:text-zinc-300":!0},"multi-step__badge":{"bg-red-500":!0,absolute:!0,"font-mono":!0,"font-bold":!0,flex:!0,"items-center":!0,"justify-center":!0,"aspect-[1/1]":!0,"[line-height:1.25rem]":!0,"text-white":!0,"rounded-full":!0,"group-data-[valid=true]/tab:bg-accent-500":!0,"group-data-[tab-style=tab]/wrapper:text-[0.66rem]":!0,"group-data-[tab-style=tab]/wrapper:p-1.5":!0,"group-data-[tab-style=tab]/wrapper:w-5":!0,"group-data-[tab-style=tab]/wrapper:h-5":!0,"group-data-[tab-style=tab]/wrapper:top-1.5":!0,"group-data-[tab-style=tab]/wrapper:right-1.5":!0,"group-data-[tab-style=progress]/wrapper:w-[1.25rem]":!0,"group-data-[tab-style=progress]/wrapper:h-[1.25rem]":!0,"group-data-[tab-style=progress]/wrapper:p-1":!0,"group-data-[tab-style=progress]/wrapper:text-[10px]":!0,"group-data-[tab-style=progress]/wrapper:[line-height:0]":!0,"group-data-[tab-style=progress]/wrapper:z-10":!0},"multi-step__validStepIcon":{"w-full":!0,"h-full":!0,"mt-0.5":!0},"multi-step__steps":{"px-10":!0,"pt-8":!0,"pb-4":!0,"bg-white":!0,border:!0,"border-zinc-200":!0,"rounded-sm":!0,"dark:bg-transparent":!0,"dark:border-zinc-800":!0,"group-data-[tab-style=tab]/wrapper:border-t-0":!0,"group-data-[tab-style=tab]/wrapper:rounded-tl-none":!0,"group-data-[tab-style=tab]/wrapper:rounded-tr-none":!0,"group-data-[tab-style=progress]/wrapper:shadow-none":!0,"[&_[data-type]]:max-w-none":!0},step__stepActions:{flex:!0,"justify-between":!0,"[&>*]:grow-0":!0},step__stepPrevious:{"mr-1.5":!0},step__stepNext:{"ml-auto":!0}},Mo={outer:{group:!0,"max-w-none":!0,"min-w-0":!0,grow:!0,"mb-4":!0,"data-[disabled]:select-none":!0,"data-[disabled]:opacity-50":!0,"text-sm":!0},label:{block:!0,"text-zinc-700":!0,"text-xs":!0,"font-bold":!0,"mb-1":!0,"dark:text-zinc-300":!0},legend:{block:!0,"text-zinc-700":!0,"text-xs":!0,"font-bold":!0,"dark:text-zinc-300":!0},input:{"appearance-none":!0,"[color-scheme:light]":!0,"dark:[color-scheme:dark]":!0,"selection:bg-accent-100":!0,"selection:text-zinc-700":!0,"group-data-[has-overlay]:selection:!text-transparent":!0},prefixIcon:{flex:!0,"items-center":!0,"-ml-1":!0,"mr-2":!0,"text-sm":!0,"h-[1em]":!0,"w-[1em]":!0,"shrink-0":!0,"[&>svg]:w-full":!0},suffixIcon:{flex:!0,"items-center":!0,"-mr-1":!0,"ml-2":!0,"text-sm":!0,"h-[1em]":!0,"w-[1em]":!0,"shrink-0":!0,"[&>svg]:w-full":!0},loaderIcon:{"animate-spin":!0,flex:!0,"items-center":!0,"my-auto":!0,"ml-2":!0,"text-sm":!0,"text-zinc-500":!0,"h-[1em]":!0,"w-[1em]":!0,"shrink-0":!0,"[&>svg]:w-full":!0},loadMoreInner:{flex:!0,"text-xs":!0,"text-zinc-500":!0,"p-2":!0,"items-center":!0,"justify-center":!0,"[&>span]:mr-2":!0},help:{"text-zinc-500":!0,"text-[11px]":!0,"[line-height:1em]":!0,"dark:text-zinc-400":!0},message:{"text-red-500":!0,"mb-1.5":!0,"text-[11px]":!0,"[line-height:1em]":!0,"dark:text-red-400":!0},overlay:{"text-zinc-700":!0,"dark:text-zinc-300":!0},overlayPlaceholder:{"text-zinc-400":!0,"dark:text-zinc-400/50":!0},overlayLiteral:{"text-zinc-700":!0,"dark:text-zinc-300":!0},overlayChar:{"text-zinc-700":!0,"dark:text-zinc-300":!0},overlayEnum:{"text-zinc-700":!0,"dark:text-zinc-300":!0},searchInput__input:{"w-full":!0,"bg-transparent":!0,border:!0,"border-zinc-200":!0,"dark:border-zinc-700":!0,"rounded-lg":!0,"focus:outline-none":!0,"focus:ring-2":!0,"focus:ring-accent-500/30":!0,"focus:border-accent-500":!0,"dark:focus:border-accent-400":!0,"transition-all":!0,"placeholder:text-zinc-400":!0,"disabled:opacity-50":!0,"disabled:cursor-not-allowed":!0,"pl-9":!0,"pr-9":!0,"py-2":!0,"text-sm":!0},"searchInput__input--sm":{"pl-7":!0,"pr-7":!0,"py-1.5":!0,"text-xs":!0},searchInput__icon:{absolute:!0,"left-3":!0,"top-1/2":!0,"-translate-y-1/2":!0,"text-zinc-400":!0,"w-4":!0,"h-4":!0},"searchInput__icon--sm":{"left-2":!0,"w-3.5":!0,"h-3.5":!0},searchInput__clearButton:{absolute:!0,"right-2.5":!0,"top-1/2":!0,"-translate-y-1/2":!0,"p-1":!0,"rounded-md":!0,"hover:bg-zinc-100":!0,"dark:hover:bg-zinc-800":!0,"transition-colors":!0},searchInput__clearIcon:{"w-3.5":!0,"h-3.5":!0,"text-zinc-400":!0,"hover:text-zinc-600":!0,"dark:hover:text-zinc-300":!0},selectSearch__button:{"w-full":!0,"min-w-[200px]":!0,"px-3":!0,"py-2":!0,"text-left":!0,"rounded-lg":!0,"focus:outline-none":!0,"focus:ring-2":!0,"focus:ring-accent-500/30":!0,"bg-transparent":!0,"disabled:opacity-50":!0,"disabled:cursor-not-allowed":!0,"text-sm":!0,"overflow-hidden":!0,"transition-colors":!0,border:!0,"border-zinc-200":!0,"dark:border-zinc-700":!0,"focus:border-accent-500":!0,"dark:focus:border-accent-400":!0}};function zo(e){const n=String(e.value||"");return n?/^[a-z][a-z0-9_]*$/.test(n):!0}function Vo(e){const n=e.value;if(n===""||n===null||n===void 0)return!0;const a=Number(n);return a>0&&Number.isInteger(a)}function Eo(e){const n=e.value;return n===""||n===null||n===void 0?!0:Number(n)>=0}function Lo(e){const n=String(e.value||"");if(!n.trim())return!0;try{return JSON.parse(n),!0}catch{return!1}}function Ao(e){const n=String(e.value||"");if(!n)return!0;try{return new URL(n),!0}catch{return!1}}function Po(e){const n=String(e.value||"");return n?n.length>=10&&!/\s/.test(n):!0}const Oo={snakeCase:zo,positiveInteger:Vo,nonNegative:Eo,validJson:Lo,validUrl:Ao,apiKey:Po},Ro={snakeCase({name:e}){return`${e} must be in snake_case format (lowercase letters, numbers, and underscores, starting with a letter).`},positiveInteger({name:e}){return`${e} must be a positive whole number.`},nonNegative({name:e}){return`${e} must be zero or greater.`},validJson({name:e}){return`${e} must be valid JSON.`},validUrl({name:e}){return`${e} must be a valid URL.`},apiKey({name:e}){return`${e} must be at least 10 characters with no spaces.`}},Zt=Se({__name:"DropShadow",props:{offsetX:{default:8},offsetY:{default:8},intensity:{default:.5},pattern:{default:"crosshatch"}},setup(e){const n=e,a=p(),s=p(),l=p(),u=p(0),i=(x,b,y,$,g,d)=>{x.beginPath(),x.moveTo(b+d,y),x.lineTo(b+$-d,y),x.quadraticCurveTo(b+$,y,b+$,y+d),x.lineTo(b+$,y+g-d),x.quadraticCurveTo(b+$,y+g,b+$-d,y+g),x.lineTo(b+d,y+g),x.quadraticCurveTo(b,y+g,b,y+g-d),x.lineTo(b,y+d),x.quadraticCurveTo(b,y,b+d,y),x.closePath()},c=async()=>{if(await Fe(),!a.value||!s.value||!l.value)return;const x=a.value.getContext("2d");if(!x)return;const b=l.value.getBoundingClientRect(),y=l.value.firstElementChild;if(y){const w=getComputedStyle(y);u.value=parseFloat(w.borderRadius)||0}const $=b.width+n.offsetX+4,g=b.height+n.offsetY+4;a.value.width=$,a.value.height=g,a.value.style.width=`${$}px`,a.value.style.height=`${g}px`,x.clearRect(0,0,a.value.width,a.value.height);const d=document.documentElement.classList.contains("dark");if(x.fillStyle=d?"#6b7280":"black",x.globalAlpha=n.intensity,x.save(),i(x,n.offsetX,n.offsetY,b.width,b.height,u.value),x.clip(),n.pattern==="crosshatch"){const w=d?4:3;x.lineWidth=1,x.strokeStyle=d?"#6b7280":"black";for(let m=-b.height;m<b.width;m+=w)x.beginPath(),x.moveTo(n.offsetX+m,n.offsetY),x.lineTo(n.offsetX+m+b.height,n.offsetY+b.height),x.stroke();for(let m=0;m<b.width+b.height;m+=w)x.beginPath(),x.moveTo(n.offsetX+m,n.offsetY+b.height),x.lineTo(n.offsetX+m-b.height,n.offsetY),x.stroke()}else if(n.pattern==="dots"){const m=d?3:2,v=[[0,8,2,10],[12,4,14,6],[3,11,1,9],[15,7,13,5]];for(let _=0;_<b.width;_+=m)for(let P=0;P<b.height;P+=m){const V=Math.floor(_/m)%4,E=Math.floor(P/m)%4;v[E][V]/16<n.intensity&&x.fillRect(n.offsetX+_,n.offsetY+P,1,1)}}else if(n.pattern==="diagonal"){const w=d?5:4;x.lineWidth=1,x.strokeStyle=d?"#6b7280":"black";for(let m=-b.height;m<b.width;m+=w)x.beginPath(),x.moveTo(n.offsetX+m,n.offsetY),x.lineTo(n.offsetX+m+b.height,n.offsetY+b.height),x.stroke()}x.restore()};let f=null,h=null;return He(()=>{f=new ResizeObserver(()=>{c()}),l.value&&f.observe(l.value),c(),h=new MutationObserver(()=>{c()}),h.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]})}),ct(()=>{l.value&&f&&f.unobserve(l.value),h&&h.disconnect()}),Ve(()=>[n.offsetX,n.offsetY,n.intensity,n.pattern],()=>{c()}),(x,b)=>(r(),o("div",{ref_key:"container",ref:s,class:"relative",style:_t({paddingRight:`${e.offsetX}px`,paddingBottom:`${e.offsetY}px`})},[t("canvas",{ref_key:"canvas",ref:a,class:"absolute top-0 left-0 pointer-events-none"},null,512),t("div",{ref_key:"contentEl",ref:l,class:"relative"},[Ye(x.$slots,"default")],512)],4))}}),jo={class:"prompt-input-container relative"},Do=["contenteditable","data-placeholder"],Uo={class:"bg-white dark:bg-zinc-900 border border-zinc-300 dark:border-zinc-700 rounded-sm overflow-hidden min-w-[240px] max-w-[320px]"},Bo={key:0,class:"p-3 text-sm text-neutral-500"},No={key:1,class:"p-3 text-sm text-neutral-500"},qo={key:2,class:"max-h-[220px] overflow-y-auto"},Fo=["onClick"],Ho={class:"font-medium flex items-center gap-2"},Wo=["title"],Ko={key:0,class:"text-xs text-neutral-500 dark:text-neutral-400 mt-0.5"},Jo={key:1,class:"text-xs text-red-600 dark:text-red-400 mt-1"},Go={class:"text-xs mt-1"},Yo=Se({__name:"PromptInput",props:{modelValue:{},search:{},placeholder:{default:"Type @ to insert variables, env, or prompts..."},disabled:{type:Boolean,default:!1},maxLength:{},allowedTypes:{default:()=>["variable","env","prompt"]},editorClass:{}},emits:["update:modelValue","segment-click"],setup(e,{emit:n}){const a=e,s=n,l=p(),u=p(),i=vn({segments:a.modelValue&&a.modelValue.length?a.modelValue:[{type:"string",value:""}],dialogOpen:!1,dialogPosition:{x:0,y:0},searchQuery:"",searchResults:[],selectedIndex:0,isSearching:!1,atTriggerIndex:-1,isComposing:!1,ignoreNextWatch:!1}),c=()=>Math.random().toString(36).slice(2)+Date.now().toString(36),f=H=>H.type==="string"?"":`@${H.type==="variable"?H.label||H.value:H.type==="env"?H.label||H.property:H.label||H.id}`,h=H=>{const ce=H._uid||(H._uid=c()),Z=f(H),U=H.type==="variable"?{type:"variable",value:H.value,label:H.label,schema:H.schema,meta:H.meta}:H.type==="env"?{type:"env",property:H.property,label:H.label,meta:H.meta}:{type:"prompt",id:H.id,label:H.label,schema:H.schema,meta:H.meta},K=encodeURIComponent(JSON.stringify(U)),me=(H.type==="prompt"||H.type==="env")&&H.meta&&!H.meta.isValid,ue=me?`<span class="prompt-tag-warning" title="${(H.meta?.validationMessage||"").replace(/"/g,"&quot;")}">⚠️</span>`:"";return`<span class="prompt-tag prompt-tag-clickable${me?" prompt-tag-invalid":""}" contenteditable="false" data-segment-uid="${ce}" data-segment="${K}">${Z}${ue}</span>`},x=H=>{const ce=document.createRange();ce.selectNode(H);const Z=window.getSelection();Z.removeAllRanges(),Z.addRange(ce),document.execCommand("delete")},b=()=>{if(!l.value)return;const H=i.segments.map(ce=>ce.type==="string"?(ce.value||"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/\n/g,"<br>")||"":h(ce)).join("");l.value.innerHTML=H||"<br>"},y=()=>{const H=[];for(const ce of i.segments)ce.type==="string"&&H.length>0&&H[H.length-1].type==="string"?H[H.length-1].value+=ce.value:H.push(ce);i.segments=H.length?H:[{type:"string",value:""}]},$=H=>{const ce=H.dataset.segmentUid;let Z=i.segments.find(U=>U._uid===ce);if(!Z){const U=H.dataset.segment;if(U)try{const K=JSON.parse(decodeURIComponent(U));K&&(K.type==="variable"||K.type==="prompt"||K.type==="env")&&(Z=K.type==="variable"?{type:"variable",value:K.value,label:K.label,schema:K.schema,meta:K.meta,_uid:ce}:K.type==="env"?{type:"env",property:K.property,label:K.label,meta:K.meta,_uid:ce}:{type:"prompt",id:K.id,label:K.label,schema:K.schema,meta:K.meta,_uid:ce})}catch{}}return Z||null},g=H=>{const ce=H.target;if(ce.classList?.contains("prompt-tag")){const Z=$(ce);Z&&s("segment-click",Z,H)}},d=H=>{if(i.isComposing)return;const ce=H.target,Z=[];let U="";const K=()=>{U.length>0&&(Z.push({type:"string",value:U}),U="")},me=ae=>{if(ae.nodeType===Node.TEXT_NODE){const ie=(ae.textContent||"").replace(/\u00A0/g," ");U+=ie;return}if(ae.nodeType===Node.ELEMENT_NODE){const ie=ae;if(ie.classList?.contains("prompt-tag")){K();const X=$(ie);X&&Z.push(X);return}if(ie.tagName==="BR"){U+=`
2
+ `;return}const xe=Array.from(ie.childNodes);for(const X of xe)me(X);(ie.tagName==="DIV"||ie.tagName==="P"||ie.tagName==="LI")&&ie.nextSibling&&(U+=`
3
+ `);return}},ue=Array.from(ce.childNodes);for(const ae of ue)me(ae);K();const G=Z.some(ae=>ae.type!=="string")?Z:[{type:"string",value:(ce.innerText||"").replace(/\r\n/g,`
4
+ `)}];i.segments=G.length?G:[{type:"string",value:""}],y(),w(),fe()},w=()=>{const H=window.getSelection();if(!H||!H.rangeCount||!l.value)return;const ce=H.getRangeAt(0);if(ce.startContainer.nodeType!==Node.TEXT_NODE){i.dialogOpen&&v();return}const U=ce.startContainer.textContent||"",K=ce.startOffset;if(K>0&&U[K-1]==="@")i.atTriggerIndex=K-1,i.searchQuery="",m(),V("");else if(i.dialogOpen&&i.atTriggerIndex>=0)if(ce.startContainer.nodeType===Node.TEXT_NODE){const me=ce.startContainer.textContent||"",ue=ce.startOffset;if(ue<=i.atTriggerIndex){v();return}const Q=me.substring(0,ue);if(Q.length>i.atTriggerIndex&&Q[i.atTriggerIndex]==="@"){const G=Q.substring(i.atTriggerIndex+1);G.includes(" ")||G.includes(`
5
+ `)||G.length>i.searchQuery.length+5?v():(i.searchQuery=G,V(G))}else v()}else v()},m=async()=>{i.dialogOpen=!0,i.selectedIndex=0,await Fe(),_()},v=()=>{i.dialogOpen=!1,i.searchResults=[],i.searchQuery="",i.atTriggerIndex=-1,i.isSearching=!1},_=()=>{if(!u.value||!l.value)return;const H=window.getSelection();if(!H||!H.rangeCount)return;const Z=H.getRangeAt(0).getBoundingClientRect(),U=l.value.getBoundingClientRect();i.dialogPosition={x:Z.left-U.left,y:Z.bottom-U.top+4}};let P=null;const V=async H=>{if(!a.search){i.searchResults=[];return}P&&clearTimeout(P),i.isSearching=!0,P=setTimeout(async()=>{try{const ce=await a.search(H);i.searchResults=(ce||[]).filter(Z=>a.allowedTypes?.includes(Z.type))}catch(ce){console.error("Search error:",ce),i.searchResults=[]}finally{i.isSearching=!1}},200)},E=H=>H.type==="variable"?{type:"variable",value:H.value??H.id??"",label:H.label,schema:H.schema,_uid:c(),meta:H.meta}:H.type==="env"?{type:"env",property:H.value??H.id??"",label:H.label,_uid:c(),meta:H.meta}:{type:"prompt",id:H.id??H.value??"",label:H.label,schema:H.schema,_uid:c(),meta:H.meta},z=H=>{if(i.atTriggerIndex<0||!l.value)return;const ce=window.getSelection();if(!ce||!ce.rangeCount)return;const Z=ce.getRangeAt(0);if(Z.startContainer.nodeType!==Node.TEXT_NODE)return;const U=Z.startContainer,K=Z.startOffset,me=document.createRange();me.setStart(U,i.atTriggerIndex),me.setEnd(U,K),ce.removeAllRanges(),ce.addRange(me);const ue=E(H),Q=h(ue);v(),document.execCommand("insertHTML",!1,Q),l.value.focus()},A=H=>{if((H.key==="ArrowLeft"||H.key==="ArrowRight")&&setTimeout(()=>w(),0),i.dialogOpen)H.key==="ArrowDown"?(H.preventDefault(),i.selectedIndex=Math.min(i.selectedIndex+1,i.searchResults.length-1)):H.key==="ArrowUp"?(H.preventDefault(),i.selectedIndex=Math.max(i.selectedIndex-1,0)):H.key==="Enter"?(H.preventDefault(),i.searchResults[i.selectedIndex]&&z(i.searchResults[i.selectedIndex])):(H.key==="Escape"||H.key==="Esc")&&(H.preventDefault(),v());else if(H.key==="Backspace"||H.key==="Delete"){const ce=window.getSelection();if(!ce||!ce.rangeCount||!l.value)return;const Z=ce.getRangeAt(0);if(!Z.collapsed)return;if(H.key==="Backspace"){if(Z.startContainer===l.value){const U=Z.startOffset-1;if(U>=0){const K=l.value.childNodes[U];if(K&&K.nodeType===Node.ELEMENT_NODE&&K.classList?.contains("prompt-tag")){H.preventDefault(),x(K);return}}}if(Z.startContainer.nodeType===Node.TEXT_NODE&&Z.startOffset===0){let U=Z.startContainer;for(;U&&U!==l.value;){const K=U.previousSibling;if(K&&K.nodeType===Node.ELEMENT_NODE&&K.classList?.contains("prompt-tag")){H.preventDefault(),x(K);return}U=U.parentNode}}}else{if(Z.startContainer===l.value){const U=l.value.childNodes[Z.startOffset];if(U&&U.nodeType===Node.ELEMENT_NODE&&U.classList?.contains("prompt-tag")){H.preventDefault(),x(U);return}}if(Z.startContainer.nodeType===Node.TEXT_NODE&&Z.startOffset===(Z.startContainer.textContent?.length??0)){let U=Z.startContainer;for(;U&&U!==l.value;){const K=U.nextSibling;if(K&&K.nodeType===Node.ELEMENT_NODE&&K.classList?.contains("prompt-tag")){H.preventDefault(),x(K);return}U=U.parentNode}}}}},oe=H=>{H.preventDefault();const ce=H.clipboardData?.getData("text/plain")||"";document.execCommand("insertText",!1,ce)},ne=H=>{if(!i.dialogOpen)return;const ce=u.value;ce&&(ce.contains(H.target)||v())},fe=()=>{i.ignoreNextWatch=!0;const H=i.segments.map(ce=>{const{_uid:Z,...U}=ce||{};return U});s("update:modelValue",H)},ye=()=>{const H=window.getSelection();if(!H||!l.value)return;const ce=H.anchorNode;ce&&l.value.contains(ce)&&w()},te=H=>{(H.key==="Escape"||H.key==="Esc")&&i.dialogOpen&&(H.preventDefault(),v())};He(()=>{a.modelValue&&a.modelValue.length&&(i.segments=JSON.parse(JSON.stringify(a.modelValue))),b(),document.addEventListener("mousedown",ne),document.addEventListener("selectionchange",ye),document.addEventListener("keydown",te,!0)}),ct(()=>{document.removeEventListener("mousedown",ne),document.removeEventListener("selectionchange",ye),document.removeEventListener("keydown",te,!0)});const q=(H,ce)=>{if(H.length!==ce.length)return!1;for(let Z=0;Z<H.length;Z++){const U=H[Z],K=ce[Z];if(U.type!==K.type)return!1;if(U.type==="string"&&K.type==="string"){if(U.value!==K.value)return!1}else if(U.type==="prompt"&&K.type==="prompt"){if(U.id!==K.id)return!1}else if(U.type==="env"&&K.type==="env"){if(U.property!==K.property)return!1}else if(U.type==="variable"&&K.type==="variable"&&U.value!==K.value)return!1}return!0},j=()=>{if(!l.value)return;l.value.querySelectorAll(".prompt-tag").forEach(ce=>{const Z=ce.dataset.segmentUid,U=i.segments.find(Q=>Q._uid===Z);if(!U)return;const K=(U.type==="prompt"||U.type==="env")&&U.meta&&!U.meta.isValid;ce.classList.toggle("prompt-tag-invalid",!!K);const me=ce.querySelector(".prompt-tag-warning");if(K&&!me){const Q=document.createElement("span");Q.className="prompt-tag-warning",Q.textContent="⚠️",Q.title=U.meta?.validationMessage||"Validation error",ce.appendChild(Q)}else!K&&me?me.remove():K&&me&&(me.title=U.meta?.validationMessage||"Validation error");const ue=U.type==="variable"?{type:"variable",value:U.value,label:U.label,schema:U.schema,meta:U.meta}:U.type==="env"?{type:"env",property:U.property,label:U.label,meta:U.meta}:{type:"prompt",id:U.id,label:U.label,schema:U.schema,meta:U.meta};ce.dataset.segment=encodeURIComponent(JSON.stringify(ue))})};Ve(()=>a.modelValue,H=>{if(i.ignoreNextWatch){i.ignoreNextWatch=!1;return}if(H){const ce=!q(H,i.segments);i.segments=JSON.parse(JSON.stringify(H)),ce?b():j()}},{deep:!0});const J=F(()=>{const H=["prompt-input-editor","min-h-[100px]",a.disabled?"opacity-50 cursor-not-allowed":""];return a.editorClass?[...H,a.editorClass,"!h-auto"]:[...H,"py-2 px-3","rounded-sm","border border-zinc-300 dark:border-zinc-700","bg-white dark:bg-transparent","text-sm text-zinc-700 dark:text-zinc-300","focus:outline-none focus:ring-1 focus:ring-accent-400 focus:border-accent-400"]});return(H,ce)=>(r(),o("div",jo,[t("div",{ref_key:"editorRef",ref:l,contenteditable:!e.disabled,onInput:d,onKeydown:A,onPaste:oe,onClick:g,onKeyup:ce[0]||(ce[0]=Z=>{Z.key==="Escape"?(Z.preventDefault(),v()):(Z.key==="ArrowLeft"||Z.key==="ArrowRight")&&w()}),onCompositionstart:ce[1]||(ce[1]=Z=>i.isComposing=!0),onCompositionend:ce[2]||(ce[2]=Z=>i.isComposing=!1),class:pe(J.value),"data-placeholder":e.placeholder},[Je(t("div",null,[Ye(H.$slots,"segment",{segment:null},void 0,!0)],512),[[pt,!1]])],42,Do),i.dialogOpen?(r(),o("div",{key:0,ref_key:"dialogRef",ref:u,class:"absolute z-50",style:_t({left:`${i.dialogPosition.x}px`,top:`${i.dialogPosition.y}px`})},[k(Zt,{"offset-x":4,"offset-y":4,intensity:.3},{default:W(()=>[t("div",Uo,[i.isSearching?(r(),o("div",Bo," Searching... ")):i.searchResults.length===0?(r(),o("div",No," No results found ")):(r(),o("div",qo,[(r(!0),o($e,null,Le(i.searchResults,(Z,U)=>(r(),o("button",{key:Z.id||Z.value||U,type:"button",onClick:K=>z(Z),class:pe(["w-full px-3 py-2 text-left text-sm","hover:bg-neutral-100 dark:hover:bg-neutral-900","focus:bg-neutral-100 dark:focus:bg-neutral-900 focus:outline-none",i.selectedIndex===U?"bg-neutral-100 dark:bg-neutral-900":""])},[t("div",Ho,[ve(C(Z.label||Z.id||Z.value)+" ",1),Z.type==="prompt"&&Z.meta&&!Z.meta.isValid?(r(),o("span",{key:0,title:Z.meta.validationMessage,class:"text-red-500"},"⚠️",8,Wo)):S("",!0)]),Z.description?(r(),o("div",Ko,C(Z.description),1)):S("",!0),Z.type==="prompt"&&Z.meta&&!Z.meta.isValid?(r(),o("div",Jo,C(Z.meta.validationMessage),1)):S("",!0),t("div",Go,[t("span",{class:pe(["inline-block px-1.5 py-0.5 rounded",Z.type==="variable"?"bg-blue-100 dark:bg-blue-900 text-blue-700 dark:text-blue-300":Z.type==="env"?"bg-emerald-100 dark:bg-emerald-900 text-emerald-700 dark:text-emerald-300":"bg-purple-100 dark:bg-purple-900 text-purple-700 dark:text-purple-300"])},C(Z.type),3)])],10,Fo))),128))]))])]),_:1})],4)):S("",!0)]))}}),mt=(e,n)=>{const a=e.__vccOpts||e;for(const[s,l]of n)a[s]=l;return a},Pr=mt(Yo,[["__scopeId","data-v-88db0e55"]]),Zo=Se({__name:"PromptInputWrapper",props:{context:{}},emits:["segment-click"],setup(e,{emit:n}){const a=e,s=($,g)=>{const d=a.context;return d[$]!==void 0?d[$]:d.attrs?.[$]!==void 0?d.attrs[$]:g},l=F(()=>a.context.classes??{}),u=F(()=>a.context._value??[]),i=$=>{a.context.node.input($)},c=F(()=>s("search",void 0)),f=F(()=>s("placeholder","Type @ to insert variables or prompts...")),h=F(()=>s("maxLength",void 0)),x=F(()=>s("allowedTypes",["variable","prompt"])),b=F(()=>a.context.disabled??!1),y=($,g)=>{const d=a.context;d.attrs?.["onSegment-click"]&&d.attrs["onSegment-click"]($,g)};return($,g)=>(r(),Y(Pr,{"model-value":u.value,search:c.value,placeholder:f.value,disabled:b.value,"max-length":h.value,"allowed-types":x.value,"editor-class":l.value.inner,"onUpdate:modelValue":i,onSegmentClick:y},null,8,["model-value","search","placeholder","disabled","max-length","allowed-types","editor-class"]))}}),Xo={type:"input",family:"text",props:["search","placeholder","maxLength","allowedTypes"],schema:()=>[{$el:"label",if:"$label",attrs:{class:"$classes.label",for:"$id"},children:"$label"},{$el:"p",if:"$help",attrs:{class:"$classes.help"},children:"$help"},{$cmp:je(Zo),props:{context:"$node.context"}}]},Qo={class:"inline-flex items-center justify-center"},Be=Se({__name:"Loader",props:{size:{default:"md"}},setup(e){const n=e,a=F(()=>{switch(n.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(s,l)=>(r(),o("div",Qo,[t("div",{class:pe([a.value,"border-current/20 border-t-current rounded-full animate-spin"])},null,2)]))}}),el=["type","disabled"],tl="inline-flex items-center justify-center gap-2 font-medium rounded transition-all disabled:opacity-50 disabled:cursor-not-allowed",Qe=Se({__name:"UiButton",props:{variant:{default:"primary"},size:{default:"md"},disabled:{type:Boolean,default:!1},loading:{type:Boolean,default:!1},iconLeft:{},iconRight:{},fullWidth:{type:Boolean,default:!1},type:{default:"button"}},emits:["click"],setup(e,{emit:n}){const a=e,s=n,l=F(()=>{switch(a.variant){case"primary":return"bg-black text-white dark:bg-white dark:text-black hover:opacity-90";case"secondary":return"border-2 border-black dark:border-neutral-300 bg-white dark:bg-black text-black dark:text-white hover:bg-neutral-50 dark:hover:bg-neutral-900";case"ghost":return"border border-black dark:border-white hover:bg-black/5 dark:hover:bg-white/10";case"danger":return"border-2 border-red-600 bg-red-600 text-white hover:bg-red-700 hover:border-red-700";case"link":return"text-accent-600 dark:text-accent-400 hover:underline p-0";default:return""}}),u=F(()=>{if(a.variant==="link")return"text-sm";switch(a.size){case"xs":return"px-2 py-1 text-xs";case"sm":return"px-3 py-1.5 text-sm";case"md":return"px-4 py-2 text-sm";case"lg":return"px-6 py-3 text-base";default:return""}}),i=F(()=>a.size==="xs"||a.size==="sm"?"xs":"sm"),c=f=>{!a.disabled&&!a.loading&&s("click",f)};return(f,h)=>(r(),o("button",{type:e.type,disabled:e.disabled||e.loading,class:pe([tl,l.value,u.value,e.fullWidth?"w-full":""]),onClick:c},[e.loading?(r(),Y(Be,{key:0,size:i.value},null,8,["size"])):e.iconLeft?(r(),Y(rt(e.iconLeft),{key:1,class:"w-4 h-4"})):S("",!0),Ye(f.$slots,"default"),e.iconRight&&!e.loading?(r(),Y(rt(e.iconRight),{key:2,class:"w-4 h-4"})):S("",!0)],10,el))}}),rl=["disabled","aria-label","title"],al="inline-flex items-center justify-center rounded transition-colors disabled:opacity-50 disabled:cursor-not-allowed",Da=Se({__name:"UiIconButton",props:{icon:{},label:{},size:{default:"sm"},variant:{default:"default"},disabled:{type:Boolean,default:!1},loading:{type:Boolean,default:!1}},emits:["click"],setup(e,{emit:n}){const a=e,s=n,l=F(()=>{switch(a.variant){case"default":return"hover:bg-black/10 dark:hover:bg-white/10";case"ghost":return"hover:bg-black/5 dark:hover:bg-white/5";case"danger":return"text-red-600 hover:bg-red-50 dark:hover:bg-red-900/20";default:return""}}),u=F(()=>{switch(a.size){case"xs":return"p-0.5";case"sm":return"p-1";case"md":return"p-1.5";default:return""}}),i=F(()=>{switch(a.size){case"xs":return"w-3.5 h-3.5";case"sm":return"w-4 h-4";case"md":return"w-5 h-5";default:return""}}),c=f=>{!a.disabled&&!a.loading&&s("click",f)};return(f,h)=>(r(),o("button",{type:"button",disabled:e.disabled||e.loading,"aria-label":e.label,title:e.label,class:pe([al,l.value,u.value]),onClick:c},[e.loading?(r(),Y(Be,{key:0,size:"xs"})):(r(),Y(rt(e.icon),{key:1,class:pe(i.value)},null,8,["class"]))],10,rl))}}),nl=["for"],ol={key:0,class:"text-red-500 ml-0.5"},Ua=Se({__name:"UiLabel",props:{required:{type:Boolean,default:!1},htmlFor:{}},setup(e){return(n,a)=>(r(),o("label",{for:e.htmlFor,class:"block text-sm font-medium text-neutral-700 dark:text-neutral-300"},[Ye(n.$slots,"default"),e.required?(r(),o("span",ol,"*")):S("",!0)],8,nl))}}),ll={class:"text-xs text-red-500 dark:text-red-400"},$t=Se({__name:"UiErrorText",setup(e){return(n,a)=>(r(),o("p",ll,[Ye(n.$slots,"default")]))}}),sl={class:"text-xs text-neutral-500 dark:text-neutral-400"},Ne=Se({__name:"UiHelpText",setup(e){return(n,a)=>(r(),o("p",sl,[Ye(n.$slots,"default")]))}}),il={class:"space-y-1.5"},At=Se({__name:"UiFormField",props:{label:{},error:{},helpText:{},required:{type:Boolean,default:!1},htmlFor:{}},setup(e){return(n,a)=>(r(),o("div",il,[Ye(n.$slots,"label",{},()=>[e.label?(r(),Y(Ua,{key:0,"html-for":e.htmlFor,required:e.required},{default:W(()=>[ve(C(e.label),1)]),_:1},8,["html-for","required"])):S("",!0)]),Ye(n.$slots,"default"),Ye(n.$slots,"error",{},()=>[e.error?(r(),Y($t,{key:0},{default:W(()=>[ve(C(e.error),1)]),_:1})):S("",!0)]),Ye(n.$slots,"help",{},()=>[e.helpText&&!e.error?(r(),Y(Ne,{key:0},{default:W(()=>[ve(C(e.helpText),1)]),_:1})):S("",!0)])]))}}),ul={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function dl(e,n){return r(),o("svg",ul,[...n[0]||(n[0]=[t("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M18 6L6 18M6 6l12 12"},null,-1)])])}const mr=je({name:"lucide-x",render:dl}),cl={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function pl(e,n){return r(),o("svg",cl,[...n[0]||(n[0]=[t("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[t("circle",{cx:"12",cy:"12",r:"10"}),t("path",{d:"M12 16v-4m0-4h.01"})],-1)])])}je({name:"lucide-info",render:pl});const ml={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function vl(e,n){return r(),o("svg",ml,[...n[0]||(n[0]=[t("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[t("circle",{cx:"12",cy:"12",r:"10"}),t("path",{d:"m9 12l2 2l4-4"})],-1)])])}je({name:"lucide-circle-check",render:vl});const fl={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function gl(e,n){return r(),o("svg",fl,[...n[0]||(n[0]=[t("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"m21.73 18l-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3M12 9v4m0 4h.01"},null,-1)])])}const Xr=je({name:"lucide-triangle-alert",render:gl}),hl={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function bl(e,n){return r(),o("svg",hl,[...n[0]||(n[0]=[t("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[t("circle",{cx:"12",cy:"12",r:"10"}),t("path",{d:"m15 9l-6 6m0-6l6 6"})],-1)])])}je({name:"lucide-circle-x",render:bl});const Ut=Se({__name:"UiBadge",props:{variant:{default:"default"},size:{default:"sm"},pill:{type:Boolean,default:!1}},setup(e){const n=e,a=F(()=>{switch(n.variant){case"default":return"bg-neutral-100 dark:bg-neutral-800 text-neutral-700 dark:text-neutral-300";case"primary":return"bg-black dark:bg-white text-white dark:text-black";case"secondary":return"bg-neutral-200 dark:bg-neutral-700 text-neutral-600 dark:text-neutral-300";case"success":return"bg-green-100 dark:bg-green-900/30 text-green-700 dark:text-green-300";case"warning":return"bg-yellow-100 dark:bg-yellow-900/30 text-yellow-700 dark:text-yellow-300";case"error":return"bg-red-100 dark:bg-red-900/30 text-red-700 dark:text-red-300";case"accent":return"bg-accent-100 dark:bg-accent-900/30 text-accent-700 dark:text-accent-300";default:return""}}),s=F(()=>{switch(n.size){case"sm":return"px-2 py-0.5 text-xs";case"md":return"px-2.5 py-1 text-sm";default:return""}});return(l,u)=>(r(),o("span",{class:pe(["inline-flex items-center font-medium",a.value,s.value,e.pill?"rounded-full":"rounded"])},[Ye(l.$slots,"default")],2))}}),xl={key:0,class:"border-b border-neutral-200 dark:border-neutral-700"},yl={key:1,class:"border-t border-neutral-200 dark:border-neutral-700"},vr=Se({__name:"UiDropdownPanel",props:{width:{},maxHeight:{},shadow:{type:[Boolean,Object],default:!0}},setup(e){const n=e,a=F(()=>n.shadow===!0?{offsetX:6,offsetY:6,intensity:.4}:n.shadow&&typeof n.shadow=="object"?n.shadow:null),s=F(()=>!!n.shadow),l=F(()=>["bg-white dark:bg-neutral-900 border border-neutral-300 dark:border-neutral-600 rounded-lg overflow-hidden",n.width]),u=F(()=>[n.maxHeight?"overflow-y-auto":"",n.maxHeight]);return(i,c)=>(r(),Y(rt(s.value?Zt:"template"),fn(gn(s.value?a.value:{})),{default:W(()=>[t("div",{class:pe(l.value)},[i.$slots.header?(r(),o("div",xl,[Ye(i.$slots,"header")])):S("",!0),t("div",{class:pe(u.value)},[Ye(i.$slots,"default")],2),i.$slots.footer?(r(),o("div",yl,[Ye(i.$slots,"footer")])):S("",!0)],2)]),_:3},16))}}),kl={class:"flex items-start gap-3"},wl={class:"flex-1 text-sm"},ot=Se({__name:"UiAlertBox",props:{variant:{default:"info"},showIcon:{type:Boolean,default:!0}},setup(e){const n=e,a=F(()=>{switch(n.variant){case"warning":return"bg-amber-50 dark:bg-amber-900/20 border-amber-200 dark:border-amber-800 text-amber-800 dark:text-amber-300";case"success":return"bg-emerald-50 dark:bg-emerald-900/20 border-emerald-200 dark:border-emerald-800 text-emerald-800 dark:text-emerald-300";case"error":return"bg-red-50 dark:bg-red-900/20 border-red-200 dark:border-red-800 text-red-800 dark:text-red-300";case"info":default:return"bg-neutral-50 dark:bg-neutral-900/50 border-neutral-200 dark:border-neutral-700 text-neutral-700 dark:text-neutral-300"}}),s=F(()=>{switch(n.variant){case"warning":return ar;case"success":return bn;case"error":return hn;case"info":default:return ya}}),l=F(()=>{switch(n.variant){case"warning":return"text-amber-500 dark:text-amber-400";case"success":return"text-emerald-500 dark:text-emerald-400";case"error":return"text-red-500 dark:text-red-400";case"info":default:return"text-neutral-500 dark:text-neutral-400"}});return(u,i)=>(r(),o("div",{class:pe(["px-4 py-3 border rounded-lg",a.value])},[t("div",kl,[e.showIcon?(r(),Y(rt(s.value),{key:0,class:pe(["w-5 h-5 mt-0.5 flex-shrink-0",l.value])},null,8,["class"])):S("",!0),t("div",wl,[Ye(u.$slots,"default")])])],2))}}),Qr=Se({__name:"UiMenuItem",props:{active:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},as:{default:"button"}},emits:["click"],setup(e,{emit:n}){const a=e,s=n;function l(u){a.disabled||s("click",u)}return(u,i)=>(r(),Y(rt(e.as),{type:e.as==="button"?"button":void 0,disabled:e.as==="button"?e.disabled:void 0,onClick:l,class:pe(["w-full flex items-center gap-2 px-3 py-2 text-sm text-left transition-colors",[e.disabled?"opacity-50 cursor-not-allowed":"hover:bg-neutral-100 dark:hover:bg-neutral-800 cursor-pointer",e.active?"bg-accent-50 dark:bg-accent-950/30":""]])},{default:W(()=>[Ye(u.$slots,"default")]),_:3},8,["type","disabled","class"]))}}),_l={class:"relative inline-flex group"},ea=Se({__name:"UiTooltip",props:{content:{},position:{default:"top"}},setup(e){const n=e,a=F(()=>{switch(n.position){case"bottom":return"top-full mt-2 left-1/2 -translate-x-1/2";case"left":return"right-full mr-2 top-1/2 -translate-y-1/2";case"right":return"left-full ml-2 top-1/2 -translate-y-1/2";case"top":default:return"bottom-full mb-2 left-1/2 -translate-x-1/2"}}),s=F(()=>{switch(n.position){case"bottom":return"bottom-full left-1/2 -translate-x-1/2 border-b-black dark:border-b-white border-t-transparent border-l-transparent border-r-transparent";case"left":return"left-full top-1/2 -translate-y-1/2 border-l-black dark:border-l-white border-t-transparent border-b-transparent border-r-transparent";case"right":return"right-full top-1/2 -translate-y-1/2 border-r-black dark:border-r-white border-t-transparent border-b-transparent border-l-transparent";case"top":default:return"top-full left-1/2 -translate-x-1/2 border-t-black dark:border-t-white border-b-transparent border-l-transparent border-r-transparent"}});return(l,u)=>(r(),o("div",_l,[Ye(l.$slots,"default"),t("div",{class:pe(["absolute z-50 px-3 py-2 text-xs whitespace-nowrap bg-black dark:bg-white text-white dark:text-black rounded opacity-0 invisible group-hover:opacity-100 group-hover:visible group-focus-within:opacity-100 group-focus-within:visible transition-opacity pointer-events-none",a.value]),role:"tooltip"},[ve(C(e.content)+" ",1),t("div",{class:pe(["absolute border-4",s.value])},null,2)],2)]))}}),Ba=Se({__name:"UiCodeBlock",props:{inline:{type:Boolean,default:!0}},setup(e){return(n,a)=>(r(),Y(rt(e.inline?"code":"pre"),{class:pe(["font-mono text-xs bg-neutral-100 dark:bg-neutral-800 rounded",e.inline?"px-1.5 py-0.5":"px-3 py-2 overflow-x-auto"])},{default:W(()=>[Ye(n.$slots,"default")]),_:3},8,["class"]))}}),$l={key:0,class:"block text-zinc-700 dark:text-zinc-300 text-xs font-bold mb-1"},Cl={key:0,class:"text-red-500"},Sl=["aria-expanded","aria-disabled"],Il={key:0,class:"flex items-center gap-2 text-zinc-400 flex-1 min-w-0"},Tl=["src","alt"],Ml={class:"block truncate"},zl={key:2,class:"block truncate text-zinc-400 flex-1 min-w-0"},Vl=["placeholder"],El=["onClick","onMouseenter"],Ll=["src","alt"],Al={key:1,class:"w-full h-full bg-zinc-200 dark:bg-zinc-700 rounded"},Pl={class:"flex-1 min-w-0"},ft=Se({__name:"SelectInput",props:{modelValue:{},options:{},optionLoader:{},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},triggerClass:{},size:{default:"md"},activeHighlight:{type:Boolean,default:!1},loadOnScroll:{type:Boolean,default:!1},searchDebounce:{default:150}},emits:["update:modelValue"],setup(e,{emit:n}){const a=e,s=n,l=p(!1),u=p(""),i=p(),c=p(),f=p(),h=p(),x=p(),b=p(),y=p(-1),$=p([]),g=p({}),d=p(1),w=p(!1),m=p(!1);let v=null,_=0;const P=F(()=>typeof a.options=="function"),V=F(()=>Array.isArray(a.options)?a.options:[]),E=F(()=>{const ie={...g.value};for(const xe of $.value)ie[xe.value]=xe;for(const xe of V.value)ie[xe.value]=xe;return ie}),z=F(()=>{if(a.modelValue)return E.value[a.modelValue]}),A=F(()=>{const ie=a.activeHighlight&&z.value,xe=a.size==="sm"?"!text-xs !py-1 !px-2":"",X=ie?"!border-accent-500 !bg-accent-50 dark:!bg-accent-950/50 !text-accent-700 dark:!text-accent-300":"";return a.triggerClass?[a.triggerClass,"text-left cursor-pointer",xe,X,a.error?"!border-red-500 dark:!border-red-400":""]:["w-full min-w-[200px] px-3 py-2 text-left rounded-lg focus:outline-none focus:ring-2 focus:ring-accent-500/30 bg-transparent disabled:opacity-50 disabled:cursor-not-allowed text-sm overflow-hidden transition-colors",xe,X,a.error?"border border-red-500 dark:border-red-400 focus:border-red-500 dark:focus:border-red-400":"border border-zinc-200 dark:border-zinc-700 focus:border-accent-500 dark:focus:border-accent-400"]}),oe=F(()=>{if(P.value)return $.value;if(!u.value)return V.value;const ie=u.value.toLowerCase();return V.value.filter(xe=>xe.label.toLowerCase().includes(ie)||xe.value.toLowerCase().includes(ie)||xe.description&&xe.description.toLowerCase().includes(ie))});Ve(oe,()=>{y.value=-1});const ne=ie=>{const xe={...g.value};for(const X of ie)xe[X.value]=X;g.value=xe},fe=(ie,xe)=>{const X=new Set(ie.map(be=>be.value)),he=[...ie];for(const be of xe)X.has(be.value)||(he.push(be),X.add(be.value));return he},ye=async({reset:ie=!1,page:xe=1}={})=>{if(!P.value)return;const X=a.options;if(typeof X!="function")return;const he=++_;m.value=!0;let be=!1;try{const B=await X({search:u.value||void 0,page:xe,hasNextPage:()=>{be=!0}});if(he!==_)return;ne(B),d.value=xe,w.value=be,$.value=ie?B:fe($.value,B)}finally{he===_&&(m.value=!1)}},te=async()=>{if(!a.modelValue||z.value||!a.optionLoader)return;const ie=await a.optionLoader(a.modelValue,g.value[a.modelValue]);ie&&ne([ie])};Ve(()=>a.modelValue,()=>{te()},{immediate:!0}),Ve(u,()=>{!P.value||!l.value||(v&&clearTimeout(v),v=setTimeout(()=>{$.value=[],ye({reset:!0,page:1})},a.searchDebounce))});const q=()=>{a.disabled||(l.value?ce():(l.value=!0,u.value="",y.value=-1,Fe(()=>{if(h.value&&(h.value.setAttribute("popover","auto"),h.value.addEventListener("toggle",Q),"showPopover"in h.value))try{h.value.showPopover()}catch{}Z(),P.value&&($.value=[],ye({reset:!0,page:1})),setTimeout(()=>i.value?.focus(),0)})))},j=ie=>{a.disabled||(ie.key==="Enter"||ie.key===" "||ie.key==="ArrowDown"&&!l.value)&&(ie.preventDefault(),q())},J=ie=>{s("update:modelValue",ie.value),ce(),u.value="",y.value=-1},H=ie=>{ie.stopPropagation(),s("update:modelValue","")},ce=()=>{if(h.value){if("hidePopover"in h.value)try{h.value.hidePopover()}catch{}h.value.removeEventListener("toggle",Q)}l.value=!1,y.value=-1},Z=()=>{if(!f.value||!h.value)return;const ie=f.value.getBoundingClientRect(),xe=window.innerWidth,X=window.innerHeight,he=16,be=8;h.value.style.position="fixed",h.value.style.left=`${ie.left}px`,h.value.style.margin="0",h.value.style.width="max-content";const B=h.value.offsetWidth,D=ie.width,M=Math.max(D,Math.min(400,xe-ie.left-he)),T=Math.max(D,Math.min(B,M));h.value.style.width=`${T}px`;const L=a.size==="sm"?192:240,ee=a.size==="sm"?96:120,le=x.value?.offsetHeight??0,Ie=2,Re=X-ie.bottom-be-he-le-Ie,qe=ie.top-be-he-le-Ie,We=Re<ee&&qe>Re,R=Math.max(0,We?qe:Re),O=Math.max(Math.min(L,R),Math.min(ee,R));b.value&&(b.value.style.maxHeight=`${O}px`);const ke=h.value.offsetHeight,de=ie.bottom+be,Ue=Math.max(he,ie.top-be-ke);h.value.style.top=We?`${Ue}px`:`${Math.max(he,Math.min(de,X-he-ke))}px`},U=ie=>{c.value&&!c.value.contains(ie.target)&&h.value&&!h.value.contains(ie.target)&&ce()},K=ie=>{ie.key==="Escape"&&l.value&&(ce(),f.value?.focus())},me=ie=>{if(!l.value)return;const xe=oe.value;if(xe.length!==0)switch(ie.key){case"ArrowDown":ie.preventDefault(),y.value=y.value<xe.length-1?y.value+1:0,ue();break;case"ArrowUp":ie.preventDefault(),y.value=y.value>0?y.value-1:xe.length-1,ue();break;case"Enter":ie.preventDefault(),y.value>=0&&y.value<xe.length&&J(xe[y.value]);break}},ue=()=>{Fe(()=>{const ie=h.value?.querySelector(".highlighted-option");ie&&ie.scrollIntoView({block:"nearest",behavior:"smooth"})})},Q=ie=>{ie.target===h.value&&(l.value=ie.newState==="open",l.value&&Z())},G=()=>{if(!a.loadOnScroll||!P.value||!w.value||m.value||!b.value)return;const{scrollTop:ie,scrollHeight:xe,clientHeight:X}=b.value;ie+X>=xe-32&&ye({page:d.value+1})},ae=()=>{l.value&&Z()};return He(()=>{document.addEventListener("click",U),document.addEventListener("keydown",K),window.addEventListener("resize",ae),window.addEventListener("scroll",ae,!0)}),ct(()=>{v&&clearTimeout(v),document.removeEventListener("click",U),document.removeEventListener("keydown",K),window.removeEventListener("resize",ae),window.removeEventListener("scroll",ae,!0)}),(ie,xe)=>(r(),o("div",{ref_key:"dropdownRef",ref:c,class:"relative"},[e.label?(r(),o("label",$l,[ve(C(e.label)+" ",1),e.required?(r(),o("span",Cl,"*")):S("",!0)])):S("",!0),t("div",{ref_key:"buttonRef",ref:f,role:"button",tabindex:"0",onClick:Xe(q,["stop"]),onKeydown:j,"aria-expanded":l.value,"aria-haspopup":!0,"aria-disabled":e.disabled,class:pe(A.value)},[t("div",{class:pe(["flex items-center gap-1 w-full",e.size==="sm"?"min-h-[1.25em]":"min-h-[1.5em]"])},[e.loading?(r(),o("span",Il,[k(Be,{size:"xs"}),xe[1]||(xe[1]=ve(" Loading... ",-1))])):z.value?(r(),o("span",{key:1,class:pe(["flex items-center flex-1 min-w-0",e.size==="sm"?"gap-1.5":"gap-2"])},[z.value.icon?(r(),o("img",{key:0,src:z.value.icon,alt:z.value.label,class:pe(["flex-shrink-0",e.size==="sm"?"w-4 h-4":"w-5 h-5"])},null,10,Tl)):S("",!0),t("span",Ml,C(z.value.label),1)],2)):(r(),o("span",zl,C(e.placeholder),1)),z.value&&!e.disabled?(r(),o("button",{key:3,type:"button",onClick:Xe(H,["stop"]),class:"flex-shrink-0 p-0.5 hover:bg-zinc-100 dark:hover:bg-zinc-800 rounded transition-colors","aria-label":"Clear selection"},[(r(),o("svg",{class:pe(["text-zinc-400 hover:text-zinc-600 dark:hover:text-zinc-300",e.size==="sm"?"h-3 w-3":"h-4 w-4"]),xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor"},[...xe[2]||(xe[2]=[t("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"},null,-1)])],2))])):S("",!0),(r(),o("svg",{class:pe(["text-zinc-400 flex-shrink-0",e.size==="sm"?"h-3.5 w-3.5":"h-5 w-5"]),xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor"},[...xe[3]||(xe[3]=[t("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"},null,-1)])],2))],2)],42,Sl),l.value?(r(),o("div",{key:1,ref_key:"popoverRef",ref:h,class:"dropdown-popover z-[9999]"},[k(I(vr),{shadow:{offsetX:4,offsetY:4,intensity:.3}},{header:W(()=>[t("div",{ref_key:"headerRef",ref:x,class:pe(e.size==="sm"?"p-1.5":"p-2")},[Je(t("input",{ref_key:"searchInput",ref:i,"onUpdate:modelValue":xe[0]||(xe[0]=X=>u.value=X),type:"text",placeholder:e.searchPlaceholder,onKeydown:me,class:pe(["w-full border border-zinc-300 dark:border-zinc-600 rounded-sm focus:outline-none focus:ring-1 focus:ring-accent-400 focus:border-accent-400 bg-transparent text-zinc-700 dark:text-zinc-200 placeholder:text-zinc-400 dark:placeholder:text-zinc-500",e.size==="sm"?"px-2 py-1 text-xs":"px-3 py-1.5 text-sm"])},null,42,Vl),[[yt,u.value]])],2)]),default:W(()=>[t("div",{ref_key:"optionsListRef",ref:b,class:"overflow-y-auto overscroll-contain",onScroll:G},[oe.value.length===0&&!m.value?(r(),o("div",{key:0,class:pe(["text-zinc-500 dark:text-zinc-400",e.size==="sm"?"px-3 py-2 text-xs":"px-4 py-3 text-sm"])}," No options found ",2)):S("",!0),(r(!0),o($e,null,Le(oe.value,(X,he)=>(r(),o("button",{key:X.value,type:"button",onClick:be=>J(X),onMouseenter:be=>y.value=he,class:pe(["w-full text-left hover:bg-zinc-100 dark:hover:bg-zinc-800 focus:bg-zinc-100 dark:focus:bg-zinc-800 focus:outline-none flex items-start",[e.size==="sm"?"px-2.5 py-1.5 gap-2":"px-4 py-2 gap-3",{"bg-zinc-50 dark:bg-zinc-900":X.value===e.modelValue,"bg-zinc-100 dark:bg-zinc-800 highlighted-option":he===y.value}]])},[t("div",{class:pe(["flex-shrink-0 mt-0.5",e.size==="sm"?"w-4 h-4":"w-5 h-5"])},[X.icon?(r(),o("img",{key:0,src:X.icon,alt:X.label,class:"w-full h-full"},null,8,Ll)):(r(),o("div",Al))],2),t("div",Pl,[t("div",{class:pe(["font-medium text-black dark:text-white",e.size==="sm"?"text-xs":"text-sm"])},C(X.label),3),X.description?(r(),o("div",{key:0,class:pe(["text-zinc-500 dark:text-zinc-400 mt-0.5",e.size==="sm"?"text-[10px]":"text-xs"])},C(X.description),3)):S("",!0)])],42,El))),128)),m.value?(r(),o("div",{key:1,class:pe(["flex items-center justify-center gap-2 text-zinc-500 dark:text-zinc-400",e.size==="sm"?"px-3 py-2 text-xs":"px-4 py-3 text-sm"])},[k(Be,{size:"xs"}),xe[4]||(xe[4]=ve(" Loading... ",-1))],2)):S("",!0)],544)]),_:1})],512)):S("",!0),e.error?(r(),Y(I($t),{key:2,class:"mt-1"},{default:W(()=>[ve(C(e.error),1)]),_:1})):S("",!0)],512))}}),Ol=["type","value","placeholder","disabled"],Mt=Se({__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(e,{expose:n,emit:a}){const s=e,l=a,u=p(null),i=F(()=>["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",s.error?"border-red-500 dark:border-red-400":"border-neutral-300 dark:border-neutral-800",s.disabled?"opacity-50 cursor-not-allowed":""]),c=x=>{const b=x.target;l("update:modelValue",b.value)},f=x=>{l("focus",x)},h=x=>{l("click",x)};return n({inputRef:u}),(x,b)=>(r(),Y(I(At),{label:e.label,error:e.error,required:e.required},{default:W(()=>[t("input",{ref_key:"inputRef",ref:u,type:e.type,value:e.modelValue,placeholder:e.placeholder,disabled:e.disabled,class:pe(i.value),onInput:c,onFocus:f,onClick:h},null,42,Ol)]),_:1},8,["label","error","required"]))}}),Rl=["data-property-id","data-nested-property-id"],jl={class:"p-3 space-y-3"},Dl={class:"flex items-start gap-2"},Ul={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"},Bl={class:"flex-1 grid grid-cols-1 md:grid-cols-3 gap-2"},Nl={class:"flex items-center gap-2 mt-2"},ql=["disabled"],Fl={key:0},Hl={key:0,class:"p-3 bg-neutral-50 dark:bg-neutral-900 rounded-lg space-y-2"},Wl={class:"flex items-center justify-between mb-2"},Kl=["disabled"],Jl={key:0,class:"space-y-1"},Gl=["onClick","disabled"],Yl={key:1,class:"p-3 bg-neutral-50 dark:bg-neutral-900 rounded-lg"},Zl={class:"text-xs font-medium text-neutral-600 dark:text-neutral-400 mb-2"},Xl={class:"space-y-2"},Ql={class:"flex items-center justify-between"},es=["disabled"],ts={class:"space-y-2"},rs={key:2,class:"p-3 bg-neutral-50 dark:bg-neutral-900 rounded-lg"},as={key:0,class:"mb-2"},ns=["disabled"],os={key:1,class:"space-y-2"},ls=Se({__name:"PropertyEditor",props:gt({propertyId:{},isNested:{type:Boolean,default:!1},parentId:{},disabled:{type:Boolean,default:!1},enableDrag:{type:Boolean,default:!0}},{modelValue:{required:!0},modelModifiers:{}}),emits:gt(["remove","description-keydown","add-top-level"],["update:modelValue"]),setup(e,{emit:n}){const a=e,s=n,l=zt(e,"modelValue"),u=p(["object","array","enum","anyOf"].includes(l.value.type));p();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"}],c=F(()=>["object","array","enum","anyOf"].includes(l.value.type));Ve(()=>l.value.type,async(g,d)=>{if(["object","array","enum","anyOf"].includes(g)&&(u.value=!0,g==="anyOf"&&!l.value.anyOf&&(l.value.anyOf=[]),g==="object"&&!l.value.properties&&(l.value.properties=[{id:crypto.randomUUID(),name:"property1",type:"string",description:""}]),g==="array"&&!l.value.items&&(l.value.items={id:crypto.randomUUID(),name:"",type:"string",description:""}),g==="enum"&&!l.value.enum&&(l.value.enum=["value1"])),d!==void 0){await Fe();const w=a.isNested?`[data-nested-property-id="${a.propertyId}"] input[placeholder="Description"]`:`[data-property-id="${a.propertyId}"] input[placeholder="Description"]`,m=document.querySelector(w);m&&m.focus()}},{immediate:!0,flush:"sync"});const f=g=>{g.shiftKey&&l.value.type==="object"&&l.value.properties?y():s("add-top-level")},h=()=>{l.value.items||(l.value.items={id:crypto.randomUUID(),name:"",type:"string",description:""})},x=()=>{l.value.enum||(l.value.enum=[]),l.value.enum.push(`value${l.value.enum.length+1}`)},b=g=>{l.value.enum&&l.value.enum.splice(g,1)},y=async()=>{const g={id:crypto.randomUUID(),name:l.value.type==="anyOf"?"":`property${(l.value.properties?.length||l.value.anyOf?.length||0)+1}`,type:"string",description:""};l.value.type==="anyOf"?(l.value.anyOf||(l.value.anyOf=[]),l.value.anyOf.push(g)):(l.value.properties||(l.value.properties=[]),l.value.properties.push(g)),await Fe();const d=document.querySelector(`[data-nested-property-id="${g.id}"] input[placeholder="Property name"]`);d&&(d.focus(),d.select())},$=g=>{l.value.type==="anyOf"&&l.value.anyOf?l.value.anyOf=l.value.anyOf.filter(d=>d.id!==g):l.value.properties&&(l.value.properties=l.value.properties.filter(d=>d.id!==g))};return(g,d)=>{const w=at("PropertyEditor",!0);return r(),o("div",{"data-property-id":e.isNested?void 0:e.propertyId,"data-nested-property-id":e.isNested?e.propertyId:void 0,class:pe(["border rounded-lg",e.isNested?"border-neutral-100 dark:border-neutral-900":"border-neutral-200 dark:border-neutral-800"])},[t("div",jl,[t("div",Dl,[e.enableDrag?(r(),o("div",Ul,[...d[10]||(d[10]=[t("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[t("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M4 8h16M4 16h16"})],-1)])])):S("",!0),t("div",Bl,[k(Mt,{modelValue:l.value.name,"onUpdate:modelValue":d[0]||(d[0]=m=>l.value.name=m),placeholder:"Property name",disabled:e.disabled},null,8,["modelValue","disabled"]),k(ft,{modelValue:l.value.type,"onUpdate:modelValue":d[1]||(d[1]=m=>l.value.type=m),options:i,disabled:e.disabled},null,8,["modelValue","disabled"]),k(Mt,{modelValue:l.value.description,"onUpdate:modelValue":d[2]||(d[2]=m=>l.value.description=m),placeholder:"Description",disabled:e.disabled,onKeydown:d[3]||(d[3]=xn(Xe(m=>f(m),["prevent"]),["enter"]))},null,8,["modelValue","disabled"])]),t("div",Nl,[c.value?(r(),o("button",{key:0,onClick:d[4]||(d[4]=m=>u.value=!u.value),type:"button",class:"p-1 hover:bg-neutral-100 dark:hover:bg-neutral-800 rounded transition-colors"},[(r(),o("svg",{class:pe(["w-4 h-4 transition-transform",u.value?"rotate-90":""]),fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[...d[11]||(d[11]=[t("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M9 5l7 7-7 7"},null,-1)])],2))])):S("",!0),t("button",{onClick:d[5]||(d[5]=m=>g.$emit("remove")),type:"button",disabled:e.disabled,class:"p-1 text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20 rounded transition-colors disabled:opacity-50"},[...d[12]||(d[12]=[t("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[t("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M6 18L18 6M6 6l12 12"})],-1)])],8,ql)])]),u.value&&c.value?(r(),o("div",Fl,[l.value.type==="enum"?(r(),o("div",Hl,[t("div",Wl,[d[13]||(d[13]=t("h4",{class:"text-xs font-medium text-neutral-600 dark:text-neutral-400"}," Enum Values ",-1)),t("button",{onClick:x,type:"button",disabled:e.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,Kl)]),l.value.enum?(r(),o("div",Jl,[(r(!0),o($e,null,Le(l.value.enum,(m,v)=>(r(),o("div",{key:v,class:"flex items-center gap-2"},[k(Mt,{modelValue:l.value.enum[v],"onUpdate:modelValue":_=>l.value.enum[v]=_,placeholder:"Enum value",disabled:e.disabled,class:"flex-1"},null,8,["modelValue","onUpdate:modelValue","disabled"]),t("button",{onClick:_=>b(v),type:"button",disabled:e.disabled,class:"p-1 text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20 rounded transition-colors disabled:opacity-50"},[...d[14]||(d[14]=[t("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[t("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M6 18L18 6M6 6l12 12"})],-1)])],8,Gl)]))),128))])):S("",!0)])):S("",!0),l.value.type==="object"||l.value.type==="anyOf"?(r(),o("div",Yl,[t("h4",Zl,C(l.value.type==="anyOf"?"Type Options":"Nested Properties"),1),t("div",Xl,[t("div",Ql,[t("button",{onClick:y,type:"button",disabled:e.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(l.value.type==="anyOf"?"Type Option":"Property"),9,es)]),t("div",ts,[(r(!0),o($e,null,Le(l.value.type==="anyOf"?l.value.anyOf:l.value.properties,(m,v)=>(r(),Y(w,{key:m.id,modelValue:(l.value.type==="anyOf"?l.value.anyOf:l.value.properties)[v],"onUpdate:modelValue":_=>(l.value.type==="anyOf"?l.value.anyOf:l.value.properties)[v]=_,"property-id":m.id,"is-nested":!0,"parent-id":e.propertyId,disabled:e.disabled,"enable-drag":!1,onRemove:_=>$(m.id),onAddTopLevel:d[6]||(d[6]=_=>s("add-top-level"))},null,8,["modelValue","onUpdate:modelValue","property-id","parent-id","disabled","onRemove"]))),128))])])])):S("",!0),l.value.type==="array"?(r(),o("div",rs,[d[15]||(d[15]=t("h4",{class:"text-xs font-medium text-neutral-600 dark:text-neutral-400 mb-2"}," Array Item Type ",-1)),l.value.items?S("",!0):(r(),o("div",as,[t("button",{onClick:h,type:"button",disabled:e.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,ns)])),l.value.items?(r(),o("div",os,[(r(),Y(w,{key:`${l.value.items.id}-${l.value.items.type}`,modelValue:l.value.items,"onUpdate:modelValue":d[7]||(d[7]=m=>l.value.items=m),"property-id":l.value.items.id,"is-nested":!0,"parent-id":e.propertyId,disabled:e.disabled,"enable-drag":!1,onRemove:d[8]||(d[8]=m=>l.value.items=null),onAddTopLevel:d[9]||(d[9]=m=>s("add-top-level"))},null,8,["modelValue","property-id","parent-id","disabled"]))])):S("",!0)])):S("",!0)])):S("",!0)])],10,Rl)}}}),ss={class:"space-y-2"},is=["disabled"],us=Se({__name:"PropertyList",props:gt({disabled:{type:Boolean,default:!1},parentId:{},isNested:{type:Boolean,default:!1}},{modelValue:{required:!0,default:()=>[]},modelModifiers:{}}),emits:gt(["add-property","description-keydown"],["update:modelValue"]),setup(e,{expose:n,emit:a}){const s=e,l=a,u=zt(e,"modelValue"),i=p();let c=!1;He(async()=>{}),ct(()=>{});const f=async()=>{if(c)return;c=!0;const x={id:crypto.randomUUID(),name:`property${u.value.length+1}`,type:"string",description:"",required:!1};u.value=[...u.value,x],await Fe();const b=s.parentId?`[data-nested-property-id="${x.id}"]`:`[data-property-id="${x.id}"]`,y=document.querySelector(`${b} input[placeholder="Property name"]`);y&&(y.focus(),y.select()),l("add-property"),c=!1},h=x=>{u.value=u.value.filter(b=>b.id!==x)};return n({addProperty:f}),(x,b)=>(r(),o("div",ss,[t("div",{ref_key:"dragAreaRef",ref:i,class:"space-y-2"},[(r(!0),o($e,null,Le(u.value,y=>(r(),Y(ls,{key:y.id,modelValue:u.value[u.value.indexOf(y)],"onUpdate:modelValue":$=>u.value[u.value.indexOf(y)]=$,"property-id":y.id,"is-nested":e.isNested,"parent-id":e.parentId,disabled:e.disabled,"enable-drag":!e.isNested,onRemove:$=>h(y.id),onAddTopLevel:b[0]||(b[0]=$=>x.$emit("add-property"))},null,8,["modelValue","onUpdate:modelValue","property-id","is-nested","parent-id","disabled","enable-drag","onRemove"]))),128))],512),t("div",{class:pe(e.isNested?"mt-2":"mt-3 pt-3 border-t border-neutral-200 dark:border-neutral-800")},[t("button",{onClick:f,type:"button",disabled:e.disabled,class:pe(e.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")},[...b[1]||(b[1]=[t("span",{class:"flex items-center justify-center gap-2"},[t("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[t("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 4v16m8-8H4"})]),ve(" Add Property ")],-1)])],10,is)],2)]))}}),ds={class:"space-y-4"},cs={key:0,class:"flex items-center justify-between"},ps={class:"text-sm font-medium"},ms={key:0,class:"text-red-500"},vs={class:"space-y-2 border border-neutral-200 dark:border-neutral-800 rounded-lg p-4"},fs={key:0,class:"flex items-center justify-between mb-2"},gs={key:1,class:"text-center py-12"},hs=["disabled"],bs={class:"mt-4 text-center"},xs={key:3,class:"mt-4"},ys={class:"bg-neutral-50 dark:bg-neutral-900 border border-neutral-200 dark:border-neutral-800 rounded-lg p-4 overflow-x-auto"},ks={class:"text-xs leading-relaxed"},ws=["innerHTML"],Na=Se({__name:"JSONSchemaInput",props:gt({label:{},disabled:{type:Boolean,default:!1},required:{type:Boolean,default:!1}},{modelValue:{required:!0,default:()=>({type:"object",properties:{},required:[]})},modelModifiers:{}}),emits:["update:modelValue"],setup(e){const n=zt(e,"modelValue"),a=p([]),s=p(),l=p(!1),u=()=>{if(n.value?.properties){const g=[];n.value.required;for(const[d,w]of Object.entries(n.value.properties)){const m=w,v={id:crypto.randomUUID(),name:d,type:m.type||"string",description:m.description||""};m.enum&&(v.enum=m.enum),m.anyOf&&(v.type="anyOf",v.anyOf=i(m.anyOf)),m.type==="array"&&m.items&&(v.items=c(m.items)),m.type==="object"&&m.properties&&(v.properties=f(m.properties,m.required||[])),g.push(v)}a.value=g}},i=g=>g.map(d=>typeof d=="object"&&d.type?{id:crypto.randomUUID(),name:"",type:d.type,description:d.description||"",properties:d.properties?f(d.properties,d.required||[]):void 0,items:d.items?c(d.items):void 0,enum:d.enum}:{id:crypto.randomUUID(),name:"",type:"string",description:""}),c=g=>{const d={id:crypto.randomUUID(),name:"",type:g.type||"string",description:g.description||""};return g.enum&&(d.enum=g.enum),g.anyOf&&(d.type="anyOf",d.anyOf=i(g.anyOf)),g.type==="array"&&g.items&&(d.items=c(g.items)),g.type==="object"&&g.properties&&(d.properties=f(g.properties,g.required||[])),d},f=(g,d)=>{const w=[];for(const[m,v]of Object.entries(g)){const _=v,P={id:crypto.randomUUID(),name:m,type:_.type||"string",description:_.description||""};_.enum&&(P.enum=_.enum),_.anyOf&&(P.type="anyOf",P.anyOf=i(_.anyOf)),_.type==="array"&&_.items&&(P.items=c(_.items)),_.type==="object"&&_.properties&&(P.properties=f(_.properties,_.required||[])),w.push(P)}return w};u();const h=()=>{const g={type:"object",properties:{},required:[],additionalProperties:!1},{properties:d}=b(a.value);g.properties=d,g.required=Object.keys(d),n.value=g},x=g=>{const d={type:g.type==="anyOf"?void 0:g.type,description:g.description};if(g.type==="enum"&&g.enum&&(d.enum=g.enum,d.type="string"),g.type==="anyOf"&&g.anyOf&&(delete d.type,d.anyOf=g.anyOf.map(x)),g.type==="object"&&g.properties){const{properties:w}=b(g.properties);d.properties=w,d.required=Object.keys(w),d.additionalProperties=!1}return g.type==="array"&&g.items&&(d.items=x(g.items)),d},b=g=>{const d={},w=[];for(const m of g){const v={type:m.type==="anyOf"?void 0:m.type,description:m.description};if(w.push(m.name),m.type==="enum"&&m.enum&&(v.enum=m.enum,v.type="string"),m.type==="anyOf"&&m.anyOf&&m.anyOf.length>0&&(delete v.type,v.anyOf=m.anyOf.map(x)),m.type==="array"&&m.items&&(v.items=x(m.items)),m.type==="object"&&m.properties){const{properties:_}=b(m.properties);v.properties=_,v.required=Object.keys(_),v.additionalProperties=!1}d[m.name]=v}return{properties:d,required:w}};Ve(a,()=>{h()},{deep:!0}),h();const y=F(()=>JSON.stringify(n.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>')),$=async()=>{if(a.value.length===0){const g={id:crypto.randomUUID(),name:"property1",type:"string",description:""};a.value.push(g),await Fe();const d=document.querySelector(`[data-property-id="${g.id}"] input[placeholder="Property name"]`);d&&(d.focus(),d.select())}else s.value&&s.value.addProperty()};return(g,d)=>(r(),o("div",ds,[e.label?(r(),o("div",cs,[t("label",ps,[ve(C(e.label)+" ",1),e.required?(r(),o("span",ms,"*")):S("",!0)])])):S("",!0),t("div",vs,[a.value.length>0?(r(),o("div",fs,[...d[2]||(d[2]=[t("h3",{class:"text-sm font-medium text-neutral-700 dark:text-neutral-300"}," Properties ",-1)])])):S("",!0),a.value.length===0?(r(),o("div",gs,[d[4]||(d[4]=t("div",{class:"mb-4"},[t("svg",{class:"w-12 h-12 mx-auto text-neutral-400 dark:text-neutral-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[t("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)),d[5]||(d[5]=t("p",{class:"text-neutral-500 dark:text-neutral-400 text-sm mb-4"}," No properties defined ",-1)),t("button",{onClick:$,type:"button",disabled:e.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"},[...d[3]||(d[3]=[t("span",{class:"flex items-center gap-2"},[t("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[t("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 4v16m8-8H4"})]),ve(" Add Property ")],-1)])],8,hs)])):S("",!0),a.value.length>0?(r(),Y(us,{key:2,ref_key:"propertyListRef",ref:s,modelValue:a.value,"onUpdate:modelValue":d[0]||(d[0]=w=>a.value=w),disabled:e.disabled,onAddProperty:$},null,8,["modelValue","disabled"])):S("",!0),t("div",bs,[t("button",{onClick:d[1]||(d[1]=w=>l.value=!l.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(l.value?"Hide":"Show")+" JSON Schema ",1)]),l.value?(r(),o("div",xs,[t("div",ys,[t("pre",ks,[t("code",{class:"font-mono",innerHTML:y.value},null,8,ws)])])])):S("",!0)])]))}}),_s=Nt(je(Na),{props:["label","disabled","required"],family:"text",features:[]}),$s={class:"space-y-2"},Cs={key:0,class:"space-y-2"},Ss={key:0,class:"block text-sm font-medium"},Is={key:0,class:"text-red-500"},Ts=["src","alt"],Ms={class:"flex-1 text-sm"},zs={key:0,class:"text-xs text-neutral-500 dark:text-neutral-400 ml-1"},Vs=["onClick","aria-label"],Bt=Se({__name:"MultipleSelectionsInput",props:gt({label:{},placeholder:{default:"Select an option"},searchPlaceholder:{default:"Search..."},error:{},required:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},options:{},addLabel:{default:"Add another"},loading:{type:Boolean,default:!1}},{modelValue:{required:!0,default:()=>[]},modelModifiers:{}}),emits:gt(["removeItem"],["update:modelValue"]),setup(e,{emit:n}){const a=e,s=n,l=zt(e,"modelValue"),u=p();ka(async()=>{u.value,await Fe(),await wa({parent:u,values:l,dragHandle:".drag-handle"})});const i=F(()=>Array.isArray(l.value)?l.value.length>0&&typeof l.value[0]=="object"?l.value:l.value.map(x=>{const b=a.options.find(y=>y.value===x);return{id:x,label:b?.label||x,description:b?.description,icon:b?.icon}}):[]),c=F(()=>{const x=i.value.map(b=>b.id);return a.options.filter(b=>!x.includes(b.value))}),f=x=>{if(!x)return;const b=a.options.find(y=>y.value===x);if(b)if(l.value.length===0||typeof l.value[0]=="string")l.value=[...l.value,x];else{const y={id:x,label:b.label,description:b.description,icon:b.icon};l.value=[...l.value,y]}},h=x=>{typeof l.value[0]=="string"?l.value=l.value.filter(b=>b!==x):l.value=l.value.filter(b=>b.id!==x),s("removeItem",x)};return(x,b)=>(r(),o("div",$s,[i.value.length>0?(r(),o("div",Cs,[e.label?(r(),o("label",Ss,[ve(C(e.label)+" ",1),e.required?(r(),o("span",Is,"*")):S("",!0)])):S("",!0),t("div",{class:"space-y-1",ref_key:"dragAreaRef",ref:u},[(r(!0),o($e,null,Le(i.value,y=>(r(),o("div",{key:y.id,class:pe(["flex items-center gap-2 px-3 py-2 bg-neutral-50 dark:bg-neutral-900 rounded border","border-neutral-200 dark:border-neutral-800",e.disabled?"opacity-50":""])},[b[1]||(b[1]=t("div",{class:"drag-handle cursor-move text-neutral-400 hover:text-neutral-600 dark:text-neutral-600 dark:hover:text-neutral-400"},[t("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[t("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M4 8h16M4 16h16"})])],-1)),y.icon?(r(),o("img",{key:0,src:y.icon,alt:y.label,class:"w-4 h-4 flex-shrink-0"},null,8,Ts)):S("",!0),t("span",Ms,[ve(C(y.label)+" ",1),y.description?(r(),o("span",zs," ("+C(y.description)+") ",1)):S("",!0)]),e.disabled?S("",!0):(r(),o("button",{key:1,onClick:$=>h(y.id),type:"button",class:"p-1 hover:bg-neutral-200 dark:hover:bg-neutral-800 rounded transition-colors","aria-label":`Remove ${y.label}`},[...b[0]||(b[0]=[t("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[t("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M6 18L18 6M6 6l12 12"})],-1)])],8,Vs))],2))),128))],512)])):S("",!0),k(ft,{"model-value":"","onUpdate:modelValue":f,label:i.value.length>0?e.addLabel:e.label,options:c.value,placeholder:e.placeholder,"search-placeholder":e.searchPlaceholder,disabled:e.disabled||c.value.length===0,loading:e.loading},null,8,["label","options","placeholder","search-placeholder","disabled","loading"]),e.error?(r(),Y(I($t),{key:1},{default:W(()=>[ve(C(e.error),1)]),_:1})):S("",!0)]))}});function qa(){return window.__AGENTBUILDER_CONFIG__||{mountPoint:"/agentbuilder"}}function Xt(){return qa().mountPoint}function fr(){return qa().devMode===!0}function ze(e){const n=Xt(),a=e.startsWith("/")?e:`/${e}`;return n==="/"?a:`${n}${a}`}const Es=Se({__name:"ModelSelectorInput",props:gt({label:{},placeholder:{default:"Select a model"},error:{},required:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},allowMultiple:{type:Boolean,default:!1}},{modelValue:{required:!0},modelModifiers:{}}),emits:["update:modelValue"],setup(e){const n=e,a=zt(e,"modelValue"),s=p([]),l=p(!1),u=F(()=>s.value.map(f=>({value:f.id,label:f.name,description:f.provider_id||f.provider,icon:f.iconId}))),i=async()=>{l.value=!0;try{const f=await fetch(ze("/api/models"));if(f.ok){const h=await f.json();s.value=h.models||[]}}catch(f){console.error("Error fetching models:",f)}finally{l.value=!1}},c=f=>{};return He(()=>{i()}),Ve(()=>n.allowMultiple,()=>{n.allowMultiple&&typeof a.value=="string"?a.value=a.value?[a.value]:[]:!n.allowMultiple&&Array.isArray(a.value)&&(a.value=a.value[0]||"")}),(f,h)=>(r(),o($e,null,[e.allowMultiple?(r(),Y(Bt,{key:0,modelValue:a.value,"onUpdate:modelValue":h[0]||(h[0]=x=>a.value=x),label:e.label,placeholder:e.placeholder,"search-placeholder":"Search models...",error:e.error,required:e.required,disabled:e.disabled,options:u.value,loading:l.value,"add-label":"Add another model",onRemoveItem:c},null,8,["modelValue","label","placeholder","error","required","disabled","options","loading"])):(r(),Y(ft,{key:1,modelValue:a.value,"onUpdate:modelValue":h[1]||(h[1]=x=>a.value=x),label:e.label,placeholder:e.placeholder,"search-placeholder":"Search models...",options:u.value,disabled:e.disabled,loading:l.value},null,8,["modelValue","label","placeholder","options","disabled","loading"])),!e.allowMultiple&&e.error?(r(),Y(I($t),{key:2,class:"mt-1"},{default:W(()=>[ve(C(e.error),1)]),_:1})):S("",!0)],64))}}),Ls=Se({__name:"AgentSelectorInput",props:gt({label:{default:"Handoff Agents"},placeholder:{default:"Select an agent"},error:{},required:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},allowMultiple:{type:Boolean,default:!0},agentType:{default:"ai_human"}},{modelValue:{required:!0,default:()=>[]},modelModifiers:{}}),emits:["update:modelValue"],setup(e){const n=e,a=zt(e,"modelValue"),s=p([]),l=p(!1),u=F(()=>s.value.map(f=>({value:f.id,label:f.title,description:f.tool_description||`Handoff to ${f.title} agent`}))),i=async()=>{l.value=!0;try{const f=ze(`/api/agents${n.agentType?`?type=${n.agentType}`:""}`),h=await fetch(f);if(h.ok){const x=await h.json();s.value=x.agents||[]}}catch(f){console.error("Error fetching agents:",f)}finally{l.value=!1}},c=f=>{};return He(()=>{i()}),Ve(()=>n.allowMultiple,()=>{n.allowMultiple&&typeof a.value=="string"?a.value=a.value?[a.value]:[]:!n.allowMultiple&&Array.isArray(a.value)&&(a.value=a.value[0]||"")},{immediate:!0}),(f,h)=>(r(),o($e,null,[e.allowMultiple?(r(),Y(Bt,{key:0,modelValue:a.value,"onUpdate:modelValue":h[0]||(h[0]=x=>a.value=x),label:e.label,placeholder:e.placeholder,"search-placeholder":"Search agents...",error:e.error,required:e.required,disabled:e.disabled,options:u.value,loading:l.value,"add-label":"Add another agent",onRemoveItem:c},null,8,["modelValue","label","placeholder","error","required","disabled","options","loading"])):(r(),Y(ft,{key:1,modelValue:a.value,"onUpdate:modelValue":h[1]||(h[1]=x=>a.value=x),label:e.label,placeholder:e.placeholder,"search-placeholder":"Search agents...",options:u.value,disabled:e.disabled,loading:l.value},null,8,["modelValue","label","placeholder","options","disabled","loading"])),!e.allowMultiple&&e.error?(r(),Y(I($t),{key:2,class:"mt-1"},{default:W(()=>[ve(C(e.error),1)]),_:1})):S("",!0)],64))}}),As=Se({__name:"ToolSelectorInput",props:gt({label:{default:"Available Tools"},placeholder:{default:"Select a tool"},error:{},required:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},allowMultiple:{type:Boolean,default:!0}},{modelValue:{required:!0,default:()=>[]},modelModifiers:{}}),emits:["update:modelValue"],setup(e){const n=e,a=zt(e,"modelValue"),s=p([]),l=p(!1),u=F(()=>s.value.map(f=>{let h=f.name;return f.type==="prompt"?h=`${f.name} (prompt)`:f.type==="mcp"&&(h=`${f.name} (mcp)`),{value:f.name,label:h,description:f.description}})),i=async()=>{l.value=!0;try{const f=await fetch(ze("/api/tools"));if(f.ok){const h=await f.json();s.value=Object.entries(h).map(([x,b])=>({name:x,description:b.description||"",type:b.type,model:b.model}))}}catch(f){console.error("Error fetching tools:",f)}finally{l.value=!1}},c=f=>{};return He(()=>{i()}),Ve(()=>n.allowMultiple,()=>{n.allowMultiple&&typeof a.value=="string"?a.value=a.value?[a.value]:[]:!n.allowMultiple&&Array.isArray(a.value)&&(a.value=a.value[0]||"")},{immediate:!0}),(f,h)=>(r(),o($e,null,[e.allowMultiple?(r(),Y(Bt,{key:0,modelValue:a.value,"onUpdate:modelValue":h[0]||(h[0]=x=>a.value=x),label:e.label,placeholder:e.placeholder,"search-placeholder":"Search tools...",error:e.error,required:e.required,disabled:e.disabled,options:u.value,loading:l.value,"add-label":"Add another tool",onRemoveItem:c},null,8,["modelValue","label","placeholder","error","required","disabled","options","loading"])):(r(),Y(ft,{key:1,modelValue:a.value,"onUpdate:modelValue":h[1]||(h[1]=x=>a.value=x),label:e.label,placeholder:e.placeholder,"search-placeholder":"Search tools...",options:u.value,disabled:e.disabled,loading:l.value},null,8,["modelValue","label","placeholder","options","disabled","loading"])),!e.allowMultiple&&e.error?(r(),Y(I($t),{key:2,class:"mt-1"},{default:W(()=>[ve(C(e.error),1)]),_:1})):S("",!0)],64))}}),Ps=Nt(je(Es),{props:["label","placeholder","error","required","disabled","allowMultiple"],family:"dropdown",features:[]}),Os=Nt(je(Ls),{props:["label","placeholder","error","required","disabled","allowMultiple","agentType"],family:"dropdown",features:[]}),Rs=Nt(je(As),{props:["label","placeholder","error","required","disabled","allowMultiple"],family:"dropdown",features:[]}),js={class:"space-y-4"},Ds={class:"flex items-start gap-2"},Us={class:"flex-1"},Bs=["onClick","disabled","title"],Ns={key:0,class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},qs={key:1,class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},Fs={key:0,class:"text-xs text-neutral-400 dark:text-neutral-500 mt-1"},Hs={key:0,class:"text-amber-500 dark:text-amber-400 ml-1"},Ws={class:"flex-1"},Ks={class:"flex-1"},Js=["onClick","disabled"],Gs=["disabled"],Ys=Se({__name:"TenvPropertyList",props:{modelValue:{},inherited:{default:()=>[]},allowCustom:{type:Boolean,default:!0},disabled:{type:Boolean,default:!1}},emits:["update:modelValue"],setup(e,{emit:n}){const a=e,s=n,l=p(new Set),u=p([]),i=F(()=>new Set(a.inherited.map(d=>d.name)));Ve(()=>a.modelValue,d=>{const w=Object.keys(d).filter(v=>!i.value.has(v)),m=new Set(u.value.map(v=>v.name));for(const v of w)m.has(v)||u.value.push({id:crypto.randomUUID(),name:v,value:String(d[v]??"")})},{immediate:!0,deep:!0});const c=d=>{if(l.value.has(d)){l.value.delete(d);const w=a.inherited.find(m=>m.name===d);w&&f(d,w.value)}else l.value.add(d)},f=(d,w)=>{const m={...a.modelValue};w===void 0||w===""?delete m[d]:m[d]=w,s("update:modelValue",m)},h=d=>a.modelValue[d.name]!==void 0?String(a.modelValue[d.name]):d.value!==void 0?String(d.value):"",x=(d,w)=>{f(d.name,w||void 0)},b=()=>{u.value.push({id:crypto.randomUUID(),name:"",value:""})},y=d=>{const w=u.value.find(m=>m.id===d);if(w&&w.name){const m={...a.modelValue};delete m[w.name],s("update:modelValue",m)}u.value=u.value.filter(m=>m.id!==d)},$=(d,w,m)=>{const v=u.value.find(P=>P.id===d);if(!v)return;v.name=m;const _={...a.modelValue};w&&delete _[w],m&&v.value&&(_[m]=v.value),s("update:modelValue",_)},g=(d,w)=>{const m=u.value.find(v=>v.id===d);m&&(m.value=w,m.name&&f(m.name,w||void 0))};return(d,w)=>(r(),o("div",js,[(r(!0),o($e,null,Le(e.inherited,m=>(r(),o("div",{key:m.name,class:"relative"},[t("div",Ds,[t("div",Us,[k(Mt,{"model-value":h(m),label:m.name,placeholder:m.description||"Enter value...",disabled:e.disabled||!l.value.has(m.name),required:m.required,"onUpdate:modelValue":v=>x(m,v)},null,8,["model-value","label","placeholder","disabled","required","onUpdate:modelValue"])]),t("button",{type:"button",onClick:v=>c(m.name),disabled:e.disabled,class:"mt-7 p-2 text-neutral-400 hover:text-neutral-600 dark:hover:text-neutral-300 transition-colors disabled:opacity-50",title:l.value.has(m.name)?"Lock (use inherited value)":"Unlock to override"},[l.value.has(m.name)?(r(),o("svg",qs,[...w[1]||(w[1]=[t("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M8 11V7a4 4 0 118 0m-4 8v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2z"},null,-1)])])):(r(),o("svg",Ns,[...w[0]||(w[0]=[t("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 15v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2zm10-10V7a4 4 0 00-8 0v4h8z"},null,-1)])]))],8,Bs)]),m.source?(r(),o("p",Fs,[ve(" From: "+C(m.source)+" ",1),m.required?(r(),o("span",Hs,"(required)")):S("",!0)])):S("",!0)]))),128)),(r(!0),o($e,null,Le(u.value,m=>(r(),o("div",{key:m.id,class:"flex items-start gap-2"},[t("div",Ws,[k(Mt,{"model-value":m.name,label:"Name",placeholder:"Variable name",disabled:e.disabled,"onUpdate:modelValue":v=>$(m.id,m.name,v)},null,8,["model-value","disabled","onUpdate:modelValue"])]),t("div",Ks,[k(Mt,{"model-value":m.value,label:"Value",placeholder:"Variable value",disabled:e.disabled,"onUpdate:modelValue":v=>g(m.id,v)},null,8,["model-value","disabled","onUpdate:modelValue"])]),t("button",{type:"button",onClick:v=>y(m.id),disabled:e.disabled,class:"mt-7 p-2 text-red-400 hover:text-red-600 dark:hover:text-red-300 transition-colors disabled:opacity-50",title:"Remove"},[...w[2]||(w[2]=[t("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[t("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M6 18L18 6M6 6l12 12"})],-1)])],8,Js)]))),128)),e.allowCustom?(r(),o("button",{key:0,type:"button",onClick:b,disabled:e.disabled,class:"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"},[...w[3]||(w[3]=[t("span",{class:"flex items-center justify-center gap-2"},[t("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[t("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 4v16m8-8H4"})]),ve(" Add custom variable ")],-1)])],8,Gs)):S("",!0)]))}}),Zs=Nt(je(Ys),{props:["inherited","allowCustom","disabled"],family:"text",features:[]}),Xs={class:"space-y-3 mt-3 pt-3 border-t border-neutral-200 dark:border-neutral-700"},Qs={class:"space-y-2 pl-4 border-l-2 border-accent-200 dark:border-accent-700"},ei={key:0,class:"space-y-2 pl-4 border-l-2 border-neutral-200 dark:border-neutral-700"},ti={key:1,class:"space-y-3 pl-4 border-l-2 border-neutral-200 dark:border-neutral-700"},ri={key:2,class:"space-y-3 pl-4 border-l-2 border-neutral-200 dark:border-neutral-700"},ai={key:0,class:"grid grid-cols-1 gap-3"},ni={key:3,class:"space-y-3 pl-4 border-l-2 border-neutral-200 dark:border-neutral-700"},oi={key:0,class:"grid grid-cols-1 gap-3"},li=Se({__name:"PromptToolOptions",props:{toolName:{},toolConfig:{},toolType:{default:"prompt"},disabled:{type:Boolean},availableEnvVariables:{default:()=>[]}},emits:["update:option"],setup(e,{emit:n}){const a=e,s=n,l=p(null),u=p(!0),i=p([]),c=p(!1),f=F(()=>l.value?.properties?Object.entries(l.value.properties).map(([te,q])=>({value:te,label:te,attrs:{description:q.description||q.type||""}})):[]),h=F(()=>a.toolType==="prompt"),x=F(()=>a.toolType==="subagent"),b=[{value:"side_a",label:"Side A",attrs:{description:"Queue parent messages as user messages in the child thread."}},{value:"side_b",label:"Side B",attrs:{description:"Queue parent messages as assistant messages in the child thread."}}],y=[{value:"implicit",label:"Implicit",attrs:{description:"Child completion is automatically queued back to the parent."}},{value:"explicit",label:"Explicit",attrs:{description:"Child stays quiet unless tools or hooks call state.notifyParent()."}}],$=F(()=>a.toolConfig.immediate!==void 0&&a.toolConfig.immediate!==!1),g=F(()=>!!a.toolConfig.resumable&&a.toolConfig.resumable!==!1),d=F(()=>(a.toolConfig.immediate&&typeof a.toolConfig.immediate=="object"?a.toolConfig.immediate.name_env:"")||""),w=F(()=>(a.toolConfig.immediate&&typeof a.toolConfig.immediate=="object"?a.toolConfig.immediate.description_env:"")||""),m=F(()=>!a.toolConfig.immediate||typeof a.toolConfig.immediate!="object"?[]:Array.isArray(a.toolConfig.immediate.scoped_env)?a.toolConfig.immediate.scoped_env:[]),v=(te,q)=>({value:te,label:te||"Not set",attrs:{description:q}}),_=F(()=>{const te=new Map,q=(j,J)=>{const H=j.trim();H&&(te.has(H)||te.set(H,new Set),te.get(H).add(J))};for(const j of a.availableEnvVariables)q(j,"Parent prompt env");for(const j of i.value){const J=["Subagent variable"];j.description&&J.push(j.description),j.required&&J.push("required"),j.scoped&&J.push("declared scoped"),q(j.property,J.join(" • "))}for(const j of[a.toolConfig.optional||"",d.value,w.value])j&&q(j,"Currently selected");return[v("","Not set"),...Array.from(te.entries()).sort(([j],[J])=>j.localeCompare(J)).map(([j,J])=>v(j,Array.from(J).join(" | ")))]}),P=F(()=>{const te=new Map;for(const q of i.value){const j=[];q.description&&j.push(q.description),q.required&&j.push("required"),q.scoped&&j.push("declared scoped"),te.set(q.property,j.length>0?j.join(" • "):"Subagent variable")}for(const q of m.value)te.has(q)||te.set(q,"Currently selected");return Array.from(te.entries()).sort(([q],[j])=>q.localeCompare(j)).map(([q,j])=>v(q,j))}),V=async()=>{try{let te=a.toolName;if(a.toolType==="handoff"||a.toolType==="subagent"){const j=await fetch(ze(`/api/agents/${encodeURIComponent(a.toolName)}`));if(j.ok){if(te=(await j.json())?.agent?.side_a_agent_prompt,!te){u.value=!1;return}}else{u.value=!1;return}}const q=await fetch(ze(`/api/prompts/${encodeURIComponent(te)}`));if(q.ok){const j=await q.json();j?.prompt?.required_schema&&(l.value=j.prompt.required_schema)}}catch(te){console.error("Error fetching prompt schema:",te)}finally{u.value=!1}},E=async()=>{if(a.toolType!=="subagent"){i.value=[];return}c.value=!0;try{const te=await fetch(ze(`/api/variables/agents/${encodeURIComponent(a.toolName)}`));if(!te.ok){i.value=[];return}const q=await te.json();i.value=Array.isArray(q?.variables)?q.variables.filter(j=>j&&typeof j.property=="string").map(j=>({property:j.property,description:j.description||"",required:!!j.required,scoped:!!j.scoped})):[]}catch(te){console.error("Error fetching subagent variables:",te),i.value=[]}finally{c.value=!1}};He(()=>{V(),E()});const z=(te,q)=>{s("update:option",te,q)},A=(te={})=>{const q=a.toolConfig.immediate&&typeof a.toolConfig.immediate=="object"?a.toolConfig.immediate:{},j={name_env:q.name_env||null,description_env:q.description_env||null,scoped_env:q.scoped_env||[],...te};return!j.name_env&&!j.description_env&&(!j.scoped_env||j.scoped_env.length===0)?!0:j},oe=te=>{if(!te){z("immediate",void 0);return}z("immediate",A())},ne=(te,q)=>{const j=A({[te]:q});z("immediate",j)},fe=te=>{if(!te){z("resumable",void 0);return}const q=a.toolConfig.resumable&&a.toolConfig.resumable!==!1?a.toolConfig.resumable:null;z("resumable",{receives_messages:q?.receives_messages||"side_a",max_instances:q?.max_instances??null,parent_communication:q?.parent_communication||"implicit"})},ye=(te,q)=>{const j=a.toolConfig.resumable&&a.toolConfig.resumable!==!1?a.toolConfig.resumable:{receives_messages:"side_a",max_instances:null,parent_communication:"implicit"};z("resumable",{receives_messages:j.receives_messages,max_instances:j.max_instances??null,parent_communication:j.parent_communication||"implicit",[te]:q})};return(te,q)=>{const j=at("FormKit");return r(),o("div",Xs,[t("div",Qs,[q[16]||(q[16]=t("p",{class:"text-xs font-medium text-neutral-600 dark:text-neutral-400 mb-2"}," Initialization Options: ",-1)),k(j,{type:"selectSearch",value:e.toolConfig.init_user_message_property||"",onInput:q[0]||(q[0]=J=>z("init_user_message_property",J||null)),label:"User message property",placeholder:"Don't inject a user message",options:f.value,disabled:e.disabled||u.value||f.value.length===0,loading:u.value,help:"Select which argument property should be used as the most recent user message for this sub-prompt. If not set no additional user message will be injected.","outer-class":"$reset mb-2"},null,8,["value","options","disabled","loading"]),k(j,{type:"selectSearch",value:e.toolConfig.init_attachments_property||"",onInput:q[1]||(q[1]=J=>z("init_attachments_property",J||null)),label:"Attachments property",placeholder:"Don't attach files",options:f.value,disabled:e.disabled||u.value||f.value.length===0,loading:u.value,help:"Select which argument contains attachment path(s). Accepts a single path string or an array of paths.","outer-class":"$reset mb-0"},null,8,["value","options","disabled","loading"]),x.value?(r(),Y(j,{key:0,type:"selectSearch",value:e.toolConfig.init_agent_name_property||"",onInput:q[2]||(q[2]=J=>z("init_agent_name_property",J||null)),label:"Agent name property",placeholder:"Don't map a child thread name",options:f.value,disabled:e.disabled||u.value||f.value.length===0,loading:u.value,help:"Select which argument property should be used to name each spawned child thread.","outer-class":"$reset mb-0"},null,8,["value","options","disabled","loading"])):S("",!0)]),h.value?(r(),o("div",ei,[q[17]||(q[17]=t("p",{class:"text-xs font-medium text-neutral-600 dark:text-neutral-400 mb-2"}," Sub-Prompt Response Options: ",-1)),k(j,{type:"checkbox",value:e.toolConfig.include_text_response,onInput:q[3]||(q[3]=J=>z("include_text_response",J)),label:"Include text response",help:"Include the final text content from the sub-prompt",disabled:e.disabled,"outer-class":"$reset mb-1"},null,8,["value","disabled"]),k(j,{type:"checkbox",value:e.toolConfig.include_tool_calls,onInput:q[4]||(q[4]=J=>z("include_tool_calls",J)),label:"Include tool calls and responses",help:"Include tool calls executed by the sub-prompt and their responses",disabled:e.disabled,"outer-class":"$reset mb-1"},null,8,["value","disabled"]),k(j,{type:"checkbox",value:e.toolConfig.include_errors,onInput:q[5]||(q[5]=J=>z("include_errors",J)),label:"Include errors",help:"Include error information if the sub-prompt fails",disabled:e.disabled,"outer-class":"$reset mb-0"},null,8,["value","disabled"])])):S("",!0),x.value?(r(),o("div",ti,[q[18]||(q[18]=t("p",{class:"text-xs font-medium text-neutral-600 dark:text-neutral-400 mb-2"}," Relationship Options: ",-1)),k(j,{type:"checkbox",value:e.toolConfig.blocking??!0,onInput:q[6]||(q[6]=J=>z("blocking",J)),label:"Blocking",help:"When enabled, the parent waits for this child to finish before continuing. Turn this off for background watchers or long-running workers.",disabled:e.disabled,"outer-class":"$reset mb-1"},null,8,["value","disabled"]),k(j,{type:"selectSearch",value:e.toolConfig.optional||"",onInput:q[7]||(q[7]=J=>z("optional",J||null)),label:"Enable this subagent when",placeholder:"Don't gate this subagent","search-placeholder":"Search env variables...",options:_.value,help:"Pick an env variable that gates this branch. Example: ENABLE_GMAIL. This subagent only appears and runs when that env resolves to true, 1, or yes on the parent thread. Leave this empty to keep the subagent always enabled.",disabled:e.disabled||c.value,"outer-class":"$reset mb-0"},null,8,["value","options","disabled"])])):S("",!0),x.value?(r(),o("div",ri,[q[19]||(q[19]=t("p",{class:"text-xs font-medium text-neutral-600 dark:text-neutral-400 mb-2"}," Immediate Bootstrap: ",-1)),k(j,{type:"checkbox",value:$.value,onInput:q[8]||(q[8]=J=>oe(!!J)),label:"Run immediately",disabled:e.disabled,help:"Boot this subagent as soon as the prompt becomes active, before the parent takes its first normal LLM step.","outer-class":"$reset mb-0"},null,8,["value","disabled"]),$.value?(r(),o("div",ai,[k(j,{type:"select",value:d.value,onInput:q[9]||(q[9]=J=>ne("name_env",J||null)),label:"Name env",placeholder:"Don't use a name env",options:_.value,help:"Optional safe env whose value can be used to name each immediate child instance. This is one of the few env values the runtime may expose during bootstrap.",disabled:e.disabled||c.value,"outer-class":"$reset mb-0"},null,8,["value","options","disabled"]),k(j,{type:"select",value:w.value,onInput:q[10]||(q[10]=J=>ne("description_env",J||null)),label:"Description env",placeholder:"Don't use a description env",options:_.value,help:"Optional safe env whose value can describe what this instance is for. The runtime may use it as bootstrap context when starting the child.",disabled:e.disabled||c.value,"outer-class":"$reset mb-0"},null,8,["value","options","disabled"]),k(j,{type:"taglist",value:m.value,onInput:q[11]||(q[11]=J=>ne("scoped_env",Array.isArray(J)?J:[])),label:"Scoped env",placeholder:"Pick subagent envs",options:P.value,"open-on-click":"","close-on-select":"false","selection-appearance":"tags","empty-message":"No subagent variables available.",help:"Pick the subagent variables that belong to each instance. These values are copied into the child thread env and stay hidden from the model unless you also selected them as Name env or Description env.",disabled:e.disabled||c.value,"outer-class":"$reset mb-0"},null,8,["value","options","disabled"])])):S("",!0)])):S("",!0),x.value?(r(),o("div",ni,[q[20]||(q[20]=t("p",{class:"text-xs font-medium text-neutral-600 dark:text-neutral-400 mb-2"}," Resumable Mode: ",-1)),k(j,{type:"checkbox",value:g.value,onInput:q[12]||(q[12]=J=>fe(J)),label:"Enable resumable child threads",help:"Keep child instances alive and addressable in the parent registry so the parent can message or reuse them later instead of always spawning a new thread.",disabled:e.disabled,"outer-class":"$reset mb-0"},null,8,["value","disabled"]),g.value?(r(),o("div",oi,[k(j,{type:"select",value:e.toolConfig.resumable&&e.toolConfig.resumable!==!1?e.toolConfig.resumable.receives_messages:"side_a",onInput:q[13]||(q[13]=J=>ye("receives_messages",J||"side_a")),label:"Receives messages",options:b,disabled:e.disabled,help:"Choose which side receives parent messages. Side A queues them as user messages in the child; Side B queues them as assistant messages.","outer-class":"$reset mb-0"},null,8,["value","disabled"]),k(j,{type:"number",value:e.toolConfig.resumable&&e.toolConfig.resumable!==!1?e.toolConfig.resumable.max_instances??"":"",onInput:q[14]||(q[14]=J=>ye("max_instances",J===""||J===null?null:Number(J))),label:"Max instances",min:"1",step:"1",placeholder:"Unlimited",help:"Cap how many resumable instances of this subagent can exist at once. Leave empty for unlimited.",disabled:e.disabled,"outer-class":"$reset mb-0"},null,8,["value","disabled"]),k(j,{type:"select",value:e.toolConfig.resumable&&e.toolConfig.resumable!==!1&&e.toolConfig.resumable.parent_communication||"implicit",onInput:q[15]||(q[15]=J=>ye("parent_communication",J||"implicit")),label:"Parent communication",options:y,disabled:e.disabled,help:"Implicit mode automatically forwards child completion back to the parent. Explicit mode keeps the child quiet until your code calls state.notifyParent() or updates status deliberately.","outer-class":"$reset mb-0"},null,8,["value","disabled"])])):S("",!0)])):S("",!0)])}}});async function ut(e,n={}){const a=localStorage.getItem("auth_token"),s={"Content-Type":"application/json",...n.headers};a&&(s.Authorization=`Bearer ${a}`);const l=e.startsWith("/")?e:`/${e}`,u=await fetch(ze(`/api${l}`),{...n,headers:s});if(u.status===401)throw localStorage.removeItem("auth_token"),window.location.href=ze("/login"),new Error("Unauthorized");return u}const si={class:"space-y-4"},ii={class:"block text-sm font-medium mb-2"},ui={key:0,class:"text-red-500"},di={class:"flex items-start justify-between"},ci={class:"flex items-center gap-2 flex-1"},pi={class:"flex-1"},mi={key:0,class:"text-xs text-neutral-500 dark:text-neutral-400 font-normal"},vi={key:1,class:"text-xs text-neutral-500 dark:text-neutral-400 font-normal"},fi={key:2,class:"text-xs text-neutral-500 dark:text-neutral-400 font-normal"},gi={key:3,class:"text-xs text-neutral-500 dark:text-neutral-400 font-normal"},hi={key:4,class:"text-xs text-neutral-500 dark:text-neutral-400 font-normal"},bi={key:0,class:"text-xs text-neutral-600 dark:text-neutral-400 mt-1"},xi={key:1,class:"text-xs text-amber-600 dark:text-amber-400 mt-1 flex items-center gap-1"},yi=["onClick","disabled","aria-label"],ki={key:0,class:"mt-3 pt-3 border-t border-neutral-200 dark:border-neutral-700"},wi={class:"space-y-2"},_i={key:0,class:"text-xs text-amber-500 dark:text-amber-400 whitespace-nowrap",title:"Required at agent or thread level"},$i={key:0,class:"text-center py-8 text-sm text-neutral-500 dark:text-neutral-400 border border-dashed border-neutral-300 dark:border-neutral-600 rounded-lg"},Fa=Se({__name:"ToolSelectorWithOptions",props:gt({label:{default:"Available Tools"},placeholder:{default:"Select a tool"},error:{},required:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},modelId:{},providerId:{},availableEnvVariables:{default:()=>[]}},{modelValue:{required:!0,default:()=>[]},modelModifiers:{}}),emits:gt(["unavailable-tools"],["update:modelValue"]),setup(e,{expose:n,emit:a}){const s=e,l=zt(e,"modelValue"),u=p([]),i=p([]),c=p(!1),f=p(!1),h=p(),x=p(""),b=F(()=>[...u.value,...i.value]),y=F(()=>new Set(b.value.map(te=>w(te)))),$=te=>(te.startsWith("provider:"),y.value.has(te)),g=F(()=>l.value.filter(te=>!$(te.name)).map(te=>te.name)),d=a;Ve(g,te=>{te.length>0&&d("unavailable-tools",te)},{immediate:!0}),ka(async()=>{h.value,await Fe(),h.value&&l.value.length>0&&await wa({parent:h,values:l,dragHandle:".drag-handle"})});const w=te=>te.type==="provider"?`provider:${te.name}`:te.type==="mcp"?`mcp:${te.name}`:te.name,m=te=>te.startsWith("provider:")?te.slice(9):te.startsWith("mcp:")?te.slice(4):te,v=te=>te.startsWith("provider:")?"provider":te.startsWith("mcp:")?"mcp":"tool",_=F(()=>{const te=new Set(l.value.map(q=>q.name));return b.value.filter(q=>!te.has(w(q))).map(q=>{let j=q.name;return q.type==="prompt"?j=`${q.name} (prompt)`:q.type==="mcp"?j=`${q.name} (mcp)`:q.type==="provider"?j=`${q.name} (provider)`:q.type==="handoff"?j=`${q.name} (handoff agent)`:q.type==="subagent"&&(j=`${q.name} (subagent)`),{value:w(q),label:j,attrs:{description:q.description}}})}),P=async()=>{c.value=!0;try{const te=await ut("/tools");if(te.ok){const q=await te.json();u.value=Object.entries(q).map(([j,J])=>({name:j,description:J.description||"",type:J.type,model:J.model}))}}catch(te){console.error("Error fetching tools:",te)}finally{c.value=!1}},V=async()=>{if(!s.providerId||!s.modelId){i.value=[];return}f.value=!0;try{const te=await ut(`/providers/${s.providerId}/tools?model=${encodeURIComponent(s.modelId)}`);if(te.ok){const q=await te.json();i.value=(q.tools||[]).map(j=>({name:j.name,description:j.description||"",type:"provider",tenvs:j.tenvs||[]}))}else i.value=[]}catch(te){console.error("Error fetching provider tools:",te),i.value=[]}finally{f.value=!1}};Ve([()=>s.providerId,()=>s.modelId],async([te,q])=>{te&&q?await V():i.value=[]},{immediate:!0});const E=te=>{if(!te||l.value.find(J=>J.name===te))return;const q=A(te),j={};if(q?.tenvs&&q.tenvs.length>0)for(const J of q.tenvs)j[J.name]="";l.value=[...l.value,{name:te,include_text_response:!0,include_tool_calls:!0,include_errors:!0,init_user_message_property:null,init_attachments_property:null,init_agent_name_property:null,optional:null,...Object.keys(j).length>0?{tenvs:j}:{}}],Fe(()=>{x.value=""})},z=te=>{l.value=l.value.filter(q=>q.name!==te)},A=te=>{const q=b.value.find(j=>w(j)===te);return q||b.value.find(j=>j.name===te)},oe=(te,q,j)=>{l.value=l.value.map(J=>{if(J.name===te){const H={...J.tenvs||{},[q]:j||void 0};for(const ce of Object.keys(H))H[ce]||delete H[ce];return{...J,tenvs:Object.keys(H).length>0?H:void 0}}return J})},ne=(te,q,j)=>{l.value=l.value.map(J=>J.name===te?{...J,[q]:j}:J)};return n({removeUnavailableTools:()=>{l.value=l.value.filter(te=>$(te.name))},getAvailableToolsOnly:()=>l.value.filter(te=>$(te.name)),unavailableTools:g}),He(()=>{P()}),(te,q)=>{const j=at("FormKit");return r(),o("div",si,[t("div",null,[t("label",ii,[ve(C(e.label)+" ",1),e.required?(r(),o("span",ui,"*")):S("",!0)]),l.value.length>0?(r(),o("div",{key:0,class:"space-y-3 mb-4",ref_key:"dragAreaRef",ref:h},[(r(!0),o($e,null,Le(l.value,J=>(r(),o("div",{key:J.name,class:pe(["border rounded-lg p-4 transition-colors",$(J.name)?"border-neutral-300 dark:border-neutral-600":"border-amber-300 dark:border-amber-700 bg-amber-50 dark:bg-amber-900/20 opacity-75"])},[t("div",di,[t("div",ci,[t("div",{class:pe(["drag-handle",$(J.name)?"cursor-move text-neutral-400 hover:text-neutral-600 dark:text-neutral-600 dark:hover:text-neutral-400":"cursor-not-allowed text-neutral-300 dark:text-neutral-700"])},[...q[1]||(q[1]=[t("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[t("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M4 8h16M4 16h16"})],-1)])],2),t("div",pi,[t("h4",{class:pe(["font-medium text-sm",!$(J.name)&&"text-neutral-500 dark:text-neutral-400"])},[ve(C(m(J.name))+" ",1),v(J.name)==="provider"?(r(),o("span",mi,"(provider)")):v(J.name)==="mcp"?(r(),o("span",vi,"(mcp)")):A(J.name)?.type==="prompt"?(r(),o("span",fi,"(prompt)")):A(J.name)?.type==="handoff"?(r(),o("span",gi,"(handoff agent)")):A(J.name)?.type==="subagent"?(r(),o("span",hi,"(subagent)")):S("",!0)],2),A(J.name)?.description?(r(),o("p",bi,C(A(J.name)?.description),1)):S("",!0),$(J.name)?S("",!0):(r(),o("p",xi,[...q[2]||(q[2]=[t("svg",{class:"w-3 h-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[t("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})],-1),ve(" Not available for selected model - will be removed on save ",-1)])]))])]),t("button",{onClick:H=>z(J.name),type:"button",disabled:e.disabled,class:"p-1 hover:bg-neutral-200 dark:hover:bg-neutral-800 rounded transition-colors text-neutral-500 hover:text-red-500","aria-label":`Remove ${m(J.name)}`},[...q[3]||(q[3]=[t("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[t("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M6 18L18 6M6 6l12 12"})],-1)])],8,yi)]),A(J.name)?.type==="provider"&&A(J.name)?.tenvs?.length?(r(),o("div",ki,[q[4]||(q[4]=t("p",{class:"text-xs text-neutral-500 dark:text-neutral-400 mb-2 font-medium"},[ve(" Environment Variables "),t("span",{class:"text-neutral-400"},"(optional at prompt level)")],-1)),t("div",wi,[(r(!0),o($e,null,Le(A(J.name)?.tenvs,H=>(r(),o("div",{key:H.name,class:"flex items-center gap-2"},[k(j,{type:"text",value:J.tenvs?.[H.name]||"",onInput:ce=>oe(J.name,H.name,ce),label:H.name,placeholder:H.description||"Enter value...",disabled:e.disabled,"outer-class":"$reset flex-1 mb-0"},null,8,["value","onInput","label","placeholder","disabled"]),H.required?(r(),o("span",_i," required* ")):S("",!0)]))),128))])])):S("",!0),A(J.name)?.type==="prompt"||A(J.name)?.type==="handoff"||A(J.name)?.type==="subagent"?(r(),Y(li,{key:1,"tool-name":J.name,"tool-config":J,"tool-type":A(J.name)?.type,disabled:e.disabled,"available-env-variables":e.availableEnvVariables,"onUpdate:option":(H,ce)=>ne(J.name,H,ce)},null,8,["tool-name","tool-config","tool-type","disabled","available-env-variables","onUpdate:option"])):S("",!0)],2))),128))],512)):S("",!0),k(j,{type:"selectSearch",modelValue:x.value,"onUpdate:modelValue":q[0]||(q[0]=J=>x.value=J),onInput:E,placeholder:l.value.length>0?"Add another tool...":e.placeholder,"search-placeholder":"Search tools...",options:_.value,disabled:e.disabled||c.value||_.value.length===0,loading:c.value,"outer-class":"$reset"},null,8,["modelValue","placeholder","options","disabled","loading"]),e.error?(r(),Y(I($t),{key:1,class:"mt-1"},{default:W(()=>[ve(C(e.error),1)]),_:1})):S("",!0)]),l.value.length===0&&!c.value&&_.value.length===0?(r(),o("div",$i," No tools available. Create tools in your agentbuilder/tools directory. ")):S("",!0)])}}}),Ci=Nt(je(Fa),{props:["label","placeholder","error","required","disabled","modelId","providerId"],family:"dropdown",features:[]}),Si=Se({__name:"SelectInputWrapper",props:{context:{}},setup(e){const n=e,a=(w,m)=>{const v=n.context;return v[w]!==void 0?v[w]:v.attrs?.[w]!==void 0?v.attrs[w]:m},s=F(()=>n.context.classes??{}),l=F(()=>a("options",[])),u=F(()=>n.context._value??""),i=w=>{n.context.node.input(w)},c=F(()=>a("placeholder","Select an option")),f=F(()=>a("searchPlaceholder","Search...")),h=F(()=>a("loading",!1)),x=F(()=>a("optionLoader",void 0)),b=F(()=>a("loadOnScroll",!1)),y=F(()=>a("searchDebounce",150)),$=F(()=>n.context.disabled??!1),g=F(()=>a("size","md")),d=F(()=>a("activeHighlight",!1));return(w,m)=>(r(),Y(ft,{"model-value":u.value,options:l.value,placeholder:c.value,"search-placeholder":f.value,loading:h.value,"option-loader":x.value,"load-on-scroll":b.value,"search-debounce":y.value,disabled:$.value,"trigger-class":s.value.inner,size:g.value,"active-highlight":d.value,"onUpdate:modelValue":i},null,8,["model-value","options","placeholder","search-placeholder","loading","option-loader","load-on-scroll","search-debounce","disabled","trigger-class","size","active-highlight"]))}}),Ii={type:"input",family:"dropdown",props:["options","optionLoader","loadOnScroll","searchDebounce","placeholder","searchPlaceholder","loading","size","activeHighlight"],schema:()=>[{$el:"label",if:"$label",attrs:{class:"$classes.label",for:"$id"},children:"$label"},{$cmp:je(Si),props:{context:"$node.context"}}]},Ti={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Mi(e,n){return r(),o("svg",Ti,[...n[0]||(n[0]=[t("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[t("path",{d:"m21 21l-4.34-4.34"}),t("circle",{cx:"11",cy:"11",r:"8"})],-1)])])}const zi=je({name:"lucide-search",render:Mi}),Vi=["data-suffix-icon"],Ei=["id","value","placeholder","disabled"],Li=Se({__name:"SearchInputWrapper",props:{context:{}},setup(e){const n=e,a=(h,x)=>{const b=n.context;return b[h]!==void 0?b[h]:b.attrs?.[h]!==void 0?b.attrs[h]:x},s=F(()=>n.context.classes??{}),l=F(()=>n.context._value??""),u=h=>{const x=h.target.value;n.context.node.input(x)},i=()=>{n.context.node.input("")},c=F(()=>a("placeholder","Search...")),f=F(()=>n.context.disabled??!1);return(h,x)=>(r(),o("div",{class:pe(s.value.inner),"data-prefix-icon":"true","data-suffix-icon":!!l.value},[t("span",{class:pe(s.value.prefixIcon)},[k(I(zi))],2),t("input",{type:"text",id:e.context.id,value:l.value,onInput:u,placeholder:c.value,disabled:f.value,class:pe(s.value.input)},null,42,Ei),l.value?(r(),o("button",{key:0,type:"button",onClick:i,class:pe([s.value.suffixIcon,"hover:text-zinc-600 dark:hover:text-zinc-300 cursor-pointer"])},[k(I(mr))],2)):S("",!0)],10,Vi))}}),Ai={type:"input",family:"text",props:["placeholder","size"],schema:()=>[{$el:"label",if:"$label",attrs:{class:"$classes.label",for:"$id"},children:"$label"},{$cmp:je(Li),props:{context:"$node.context"}}]},Pi=Se({__name:"SortableMultiSelectWrapper",props:{context:{}},setup(e){const n=e,a=F(()=>n.context.options??[]),s=F(()=>n.context.placeholder??"Select an option"),l=F(()=>n.context.searchPlaceholder??"Search..."),u=F(()=>n.context.addLabel??"Add another"),i=F(()=>n.context.loading??!1),c=F(()=>n.context.disabled??!1),f=F({get:()=>n.context._value??[],set:h=>n.context.node.input(h)});return(h,x)=>(r(),Y(Bt,{modelValue:f.value,"onUpdate:modelValue":x[0]||(x[0]=b=>f.value=b),options:a.value,placeholder:s.value,"search-placeholder":l.value,"add-label":u.value,loading:i.value,disabled:c.value},null,8,["modelValue","options","placeholder","search-placeholder","add-label","loading","disabled"]))}}),Oi={type:"input",family:"dropdown",props:["options","placeholder","searchPlaceholder","addLabel","loading"],schema:()=>[{$el:"label",if:"$label",attrs:{class:"$classes.label",for:"$id"},children:"$label"},{$cmp:je(Pi),props:{context:"$node.context"}}]},Ri={class:"flex items-center gap-2 py-1 pl-2 pr-1"},ji={class:"flex-1 grid grid-cols-1 md:grid-cols-3 gap-2"},Di={class:"flex items-center gap-0.5 shrink-0"},Ui={key:1,class:"w-7"},Bi={class:"pl-2 pb-1"},Ni={key:0},qi={class:"space-y-1.5"},Fi=["onClick"],Hi=["onClick"],Wi={key:1},Ki=["onClick"],Ji={key:2},Gi=["onClick"],Yi={key:3},Zi={class:"flex items-center gap-2 py-1 pl-2 pr-1"},Xi={class:"flex-1 grid grid-cols-1 md:grid-cols-2 gap-2"},Qi={class:"flex items-center gap-0.5 shrink-0"},eu={key:1,class:"w-7"},tu={class:"pl-2 pb-1"},ru={key:0},au={class:"space-y-1.5"},nu=["onClick"],ou=["onClick"],lu={key:1},su=["onClick"],iu={key:2},uu=["onClick"],du={key:3},cu=["onClick"],pu=Se({__name:"SchemaPropertyRow",props:{typeOptions:{},depth:{},index:{}},emits:["remove"],setup(e){const n=e,a=p(!1),s=p("string"),l=p("string"),u=p(!1),i=g=>{s.value=g,h(g)&&(a.value=!0)},c=g=>{l.value=g,h(g)&&(u.value=!0)},f=g=>{g.value?.type&&(l.value=g.value.type,h(l.value)&&(u.value=!0)),g.on("input",({payload:d})=>{d?.type&&d.type!==l.value&&c(d.type)})},h=g=>["object","array","enum","anyOf"].includes(g),x=["#3b82f6","#8b5cf6","#ec4899","#f97316","#10b981"],b=F(()=>n.depth||0),y=g=>x[g%x.length],$=F(()=>y(b.value));return(g,d)=>{const w=at("FormKit"),m=at("SchemaPropertyRow",!0);return r(),Y(w,{type:"group",index:e.index,onNode:d[3]||(d[3]=v=>{v.value?.type&&(s.value=v.value.type,h(s.value)&&(a.value=!0)),v.on("input",({payload:_})=>{_?.type&&_.type!==s.value&&i(_.type)})})},{default:W(({value:v})=>[t("div",{class:pe(["schema-row",b.value>0?"border-l-[3px] ml-2":""]),style:_t(b.value>0?{borderColor:$.value}:{})},[t("div",Ri,[t("div",ji,[k(w,{type:"text",name:"name",placeholder:"Property name","outer-class":"$reset"}),k(w,{type:"selectSearch",name:"type",options:e.typeOptions,placeholder:"Type","outer-class":"$reset",onInput:i},null,8,["options"]),k(w,{type:"text",name:"description",placeholder:"Description","outer-class":"$reset"})]),t("div",Di,[h(s.value)?(r(),o("button",{key:0,onClick:d[0]||(d[0]=_=>a.value=!a.value),type:"button",class:"p-1.5 text-neutral-500 dark:text-white/70 hover:text-neutral-700 dark:hover:text-white hover:bg-neutral-100 dark:hover:bg-neutral-700 rounded transition-colors"},[(r(),o("svg",{class:pe(["w-4 h-4 transition-transform duration-150",a.value?"rotate-90":""]),fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[...d[4]||(d[4]=[t("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M9 5l7 7-7 7"},null,-1)])],2))])):(r(),o("div",Ui)),t("button",{onClick:d[1]||(d[1]=_=>g.$emit("remove")),type:"button",class:"p-1.5 text-neutral-500 dark:text-white/70 hover:text-red-500 dark:hover:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/30 rounded transition-colors"},[...d[5]||(d[5]=[t("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[t("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M6 18L18 6M6 6l12 12"})],-1)])])])]),Je(t("div",Bi,[s.value==="enum"?(r(),o("div",Ni,[d[7]||(d[7]=t("div",{class:"text-[11px] font-medium text-neutral-400 uppercase tracking-wider mb-2"}," Enum Values ",-1)),k(w,{type:"list",name:"enumValues",dynamic:""},{default:W(({items:_,value:P,node:V})=>[t("div",qi,[(r(!0),o($e,null,Le(_,(E,z)=>(r(),o("div",{key:E,class:"flex items-center gap-2"},[k(w,{type:"group",index:z},{default:W(()=>[k(w,{type:"text",name:"value",placeholder:"Value","outer-class":"$reset flex-1"})]),_:1},8,["index"]),t("button",{onClick:A=>V.input(P.filter((oe,ne)=>ne!==z)),type:"button",class:"p-1 text-neutral-500 dark:text-white/70 hover:text-red-500 dark:hover:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/30 rounded"},[...d[6]||(d[6]=[t("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[t("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M6 18L18 6M6 6l12 12"})],-1)])],8,Fi)]))),128))]),t("button",{onClick:E=>V.input((P||[]).concat({value:""})),type:"button",class:"mt-2 px-3 py-1.5 text-xs font-medium text-neutral-600 dark:text-neutral-400 bg-neutral-100 dark:bg-neutral-800 hover:bg-neutral-200 dark:hover:bg-neutral-700 rounded transition-colors"}," + Add Value ",8,Hi)]),_:1})])):S("",!0),s.value==="object"?(r(),o("div",Wi,[k(w,{type:"list",name:"properties",dynamic:""},{default:W(({items:_,value:P,node:V})=>[t("div",null,[(r(!0),o($e,null,Le(_,(E,z)=>(r(),Y(m,{key:E,index:z,"type-options":e.typeOptions,depth:b.value+1,onRemove:A=>V.input(P.filter((oe,ne)=>ne!==z))},null,8,["index","type-options","depth","onRemove"]))),128))]),t("button",{onClick:E=>V.input((P||[]).concat({name:"",type:"string",description:""})),type:"button",class:"mt-2 px-3 py-1.5 text-xs font-medium text-neutral-600 dark:text-neutral-400 bg-neutral-100 dark:bg-neutral-800 hover:bg-neutral-200 dark:hover:bg-neutral-700 rounded transition-colors"}," + Add Nested Property ",8,Ki)]),_:1})])):S("",!0),s.value==="anyOf"?(r(),o("div",Ji,[d[8]||(d[8]=t("div",{class:"text-[11px] font-medium text-neutral-400 uppercase tracking-wider mb-2"}," Type Options ",-1)),k(w,{type:"list",name:"anyOfTypes",dynamic:""},{default:W(({items:_,value:P,node:V})=>[t("div",null,[(r(!0),o($e,null,Le(_,(E,z)=>(r(),Y(m,{key:E,index:z,"type-options":e.typeOptions,depth:b.value+1,onRemove:A=>V.input(P.filter((oe,ne)=>ne!==z))},null,8,["index","type-options","depth","onRemove"]))),128))]),t("button",{onClick:E=>V.input((P||[]).concat({name:"",type:"string",description:""})),type:"button",class:"mt-2 px-3 py-1.5 text-xs font-medium text-neutral-600 dark:text-neutral-400 bg-neutral-100 dark:bg-neutral-800 hover:bg-neutral-200 dark:hover:bg-neutral-700 rounded transition-colors"}," + Add Type ",8,Gi)]),_:1})])):S("",!0),s.value==="array"?(r(),o("div",Yi,[d[14]||(d[14]=t("div",{class:"text-[11px] font-medium text-neutral-400 uppercase tracking-wider mb-2"}," Array Item Type ",-1)),k(w,{type:"group",name:"items",onNode:f},{default:W(({value:_,node:P})=>[t("div",{class:"schema-row border-l-[3px] ml-2",style:_t({borderColor:y(b.value+1)})},[t("div",Zi,[t("div",Xi,[k(w,{type:"selectSearch",name:"type",options:e.typeOptions,placeholder:"Item type","outer-class":"$reset",onInput:c},null,8,["options"]),k(w,{type:"text",name:"description",placeholder:"Description","outer-class":"$reset"})]),t("div",Qi,[h(l.value)?(r(),o("button",{key:0,onClick:d[2]||(d[2]=V=>u.value=!u.value),type:"button",class:"p-1.5 text-neutral-500 dark:text-white/70 hover:text-neutral-700 dark:hover:text-white hover:bg-neutral-100 dark:hover:bg-neutral-700 rounded transition-colors"},[(r(),o("svg",{class:pe(["w-4 h-4 transition-transform duration-150",u.value?"rotate-90":""]),fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[...d[9]||(d[9]=[t("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M9 5l7 7-7 7"},null,-1)])],2))])):(r(),o("div",eu))])]),Je(t("div",tu,[l.value==="enum"?(r(),o("div",ru,[d[11]||(d[11]=t("div",{class:"text-[11px] font-medium text-neutral-400 uppercase tracking-wider mb-2"}," Enum Values ",-1)),k(w,{type:"list",name:"enumValues",dynamic:""},{default:W(({items:V,value:E,node:z})=>[t("div",au,[(r(!0),o($e,null,Le(V,(A,oe)=>(r(),o("div",{key:A,class:"flex items-center gap-2"},[k(w,{type:"group",index:oe},{default:W(()=>[k(w,{type:"text",name:"value",placeholder:"Value","outer-class":"$reset flex-1"})]),_:1},8,["index"]),t("button",{onClick:ne=>z.input(E.filter((fe,ye)=>ye!==oe)),type:"button",class:"p-1 text-neutral-500 dark:text-white/70 hover:text-red-500 dark:hover:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/30 rounded"},[...d[10]||(d[10]=[t("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[t("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M6 18L18 6M6 6l12 12"})],-1)])],8,nu)]))),128))]),t("button",{onClick:A=>z.input((E||[]).concat({value:""})),type:"button",class:"mt-2 px-3 py-1.5 text-xs font-medium text-neutral-600 dark:text-neutral-400 bg-neutral-100 dark:bg-neutral-800 hover:bg-neutral-200 dark:hover:bg-neutral-700 rounded transition-colors"}," + Add Value ",8,ou)]),_:1})])):S("",!0),l.value==="object"?(r(),o("div",lu,[k(w,{type:"list",name:"properties",dynamic:""},{default:W(({items:V,value:E,node:z})=>[t("div",null,[(r(!0),o($e,null,Le(V,(A,oe)=>(r(),Y(m,{key:A,index:oe,"type-options":e.typeOptions,depth:b.value+2,onRemove:ne=>z.input(E.filter((fe,ye)=>ye!==oe))},null,8,["index","type-options","depth","onRemove"]))),128))]),t("button",{onClick:A=>z.input((E||[]).concat({name:"",type:"string",description:""})),type:"button",class:"mt-2 px-3 py-1.5 text-xs font-medium text-neutral-600 dark:text-neutral-400 bg-neutral-100 dark:bg-neutral-800 hover:bg-neutral-200 dark:hover:bg-neutral-700 rounded transition-colors"}," + Add Nested Property ",8,su)]),_:1})])):S("",!0),l.value==="anyOf"?(r(),o("div",iu,[d[12]||(d[12]=t("div",{class:"text-[11px] font-medium text-neutral-400 uppercase tracking-wider mb-2"}," Type Options ",-1)),k(w,{type:"list",name:"anyOfTypes",dynamic:""},{default:W(({items:V,value:E,node:z})=>[t("div",null,[(r(!0),o($e,null,Le(V,(A,oe)=>(r(),Y(m,{key:A,index:oe,"type-options":e.typeOptions,depth:b.value+2,onRemove:ne=>z.input(E.filter((fe,ye)=>ye!==oe))},null,8,["index","type-options","depth","onRemove"]))),128))]),t("button",{onClick:A=>z.input((E||[]).concat({name:"",type:"string",description:""})),type:"button",class:"mt-2 px-3 py-1.5 text-xs font-medium text-neutral-600 dark:text-neutral-400 bg-neutral-100 dark:bg-neutral-800 hover:bg-neutral-200 dark:hover:bg-neutral-700 rounded transition-colors"}," + Add Type ",8,uu)]),_:1})])):S("",!0),l.value==="array"?(r(),o("div",du,[d[13]||(d[13]=t("div",{class:"text-[11px] font-medium text-neutral-400 uppercase tracking-wider mb-2"}," Nested Array Item Type ",-1)),k(w,{type:"list",name:"items",dynamic:""},{default:W(({items:V,value:E,node:z})=>[t("div",null,[(r(!0),o($e,null,Le(V,(A,oe)=>(r(),Y(m,{key:A,index:oe,"type-options":e.typeOptions,depth:b.value+2,onRemove:ne=>z.input(E.filter((fe,ye)=>ye!==oe))},null,8,["index","type-options","depth","onRemove"]))),128))]),t("button",{onClick:A=>z.input((E||[]).concat({type:"string",description:""})),type:"button",class:"mt-2 px-3 py-1.5 text-xs font-medium text-neutral-600 dark:text-neutral-400 bg-neutral-100 dark:bg-neutral-800 hover:bg-neutral-200 dark:hover:bg-neutral-700 rounded transition-colors"}," + Define Nested Item ",8,cu)]),_:1})])):S("",!0)],512),[[pt,u.value&&h(l.value)]])],4)]),_:1})])):S("",!0)],512),[[pt,a.value&&h(s.value)]])],6)]),_:1},8,["index"])}}}),mu=mt(pu,[["__scopeId","data-v-a52ecd3f"]]),vu={"data-schema-editor":"",class:"space-y-4"},fu={class:"space-y-2 border border-neutral-200 dark:border-neutral-800 rounded-lg p-4"},gu={key:0,class:"flex items-center justify-between mb-2"},hu={key:1,class:"text-center py-12"},bu={class:"divide-y divide-neutral-100 dark:divide-neutral-800"},xu={class:"mt-3 pt-3 border-t border-neutral-200 dark:border-neutral-800"},yu=["onClick"],ku={class:"mt-4 text-center"},wu={key:3,class:"mt-4"},_u={class:"bg-neutral-50 dark:bg-neutral-900 border border-neutral-200 dark:border-neutral-800 rounded-lg p-4 overflow-x-auto"},$u={class:"text-xs leading-relaxed"},Cu=["innerHTML"],Su=Se({__name:"FormKitSchemaEditor",props:{context:{}},setup(e){const n=[{value:"string",label:"String",icon:"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' 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' 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' 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' 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' 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' 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",icon:"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' 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"}],a=e,s=p(!1),l=h=>h?.properties?Object.entries(h.properties).map(([x,b])=>{const y={name:x,type:b.enum?"enum":b.anyOf?"anyOf":b.type||"string",description:b.description||""};return b.enum&&(y.enumValues=b.enum.map($=>({value:$}))),b.anyOf&&(y.anyOfTypes=b.anyOf.map($=>({type:$.type||"string",description:$.description||""}))),b.type==="object"&&b.properties&&(y.properties=l(b)),b.type==="array"&&b.items&&(y.items={type:b.items.type||"string",description:b.items.description||""},b.items.properties&&(y.items.properties=l(b.items))),y}):[],u=h=>{const x={type:"object",properties:{},required:[],additionalProperties:!1};for(const b of h||[]){if(!b.name)continue;const y={type:b.type==="enum"||b.type==="anyOf"?void 0:b.type,description:b.description||void 0};if(b.type==="enum"&&b.enumValues&&(y.type="string",y.enum=b.enumValues.map($=>$.value)),b.type==="anyOf"&&b.anyOfTypes&&(y.anyOf=b.anyOfTypes.map($=>({type:$.type,description:$.description||void 0}))),b.type==="object"&&b.properties){const $=u(b.properties);y.properties=$.properties,y.required=$.required,y.additionalProperties=!1}if(b.type==="array"&&b.items&&(y.items={type:b.items.type,description:b.items.description||void 0},b.items.properties)){const $=u(b.items.properties);y.items.properties=$.properties,y.items.required=$.required}Object.keys(y).forEach($=>y[$]===void 0&&delete y[$]),x.properties[b.name]=y,x.required.push(b.name)}return x},i=F({get:()=>{const h=a.context._value;return l(h)},set:h=>{const x=u(h);a.context.node.input(x)}}),c=F(()=>{const h=a.context._value||{type:"object",properties:{},required:[]};return JSON.stringify(h,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>')}),f=()=>{i.value=[{name:"property1",type:"string",description:""}]};return(h,x)=>{const b=at("FormKit");return r(),o("div",vu,[t("div",fu,[i.value.length>0?(r(),o("div",gu,[...x[3]||(x[3]=[t("h3",{class:"text-sm font-medium text-neutral-700 dark:text-neutral-300"}," Properties ",-1)])])):S("",!0),i.value.length===0?(r(),o("div",hu,[x[5]||(x[5]=t("div",{class:"mb-4"},[t("svg",{class:"w-12 h-12 mx-auto text-neutral-400 dark:text-neutral-600",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[t("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)),x[6]||(x[6]=t("p",{class:"text-neutral-500 dark:text-neutral-400 text-sm mb-4"}," No properties defined ",-1)),t("button",{onClick:x[0]||(x[0]=y=>f()),type:"button",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 font-medium text-sm"},[...x[4]||(x[4]=[t("span",{class:"flex items-center gap-2"},[t("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[t("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 4v16m8-8H4"})]),ve(" Add Property ")],-1)])])])):S("",!0),i.value.length>0?(r(),Y(b,{key:2,type:"list",value:i.value,onInput:x[1]||(x[1]=y=>i.value=y),dynamic:""},{default:W(({items:y,value:$,node:g})=>[t("div",bu,[(r(!0),o($e,null,Le(y,(d,w)=>(r(),Y(mu,{key:d,index:w,"type-options":n,depth:0,onRemove:m=>g.input($.filter((v,_)=>_!==w))},null,8,["index","onRemove"]))),128))]),t("div",xu,[t("button",{onClick:d=>g.input($.concat({name:`property${$.length+1}`,type:"string",description:""})),type:"button",class:"px-3 py-1.5 text-xs font-medium text-neutral-700 dark:text-neutral-300 bg-white dark:bg-neutral-800 border border-neutral-300 dark:border-neutral-600 rounded-md hover:bg-neutral-50 dark:hover:bg-neutral-700 transition-colors shadow-sm"}," + Add Property ",8,yu)])]),_:1},8,["value"])):S("",!0),t("div",ku,[t("button",{onClick:x[2]||(x[2]=y=>s.value=!s.value),type:"button",class:"text-xs font-medium text-neutral-600 dark:text-neutral-400 hover:text-neutral-900 dark:hover:text-neutral-100 underline underline-offset-2 transition-colors"},C(s.value?"Hide":"Show")+" JSON Schema ",1)]),s.value?(r(),o("div",wu,[t("div",_u,[t("pre",$u,[t("code",{class:"font-mono",innerHTML:c.value},null,8,Cu)])])])):S("",!0)])])}}}),Iu={type:"input",family:"text",props:["label","disabled","required"],schema:()=>[{$el:"label",if:"$label",attrs:{class:"$classes.label",for:"$id"},children:"$label"},{$cmp:je(Su),props:{context:"$node.context"}}]},Tu={promptInput:Xo,jsonSchema:_s,modelSelector:Ps,agentSelector:Os,toolSelector:Rs,tenvPropertyList:Zs,toolSelectorWithOptions:Ci,selectSearch:Ii,searchInput:Ai,sortableMultiSelect:Oi,schemaEditor:Iu},Rt=6,jt=6,Mu=.4,ur=new WeakMap;function zu(e,n,a,s,l,u){e.beginPath(),e.moveTo(n+u,a),e.lineTo(n+s-u,a),e.quadraticCurveTo(n+s,a,n+s,a+u),e.lineTo(n+s,a+l-u),e.quadraticCurveTo(n+s,a+l,n+s-u,a+l),e.lineTo(n+u,a+l),e.quadraticCurveTo(n,a+l,n,a+l-u),e.lineTo(n,a+u),e.quadraticCurveTo(n,a,n+u,a),e.closePath()}function Vu(e,n){const a=n.getBoundingClientRect();if(a.width===0||a.height===0)return;const s=parseFloat(getComputedStyle(n).borderRadius)||0,l=a.width+Rt+4,u=a.height+jt+4;e.width=l,e.height=u,e.style.width=`${l}px`,e.style.height=`${u}px`;const i=e.getContext("2d");if(!i)return;i.clearRect(0,0,l,u);const c=document.documentElement.classList.contains("dark");i.globalAlpha=Mu,i.lineWidth=1,i.strokeStyle=c?"#6b7280":"black",i.save(),zu(i,Rt,jt,a.width,a.height,s),i.clip();const f=c?4:3;for(let h=-a.height;h<a.width;h+=f)i.beginPath(),i.moveTo(Rt+h,jt),i.lineTo(Rt+h+a.height,jt+a.height),i.stroke();for(let h=0;h<a.width+a.height;h+=f)i.beginPath(),i.moveTo(Rt+h,jt+a.height),i.lineTo(Rt+h-a.height,jt),i.stroke();i.restore()}function ta(e){if(ur.has(e))return;const n=e.closest(".formkit-dropdownWrapper");if(!n)return;const a=document.createElement("canvas");a.style.cssText="position:absolute;top:0;left:0;pointer-events:none;z-index:-1";const s=n.parentElement;s?(s.style.position="relative",s.insertBefore(a,n)):n.insertBefore(a,n.firstChild);const l=()=>requestAnimationFrame(()=>Vu(a,n));l();const u=new ResizeObserver(l);u.observe(n);const i=new MutationObserver(l);i.observe(e,{childList:!0,subtree:!0});const c=new MutationObserver(l);c.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),ur.set(e,{canvas:a,resizeOb:u,darkModeOb:c,childOb:i})}function ra(e){const n=ur.get(e);n&&(n.canvas.remove(),n.resizeOb.disconnect(),n.childOb.disconnect(),n.darkModeOb.disconnect(),ur.delete(e))}function Eu(e){e.classList?.contains("formkit-listbox")&&requestAnimationFrame(()=>ta(e));for(const n of e.querySelectorAll(".formkit-listbox"))requestAnimationFrame(()=>ta(n))}function Lu(e){e.classList?.contains("formkit-listbox")&&ra(e);for(const n of e.querySelectorAll(".formkit-listbox"))ra(n)}let yr=null;function Au(){yr||(yr=new MutationObserver(e=>{for(const n of e){for(const a of n.addedNodes)a instanceof HTMLElement&&Eu(a);for(const a of n.removedNodes)a instanceof HTMLElement&&Lu(a)}}),yr.observe(document.body,{childList:!0,subtree:!0}))}const Pu=Jn("fk-2d3e4e0bb",Yn);typeof window<"u"&&Au();function Ou(e){if(e.props.type!=="autocomplete")return;const n={};function a(s){for(const l of Object.keys(n))delete n[l];if(Array.isArray(s)){for(const l of s)if(typeof l=="object"&&l!==null){const u=l;n[String(u.value)]={icon:u.icon||void 0,description:u.description||void 0}}}}a(e.props.options),e.on("prop:options",({payload:s})=>a(s)),e.on("created",()=>{typeof window<"u"&&requestAnimationFrame(()=>{const i=document.querySelector(`[data-id="${e.props.id}"]`);if(!i)return;let c=null;const f=()=>{const x=i.querySelector(".formkit-inner");if(!x)return;const b=x.getBoundingClientRect();e.props.popoverCoordinates={x:b.left,y:b.bottom,width:b.width,height:0},e.props.popoverAncestorCoordinates={x:b.left,y:b.bottom,width:b.width,height:b.height}};new MutationObserver(()=>{if(i.hasAttribute("data-expanded")){const x=i.querySelector(".formkit-input");if(x&&document.activeElement!==x&&setTimeout(()=>x.focus(),0),!c){c=new ResizeObserver(()=>{f()});const b=i.closest("[role=dialog]")||i.closest(".modal")||i.closest("form")||i.parentElement;b&&c.observe(b)}}else c&&(c.disconnect(),c=null)}).observe(i,{attributes:!0,attributeFilter:["data-expanded"]})});const s=e.context,l=i=>{e.context?.state&&(e.context.state.loading=!!i)};s.getOptionIcon=i=>String(i?.icon||n[String(i?.value)]?.icon||""),s.getOptionDesc=i=>String(i?.description||n[String(i?.value)]?.description||""),s.isAutocompleteLoading=()=>!!(e.context?.state?.loading||e.props.loading),s.isOptionLoading=i=>{if(!!!(e.context?.state?.loading||e.props.loading))return!1;const f=e.context.fns;if(typeof f?.hasOptionLoaderValue=="function")return!!f.hasOptionLoaderValue(i);const h=e.context.optionLoaderValues;return Array.isArray(h)&&h.includes(i?.value)},l(e.props.loading),e.on("prop:loading",({payload:i})=>l(i)),e.props.definition?.schemaMemoKey&&(e.props.definition.schemaMemoKey+="_custom_autocomplete");const u=e.props.definition?.schema;typeof u=="function"&&(e.props.definition.schema=(i={})=>(i.option={$el:"div",attrs:{class:"flex items-start gap-3 py-0.5 pl-0.5"},children:[{if:"$isOptionLoading($option)",$el:"div",attrs:{class:"font-medium text-sm text-zinc-500 dark:text-zinc-400"},children:"$ui.isLoading.value"},{if:"!$isOptionLoading($option) && $getOptionIcon($option)",$el:"img",attrs:{src:"$getOptionIcon($option)",alt:"$option.label",class:"w-5 h-5 flex-shrink-0 mt-0.5"}},{if:"!$isOptionLoading($option)",$el:"div",attrs:{class:"flex-1 min-w-0"},children:[{$el:"div",attrs:{class:"font-medium text-sm text-black dark:text-white"},children:"$option.label"},{$el:"div",if:"$getOptionDesc($option)",attrs:{class:"text-xs text-zinc-500 dark:text-zinc-400 mt-0.5"},children:"$getOptionDesc($option)"}]}]},i.selection={$el:"div",attrs:{class:"flex items-center gap-2 flex-1"},children:[{$el:"img",if:"!$isOptionLoading($option) && $getOptionIcon($option)",attrs:{src:"$getOptionIcon($option)",alt:"$option.label",class:"w-5 h-5 flex-shrink-0"}},{if:"$isOptionLoading($option)",$el:"span",attrs:{class:"text-zinc-500 dark:text-zinc-400"},children:"$ui.isLoading.value"},{if:"!$isOptionLoading($option)",$el:"span",children:"$option.label"}]},u(i)))})}const Ru={config:{rootClasses:To,popover:!0,openOnClick:!0,openOnRemove:!0,clearSearchOnOpen:!0,selectionAppearance:"option",emptyMessage:"No results found."},plugins:[Pu,Ou],rules:Oo,messages:{en:Ro},inputs:Tu,icons:{...Gn}},ju={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Du(e,n){return r(),o("svg",ju,[...n[0]||(n[0]=[t("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[t("path",{d:"M12 8V4H8"}),t("rect",{width:"16",height:"12",x:"4",y:"8",rx:"2"}),t("path",{d:"M2 14h2m16 0h2m-7-1v2m-6-2v2"})],-1)])])}const Dt=je({name:"lucide-bot",render:Du}),Uu={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Bu(e,n){return r(),o("svg",Uu,[...n[0]||(n[0]=[t("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 dr=je({name:"lucide-message-square",render:Bu}),Nu={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function qu(e,n){return r(),o("svg",Nu,[...n[0]||(n[0]=[t("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[t("path",{d:"M12 20v2m0-20v2m5 16v2m0-20v2M2 12h2m-2 5h2M2 7h2m16 5h2m-2 5h2M20 7h2M7 20v2M7 2v2"}),t("rect",{width:"16",height:"16",x:"4",y:"4",rx:"2"}),t("rect",{width:"8",height:"8",x:"8",y:"8",rx:"1"})],-1)])])}const Fu=je({name:"lucide-cpu",render:qu}),Hu={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Wu(e,n){return r(),o("svg",Hu,[...n[0]||(n[0]=[t("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[t("rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2"}),t("rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2"}),t("path",{d:"M6 6h.01M6 18h.01"})],-1)])])}const Ku=je({name:"lucide-server",render:Wu}),Ju={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Gu(e,n){return r(),o("svg",Ju,[...n[0]||(n[0]=[t("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 Mr=je({name:"lucide-wrench",render:Gu}),Yu={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Zu(e,n){return r(),o("svg",Yu,[...n[0]||(n[0]=[t("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[t("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"}),t("circle",{cx:"12",cy:"12",r:"3"})],-1)])])}const Jt=je({name:"lucide-settings",render:Zu}),Xu={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Qu(e,n){return r(),o("svg",Xu,[...n[0]||(n[0]=[t("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"m15 18l-6-6l6-6"},null,-1)])])}const Ha=je({name:"lucide-chevron-left",render:Qu}),ed={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function td(e,n){return r(),o("svg",ed,[...n[0]||(n[0]=[t("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[t("circle",{cx:"12",cy:"12",r:"4"}),t("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 rd=je({name:"lucide-sun",render:td}),ad={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function nd(e,n){return r(),o("svg",ad,[...n[0]||(n[0]=[t("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 od=je({name:"lucide-moon",render:nd}),ld={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function sd(e,n){return r(),o("svg",ld,[...n[0]||(n[0]=[t("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 id=je({name:"lucide-activity",render:sd}),ud={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function dd(e,n){return r(),o("svg",ud,[...n[0]||(n[0]=[t("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[t("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2"}),t("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 cd=je({name:"lucide-function-square",render:dd}),pd={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function md(e,n){return r(),o("svg",pd,[...n[0]||(n[0]=[t("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 vd=je({name:"lucide-log-out",render:md}),fd={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function gd(e,n){return r(),o("svg",fd,[...n[0]||(n[0]=[t("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[t("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"}),t("circle",{cx:"9",cy:"7",r:"4"})],-1)])])}const hd=je({name:"lucide-users",render:gd}),bd={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function xd(e,n){return r(),o("svg",bd,[...n[0]||(n[0]=[t("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[t("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"}),t("circle",{cx:"7.5",cy:"15.5",r:"5.5"})],-1)])])}const yd=je({name:"lucide-key",render:xd}),kd={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function wd(e,n){return r(),o("svg",kd,[...n[0]||(n[0]=[t("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 _d=je({name:"lucide-book-open",render:wd}),$d={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Cd(e,n){return r(),o("svg",$d,[...n[0]||(n[0]=[t("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 Sd=je({name:"lucide-external-link",render:Cd}),Wa="agentbuilder-accent-theme",Ka=["amber","lime","emerald","sky","blue","indigo","purple","fuchsia","pink","white"],zr=p("purple");let aa=!1;function Ja(e){typeof document>"u"||(e==="purple"?delete document.documentElement.dataset.accent:document.documentElement.dataset.accent=e)}function Id(e){try{localStorage.setItem(Wa,e)}catch{}}function Td(){try{const e=localStorage.getItem(Wa);if(e&&Ka.includes(e))return e}catch{}return"purple"}function Ga(){if(aa)return;aa=!0;const e=Td();zr.value=e,Ja(e)}function Md(){Ga();function e(n){zr.value=n,Ja(n),Id(n)}return{theme:zr,themes:Ka,setTheme:e}}const Ya="/agents/assets/img/agent-builder-logo-light.svg",Za="/agents/assets/img/agent-builder-logo-dark.svg",zd="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",Vd="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",Ed=["src"],Ld=["src"],Ad={class:"flex-1 flex flex-col justify-between pt-2 pb-4"},Pd={class:"flex flex-col gap-1 px-2"},Od={key:0},Rd=["onClick","title"],jd={key:0,class:"flex-1 whitespace-nowrap overflow-hidden text-ellipsis text-left"},Dd={key:0,class:"ml-4 space-y-0.5"},Ud=["onClick"],Bd={class:"whitespace-nowrap overflow-hidden text-ellipsis"},Nd=["onClick","title"],qd={key:0,class:"whitespace-nowrap overflow-hidden text-ellipsis"},Fd={class:"flex flex-col gap-1 px-2"},Hd=["title"],Wd={key:0,class:"flex-1 whitespace-nowrap overflow-hidden text-ellipsis"},Kd={class:"relative settings-menu-container"},Jd={key:0,class:"absolute bottom-full mb-2 left-0 z-50"},Gd={class:"px-4 py-3 border-b border-neutral-200 dark:border-neutral-700"},Yd=["title"],Zd={class:"relative z-10 flex items-center justify-center w-8 h-full"},Xd={class:"relative z-10 flex items-center justify-center w-8 h-full"},Qd={class:"px-4 pt-3 pb-4 border-b border-neutral-200 dark:border-neutral-700"},ec={class:"grid grid-cols-5 gap-3"},tc=["onClick","title"],rc={key:0,class:"w-2 h-2 rounded-full bg-white shadow-sm"},ac={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"},nc=Se({__name:"Sidebar",props:{isCollapsed:{type:Boolean},isDark:{type:Boolean}},emits:["toggle-sidebar","toggle-theme"],setup(e,{emit:n}){function a(fe){if(fe.startsWith("/src/")||fe.startsWith("data:"))return fe;const ye=Xt();return ye==="/"?fe.replace("/agents/","/"):fe.replace("/agents/",`${ye}/`)}const s=a(Ya),l=a(Za),u=a(zd),i=a(Vd),c=e,f=Vt(),h=qt(),x=F(()=>f.name);function b(fe){const ye=f.path;return ye===fe.path||ye.startsWith(fe.path+"/")}const y=F(()=>c.isDark?l:s),$=F(()=>c.isDark?i:u),g=[{id:"threads",label:"Threads",icon:id,path:"/threads"},{id:"agents",label:"Agents",icon:Dt,path:"/agents"},{id:"prompts",label:"Prompts",icon:dr,path:"/prompts"},{id:"tools",label:"Tools",icon:Mr,path:"/tools",hasSubnav:!0,subnav:[{id:"tools-functions",label:"Functions",icon:cd,path:"/tools#functions"},{id:"tools-prompts",label:"Prompts",icon:dr,path:"/tools#prompts"},{id:"tools-agents",label:"Agents",icon:Dt,path:"/tools#agents"}]},{id:"models",label:"Models",icon:Fu,path:"/models"},{id:"providers",label:"Providers",icon:Ku,path:"/providers"}],d=fe=>{h.push(fe)},w=fe=>{h.push(fe),v.value=!1},m=F(()=>typeof x.value=="string"&&(x.value==="tools"||x.value.startsWith("tools-"))),v=p(!1),{theme:_,themes:P,setTheme:V}=Md(),E={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"},z=F(()=>x.value==="users"||x.value==="api-keys"),A=()=>{v.value=!v.value},oe=()=>{localStorage.removeItem("auth_token"),h.push("/login")},ne=fe=>{const ye=fe.target;v.value&&!ye.closest(".settings-menu-container")&&(v.value=!1)};return He(()=>{document.addEventListener("click",ne)}),ct(()=>{document.removeEventListener("click",ne)}),(fe,ye)=>(r(),o("aside",{class:pe(["flex flex-col transition-all duration-300 pt-2.5",e.isCollapsed?"w-16":"w-60"])},[t("div",{class:pe(`flex items-center justify-between ${e.isCollapsed?"px-2 py-4":"p-4"}`)},[e.isCollapsed?S("",!0):(r(),o("img",{key:0,src:y.value,alt:"AgentBuilder",class:"h-8 mr-2 mt-0.5"},null,8,Ed)),t("button",{onClick:ye[0]||(ye[0]=te=>fe.$emit("toggle-sidebar")),class:pe(`p-1 rounded hover:bg-black/5 dark:hover:bg-white/10 transition-colors ${e.isCollapsed?"m-auto":"border border-black/20 dark:border-white/20 opacity-50 hover:opacity-100"}`),"aria-label":"Toggle sidebar"},[e.isCollapsed?(r(),o("img",{key:1,src:$.value,alt:"AgentBuilder",class:"w-7 h-7 m-auto"},null,8,Ld)):(r(),Y(I(Ha),{key:0,class:"w-5 h-5"}))],2)],2),t("nav",Ad,[t("div",Pd,[(r(),o($e,null,Le(g,te=>(r(),o($e,{key:te.id},[te.hasSubnav?(r(),o("div",Od,[t("button",{onClick:q=>d(te.path),class:pe(["flex items-center gap-3 px-3 py-3 rounded text-sm font-medium transition-all w-full",m.value?"bg-black text-white dark:bg-white dark:text-black":"hover:bg-black/5 dark:hover:bg-white/10",e.isCollapsed&&"justify-center"]),title:e.isCollapsed?te.label:void 0},[(r(),Y(rt(te.icon),{class:"w-5 h-5 flex-shrink-0"})),e.isCollapsed?S("",!0):(r(),o("span",jd,C(te.label),1))],10,Rd),!e.isCollapsed&&te.subnav?(r(),o("div",Dd,[(r(!0),o($e,null,Le(te.subnav,q=>(r(),o("button",{key:q.id,onClick:j=>d(q.path),class:pe(["flex items-center gap-3 px-3 py-1.5 text-sm transition-all w-full",x.value===q.id?"bg-black text-white dark:bg-white dark:text-black rounded":"hover:underline"])},[(r(),Y(rt(q.icon),{class:"w-4 h-4 flex-shrink-0"})),t("span",Bd,C(q.label),1)],10,Ud))),128))])):S("",!0)])):(r(),o("button",{key:1,onClick:q=>d(te.path),class:pe(["flex items-center gap-3 px-3 py-3 rounded text-sm font-medium transition-all",b(te)?"bg-black text-white dark:bg-white dark:text-black":"hover:bg-black/5 dark:hover:bg-white/10",e.isCollapsed&&"justify-center"]),title:e.isCollapsed?te.label:void 0},[(r(),Y(rt(te.icon),{class:"w-5 h-5 flex-shrink-0"})),e.isCollapsed?S("",!0):(r(),o("span",qd,C(te.label),1))],10,Nd))],64))),64))]),t("div",Fd,[t("a",{href:"https://docs.standardagentbuilder.com/",target:"_blank",rel:"noopener noreferrer",class:pe(["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",e.isCollapsed&&"justify-center"]),title:e.isCollapsed?"Documentation":void 0},[k(I(_d),{class:"w-5 h-5 flex-shrink-0"}),e.isCollapsed?S("",!0):(r(),o("span",Wd," Docs ")),e.isCollapsed?S("",!0):(r(),Y(I(Sd),{key:1,class:"w-3 h-3 flex-shrink-0 opacity-50"}))],10,Hd),t("div",{class:pe(["flex items-center gap-1 pt-2 mt-1 border-t border-black/10 dark:border-white/10",e.isCollapsed?"flex-col":"justify-between"])},[t("div",Kd,[t("button",{onClick:Xe(A,["stop"]),class:pe(["p-2 rounded transition-colors flex items-center",v.value||z.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"},[k(I(Jt),{class:"w-5 h-5 flex-shrink-0"})],2),v.value?(r(),o("div",Jd,[k(I(vr),{width:"min-w-[200px]",shadow:{offsetX:6,offsetY:6,intensity:.4}},{default:W(()=>[t("div",Gd,[ye[4]||(ye[4]=t("div",{class:"text-xs font-bold text-neutral-600 dark:text-neutral-400 pb-3"}," Appearance ",-1)),t("button",{onClick:ye[1]||(ye[1]=Xe(te=>fe.$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:e.isDark?"Switch to light mode":"Switch to dark mode"},[t("span",{class:pe(["absolute top-0.5 h-6 w-8 rounded-full bg-white dark:bg-black shadow-sm transition-transform duration-200",e.isDark?"translate-x-[calc(100%-2px)]":"translate-x-0.5"])},null,2),t("span",Zd,[k(I(rd),{class:pe(["w-4 h-4",e.isDark?"text-neutral-500":"text-black"])},null,8,["class"])]),t("span",Xd,[k(I(od),{class:pe(["w-4 h-4",e.isDark?"text-white":"text-neutral-400"])},null,8,["class"])])],8,Yd)]),t("div",Qd,[ye[5]||(ye[5]=t("div",{class:"text-xs font-bold text-neutral-600 dark:text-neutral-400 pb-3"}," Accent Color ",-1)),t("div",ec,[(r(!0),o($e,null,Le(I(P),te=>(r(),o("button",{key:te,onClick:Xe(q=>I(V)(te),["stop"]),class:pe(["w-6 h-6 rounded-full transition-all flex items-center justify-center ring-1 ring-black/10 dark:ring-white/10",[E[te],I(_)===te?"ring-2 ring-black/50 dark:ring-white/50":"hover:scale-110"]]),title:te.charAt(0).toUpperCase()+te.slice(1)},[I(_)===te?(r(),o("span",rc)):S("",!0)],10,tc))),128))])]),t("button",{onClick:ye[2]||(ye[2]=te=>w("/settings/users")),class:pe(["flex items-center gap-3 px-4 py-2 text-sm transition-all w-full text-left",x.value==="users"?"bg-black text-white dark:bg-white dark:text-black":"hover:bg-black/5 dark:hover:bg-white/10"])},[k(I(hd),{class:"w-4 h-4 flex-shrink-0"}),ye[6]||(ye[6]=t("span",{class:"whitespace-nowrap"},"Users",-1))],2),t("button",{onClick:ye[3]||(ye[3]=te=>w("/settings/api-keys")),class:pe(["flex items-center gap-3 px-4 py-2 text-sm transition-all w-full text-left",x.value==="api-keys"?"bg-black text-white dark:bg-white dark:text-black":"hover:bg-black/5 dark:hover:bg-white/10"])},[k(I(yd),{class:"w-4 h-4 flex-shrink-0"}),ye[7]||(ye[7]=t("span",{class:"whitespace-nowrap"},"API Keys",-1))],2)]),_:1})])):S("",!0)]),t("button",{onClick:oe,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"},[k(I(vd),{class:"w-5 h-5 flex-shrink-0"}),e.isCollapsed?S("",!0):(r(),o("span",ac,"Logout"))])],2)])])],2))}}),oc={class:"warning-banner-container"},lc={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"},sc={class:"flex items-center gap-2"},ic=["onClick"],uc=Se({__name:"WarningBanner",setup(e){const n=p([]),a=p(new Set),s=async()=>{if(localStorage.getItem("auth_token"))try{const f=await fetch(ze("/api/diagnostics"));if(f.ok){const h=await f.json();n.value=h.warnings||[]}}catch{}},l=c=>{const f=`${c.type}:${c.details?.name||c.message}`;a.value.add(f)},u=c=>{const f=`${c.type}:${c.details?.name||c.message}`;return!a.value.has(f)},i=c=>{if(c.type==="duplicate_tool_name"){const f=c.details?.sources?.join(" and ")||"multiple sources";return`Duplicate tool name "${c.details?.name}" (defined as both ${f}). This may cause unexpected behavior.`}return c.message};return He(()=>{s()}),(c,f)=>(r(),o("div",oc,[(r(!0),o($e,null,Le(n.value,h=>(r(),o($e,{key:`${h.type}:${h.details?.name}`},[u(h)?(r(),o("div",lc,[t("div",sc,[f[0]||(f[0]=t("svg",{xmlns:"http://www.w3.org/2000/svg",class:"h-4 w-4 flex-shrink-0",viewBox:"0 0 20 20",fill:"currentColor"},[t("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)),t("span",null,C(i(h)),1)]),t("button",{onClick:x=>l(h),class:"text-amber-600 dark:text-amber-400 hover:text-amber-800 dark:hover:text-amber-200 p-1",title:"Dismiss"},[...f[1]||(f[1]=[t("svg",{xmlns:"http://www.w3.org/2000/svg",class:"h-4 w-4",viewBox:"0 0 20 20",fill:"currentColor"},[t("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,ic)])):S("",!0)],64))),128))]))}}),dc={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"},cc={class:"flex-1 overflow-auto"},pc=Se({__name:"App",setup(e){Ga();const n=Vt(),a=p(!1),s=p(!1),l=F(()=>n.name!=="login"),u=()=>{a.value=!a.value},i=()=>{s.value=!s.value,s.value?(document.documentElement.classList.add("dark"),localStorage.setItem("theme","dark")):(document.documentElement.classList.remove("dark"),localStorage.setItem("theme","light"))};return He(()=>{const c=localStorage.getItem("theme");(c==="dark"||!c&&window.matchMedia("(prefers-color-scheme: dark)").matches)&&(s.value=!0,document.documentElement.classList.add("dark"))}),(c,f)=>(r(),o("div",{class:pe(["app-container relative flex h-screen font-sans bg-neutral-50/80 text-black dark:bg-black dark:text-white",{"is-dark":s.value}])},[l.value?(r(),Y(nc,{key:0,"is-collapsed":a.value,"is-dark":s.value,onToggleSidebar:u,onToggleTheme:i},null,8,["is-collapsed","is-dark"])):S("",!0),l.value?(r(),o("main",dc,[k(uc),t("div",cc,[k(I(Br))])])):(r(),Y(I(Br),{key:1}))],2))}}),mc=mt(pc,[["__scopeId","data-v-2125e5d3"]]),vc={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function fc(e,n){return r(),o("svg",vc,[...n[0]||(n[0]=[t("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 gc=je({name:"lucide-trash-2",render:fc}),hc={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function bc(e,n){return r(),o("svg",hc,[...n[0]||(n[0]=[t("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[t("path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),t("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 xc=je({name:"lucide-edit",render:bc}),yc={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function kc(e,n){return r(),o("svg",yc,[...n[0]||(n[0]=[t("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[t("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"}),t("circle",{cx:"12",cy:"12",r:"3"})],-1)])])}const Vr=je({name:"lucide-eye",render:kc}),wc={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function _c(e,n){return r(),o("svg",wc,[...n[0]||(n[0]=[t("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"m18 15l-6-6l-6 6"},null,-1)])])}const $c=je({name:"lucide-chevron-up",render:_c}),Cc={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Sc(e,n){return r(),o("svg",Cc,[...n[0]||(n[0]=[t("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"m6 9l6 6l6-6"},null,-1)])])}const Ic=je({name:"lucide-chevron-down",render:Sc}),Tc={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Mc(e,n){return r(),o("svg",Tc,[...n[0]||(n[0]=[t("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"m7 15l5 5l5-5M7 9l5-5l5 5"},null,-1)])])}const zc=je({name:"lucide-chevrons-up-down",render:Mc}),Vc={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Ec(e,n){return r(),o("svg",Vc,[...n[0]||(n[0]=[t("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[t("path",{d:"M22 12h-6l-2 3h-4l-2-3H2"}),t("path",{d:"M5.45 5.11L2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11"})],-1)])])}const Lc=je({name:"lucide-inbox",render:Ec}),Ac={key:0,class:"w-full max-w-md"},Pc={class:"flex items-center justify-between p-4 border-b border-red-200 dark:border-red-900 flex-shrink-0"},Oc={class:"text-xl font-bold text-red-600"},Rc={class:"p-6"},jc={class:"text-neutral-700 dark:text-neutral-300 mb-6"},Dc={class:"flex justify-end gap-3"},Or=Se({__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(e,{emit:n}){const a=e,s=n,l=()=>{s("update:modelValue",!1)},u=()=>{s("confirm"),l()},i=()=>{s("cancel"),l()},c=f=>{f.key==="Escape"&&a.modelValue&&i()};return Ve(()=>a.modelValue,f=>{f?(document.addEventListener("keydown",c),document.body.style.overflow="hidden"):(document.removeEventListener("keydown",c),document.body.style.overflow="")}),(f,h)=>(r(),Y(Yt,{to:"body"},[k(kt,{"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:W(()=>[e.modelValue?(r(),o("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},[k(kt,{"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:W(()=>[e.modelValue?(r(),o("div",Ac,[k(Zt,{"offset-x":8,"offset-y":8,intensity:.35},{default:W(()=>[t("div",{class:"bg-white dark:bg-neutral-900 border border-red-400 dark:border-red-500 rounded-lg flex flex-col",onClick:h[0]||(h[0]=Xe(()=>{},["stop"]))},[t("div",Pc,[t("h2",Oc,C(e.title),1),k(I(Da),{icon:I(mr),label:"Close dialog",variant:"danger",onClick:i},null,8,["icon"])]),t("div",Rc,[t("p",jc,C(e.message),1),t("div",Dc,[k(I(Qe),{variant:"secondary",onClick:i},{default:W(()=>[ve(C(e.cancelText),1)]),_:1}),k(I(Qe),{variant:"danger",onClick:u},{default:W(()=>[ve(C(e.confirmText),1)]),_:1})])])])]),_:1})])):S("",!0)]),_:1})])):S("",!0)]),_:1})]))}}),Uc={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Bc(e,n){return r(),o("svg",Uc,[...n[0]||(n[0]=[t("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"m9 18l6-6l-6-6"},null,-1)])])}const Nc=je({name:"lucide-chevron-right",render:Bc}),qc={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Fc(e,n){return r(),o("svg",qc,[...n[0]||(n[0]=[t("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"m11 17l-5-5l5-5m7 10l-5-5l5-5"},null,-1)])])}const Hc=je({name:"lucide-chevrons-left",render:Fc}),Wc={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Kc(e,n){return r(),o("svg",Wc,[...n[0]||(n[0]=[t("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"m6 17l5-5l-5-5m7 10l5-5l-5-5"},null,-1)])])}const Jc=je({name:"lucide-chevrons-right",render:Kc}),Gc={key:0,class:"flex flex-wrap items-center justify-between gap-4 px-4 py-2.5 text-sm bg-neutral-50 dark:bg-neutral-800/50 border-t border-neutral-300 dark:border-neutral-700"},Yc={class:"text-neutral-500 dark:text-neutral-400 text-xs font-medium"},Zc={class:"text-neutral-700 dark:text-neutral-300"},Xc={class:"text-neutral-700 dark:text-neutral-300"},Qc={class:"text-neutral-700 dark:text-neutral-300"},ep={class:"flex items-center gap-0.5"},tp=["disabled"],rp=["disabled"],ap={class:"flex items-center gap-0.5 mx-1"},np={key:0,class:"px-2 text-neutral-400 dark:text-neutral-500 text-xs"},op=["onClick"],lp=["disabled"],sp=["disabled"],ip={class:"flex items-center gap-2"},up=["value"],dp=["value"],cp=Se({__name:"DataTablePagination",props:{page:{},pageSize:{},totalItems:{},pageSizeOptions:{default:()=>[10,25,50,100]}},emits:["update:page","update:pageSize"],setup(e,{emit:n}){const a=e,s=n,l=F(()=>Math.ceil(a.totalItems/a.pageSize)),u=F(()=>a.totalItems===0?0:(a.page-1)*a.pageSize+1),i=F(()=>Math.min(a.page*a.pageSize,a.totalItems)),c=F(()=>a.page>1),f=F(()=>a.page<l.value),h=F(()=>{const w=[],m=l.value,v=a.page;if(m<=7)for(let _=1;_<=m;_++)w.push(_);else{w.push(1),v>3&&w.push("...");const _=Math.max(2,v-1),P=Math.min(m-1,v+1);for(let V=_;V<=P;V++)w.includes(V)||w.push(V);v<m-2&&w.push("..."),w.includes(m)||w.push(m)}return w}),x=w=>{w>=1&&w<=l.value&&s("update:page",w)},b=()=>x(1),y=()=>x(a.page-1),$=()=>x(a.page+1),g=()=>x(l.value),d=w=>{const m=w.target;s("update:pageSize",parseInt(m.value,10)),s("update:page",1)};return(w,m)=>e.totalItems>0?(r(),o("div",Gc,[t("div",Yc,[m[0]||(m[0]=ve(" Showing ",-1)),t("span",Zc,C(u.value),1),m[1]||(m[1]=ve(" to ",-1)),t("span",Xc,C(i.value),1),m[2]||(m[2]=ve(" of ",-1)),t("span",Qc,C(e.totalItems),1)]),t("div",ep,[t("button",{type:"button",onClick:b,disabled:!c.value,class:"p-1.5 rounded-md transition-all duration-150 hover:bg-neutral-200 dark:hover:bg-neutral-700 disabled:opacity-30 disabled:cursor-not-allowed disabled:hover:bg-transparent",title:"First page"},[k(I(Hc),{class:"w-4 h-4 text-neutral-500 dark:text-neutral-400"})],8,tp),t("button",{type:"button",onClick:y,disabled:!c.value,class:"p-1.5 rounded-md transition-all duration-150 hover:bg-neutral-200 dark:hover:bg-neutral-700 disabled:opacity-30 disabled:cursor-not-allowed disabled:hover:bg-transparent",title:"Previous page"},[k(I(Ha),{class:"w-4 h-4 text-neutral-500 dark:text-neutral-400"})],8,rp),t("div",ap,[(r(!0),o($e,null,Le(h.value,(v,_)=>(r(),o($e,{key:_},[v==="..."?(r(),o("span",np," ... ")):(r(),o("button",{key:1,type:"button",onClick:P=>x(v),class:pe(["min-w-[1.75rem] px-2 py-1 rounded-md text-xs font-medium transition-all duration-150",v===e.page?"bg-accent-600 text-white shadow-sm":"text-neutral-600 dark:text-neutral-400 hover:bg-neutral-200 dark:hover:bg-neutral-700 hover:text-neutral-900 dark:hover:text-neutral-200"])},C(v),11,op))],64))),128))]),t("button",{type:"button",onClick:$,disabled:!f.value,class:"p-1.5 rounded-md transition-all duration-150 hover:bg-neutral-200 dark:hover:bg-neutral-700 disabled:opacity-30 disabled:cursor-not-allowed disabled:hover:bg-transparent",title:"Next page"},[k(I(Nc),{class:"w-4 h-4 text-neutral-500 dark:text-neutral-400"})],8,lp),t("button",{type:"button",onClick:g,disabled:!f.value,class:"p-1.5 rounded-md transition-all duration-150 hover:bg-neutral-200 dark:hover:bg-neutral-700 disabled:opacity-30 disabled:cursor-not-allowed disabled:hover:bg-transparent",title:"Last page"},[k(I(Jc),{class:"w-4 h-4 text-neutral-500 dark:text-neutral-400"})],8,sp)]),t("div",ip,[t("select",{value:e.pageSize,onChange:d,class:"px-2 py-1 rounded-md border border-neutral-200 dark:border-neutral-700 bg-white dark:bg-neutral-800 text-xs font-medium text-neutral-700 dark:text-neutral-300 focus:outline-none focus:ring-2 focus:ring-accent-500/30 focus:border-accent-500 dark:focus:border-accent-400 cursor-pointer transition-all"},[(r(!0),o($e,null,Le(e.pageSizeOptions,v=>(r(),o("option",{key:v,value:v},C(v),9,dp))),128))],40,up),m[3]||(m[3]=t("span",{class:"text-neutral-500 dark:text-neutral-400 text-xs"},"per page",-1))])])):S("",!0)}}),pp={class:"w-full"},mp={key:0,class:"flex flex-wrap items-start justify-between gap-4 mb-5"},vp={class:"flex items-center gap-3"},fp={class:"flex items-center gap-2"},gp={key:0,class:"text-xl font-bold tracking-tight"},hp={key:1,class:"text-xs font-mono text-neutral-400 dark:text-neutral-500"},bp={key:0,class:"text-sm text-neutral-500 dark:text-neutral-400 mt-0.5"},xp={key:0,class:"flex items-center gap-2"},yp={key:1,class:"mb-4"},kp={class:"flex flex-wrap items-center gap-3"},wp={key:0,class:"flex-1 min-w-[200px] max-w-md"},_p={key:2,class:"flex items-center gap-2 ml-auto"},$p={class:"text-sm text-neutral-500 dark:text-neutral-400 font-medium"},Cp={class:"flex items-center gap-1.5"},Sp=["onClick"],Ip={class:"rounded-xl border border-neutral-300 dark:border-neutral-700 overflow-hidden bg-white dark:bg-transparent"},Tp={class:"overflow-x-auto"},Mp={class:"w-full"},zp={class:"bg-neutral-50 dark:bg-neutral-800/50 border-b border-neutral-300 dark:border-neutral-700"},Vp={key:0,class:"px-4 py-2.5 w-12"},Ep={class:"flex items-center justify-center"},Lp=["checked","indeterminate"],Ap=["onClick"],Pp={key:1,class:"px-4 py-2.5 text-right font-medium text-xs uppercase tracking-wide text-neutral-500 dark:text-neutral-400 w-24"},Op={class:"divide-y divide-neutral-200 dark:divide-neutral-800"},Rp={key:0},jp=["colspan"],Dp={class:"flex flex-col items-center justify-center gap-3 text-neutral-400"},Up={key:1},Bp=["colspan"],Np={class:"flex flex-col items-center justify-center gap-3 text-neutral-400"},qp={class:"w-12 h-12 rounded-full bg-neutral-100 dark:bg-neutral-800 flex items-center justify-center"},Fp={class:"text-sm"},Hp=["onClick"],Wp={key:0,class:"absolute left-0 top-0 bottom-0 w-0.5 bg-accent-500"},Kp={class:"flex items-center justify-center"},Jp=["checked","onChange"],Gp=["innerHTML"],Yp={class:"inline-flex gap-0.5"},Zp=["disabled","onClick","title"],Xp=["disabled","onClick","title"],It=Se({__name:"DataTable",props:{columns:{},data:{},actions:{},emptyMessage:{default:"No data available"},loading:{type:Boolean,default:!1},title:{},description:{},primaryAction:{},sortable:{type:Boolean,default:!1},sortKey:{},sortDirection:{default:"asc"},searchable:{type:Boolean,default:!1},searchQuery:{default:""},searchPlaceholder:{default:"Search..."},paginated:{type:Boolean,default:!1},page:{default:1},pageSize:{default:10},totalItems:{default:0},pageSizeOptions:{default:()=>[10,25,50,100]},selectable:{type:Boolean,default:!1},selectedRows:{default:()=>[]},rowKey:{default:"id"},bulkActions:{default:()=>[]}},emits:["update:sortKey","update:sortDirection","sort","update:searchQuery","search","update:page","update:pageSize","page-change","update:selectedRows","selection-change","row-click"],setup(e,{emit:n}){const a=e,s=n,l=p(!1),u=p(""),i=p(null),c=B=>{if(typeof B!="string")return B;switch(B){case"edit":return xc;case"delete":return gc;case"view":return Vr;default:return null}},f=(B,D)=>{const M=B[D.key];return D.formatter?D.formatter(M,B):M??"-"},h=B=>{switch(B){case"center":return"text-center";case"right":return"text-right";default:return"text-left"}},x=(B,D)=>D.cellClass?typeof D.cellClass=="function"?D.cellClass(B):D.cellClass:"",b=async(B,D)=>{if(B.confirm){const M=typeof B.confirmMessage=="function"?B.confirmMessage(D):B.confirmMessage||`Are you sure you want to ${B.label.toLowerCase()}?`;u.value=M,i.value=async()=>{await B.handler(D)},l.value=!0}else await B.handler(D)},y=async()=>{i.value&&(await i.value(),i.value=null),l.value=!1},$=()=>{i.value=null,l.value=!1},g=(B,D)=>B.visible===void 0?!0:typeof B.visible=="function"?B.visible(D):B.visible,d=(B,D)=>B.disabled===void 0?!1:typeof B.disabled=="function"?B.disabled(D):B.disabled,w=p(null),m=p("asc"),v=F(()=>a.sortKey??w.value),_=F(()=>a.sortKey!==void 0?a.sortDirection:m.value),P=B=>a.sortable&&B.sortable===!0,V=B=>{if(!P(B))return;const D=B.key;let M="asc";v.value===D&&(M=_.value==="asc"?"desc":"asc"),w.value=D,m.value=M,s("update:sortKey",D),s("update:sortDirection",M),s("sort",{key:D,direction:M})},E=B=>v.value!==B.key?zc:_.value==="asc"?$c:Ic,z=F(()=>{if(!v.value||!a.sortable)return j.value;const B=v.value,D=_.value;return[...j.value].sort((M,T)=>{const L=M[B],ee=T[B];if(L==null&&ee==null)return 0;if(L==null)return D==="asc"?1:-1;if(ee==null)return D==="asc"?-1:1;let le=0;return typeof L=="string"&&typeof ee=="string"?le=L.localeCompare(ee,void 0,{sensitivity:"base"}):typeof L=="number"&&typeof ee=="number"?le=L-ee:le=String(L).localeCompare(String(ee)),D==="asc"?le:-le})}),A=p(a.searchQuery),oe=p({}),ne=_a(B=>{s("update:searchQuery",B),s("search",B)},300),fe=B=>{A.value=B,ne(B)},ye=()=>{A.value="",s("update:searchQuery",""),s("search","")},te=F(()=>a.columns.filter(B=>B.filterable===!0).map(B=>{const D=new Map;a.data.forEach(T=>{const L=T[B.key];if(L!=null){const ee=B.formatter?B.formatter(L,T):String(L);if(!D.has(ee)){const le=B.filterIcon?B.filterIcon(L,T):void 0;D.set(ee,{value:ee,icon:le})}}});const M=Array.from(D.entries()).sort((T,L)=>T[0].localeCompare(L[0]));return{key:B.key,label:B.label,options:M.map(([T,L])=>({value:T,label:T,icon:L.icon}))}})),q=(B,D)=>{if(D===""){const{[B]:M,...T}=oe.value;oe.value=T}else oe.value={...oe.value,[B]:D}},j=F(()=>{let B=a.data;const D=Object.entries(oe.value);if(D.length>0&&(B=B.filter(M=>D.every(([T,L])=>{const ee=a.columns.find(Re=>Re.key===T);if(!ee)return!0;const le=M[T];return le==null?!1:(ee.formatter?ee.formatter(le,M):String(le))===L}))),a.searchable&&A.value.trim()){const M=A.value.toLowerCase().trim();B=B.filter(T=>a.columns.some(L=>{if(L.searchable===!1)return!1;const ee=T[L.key];return ee==null?!1:(L.formatter?L.formatter(ee,T):String(ee)).toLowerCase().includes(M)}))}return B}),J=F(()=>{let B=0;return A.value&&B++,B+=Object.keys(oe.value).length,B}),H=()=>{ye(),oe.value={}},ce=B=>B[a.rowKey],Z=B=>{const D=ce(B);return a.selectedRows.some(M=>M[a.rowKey]===D)},U=F(()=>z.value.length>0&&a.selectedRows.length===z.value.length),K=F(()=>a.selectedRows.length>0&&a.selectedRows.length<z.value.length),me=B=>{const D=ce(B);let M;Z(B)?M=a.selectedRows.filter(T=>T[a.rowKey]!==D):M=[...a.selectedRows,B],s("update:selectedRows",M),s("selection-change",M)},ue=()=>{const B=U.value?[]:[...z.value];s("update:selectedRows",B),s("selection-change",B)},Q=async B=>{if(B.confirm){const D=B.confirmMessage||`Are you sure you want to ${B.label.toLowerCase()} ${a.selectedRows.length} item(s)?`;u.value=D,i.value=async()=>{await B.handler(a.selectedRows)},l.value=!0}else await B.handler(a.selectedRows)},G=B=>{s("update:page",B),s("page-change",B)},ae=B=>{s("update:pageSize",B)},ie=F(()=>a.title||a.description||a.primaryAction),xe=F(()=>a.actions&&a.actions.length>0),X=F(()=>a.actions?.filter(B=>B.variant!=="danger")||[]),he=F(()=>a.actions?.filter(B=>B.variant==="danger")||[]),be=F(()=>{let B=a.columns.length;return a.selectable&&B++,xe.value&&B++,B});return(B,D)=>{const M=at("FormKit");return r(),o("div",pp,[ie.value?(r(),o("div",mp,[t("div",vp,[t("div",null,[t("div",fp,[e.title?(r(),o("h2",gp,C(e.title),1)):S("",!0),!e.loading&&e.data.length>0?(r(),o("span",hp,[J.value>0&&j.value.length!==e.data.length?(r(),o($e,{key:0},[ve(" ("+C(j.value.length)+" of "+C(e.data.length)+") ",1)],64)):(r(),o($e,{key:1},[ve(" ("+C(e.data.length)+") ",1)],64))])):S("",!0)]),e.description?(r(),o("p",bp,C(e.description),1)):S("",!0)])]),e.primaryAction?(r(),o("div",xp,[Ye(B.$slots,"header-actions"),k(I(Qe),{onClick:e.primaryAction.handler},{default:W(()=>[e.primaryAction.icon?(r(),Y(rt(e.primaryAction.icon),{key:0,class:"w-4 h-4 mr-2"})):S("",!0),ve(" "+C(e.primaryAction.label),1)]),_:1},8,["onClick"])])):S("",!0)])):S("",!0),e.searchable||te.value.length>0?(r(),o("div",yp,[t("div",kp,[e.searchable?(r(),o("div",wp,[k(M,{type:"searchInput",value:A.value,placeholder:e.searchPlaceholder,onInput:fe},null,8,["value","placeholder"])])):S("",!0),(r(!0),o($e,null,Le(te.value,T=>(r(),o("div",{key:T.key,class:"min-w-[220px]"},[k(M,{type:"selectSearch",value:oe.value[T.key]||"",options:T.options,placeholder:`All ${T.label}s`,onInput:L=>q(T.key,L)},null,8,["value","options","placeholder","onInput"])]))),128)),J.value>0?(r(),o("button",{key:1,type:"button",onClick:H,class:"px-3 py-2 text-sm font-medium text-neutral-500 hover:text-neutral-700 dark:text-neutral-400 dark:hover:text-neutral-200 transition-colors"}," Clear filters ")):S("",!0),e.selectable&&e.selectedRows.length>0&&e.bulkActions.length>0?(r(),o("div",_p,[t("span",$p,C(e.selectedRows.length)+" selected ",1),t("div",Cp,[(r(!0),o($e,null,Le(e.bulkActions,(T,L)=>(r(),o("button",{key:L,type:"button",onClick:ee=>Q(T),class:pe(["inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-sm font-medium transition-all duration-150",T.variant==="danger"?"bg-red-100 text-red-700 hover:bg-red-200 dark:bg-red-900/30 dark:text-red-400 dark:hover:bg-red-900/50":"bg-neutral-100 text-neutral-700 hover:bg-neutral-200 dark:bg-neutral-800 dark:text-neutral-300 dark:hover:bg-neutral-700"])},[(r(),Y(rt(T.icon),{class:"w-4 h-4"})),ve(" "+C(T.label),1)],10,Sp))),128))])])):S("",!0)])])):S("",!0),Ye(B.$slots,"toolbar"),t("div",Ip,[t("div",Tp,[t("table",Mp,[t("thead",zp,[t("tr",null,[e.selectable?(r(),o("th",Vp,[t("div",Ep,[t("input",{type:"checkbox",checked:U.value,indeterminate:K.value,onChange:ue,class:"w-4 h-4 rounded border-neutral-300 dark:border-neutral-600 text-accent-600 focus:ring-accent-500 focus:ring-offset-0 cursor-pointer transition-colors"},null,40,Lp)])])):S("",!0),(r(!0),o($e,null,Le(e.columns,T=>(r(),o("th",{key:T.key,class:pe(["px-4 py-2.5 font-medium text-xs uppercase tracking-wide text-neutral-500 dark:text-neutral-400",h(T.align),T.width||"",P(T)?"cursor-pointer select-none group":""]),onClick:L=>V(T)},[t("div",{class:pe(["inline-flex items-center gap-1",T.align==="right"?"flex-row-reverse":"",P(T)?"hover:text-neutral-700 dark:hover:text-neutral-200 transition-colors":""])},[t("span",null,C(T.label),1),P(T)?(r(),o("span",{key:0,class:pe(["inline-flex items-center justify-center w-5 h-5 rounded transition-all duration-150",v.value===T.key?"bg-accent-100 dark:bg-accent-900/50":"group-hover:bg-neutral-200 dark:group-hover:bg-neutral-700"])},[(r(),Y(rt(E(T)),{class:pe(["w-3.5 h-3.5",v.value===T.key?"text-accent-600 dark:text-accent-400":"text-neutral-400 dark:text-neutral-500"])},null,8,["class"]))],2)):S("",!0)],2)],10,Ap))),128)),xe.value?(r(),o("th",Pp," Actions ")):S("",!0)])]),t("tbody",Op,[e.loading?(r(),o("tr",Rp,[t("td",{colspan:be.value,class:"px-4 py-16"},[Ye(B.$slots,"loading",{},()=>[t("div",Dp,[k(Be,{size:"md"}),D[3]||(D[3]=t("span",{class:"text-sm"},"Loading data...",-1))])])],8,jp)])):z.value.length===0?(r(),o("tr",Up,[t("td",{colspan:be.value,class:"px-4 py-16"},[Ye(B.$slots,"empty",{},()=>[t("div",Np,[t("div",qp,[k(I(Lc),{class:"w-6 h-6"})]),t("p",Fp,C(e.emptyMessage),1),J.value>0?(r(),o("button",{key:0,onClick:H,type:"button",class:"text-xs text-accent-600 dark:text-accent-400 hover:underline font-medium"}," Clear filters ")):S("",!0)])])],8,Bp)])):(r(!0),o($e,{key:2},Le(z.value,(T,L)=>(r(),o("tr",{key:T[e.rowKey]??L,class:pe(["transition-all duration-150 cursor-pointer relative",Z(T)?"bg-accent-50 dark:bg-accent-950/30":"hover:bg-neutral-50 dark:hover:bg-neutral-900/50"]),onClick:ee=>s("row-click",T)},[Z(T)?(r(),o("div",Wp)):S("",!0),e.selectable?(r(),o("td",{key:1,class:"px-4 py-3",onClick:D[0]||(D[0]=Xe(()=>{},["stop"]))},[t("div",Kp,[t("input",{type:"checkbox",checked:Z(T),onChange:ee=>me(T),class:"w-4 h-4 rounded border-neutral-300 dark:border-neutral-600 text-accent-600 focus:ring-accent-500 focus:ring-offset-0 cursor-pointer transition-colors"},null,40,Jp)])])):S("",!0),(r(!0),o($e,null,Le(e.columns,ee=>(r(),o("td",{key:ee.key,class:pe(["px-4 py-3 text-sm",h(ee.align),x(T,ee),Z(T)?"text-accent-900 dark:text-accent-100":"text-neutral-700 dark:text-neutral-300"])},[Ye(B.$slots,`cell-${ee.key}`,{value:T[ee.key],row:T,column:ee},()=>[ee.html?(r(),o("span",{key:0,innerHTML:f(T,ee)},null,8,Gp)):(r(),o($e,{key:1},[ve(C(f(T,ee)),1)],64))])],2))),128)),xe.value?(r(),o("td",{key:2,class:"px-4 py-3 text-right",onClick:D[1]||(D[1]=Xe(()=>{},["stop"]))},[t("div",Yp,[(r(!0),o($e,null,Le(X.value,(ee,le)=>Je((r(),o("button",{key:`non-delete-${le}`,disabled:d(ee,T),onClick:Ie=>b(ee,T),class:pe(["p-1.5 rounded-md transition-all duration-150",d(ee,T)?"opacity-30 cursor-not-allowed":"text-neutral-400 hover:text-neutral-700 hover:bg-neutral-100 dark:hover:text-neutral-200 dark:hover:bg-neutral-800"]),title:ee.label},[(r(),Y(rt(c(ee.icon)),{class:"w-4 h-4"}))],10,Zp)),[[pt,g(ee,T)]])),128)),Ye(B.$slots,"extra-actions",{row:T}),(r(!0),o($e,null,Le(he.value,(ee,le)=>Je((r(),o("button",{key:`delete-${le}`,disabled:d(ee,T),onClick:Ie=>b(ee,T),class:pe(["p-1.5 rounded-md transition-all duration-150",d(ee,T)?"opacity-30 cursor-not-allowed":"text-neutral-400 hover:text-red-600 hover:bg-red-50 dark:hover:text-red-400 dark:hover:bg-red-900/30"]),title:ee.label},[(r(),Y(rt(c(ee.icon)),{class:"w-4 h-4"}))],10,Xp)),[[pt,g(ee,T)]])),128))])])):S("",!0)],10,Hp))),128))])])]),e.paginated?(r(),Y(cp,{key:0,page:e.page,"page-size":e.pageSize,"total-items":e.totalItems,"page-size-options":e.pageSizeOptions,"onUpdate:page":G,"onUpdate:pageSize":ae},null,8,["page","page-size","total-items","page-size-options"])):S("",!0)]),k(Or,{modelValue:l.value,"onUpdate:modelValue":D[2]||(D[2]=T=>l.value=T),title:"Confirm Action",message:u.value,"confirm-text":"Confirm","cancel-text":"Cancel",onConfirm:y,onCancel:$},null,8,["modelValue","message"])])}}}),Qp={},e0={xmlns:"http://www.w3.org/2000/svg",viewBox:"-12 -12 408 408",width:"1em",height:"1em",fill:"currentColor",stroke:"currentColor","stroke-width":"24","stroke-linejoin":"round","aria-hidden":"true"};function t0(e,n){return r(),o("svg",e0,[...n[0]||(n[0]=[t("path",{d:"M384,171.75v9.75c-1.68,7.91-4.76,14.74-10.77,20.88l-113.42,115.85c-10.42,10.65-25.58,13.8-39.31,8.04-12.9-5.41-21.53-18.19-21.52-33.02l.03-43.8h-26.55c-32.35.02-67.19,7.63-94.92,24.63s-44.76,42.35-51.3,73.05c-1.42,6.68-5.61,11.51-12.38,12.08-6.37.54-11.26-3.83-13.86-9.7v-46.5c.42-1.2.55-2.61.71-4.61,7.99-103.74,94.18-186.48,198.25-192.75l.08-45.6c.02-14.6,8.87-27.11,21.33-32.38,13.91-5.89,29.05-2.63,39.51,8.05l112.3,114.71c6.23,6.36,9.94,13.03,11.82,21.33ZM211.97,223.41c7.34,0,13.01,5.78,13.01,12.84v56.98c.01,4.38,2.23,7.69,5.66,9.09,4.03,1.65,7.66.72,10.83-2.51l113.71-116.2c3.69-3.77,3.73-9.48.04-13.25l-113.69-116.21c-3.21-3.28-6.81-4.26-11.03-2.51-3.33,1.38-5.52,4.74-5.52,9.15l.03,56.96c0,7.8-5.62,13.53-13.58,13.54-48.85.09-95.31,19.31-130.18,53.54-26.49,26-45.26,59.26-51.99,96.82,34.96-40.83,86.25-56.16,137.95-58.21l44.76-.03Z"},null,-1)])])}const r0=mt(Qp,[["render",t0]]),a0={},n0={xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",fill:"currentColor"};function o0(e,n){return r(),o("svg",n0,[...n[0]||(n[0]=[t("path",{d:"M4 4h16v16H4V4zm2 2v12h4v-10h3v10h5V6H6z"},null,-1)])])}const l0=mt(a0,[["render",o0]]),s0={class:"py-1"},i0=Se({__name:"ShareDropdown",props:{packageId:{}},emits:["download","publish"],setup(e,{emit:n}){const a=n,s=p(null),l=p(null);function u(){if(!s.value||!l.value)return;const h=s.value.getBoundingClientRect();let b=h.right-160;const y=8;b<y&&(b=y),l.value.style.top=`${h.bottom+4}px`,l.value.style.left=`${b}px`}function i(){l.value&&(l.value.matches(":popover-open")?l.value.hidePopover():(u(),l.value.showPopover()))}function c(h){l.value?.hidePopover(),a(h)}function f(){l.value?.matches(":popover-open")&&u()}return He(()=>{window.addEventListener("scroll",f,!0),window.addEventListener("resize",f)}),ct(()=>{window.removeEventListener("scroll",f,!0),window.removeEventListener("resize",f)}),(h,x)=>(r(),o($e,null,[t("button",{ref_key:"triggerButton",ref:s,type:"button",onClick:i,class:"p-1.5 rounded-md transition-all duration-150 text-neutral-400 hover:text-neutral-700 hover:bg-neutral-100 dark:hover:text-neutral-200 dark:hover:bg-neutral-800",title:"Share"},[k(r0,{class:"w-4 h-4"})],512),t("div",{ref_key:"popoverEl",ref:l,popover:"auto",class:"w-40 p-0 m-0 border-0 bg-transparent overflow-visible"},[k(I(vr),{width:"w-40",shadow:{offsetX:4,offsetY:4,intensity:.3}},{default:W(()=>[t("div",s0,[k(I(Qr),{onClick:x[0]||(x[0]=b=>c("download"))},{default:W(()=>[k(I(yn),{class:"w-4 h-4 text-neutral-500"}),x[2]||(x[2]=t("span",null,"Download",-1))]),_:1}),k(I(Qr),{onClick:x[1]||(x[1]=b=>c("publish"))},{default:W(()=>[k(l0,{class:"w-4 h-4 text-neutral-500"}),x[3]||(x[3]=t("span",null,"Publish",-1))]),_:1})])]),_:1})],512)],64))}}),u0={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function d0(e,n){return r(),o("svg",u0,[...n[0]||(n[0]=[t("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[t("path",{d:"M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73zm1 .27V12"}),t("path",{d:"M3.29 7L12 12l8.71-5M7.5 4.27l9 5.15"})],-1)])])}const na=je({name:"lucide-package",render:d0}),c0={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function p0(e,n){return r(),o("svg",c0,[...n[0]||(n[0]=[t("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[t("path",{d:"M12 22v-9m3.17-10.79a1.67 1.67 0 0 1 1.63 0L21 4.57a1.93 1.93 0 0 1 0 3.36L8.82 14.79a1.66 1.66 0 0 1-1.64 0L3 12.43a1.93 1.93 0 0 1 0-3.36z"}),t("path",{d:"M20 13v3.87a2.06 2.06 0 0 1-1.11 1.83l-6 3.08a1.93 1.93 0 0 1-1.78 0l-6-3.08A2.06 2.06 0 0 1 4 16.87V13"}),t("path",{d:"M21 12.43a1.93 1.93 0 0 0 0-3.36L8.83 2.2a1.64 1.64 0 0 0-1.63 0L3 4.57a1.93 1.93 0 0 0 0 3.36l12.18 6.86a1.64 1.64 0 0 0 1.63 0z"})],-1)])])}const m0=je({name:"lucide-package-open",render:p0}),v0={class:"flex items-center gap-2"},f0=Se({__name:"AgentsDataTable",props:{title:{},description:{},primaryAction:{},readonly:{type:Boolean,default:!1}},emits:["add","edit","delete","pack","unpack","publish"],setup(e,{expose:n,emit:a}){const s=e,l=a,u=p([]),i=p(!1),c=[{key:"title",label:"Title",width:"w-1/5",sortable:!0},{key:"type",label:"Type",width:"w-1/12",sortable:!0,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",sortable:!0,searchable:!1,formatter:d=>d?new Date(d*1e3).toLocaleDateString():"-"}],f=[{icon:na,label:"Pack",handler:d=>l("pack",d),visible:d=>!d.packed},{icon:m0,label:"Unpack",handler:d=>l("unpack",d),visible:d=>!!d.packed},{icon:"edit",label:"Edit",handler:d=>l("edit",d),visible:d=>!d.packed},{icon:"delete",label:"Delete",handler:async d=>{await b(d)},confirm:!0,confirmMessage:"Are you sure you want to delete this agent?",variant:"danger",visible:d=>!d.packed},{icon:"delete",label:"Delete Package",handler:async d=>{await y(d)},confirm:!0,confirmMessage:"Are you sure you want to delete this packed agent and all its contents?",variant:"danger",visible:d=>!!d.packed&&d.source==="local"}],h=F(()=>s.readonly?f.filter(d=>d.variant!=="danger"):f),x=async()=>{i.value=!0;try{const d=await fetch(ze("/api/agents"));if(d.ok){const w=await d.json();u.value=w.agents||[]}}catch(d){console.error("Error fetching agents:",d)}finally{i.value=!1}},b=async d=>{try{const w=await fetch(ze(`/api/agents/${encodeURIComponent(d.id)}`),{method:"DELETE"});if(w.ok)await x();else{const m=await w.json();alert(m.error||"Failed to delete agent")}}catch(w){console.error("Error deleting agent:",w),alert("Failed to delete agent")}},y=async d=>{if(d.packageId)try{const w=await fetch(ze(`/api/pack/${encodeURIComponent(d.packageId)}`),{method:"DELETE"});if(w.ok)await x();else{const m=await w.json();alert(m.error||"Failed to delete packed agent")}}catch(w){console.error("Error deleting packed agent:",w),alert("Failed to delete packed agent")}},$=d=>{d.packageId&&(window.location.href=ze(`/api/pack/${encodeURIComponent(d.packageId)}/download`))},g=d=>{l("publish",d)};return He(()=>{x()}),n({refresh:x}),(d,w)=>(r(),o("div",null,[k(It,{title:e.title,description:e.description,"primary-action":e.primaryAction,columns:c,data:u.value,actions:h.value,loading:i.value,sortable:"",searchable:"","search-placeholder":"Search agents...","empty-message":"No agents available. Create your first agent to get started.",onRowClick:w[0]||(w[0]=m=>{m.packed||l("edit",m)})},kn({"cell-title":W(({row:m})=>[t("div",v0,[m.packed?(r(),Y(I(na),{key:0,class:"w-4 h-4 text-blue-500 flex-shrink-0",title:`Packed agent from ${m.packageId}`},null,8,["title"])):S("",!0),t("span",null,C(m.title),1)])]),_:2},[e.readonly?void 0:{name:"extra-actions",fn:W(({row:m})=>[m.packed?(r(),Y(i0,{key:0,"package-id":m.packageId,onDownload:v=>$(m),onPublish:v=>g(m)},null,8,["package-id","onDownload","onPublish"])):S("",!0)]),key:"0"}]),1032,["title","description","primary-action","data","actions","loading"])]))}}),g0={class:"flex items-center justify-between p-4 border-b border-neutral-200 dark:border-neutral-700 flex-shrink-0"},h0={class:"text-xl font-bold"},b0={key:0,class:"p-6 border-t border-neutral-200 dark:border-neutral-700 flex-shrink-0"},dt=Se({__name:"Modal",props:{modelValue:{type:Boolean},title:{},width:{default:"max-w-lg"},minHeight:{default:"min-h-[24rem]"},hasChanges:{type:Boolean,default:void 0},contentPadding:{type:Boolean,default:!0}},emits:["update:modelValue","close"],setup(e,{emit:n}){const a=e,s=n,l=p(),u=p(!1),i=p(new Map),c=()=>l.value&&(l.value.querySelector("input")||l.value.querySelector("textarea")||l.value.querySelector("select")||l.value.querySelector("[contenteditable]")||l.value.querySelector(".monaco-editor")),f=()=>{if(!l.value)return;l.value.querySelectorAll(".monaco-editor-container").forEach(V=>{const E=V.__monacoEditor;if(E&&typeof E.getValue=="function"){const z=E.getValue();i.value.set(V,z)}})},h=()=>{if(!l.value)return!1;const P=l.value.querySelectorAll(".monaco-editor-container");for(const V of P){const E=V.__monacoEditor;if(E&&typeof E.getValue=="function"){const z=E.getValue(),A=i.value.get(V);if(A===void 0||(E.getRawOptions?.()||{}).readOnly===!0)continue;if(z!==A)return!0}}return!1},x=P=>{const V=P;return V.type==="checkbox"||V.type==="radio"?V.checked!==V.defaultChecked:(V.tagName==="SELECT",V.value!==V.defaultValue)},b=()=>{if(a.hasChanges!==void 0)return a.hasChanges;if(!l.value)return!1;if(h())return!0;const P=l.value.querySelectorAll("input, textarea, select");for(const V of P)if(x(V))return!0;return!1},y=()=>{c()&&b()?u.value=!0:$()},$=()=>{s("update:modelValue",!1),s("close")},g=()=>{u.value=!1,$()},d=()=>{u.value=!1},w=P=>{P.key==="Escape"&&a.modelValue&&(c()||$())};Ve(()=>a.modelValue,async P=>{P?(document.addEventListener("keydown",w),document.body.style.overflow="hidden",await Fe(),setTimeout(()=>{f()},100)):(document.removeEventListener("keydown",w),document.body.style.overflow="",i.value.clear())});const m=p(!1),v=P=>{m.value=P.target===P.currentTarget},_=P=>{P.target===P.currentTarget&&m.value&&(c()||$()),m.value=!1};return(P,V)=>(r(),Y(Yt,{to:"body"},[k(kt,{"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:W(()=>[e.modelValue?(r(),o("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:v,onClick:_},[k(kt,{"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:W(()=>[e.modelValue?(r(),o("div",{key:0,class:pe(["w-full",e.width,"max-h-[85vh] flex flex-col"])},[k(Zt,{"offset-x":8,"offset-y":8,intensity:.35},{default:W(()=>[t("div",{ref_key:"modalRef",ref:l,class:pe(["bg-white dark:bg-neutral-900 border border-neutral-300 dark:border-neutral-600 rounded-lg flex flex-col max-h-[85vh]",e.minHeight])},[t("div",g0,[t("h2",h0,C(e.title),1),k(I(Da),{icon:I(mr),label:"Close modal",variant:"ghost",onClick:y},null,8,["icon"])]),t("div",{class:pe(["flex-1 min-h-0",e.contentPadding?"overflow-y-auto p-6":"overflow-hidden flex flex-col"])},[Ye(P.$slots,"default")],2),P.$slots.footer?(r(),o("div",b0,[Ye(P.$slots,"footer")])):S("",!0)],2)]),_:3})],2)):S("",!0)]),_:3})],32)):S("",!0)]),_:3}),k(Or,{modelValue:u.value,"onUpdate:modelValue":V[0]||(V[0]=E=>u.value=E),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:g,onCancel:d},null,8,["modelValue"])]))}}),x0=["id"],y0={class:"px-5 py-3 border-b border-neutral-100 dark:border-neutral-800"},k0={class:"text-sm font-semibold text-neutral-900 dark:text-neutral-100 flex items-center gap-2"},w0={class:"p-5"},_0={key:0,class:"px-5 py-3 border-t border-neutral-100 dark:border-neutral-800 bg-neutral-50 dark:bg-neutral-800/50"},bt=Se({__name:"ModalCard",props:{id:{},title:{},icon:{}},setup(e){return(n,a)=>(r(),o("section",{id:e.id,class:"bg-white dark:bg-neutral-900 rounded-lg border border-neutral-200 dark:border-neutral-700 overflow-hidden"},[t("div",y0,[t("h3",k0,[e.icon?(r(),Y(rt(e.icon),{key:0,class:"w-4 h-4 text-neutral-500"})):S("",!0),ve(" "+C(e.title),1)])]),t("div",w0,[Ye(n.$slots,"default")]),n.$slots.footer?(r(),o("div",_0,[Ye(n.$slots,"footer")])):S("",!0)],8,x0))}}),$0={class:"flex flex-col gap-1 px-2"},C0=["onClick"],S0={class:"whitespace-nowrap overflow-hidden text-ellipsis"},Xa=Se({__name:"ModalTabs",props:{tabs:{},activeTab:{}},emits:["select"],setup(e,{emit:n}){const a=n;return(s,l)=>(r(),o("div",$0,[(r(!0),o($e,null,Le(e.tabs,u=>(r(),o("button",{key:u.id,type:"button",onClick:Xe(i=>a("select",u.id),["prevent"]),class:pe(["flex items-center gap-3 px-3 py-2.5 rounded text-sm font-medium transition-all w-full text-left",e.activeTab===u.id?"bg-black text-white dark:bg-white dark:text-black":"text-neutral-600 dark:text-neutral-400 hover:bg-black/5 dark:hover:bg-white/10"])},[(r(),Y(rt(u.icon),{class:"w-4 h-4 flex-shrink-0"})),t("span",S0,C(u.label),1)],10,C0))),128))]))}}),I0={class:"text-sm font-semibold text-neutral-900 dark:text-neutral-100 pl-3 border-l-2 border-neutral-300 dark:border-neutral-600"},Ht=Se({__name:"ModalSubHeader",props:{title:{}},setup(e){return(n,a)=>(r(),o("h4",I0,C(e.title),1))}});function Qa(e,n){const a=p(n[0]),s=()=>{const u=e.value;if(!u)return;const i=n.filter(b=>document.getElementById(`section-${b}`)!==null);if(i.length===0)return;if(u.scrollHeight-u.scrollTop-u.clientHeight<50){a.value=i[i.length-1];return}const f=u.getBoundingClientRect(),h=f.top+f.height*.3;let x=i[0];for(const b of i)document.getElementById(`section-${b}`).getBoundingClientRect().top<=h&&(x=b);a.value=x},l=u=>{const i=document.getElementById(`section-${u}`);if(i&&e.value){const c=e.value.getBoundingClientRect().top,f=i.getBoundingClientRect().top,h=e.value.scrollTop+(f-c);e.value.scrollTo({top:h,behavior:"smooth"})}};return Ve(e,(u,i)=>{i&&i.removeEventListener("scroll",s),u&&(u.addEventListener("scroll",s),s())}),$a(()=>{e.value?.removeEventListener("scroll",s)}),{activeTab:a,scrollToSection:l}}const T0={class:"space-y-3"},M0=["data-variable-property"],z0={class:"relative"},V0=["disabled","onClick"],E0=["disabled","onClick"],L0={key:1,class:"h-[34px] w-7 justify-self-center"},A0={class:"text-xs text-neutral-400 dark:text-neutral-500 px-1"},P0={key:0,class:"text-xs text-neutral-400 dark:text-neutral-500 px-1"},O0=["data-enabler-property"],R0={class:"text-[11px] text-neutral-500 dark:text-neutral-400"},j0={key:0,class:"text-[11px] text-neutral-500 dark:text-neutral-400"},D0={class:"space-y-2"},U0={class:"flex items-center justify-between"},B0={class:"text-xs text-neutral-500 dark:text-neutral-400"},N0=["disabled","onClick"],q0={class:"grid gap-2 items-start grid-cols-[minmax(180px,1fr)_minmax(220px,1fr)]"},F0={class:"text-xs text-neutral-400 dark:text-neutral-500 px-1"},H0=["disabled","onClick"],W0=["disabled","onClick"],K0=["disabled"],kr="grid-cols-[minmax(180px,1fr)_140px_minmax(220px,1fr)_44px_28px]",en=Se({__name:"VariableScanEditor",props:{modelValue:{},declarations:{default:()=>[]},scanned:{default:()=>[]},allowDeclarationEdit:{type:Boolean,default:!1},allowSecretValues:{type:Boolean,default:!0},allowSecretDeclarations:{type:Boolean,default:!0},requireRequiredValues:{type:Boolean,default:!1},showCustomRows:{type:Boolean,default:!0},disabled:{type:Boolean,default:!1}},emits:["update:modelValue","update:declarations"],setup(e,{emit:n}){const a=e,s=n,l=[{value:"text",label:"text",icon:"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' stroke='currentColor' viewBox='0 0 24 24'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M4 7h16M4 12h10M4 17h16'/%3E%3C/svg%3E"},{value:"secret",label:"secret",icon:"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' stroke='currentColor' viewBox='0 0 24 24'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M7 10V7a5 5 0 1110 0v3m-9 0h8a2 2 0 012 2v6a2 2 0 01-2 2H8a2 2 0 01-2-2v-6a2 2 0 012-2z'/%3E%3C/svg%3E"}],u=N=>N==="secret"&&a.allowSecretDeclarations?"secret":"text",i=N=>({name:N.name||"",type:u(N.type),required:!!N.required,description:N.description||""}),c=N=>N.filter(re=>re.name?.trim()).map(re=>({name:re.name.trim(),type:u(re.type),required:!!re.required,description:re.description||""})),f=N=>JSON.stringify(c(N)),h=N=>!!(a.scanned||[]).some(re=>re.property===N),x=p((a.declarations||[]).map(N=>i(N)).filter(N=>{const re=N.name.trim();return re&&h(re)})),b=p(!1);Ve(x,N=>{const re=c(N),_e=c((a.declarations||[]).map(De=>i(De))),ge=_e.filter(De=>{const lt=De.name.trim();return lt&&!h(lt)}),Me=[...re,...ge];if(b.value){if(b.value=!1,f(Me)===f(_e))return}else if(f(Me)===f(_e))return;s("update:declarations",Me)},{deep:!0,flush:"sync"}),Ve([()=>a.declarations,()=>a.scanned],([N])=>{const re=(N||[]).map(_e=>i(_e)).filter(_e=>{const ge=_e.name.trim();return ge&&h(ge)});f(re)!==f(x.value)&&(b.value=!0,x.value=re)},{deep:!0,immediate:!0});const y=F(()=>{const N=new Map;for(const re of a.scanned||[]){const _e=Array.isArray(re.optionalBranches)?re.optionalBranches.map(ge=>{const Me=typeof ge?.gate=="string"?ge.gate.trim():"",De=typeof ge?.tool=="string"?ge.tool.trim():"";return!Me||!De?null:{gate:Me,tool:De,immediate:!!ge.immediate,maxInstances:typeof ge.maxInstances=="number"&&ge.maxInstances>0?ge.maxInstances:void 0}}).filter(ge=>!!ge):[];N.set(re.property,{...re,type:re.type==="secret"?"secret":"text",required:!!re.required,description:re.description||"",optionalOnly:!!re.optionalOnly,optionalBranches:_e.length>0?_e:void 0})}return N}),$=F(()=>{const N=new Map;for(const re of x.value){const _e=re.name?.trim();_e&&N.set(_e,{...re,name:_e,type:u(re.type),required:!!re.required,description:re.description||""})}return N}),g=F(()=>{const N=new Map;for(const[re,_e]of y.value.entries())N.set(re,{..._e});for(const[re,_e]of $.value.entries()){if(!N.has(re)){N.set(re,{property:re,declared:[{type:"prompt",name:"local"}],defined:!1,type:_e.type,required:_e.required,description:_e.description,optionalOnly:!1});continue}const ge=N.get(re);ge.required=ge.required||_e.required,_e.type==="secret"&&(ge.type="secret"),!ge.description&&_e.description&&(ge.description=_e.description)}return Array.from(N.values())}),d=N=>{if(!N.optionalOnly)return null;const re=N.optionalBranches?.[0];return re?.gate?re.gate:null},w=F(()=>{const N=new Map;for(const re of g.value){const _e=d(re);_e&&(N.has(_e)||N.set(_e,[]),N.get(_e).push(re))}for(const re of N.values())re.sort((_e,ge)=>_e.property.localeCompare(ge.property));return N}),m=F(()=>g.value.filter(N=>!d(N))),v=N=>(w.value.get(N)||[]).map(re=>re.property),_=N=>{const re=w.value.get(N)||[],_e=[];for(const ge of re){const Me=ge.optionalBranches||[];for(const De of Me)De.gate===N&&typeof De.maxInstances=="number"&&De.maxInstances>0&&_e.push(De.maxInstances)}if(_e.length!==0)return Math.min(..._e)},P=N=>{for(const re of w.value.values())for(const _e of re){const ge=`${_e.property}__`;if(!N.startsWith(ge))continue;const Me=N.slice(ge.length);if(/^\d+$/.test(Me))return!0}return!1},V=(N,re)=>{for(const _e of v(N)){const ge=`${_e}__`;if(!re.startsWith(ge))continue;const Me=re.slice(ge.length);if(/^\d+$/.test(Me))return!0}return!1},E=N=>{const re={};for(const _e of v(N))re[_e]="";return re},z=(N,re,_e)=>{const ge=v(N),Me=_(N),De=[];if(Array.isArray(re))for(const vt of re){const wt=vt&&typeof vt=="object"?vt:{},ht=E(N);for(const Et of ge){const Ct=wt[Et];ht[Et]=Ct==null?"":String(Ct)}De.push(ht)}const lt=typeof Me=="number"&&Me>0?De.slice(0,Me):De;return lt.length===0&&ge.length>0&&lt.push(E(N)),lt},A=(N,re)=>{const _e=v(N);if(_e.length===0)return[];const ge=new Map;for(const De of _e){const lt=re[De];lt!=null&&lt!==""&&(ge.has(0)||ge.set(0,E(N)),ge.get(0)[De]=String(lt));const vt=`${De}__`;for(const[wt,ht]of Object.entries(re||{})){if(!wt.startsWith(vt))continue;const Et=wt.slice(vt.length);if(!/^\d+$/.test(Et))continue;const Ct=Number.parseInt(Et,10);if(!Number.isFinite(Ct)||Ct<2)continue;const Ot=Ct-1;ge.has(Ot)||ge.set(Ot,E(N)),ge.get(Ot)[De]=ht==null?"":String(ht)}}ge.size>0&&!ge.has(0)&&ge.set(0,E(N));const Me=Array.from(ge.entries()).sort((De,lt)=>De[0]-lt[0]).map(De=>De[1]);return z(N,Me)},oe=N=>J(N)?A(N,a.modelValue||{}):[],ne=(N,re)=>{const _e=v(N);if(_e.length===0)return!1;let ge=!1;for(const Me of Object.keys(re))(_e.includes(Me)||V(N,Me))&&(delete re[Me],ge=!0);return ge},fe=(N,re)=>{const _e=z(N,re),ge=v(N);if(ge.length===0)return;const Me={...a.modelValue};ne(N,Me);for(let De=0;De<_e.length;De++){const lt=_e[De]||{};for(const vt of ge){const wt=lt[vt],ht=De===0?vt:`${vt}__${De+1}`;if(De===0){wt&&(Me[ht]=wt);continue}Me[ht]=wt||""}}K(Me)!==K(a.modelValue||{})&&s("update:modelValue",Me)},ye=N=>{const re=oe(N),_e=_(N);typeof _e=="number"&&_e>0&&re.length>=_e||fe(N,[...re,E(N)])},te=(N,re)=>{const _e=[...oe(N)];if(_e.length<=1){fe(N,[E(N)]);return}re<0||re>=_e.length||(_e.splice(re,1),fe(N,_e))},q=N=>{if(N==null)return!1;const re=String(N).trim().toLowerCase();return re==="true"||re==="1"||re==="yes"},j=N=>{const re=a.modelValue[N];if(re!=null)return String(re);const _e=y.value.get(N);return _e?.value!==void 0&&_e.value!==null?String(_e.value):""},J=N=>q(j(N)),H=F(()=>new Set(g.value.map(N=>N.property))),ce=N=>({name:N.name||"",value:N.value===void 0||N.value===null?"":String(N.value),type:u(N.type),required:!!N.required}),Z=N=>N.map(re=>ce(re)),U=N=>JSON.stringify(Z(N).map(re=>({name:re.name,value:re.value,type:re.type,required:re.required}))),K=N=>JSON.stringify(Object.keys(N).sort((re,_e)=>re.localeCompare(_e)).map(re=>[re,N[re]===void 0||N[re]===null?"":String(N[re])])),me=p([]),ue=p(null),Q=p(!1),G=N=>{const re=Array.isArray(N)?N:[],_e=Z(re);U(_e)!==U(me.value)&&(me.value=_e)},ae=N=>{ue.value=N},ie=N=>{const re=Z(N);U(re)!==U(me.value)&&(me.value=re,ue.value&&ue.value.input(re))},xe=N=>Z(N).map(re=>{const _e=re.name.trim();return!_e||h(_e)?null:{name:_e,type:u(re.type),required:!!re.required,description:""}}).filter(re=>!!re);function X(){const N=new Map;for(const[ge,Me]of Object.entries(a.modelValue||{}))H.value.has(ge)||P(ge)||Me==null||Me===""||N.set(ge,String(Me));const re=new Map;for(const ge of c((a.declarations||[]).map(Me=>i(Me)))){const Me=ge.name.trim();!Me||h(Me)||re.set(Me,{type:u(ge.type),required:!!ge.required})}const _e=[];for(const ge of me.value.map(Me=>ce(Me))){const Me=ge.name.trim();if(!Me){_e.push(ge);continue}if(!H.value.has(Me)){if(re.has(Me)){const De=re.get(Me);ge.type=De.type,ge.required=De.required,re.delete(Me)}N.has(Me)&&(ge.value=N.get(Me)||"",N.delete(Me)),_e.push(ge)}}for(const[ge,Me]of re.entries()){const De=N.get(ge)||"";N.delete(ge),_e.push({name:ge,value:De,type:Me.type,required:Me.required})}for(const[ge,Me]of N.entries())_e.push({name:ge,value:Me,type:"text",required:!1});U(_e)!==U(me.value)&&(Q.value=!0,me.value=_e)}Ve(me,N=>{const re=Z(N);if(Q.value&&(Q.value=!1,U(re)===U(me.value)))return;if(U(re)!==U(me.value)){Q.value=!0,me.value=re;return}const _e={...a.modelValue};for(const ge of Object.keys(_e))!H.value.has(ge)&&!P(ge)&&delete _e[ge];for(const ge of re){const Me=ge.name.trim();!Me||H.value.has(Me)||!ge.value||(_e[Me]=ge.value)}if(K(_e)!==K(a.modelValue||{})&&s("update:modelValue",_e),a.allowDeclarationEdit){const ge=[...c(x.value),...xe(re)],Me=c((a.declarations||[]).map(De=>i(De)));f(ge)!==f(Me)&&s("update:declarations",ge)}},{deep:!0,flush:"sync"}),Ve([()=>a.modelValue,()=>a.declarations,()=>a.scanned,H],(N,re)=>{const[_e,ge,Me,De]=N,[lt,vt,wt,ht]=re||[],Et=ge!==vt||Me!==wt||De!==ht,Ct=(()=>{if(!lt||typeof lt!="object")return!0;const Ot=_e||{},Ur=lt,un=new Set([...Object.keys(Ot),...Object.keys(Ur)]);for(const Qt of un){const hr=Ot[Qt],br=Ur[Qt],dn=hr==null?"":String(hr),cn=br==null?"":String(br);if(dn!==cn&&!(H.value.has(Qt)||P(Qt)))return!0}return!1})();!Et&&!Ct||X()},{deep:!0,immediate:!0});const he=p(new Set),be=p(new Set),B=N=>{if(be.value.has(N))return;const re=new Set(be.value);re.add(N),be.value=re},D=N=>{if(!be.value.has(N))return!1;const re=new Set(be.value);return re.delete(N),be.value=re,!0},M=N=>({outer:"$remove:mb-4 group mb-0",wrapper:"$remove:flex-1 flex-1",inner:N?"!bg-zinc-100 dark:!bg-zinc-700/40 !cursor-not-allowed":""}),T=N=>({outer:"$remove:mb-4 group mb-0",wrapper:"$remove:flex-1 flex-1",inner:[N?.insetRight?"!pr-8":"",N?.requiredHighlight?"!border-amber-400 dark:!border-amber-500":"",N?.disabled?"!bg-zinc-100 dark:!bg-zinc-700/40 !cursor-not-allowed":""].filter(Boolean).join(" ")}),L=N=>a.modelValue[N]!==void 0&&a.modelValue[N]!==null,ee=N=>!!N.defined,le=N=>{const re=$.value.get(N.property);return re?u(re.type):N.type==="secret"?"secret":"text"},Ie=N=>{const re=$.value.get(N.property);return re?u(re.type):N.type==="secret"?"secret":"text"},Re=N=>a.requireRequiredValues&&N.required&&!N.defined&&!L(N.property),qe=N=>a.disabled||le(N)==="secret"&&!a.allowSecretValues?!1:!!(L(N.property)||!ee(N)||he.value.has(N.property)),We=N=>ee(N)&&(le(N)!=="secret"||a.allowSecretValues),R=N=>ee(N)&&(L(N.property)||he.value.has(N.property)),O=N=>a.allowDeclarationEdit&&$.value.has(N.property)&&!y.value.has(N.property)&&!a.disabled,ke=N=>O(N),de=N=>{const re=a.modelValue[N.property];return re!=null?String(re):ee(N)&&he.value.has(N.property)||le(N)==="secret"?"":N.value||""},Ue=(N,re)=>{if(!a.allowDeclarationEdit)return;const _e=N.trim();if(!_e)return;let ge=!1;x.value=x.value.map(Me=>Me.name.trim()!==_e?Me:(ge=!0,{...Me,name:_e,type:u(re.type??Me.type),required:re.required??!!Me.required,description:re.description??(Me.description||"")})),ge||(x.value=[...x.value,{name:_e,type:u(re.type??"text"),required:!!re.required,description:re.description||""}])},Ge=N=>{const re=N.trim();re&&(x.value=x.value.filter(_e=>_e.name.trim()!==re))},Ce=(N,re)=>{Ue(N,{type:u(re)})},we=(N,re)=>{Ue(N,{required:!!re})},Ae=(N,re)=>{if(D(N))return;const _e=g.value.find(Me=>Me.property===N);if(_e&&le(_e)==="secret"&&!a.allowSecretValues)return;const ge={...a.modelValue};re?ge[N]=re:delete ge[N],w.value.has(N)&&!q(re)&&ne(N,ge),K(ge)!==K(a.modelValue||{})&&s("update:modelValue",ge)},Te=N=>{if(he.value.has(N))return;const re=new Set(he.value);re.add(N),he.value=re},Ke=N=>{if(a.disabled||!We(N))return;if(R(N)){et(N.property);return}const re={...a.modelValue};delete re[N.property],s("update:modelValue",re),Te(N.property)},et=N=>{B(N);const re={...a.modelValue};if(delete re[N],s("update:modelValue",re),!he.value.has(N))return;const _e=new Set(he.value);_e.delete(N),he.value=_e},Ze=N=>{Ge(N),et(N)},st=N=>N.name==="local"?`this ${N.type}`:`the ${N.name} ${N.type}`,Pe=N=>N.length===0?"":N.length===1?N[0]:N.length===2?`${N[0]} and ${N[1]}`:`${N.slice(0,-1).join(", ")}, and ${N[N.length-1]}`,se=N=>(N.type==="agent"||N.type==="prompt")&&N.name?`the ${N.name} ${N.type}`:N.type==="thread"?"the thread":N.type==="account"?"the account":N.type==="instance"?"the instance":`the ${N.type}`,Ee=N=>{const re=N.required?"Required by":"Requested by",_e=N.declared.length?Pe(N.declared.map(st)):"this configuration";return N.defined?`${re} ${_e}, value provided by ${se(N.defined)}.`:`${re} ${_e}.`},Oe=()=>{ie([...me.value,{name:"",value:"",type:"text",required:!1}])},nt=N=>{if(N<0||N>=me.value.length)return;const re=[...me.value];re.splice(N,1),ie(re)};return(N,re)=>{const _e=at("FormKit");return r(),o("div",T0,[t("div",{class:pe(["grid gap-2 text-xs font-medium text-neutral-500 dark:text-neutral-400 px-1",kr])},[...re[2]||(re[2]=[t("span",null,"Name",-1),t("span",null,"Type",-1),t("span",null,"Value",-1),t("span",{class:"text-center text-[10px] leading-none tracking-tight self-center"},"Required",-1),t("span",null,null,-1)])]),(r(!0),o($e,null,Le(m.value,ge=>(r(),o("div",{key:ge.property,class:"space-y-1","data-variable-property":ge.property},[t("div",{class:pe(["grid gap-2 items-start",kr])},[k(_e,{type:"text",value:ge.property,disabled:!0,"outer-class":"$reset",classes:T({disabled:!0})},null,8,["value","classes"]),k(_e,{type:"selectSearch",value:Ie(ge),options:e.allowSecretDeclarations?l:l.filter(Me=>Me.value!=="secret"),disabled:!O(ge),"outer-class":"$reset",classes:M(!O(ge)),onInput:Me=>Ce(ge.property,Me||"text")},null,8,["value","options","disabled","classes","onInput"]),t("div",z0,[k(_e,{type:le(ge)==="secret"?"password":"text","model-value":de(ge),placeholder:ge.description||"Enter value...",disabled:!qe(ge),validation:e.requireRequiredValues&&ge.required&&!ge.defined?"required":"","validation-label":"Value","validation-visibility":"submit","outer-class":"$reset",classes:T({insetRight:We(ge),requiredHighlight:Re(ge),disabled:!qe(ge)}),onInput:Me=>Ae(ge.property,String(Me??""))},null,8,["type","model-value","placeholder","disabled","validation","classes","onInput"]),We(ge)?(r(),o("button",{key:0,type:"button",class:"absolute top-1/2 right-1 -translate-y-1/2 h-6 w-6 flex items-center justify-center rounded text-neutral-400 hover:text-neutral-700 dark:hover:text-neutral-200 hover:bg-neutral-100 dark:hover:bg-neutral-800 transition-colors disabled:opacity-50",disabled:e.disabled,title:"Override value",onMousedown:re[0]||(re[0]=Xe(()=>{},["prevent"])),onClick:Me=>Ke(ge)},[...re[3]||(re[3]=[t("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[t("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M6 18L18 6M6 6l12 12"})],-1)])],40,V0)):S("",!0)]),k(_e,{type:"checkbox",value:ge.required,disabled:!O(ge),classes:{outer:"$remove:mb-4 mb-0 pt-[8px] h-[34px] w-full flex items-center justify-center justify-self-center",wrapper:"$remove:items-center flex items-center justify-center",decorator:"$remove:mr-1.5 mr-0",label:"$remove:hidden",help:"$remove:hidden",messages:"$remove:formkit-messages hidden"},onInput:Me=>we(ge.property,!!Me)},null,8,["value","disabled","onInput"]),ke(ge)?(r(),o("button",{key:0,type:"button",class:"justify-self-center pt-[3px] h-[34px] w-7 flex items-center justify-center text-neutral-500 dark:text-white/70 hover:text-red-500 dark:hover:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/30 rounded transition-colors disabled:opacity-50",disabled:e.disabled,title:"Remove variable",onClick:Me=>Ze(ge.property)},[...re[4]||(re[4]=[t("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[t("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M6 18L18 6M6 6l12 12"})],-1)])],8,E0)):(r(),o("span",L0))]),t("p",A0,C(Ee(ge)),1),le(ge)==="secret"&&!e.allowSecretValues?(r(),o("p",P0," Secret values cannot be set here. ")):S("",!0),(w.value.get(ge.property)||[]).length>0?(r(),Y(_e,{key:1,type:"group",name:`optional-group-${ge.property}`,"outer-class":"$reset",classes:{outer:"$remove:mb-4 mb-0"}},{default:W(()=>[J(ge.property)?(r(),o("div",{key:0,class:"ml-5 space-y-2","data-enabler-property":ge.property},[t("p",R0,[re[5]||(re[5]=ve(" Optional branch enabled by ",-1)),t("code",null,C(ge.property),1)]),typeof _(ge.property)=="number"?(r(),o("p",j0," Max instances: "+C(_(ge.property)),1)):S("",!0),k(_e,{type:"repeater",name:`optional-repeater-${ge.property}`,"model-value":oe(ge.property),min:1,max:_(ge.property),"add-button":!1,"insert-control":!1,"up-control":!1,"down-control":!1,"remove-control":!1,"outer-class":"$reset",classes:{outer:"$remove:mb-4 mb-0",wrapper:"$remove",fieldset:"$remove:border-0 p-0 m-0 min-w-0",legend:"$remove:hidden",content:"$remove:p-5 $remove:space-y-2 p-0 space-y-2",item:"$remove:bg-white $remove:border $remove:border-zinc-200 $remove:rounded-sm $remove:dark:border-zinc-700 $remove:dark:bg-transparent $remove:mb-2 mb-0 border border-neutral-200 dark:border-neutral-700 bg-transparent rounded-sm p-2",help:"$remove:hidden",messages:"$remove:formkit-messages hidden"},onInput:Me=>fe(ge.property,Me)},{default:W(({index:Me})=>[t("div",D0,[t("div",U0,[t("p",B0," Instance "+C(Number(Me)+1),1),t("button",{type:"button",class:"h-5 px-1.5 text-[10px] rounded-sm border border-neutral-500/40 dark:border-neutral-600 text-neutral-500 dark:text-neutral-400 hover:text-neutral-200 hover:border-neutral-400 disabled:opacity-50",disabled:e.disabled||oe(ge.property).length<=1,onClick:De=>te(ge.property,Number(Me))}," Remove ",8,N0)]),(r(!0),o($e,null,Le(w.value.get(ge.property)||[],De=>(r(),o("div",{key:`${ge.property}-${De.property}-${Me}`,class:"space-y-1"},[t("div",q0,[k(_e,{type:"text",value:De.property,disabled:!0,"outer-class":"$reset",classes:T({disabled:!0})},null,8,["value","classes"]),k(_e,{name:De.property,type:le(De)==="secret"?"password":"text",placeholder:De.description||"Enter value...",disabled:e.disabled||le(De)==="secret"&&!e.allowSecretValues,validation:e.requireRequiredValues&&De.required?"required":"","validation-label":"Value","validation-visibility":"submit","outer-class":"$reset",classes:T({disabled:e.disabled||le(De)==="secret"&&!e.allowSecretValues})},null,8,["name","type","placeholder","disabled","validation","classes"])]),t("p",F0,C(Ee(De)),1)]))),128))])]),_:2},1032,["name","model-value","max","onInput"]),_(ge.property)!==1&&(_(ge.property)===void 0||oe(ge.property).length<(_(ge.property)||0))?(r(),o("button",{key:1,type:"button",class:"inline-flex h-5 px-2 text-[10px] rounded-sm border border-neutral-500/40 dark:border-neutral-600 text-neutral-500 dark:text-neutral-400 hover:text-neutral-200 hover:border-neutral-400 disabled:opacity-50",disabled:e.disabled,onClick:Me=>ye(ge.property)}," Add instance ",8,H0)):S("",!0)],8,O0)):S("",!0)]),_:2},1032,["name"])):S("",!0)],8,M0))),128)),e.showCustomRows?(r(),Y(_e,{key:0,type:"repeater","model-value":me.value,min:0,"add-button":!1,"insert-control":!1,"up-control":!1,"down-control":!1,"remove-control":!1,"outer-class":"$reset",classes:{outer:"$remove:mb-4 mb-0",wrapper:"$remove",fieldset:"$remove:border-0 p-0 m-0 min-w-0",legend:"$remove:hidden",content:"$remove:p-5 $remove:space-y-2 p-0 space-y-2",item:"$remove:bg-white $remove:border $remove:border-zinc-200 $remove:rounded-sm $remove:dark:border-zinc-700 $remove:dark:bg-transparent $remove:mb-2 mb-0 border-0 bg-transparent rounded-none",controls:"$remove:hidden",help:"$remove:hidden",messages:"$remove:formkit-messages hidden"},onNode:ae,onInput:re[1]||(re[1]=ge=>G(ge))},{default:W(({index:ge})=>[t("div",{class:pe(["grid gap-2 items-start pb-1",kr])},[k(_e,{type:"text",name:"name",placeholder:"VARIABLE_NAME",disabled:e.disabled,"outer-class":"$reset",classes:T({disabled:e.disabled})},null,8,["disabled","classes"]),k(_e,{type:"selectSearch",name:"type",options:e.allowSecretDeclarations?l:l.filter(Me=>Me.value!=="secret"),disabled:e.disabled||!e.allowDeclarationEdit||!me.value[ge]?.name?.trim(),"outer-class":"$reset",classes:M(e.disabled||!e.allowDeclarationEdit||!me.value[ge]?.name?.trim())},null,8,["options","disabled","classes"]),k(_e,{type:me.value[ge]?.type==="secret"?"password":"text",name:"value",placeholder:"Enter value...",disabled:e.disabled||me.value[ge]?.type==="secret"&&!e.allowSecretValues,"outer-class":"$reset",classes:T({disabled:e.disabled||me.value[ge]?.type==="secret"&&!e.allowSecretValues})},null,8,["type","disabled","classes"]),k(_e,{type:"checkbox",name:"required",disabled:e.disabled||!e.allowDeclarationEdit||!me.value[ge]?.name?.trim(),classes:{outer:"$remove:mb-4 mb-0 pt-[8px] h-[34px] w-full flex items-center justify-center justify-self-center",wrapper:"$remove:items-center flex items-center justify-center",decorator:"$remove:mr-1.5 mr-0",label:"$remove:hidden",help:"$remove:hidden",messages:"$remove:formkit-messages hidden"}},null,8,["disabled"]),t("button",{type:"button",class:"justify-self-center pt-[3px] h-[34px] w-7 flex items-center justify-center text-neutral-500 dark:text-white/70 hover:text-red-500 dark:hover:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/30 rounded transition-colors disabled:opacity-50",disabled:e.disabled,title:"Remove variable",onClick:Me=>nt(ge)},[...re[6]||(re[6]=[t("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[t("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M6 18L18 6M6 6l12 12"})],-1)])],8,W0)])]),_:1},8,["model-value"])):S("",!0),e.showCustomRows?(r(),o("button",{key:1,type:"button",class:"w-full rounded-sm border border-dashed border-neutral-300 dark:border-neutral-700 px-3 py-2 text-sm text-neutral-600 dark:text-neutral-300 hover:bg-neutral-50 dark:hover:bg-neutral-900",disabled:e.disabled,onClick:Oe}," + Add custom variable ",8,K0)):S("",!0)])}}}),J0={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function G0(e,n){return r(),o("svg",J0,[...n[0]||(n[0]=[t("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[t("path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z"}),t("path",{d:"M14 2v4a2 2 0 0 0 2 2h4M10 9H8m8 4H8m8 4H8"})],-1)])])}const cr=je({name:"lucide-file-text",render:G0}),Y0={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Z0(e,n){return r(),o("svg",Y0,[...n[0]||(n[0]=[t("g",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2"},[t("path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2"}),t("circle",{cx:"12",cy:"7",r:"4"})],-1)])])}const oa=je({name:"lucide-user",render:Z0}),X0={key:0,class:"min-h-[500px] flex items-center justify-center"},Q0={class:"flex flex-1 min-h-0"},em={class:"w-44 flex-shrink-0 border-r border-neutral-200 dark:border-neutral-700 py-4"},tm={class:"space-y-4"},rm={class:"space-y-5"},am={class:"grid grid-cols-2 gap-4"},nm={key:0},om={key:1},lm={key:2},sm={class:"space-y-5"},im={class:"grid grid-cols-2 gap-4"},um={class:"space-y-4 pt-4 border-t border-neutral-100 dark:border-neutral-800"},dm={key:0,class:"ml-6 mt-3 space-y-3"},cm={key:2},pm={class:"grid grid-cols-2 gap-4 pt-4 border-t border-neutral-100 dark:border-neutral-800"},mm={class:"space-y-5"},vm={class:"grid grid-cols-2 gap-4"},fm={class:"space-y-4 pt-4 border-t border-neutral-100 dark:border-neutral-800"},gm={key:0,class:"ml-6 mt-3 space-y-3"},hm={key:2},bm={class:"grid grid-cols-2 gap-4 pt-4 border-t border-neutral-100 dark:border-neutral-800"},xm={class:"space-y-3"},ym={key:0,class:"text-xs text-neutral-500"},km={class:"p-6 border-t border-neutral-200 dark:border-neutral-700 flex-shrink-0"},wm={class:"flex justify-between items-center"},_m={key:0,class:"flex items-center gap-3"},$m=Se({__name:"AgentModal",props:{modelValue:{type:Boolean},editAgent:{},mode:{},apiError:{},readonly:{type:Boolean,default:!1},saving:{type:Boolean,default:!1}},emits:["update:modelValue","save"],setup(e,{expose:n,emit:a}){const s=e,l=a,u=F(()=>s.mode==="edit"),i=p(!1),c=p(null),f=["basics","side-a","side-b","variables"],{activeTab:h,scrollToSection:x}=Qa(c,f),b=F(()=>[{id:"basics",label:"Basics",icon:cr},{id:"side-a",label:"Side A",icon:Dt},{id:"side-b",label:"Side B",icon:d.value==="ai_human"?oa:Dt},{id:"variables",label:"Variables",icon:Jt}]),y=p(""),$=p(""),g=p(""),d=p("dual_ai"),w=p(!1),m=p(""),v=p(null),_=p(""),P=p(""),V=p(""),E=p(!0),z=p(!1),A=p(""),oe=p(""),ne=p(""),fe=p(""),ye=p(!1),te=p(null),q=p(""),j=p(""),J=p(""),H=p(""),ce=p(""),Z=p(""),U=p(!0),K=p(!1),me=p(""),ue=p(""),Q=p(""),G=p(""),ae=p(null),ie=p(""),xe=p(""),X=p(""),he=p([]),be=p({}),B=p(!1),{data:D,execute:M}=it(ze("/api/prompts"),{immediate:!1}).json(),{data:T,execute:L}=it(ze("/api/tools?schema=true"),{immediate:!1}).json(),ee=p(null),le=p(!1),Ie=p(null),Re=p(!1),qe=p(!1),We=F(()=>{if(!D.value)return[{value:"",label:"Select a prompt..."}];const Pe=D.value?.prompts||[];return[{value:"",label:"None"},...Pe.map(se=>({value:se.id,label:se.name}))]}),R=Pe=>T.value?T.value[Pe]:null,O=F(()=>!ee.value||!ee.value.tools?[{value:"",label:"None"}]:[{value:"",label:"None"},...ee.value.tools.map(Pe=>{const se=typeof Pe=="string"?Pe:Pe.name;return{value:se,label:se}})]),ke=F(()=>!Ie.value||!Ie.value.tools?[{value:"",label:"None"}]:[{value:"",label:"None"},...Ie.value.tools.map(Pe=>{const se=typeof Pe=="string"?Pe:Pe.name;return{value:se,label:se}})]),de=F(()=>{if(!A.value)return[];const Pe=R(A.value);return!Pe||!Pe.schema||!Pe.schema.properties?[]:Object.keys(Pe.schema.properties).map(se=>({value:se,label:se}))}),Ue=F(()=>{if(!me.value)return[];const Pe=R(me.value);return!Pe||!Pe.schema||!Pe.schema.properties?[]:Object.keys(Pe.schema.properties).map(se=>({value:se,label:se}))}),Ge=async()=>{const Pe=[P.value,d.value==="dual_ai"?ce.value:""].filter(Boolean);if(Pe.length===0){he.value=[];return}B.value=!0;try{const se=Pe.slice(1).map(N=>({type:"prompt",name:N})),Ee=se.length>0?`?include=${encodeURIComponent(JSON.stringify(se))}`:"",Oe=await ut(`/variables/prompts/${encodeURIComponent(Pe[0])}${Ee}`);if(!Oe.ok){he.value=[];return}const nt=await Oe.json();he.value=nt.variables||[]}catch(se){console.error("Error scanning variables from prompts:",se),he.value=[]}finally{B.value=!1}},Ce=p(null),we=Pe=>{Ce.value=Pe};n({formNode:Ce});const Ae=[{value:"dual_ai",label:"AI + AI (Subagent)"},{value:"ai_human",label:"AI + Human"}],Te=Pe=>{let se=Pe.toLowerCase().replace(/\s+/g,"_").replace(/[^a-z0-9_]/g,"");return!se.endsWith("_agent")&&se.length>0&&(se=se+"_agent"),se},Ke=()=>{$.value="",y.value="",g.value="",d.value="dual_ai",w.value=!1,m.value="",v.value=null,_.value="",P.value="",V.value="",E.value=!0,z.value=!1,A.value="",oe.value="",ne.value="",fe.value="",ye.value=!1,te.value=null,q.value="",j.value="",J.value="",ee.value=null,H.value="",ce.value="",Z.value="",U.value=!0,K.value=!1,me.value="",ue.value="",Q.value="",G.value="",ae.value=null,ie.value="",xe.value="",X.value="",Ie.value=null,he.value=[],be.value={}},et=async()=>{if(s.editAgent?.id){i.value=!0,qe.value=!0;try{const Pe=await fetch(ze(`/api/agents/${encodeURIComponent(s.editAgent.id)}`));if(Pe.ok){const se=await Pe.json(),Ee=se.agent||se;$.value=Ee.name||"",y.value=Ee.name||"",g.value=Ee.title||"",d.value=Ee.type||"dual_ai",w.value=Ee.expose_as_tool||!1,m.value=Ee.tool_description||"",v.value=Ee.max_session_turns;const Oe=Ee.side_a_stop_tool||"",nt=Ee.side_a_stop_tool_response_property||"",N=Ee.side_b_stop_tool||"",re=Ee.side_b_stop_tool_response_property||"",_e=Ee.side_a_end_conversation_tool||"",ge=Ee.side_b_end_conversation_tool||"";_.value=Ee.side_a_label||"",H.value=Ee.side_b_label||"",P.value=Ee.side_a_agent_prompt||"",ce.value=Ee.side_b_agent_prompt||"",E.value=!!Ee.side_a_stop_on_response,z.value=!!Ee.side_a_stop_tool,ye.value=!!Ee.side_a_manual_stop_condition,te.value=Ee.side_a_max_steps,U.value=!!Ee.side_b_stop_on_response,K.value=!!Ee.side_b_stop_tool,ae.value=Ee.side_b_max_steps,await Fe(),A.value=Oe,ne.value=nt,me.value=N,Q.value=re,j.value=_e,xe.value=ge;const Me=(Ee.env&&typeof Ee.env=="object"?Ee.env:null)||(Ee.tenvs&&typeof Ee.tenvs=="object"?Ee.tenvs:null);be.value=Me||{},await Ge()}}catch(Pe){console.error("Error loading agent data:",Pe)}finally{i.value=!1,qe.value=!1}}},Ze=async()=>{V.value="",oe.value="",fe.value="",q.value="",J.value="",Z.value="",ue.value="",G.value="",ie.value="",X.value="";let Pe=!1;const se=$.value,Ee=E.value||A.value,Oe=d.value==="ai_human"&&ye.value;if(!Ee&&!Oe&&(V.value="At least one stop condition is required (or check manual stop condition for ai_human agents)",Pe=!0),A.value&&!ne.value&&(fe.value="Response property required when using stop tool",Pe=!0),te.value!==null&&te.value<=0&&(q.value="Max steps must be a positive number",Pe=!0),d.value==="dual_ai"&&!j.value&&!xe.value&&(J.value="At least one side must have an end conversation tool",X.value="At least one side must have an end conversation tool",Pe=!0),d.value==="dual_ai"&&(me.value&&!Q.value&&(G.value="Response property required when using stop tool",Pe=!0),ae.value!==null&&ae.value<=0&&(ie.value="Max steps must be a positive number",Pe=!0)),Pe)return;const nt={name:se,title:g.value||null,type:d.value,expose_as_tool:w.value,tool_description:w.value?m.value:null,max_session_turns:d.value==="dual_ai"?v.value:null,side_a_label:_.value||null,side_a_agent_prompt:P.value,side_a_stop_on_response:E.value,side_a_stop_tool:A.value||null,side_a_stop_tool_response_property:ne.value||null,side_a_manual_stop_condition:ye.value,side_a_max_steps:te.value,side_a_end_conversation_tool:j.value||null};d.value==="dual_ai"&&(nt.side_b_label=H.value||null,nt.side_b_agent_prompt=ce.value,nt.side_b_stop_on_response=U.value,nt.side_b_stop_tool=me.value||null,nt.side_b_stop_tool_response_property=Q.value||null,nt.side_b_max_steps=ae.value,nt.side_b_end_conversation_tool=xe.value||null),nt.env=be.value,u.value&&s.editAgent?.id&&(nt.id=s.editAgent.id),l("save",nt)},st=()=>{Ke(),l("update:modelValue",!1)};return Ve(P,async Pe=>{if(qe.value||(A.value="",ne.value=""),!Pe){ee.value=null;return}le.value=!0;try{const se=await fetch(ze(`/api/prompts/${encodeURIComponent(Pe)}`));if(se.ok){const Ee=await se.json();ee.value=Ee.prompt||Ee}}catch(se){console.error("Error fetching Side A prompt:",se)}finally{le.value=!1}qe.value||await Ge()}),Ve(ce,async Pe=>{if(qe.value||(me.value="",Q.value=""),!Pe){Ie.value=null;return}Re.value=!0;try{const se=await fetch(ze(`/api/prompts/${encodeURIComponent(Pe)}`));if(se.ok){const Ee=await se.json();Ie.value=Ee.prompt||Ee}}catch(se){console.error("Error fetching Side B prompt:",se)}finally{Re.value=!1}qe.value||await Ge()}),Ve(z,Pe=>{Pe||(A.value="",ne.value="")}),Ve(K,Pe=>{Pe||(me.value="",Q.value="")}),Ve(d,async()=>{!s.modelValue||qe.value||await Ge()}),Ve(()=>s.modelValue,async Pe=>{Pe?(await Promise.all([M(),L()]),u.value?(Ke(),await et()):Ke()):Ke()}),(Pe,se)=>{const Ee=at("FormKit");return r(),Y(dt,{"model-value":e.modelValue,"onUpdate:modelValue":se[26]||(se[26]=Oe=>Pe.$emit("update:modelValue",Oe)),title:u.value?"Edit Agent":"Create Agent",width:"max-w-5xl","content-padding":!1},{default:W(()=>[i.value?(r(),o("div",X0,[...se[27]||(se[27]=[t("span",{class:"text-neutral-500"},"Loading agent data...",-1)])])):(r(),Y(Ee,{key:1,type:"form",id:"agent-form",actions:!1,disabled:e.readonly||e.saving,onSubmit:Ze,onNode:we,"form-class":"$reset flex-1 min-h-0 flex flex-col"},{default:W(()=>[t("div",Q0,[t("nav",em,[k(I(Xa),{tabs:b.value,"active-tab":I(h),onSelect:I(x)},null,8,["tabs","active-tab","onSelect"])]),t("div",{ref_key:"contentRef",ref:c,class:"flex-1 overflow-y-auto p-5 bg-neutral-100 dark:bg-neutral-950"},[t("div",tm,[e.apiError?(r(),Y(I(ot),{key:0,variant:"error"},{default:W(()=>[ve(C(e.apiError),1)]),_:1})):S("",!0),k(I(bt),{id:"section-basics",title:"Basics",icon:I(cr)},{default:W(()=>[t("div",rm,[t("div",null,[k(Ee,{type:"text",name:"name",modelValue:$.value,"onUpdate:modelValue":se[0]||(se[0]=Oe=>$.value=Oe),label:"Agent Name",disabled:u.value,validation:"required|matches:/^[a-z][a-z0-9_]*_agent$/","validation-visibility":"submit","validation-messages":{required:"Name is required",matches:"Must start with a letter and end with _agent (e.g., research_agent)"},"outer-class":"$reset",onBlur:se[1]||(se[1]=Oe=>$.value=Te($.value))},null,8,["modelValue","disabled"]),u.value?(r(),Y(I(Ne),{key:1,class:"mt-1"},{default:W(()=>[...se[29]||(se[29]=[ve(" Agent names cannot be changed after creation (used as foreign key for threads) ",-1)])]),_:1})):(r(),Y(I(Ne),{key:0,class:"mt-1"},{default:W(()=>[...se[28]||(se[28]=[ve(" Automatically formatted to snake_case with _agent suffix (e.g., research_agent) ",-1)])]),_:1}))]),t("div",am,[t("div",null,[k(Ee,{type:"text",name:"title",modelValue:g.value,"onUpdate:modelValue":se[2]||(se[2]=Oe=>g.value=Oe),label:"Display Title (Optional)","outer-class":"$reset"},null,8,["modelValue"]),k(I(Ne),{class:"mt-1"},{default:W(()=>[...se[30]||(se[30]=[ve(" Human-readable title shown in the UI ",-1)])]),_:1})]),t("div",null,[k(Ee,{type:"selectSearch",name:"type",modelValue:d.value,"onUpdate:modelValue":se[3]||(se[3]=Oe=>d.value=Oe),label:"Agent Type",options:Ae,"outer-class":"$reset"},null,8,["modelValue"]),k(I(Ne),{class:"mt-1"},{default:W(()=>[...se[31]||(se[31]=[ve(" AI + AI or AI + Human conversation ",-1)])]),_:1})])]),d.value==="dual_ai"?(r(),o("div",nm,[k(Ee,{type:"checkbox",modelValue:w.value,"onUpdate:modelValue":se[4]||(se[4]=Oe=>w.value=Oe),label:"Expose as Tool","outer-class":"$reset"},null,8,["modelValue"]),k(I(Ne),{class:"mt-1"},{default:W(()=>[...se[32]||(se[32]=[ve(" Make this subagent available as a tool that can be called by other prompts or agents ",-1)])]),_:1})])):S("",!0),w.value&&d.value==="dual_ai"?(r(),o("div",om,[k(Ee,{type:"textarea",name:"tool_description",modelValue:m.value,"onUpdate:modelValue":se[5]||(se[5]=Oe=>m.value=Oe),label:"Tool Description",placeholder:"Describe what this agent does when called as a tool",rows:3,"outer-class":"$reset"},null,8,["modelValue"]),k(I(Ne),{class:"mt-1"},{default:W(()=>[...se[33]||(se[33]=[ve(" This description helps other agents understand when to use this agent ",-1)])]),_:1})])):S("",!0),d.value==="dual_ai"?(r(),o("div",lm,[k(Ee,{type:"number",name:"max_session_turns",modelValue:v.value,"onUpdate:modelValue":se[6]||(se[6]=Oe=>v.value=Oe),label:"Max Session Turns",placeholder:"Unlimited","outer-class":"$reset"},null,8,["modelValue"]),k(I(Ne),{class:"mt-1"},{default:W(()=>[...se[34]||(se[34]=[ve(" Maximum number of back-and-forth exchanges between the two agents before the conversation ends ",-1)])]),_:1})])):S("",!0)])]),_:1},8,["icon"]),k(I(bt),{id:"section-side-a",title:"Side A (AI)",icon:I(Dt)},{default:W(()=>[t("div",sm,[t("div",im,[t("div",null,[k(Ee,{type:"text",modelValue:_.value,"onUpdate:modelValue":se[7]||(se[7]=Oe=>_.value=Oe),label:"Side Label (Optional)",placeholder:"e.g., ATC, Pilot, Customer","outer-class":"$reset"},null,8,["modelValue"]),k(I(Ne),{class:"mt-1"},{default:W(()=>[...se[35]||(se[35]=[ve(" Custom label for this side ",-1)])]),_:1})]),t("div",null,[k(Ee,{type:"selectSearch",name:"side_a_agent_prompt",modelValue:P.value,"onUpdate:modelValue":se[8]||(se[8]=Oe=>P.value=Oe),label:"Agent Prompt",options:We.value,validation:"required","validation-visibility":"submit","validation-messages":{required:"Please select an agent prompt"},"outer-class":"$reset"},null,8,["modelValue","options"]),V.value?(r(),Y(I(Ne),{key:0,class:"mt-1 text-red-600 dark:text-red-400"},{default:W(()=>[ve(C(V.value),1)]),_:1})):(r(),Y(I(Ne),{key:1,class:"mt-1"},{default:W(()=>[...se[36]||(se[36]=[ve(" Defines this agent's behavior ",-1)])]),_:1}))])]),t("div",um,[k(I(Ht),{title:"Stop Conditions"}),k(I(Ne),null,{default:W(()=>[...se[37]||(se[37]=[ve(" Optional. If no stop conditions are set, the agent will continue until programmatically stopped or end conversation tool is called. ",-1)])]),_:1}),t("div",null,[k(Ee,{type:"checkbox",modelValue:E.value,"onUpdate:modelValue":se[9]||(se[9]=Oe=>E.value=Oe),label:"Stop when agent returns content","outer-class":"$reset"},null,8,["modelValue"]),k(I(Ne),{class:"ml-6"},{default:W(()=>[...se[38]||(se[38]=[ve(" Agent stops when it returns a response without calling tools ",-1)])]),_:1})]),t("div",null,[k(Ee,{type:"checkbox",modelValue:z.value,"onUpdate:modelValue":se[10]||(se[10]=Oe=>z.value=Oe),label:"Stop on specific tool call","outer-class":"$reset"},null,8,["modelValue"]),z.value?(r(),o("div",dm,[k(Ee,{type:"selectSearch",modelValue:A.value,"onUpdate:modelValue":se[11]||(se[11]=Oe=>A.value=Oe),label:"Stop Tool",options:O.value,placeholder:"Select a tool...",disabled:le.value||!P.value,"outer-class":"$reset"},null,8,["modelValue","options","disabled"]),oe.value?(r(),Y(I(Ne),{key:0,class:"text-red-600 dark:text-red-400"},{default:W(()=>[ve(C(oe.value),1)]),_:1})):(r(),Y(I(Ne),{key:1},{default:W(()=>[...se[39]||(se[39]=[ve(" Agent stops when this tool is called ",-1)])]),_:1})),A.value?(r(),o("div",cm,[k(Ee,{type:"selectSearch",modelValue:ne.value,"onUpdate:modelValue":se[12]||(se[12]=Oe=>ne.value=Oe),label:"Response Property",options:de.value,placeholder:"Select property...","outer-class":"$reset"},null,8,["modelValue","options"]),fe.value?(r(),Y(I(Ne),{key:0,class:"mt-1 text-red-600 dark:text-red-400"},{default:W(()=>[ve(C(fe.value),1)]),_:1})):(r(),Y(I(Ne),{key:1,class:"mt-1"},{default:W(()=>[...se[40]||(se[40]=[ve(" Property from tool arguments to return as final response ",-1)])]),_:1}))])):S("",!0)])):S("",!0)]),d.value==="ai_human"&&!E.value&&!z.value?(r(),Y(I(ot),{key:0,variant:"warning",class:"mt-3"},{default:W(()=>[k(Ee,{type:"checkbox",modelValue:ye.value,"onUpdate:modelValue":se[13]||(se[13]=Oe=>ye.value=Oe),label:"I have manually implemented a stop condition","outer-class":"$reset"},null,8,["modelValue"]),se[41]||(se[41]=t("p",{class:"mt-2 text-xs"}," 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))]),_:1})):S("",!0)]),t("div",pm,[t("div",null,[k(Ee,{type:"number",name:"side_a_max_steps",modelValue:te.value,"onUpdate:modelValue":se[14]||(se[14]=Oe=>te.value=Oe),label:"Max Steps",placeholder:"Unlimited","outer-class":"$reset"},null,8,["modelValue"]),q.value?(r(),Y(I(Ne),{key:0,class:"mt-1 text-red-600 dark:text-red-400"},{default:W(()=>[ve(C(q.value),1)]),_:1})):(r(),Y(I(Ne),{key:1,class:"mt-1"},{default:W(()=>[...se[42]||(se[42]=[ve(" Safety limit before yielding ",-1)])]),_:1}))]),t("div",null,[k(Ee,{type:"selectSearch",modelValue:j.value,"onUpdate:modelValue":se[15]||(se[15]=Oe=>j.value=Oe),label:"End Conversation Tool",options:O.value,placeholder:"Select a tool...",disabled:le.value||!P.value,"outer-class":"$reset"},null,8,["modelValue","options","disabled"]),J.value?(r(),Y(I(Ne),{key:0,class:"mt-1 text-red-600 dark:text-red-400"},{default:W(()=>[ve(C(J.value),1)]),_:1})):(r(),Y(I(Ne),{key:1,class:"mt-1"},{default:W(()=>[...se[43]||(se[43]=[ve(" Ends entire conversation when called ",-1)])]),_:1}))])])])]),_:1},8,["icon"]),k(I(bt),{id:"section-side-b",title:d.value==="ai_human"?"Side B (Human)":"Side B (AI)",icon:d.value==="ai_human"?I(oa):I(Dt)},{default:W(()=>[t("div",mm,[d.value==="ai_human"?(r(),o($e,{key:0},[t("div",null,[k(Ee,{type:"text",modelValue:H.value,"onUpdate:modelValue":se[16]||(se[16]=Oe=>H.value=Oe),label:"Side Label (Optional)",placeholder:"e.g., Customer, User","outer-class":"$reset"},null,8,["modelValue"]),k(I(Ne),{class:"mt-1"},{default:W(()=>[...se[44]||(se[44]=[ve(" Custom label for this side ",-1)])]),_:1})]),se[45]||(se[45]=t("div",{class:"flex flex-col items-center justify-center py-8 bg-neutral-50 dark:bg-neutral-800/50 rounded-lg"},[t("svg",{class:"w-16 h-16 mb-4 text-neutral-400",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[t("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"1.5",d:"M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z"})]),t("h5",{class:"font-medium text-lg mb-2 text-neutral-700 dark:text-neutral-300"},"Human User"),t("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))],64)):(r(),o($e,{key:1},[t("div",vm,[t("div",null,[k(Ee,{type:"text",modelValue:H.value,"onUpdate:modelValue":se[17]||(se[17]=Oe=>H.value=Oe),label:"Side Label (Optional)",placeholder:"e.g., ATC, Pilot, Customer","outer-class":"$reset"},null,8,["modelValue"]),k(I(Ne),{class:"mt-1"},{default:W(()=>[...se[46]||(se[46]=[ve(" Custom label for this side ",-1)])]),_:1})]),t("div",null,[k(Ee,{type:"selectSearch",name:"side_b_agent_prompt",modelValue:ce.value,"onUpdate:modelValue":se[18]||(se[18]=Oe=>ce.value=Oe),label:"Agent Prompt",options:We.value,validation:"required","validation-visibility":"submit","validation-messages":{required:"Please select an agent prompt"},"outer-class":"$reset"},null,8,["modelValue","options"]),Z.value?(r(),Y(I(Ne),{key:0,class:"mt-1 text-red-600 dark:text-red-400"},{default:W(()=>[ve(C(Z.value),1)]),_:1})):(r(),Y(I(Ne),{key:1,class:"mt-1"},{default:W(()=>[...se[47]||(se[47]=[ve(" Defines this agent's behavior ",-1)])]),_:1}))])]),t("div",fm,[k(I(Ht),{title:"Stop Conditions"}),k(I(Ne),null,{default:W(()=>[...se[48]||(se[48]=[ve(" Optional. If no stop conditions are set, the agent will continue until programmatically stopped or end conversation tool is called. ",-1)])]),_:1}),t("div",null,[k(Ee,{type:"checkbox",modelValue:U.value,"onUpdate:modelValue":se[19]||(se[19]=Oe=>U.value=Oe),label:"Stop when agent returns content","outer-class":"$reset"},null,8,["modelValue"]),k(I(Ne),{class:"ml-6"},{default:W(()=>[...se[49]||(se[49]=[ve(" Agent stops when it returns a response without calling tools ",-1)])]),_:1})]),t("div",null,[k(Ee,{type:"checkbox",modelValue:K.value,"onUpdate:modelValue":se[20]||(se[20]=Oe=>K.value=Oe),label:"Stop on specific tool call","outer-class":"$reset"},null,8,["modelValue"]),K.value?(r(),o("div",gm,[k(Ee,{type:"selectSearch",modelValue:me.value,"onUpdate:modelValue":se[21]||(se[21]=Oe=>me.value=Oe),label:"Stop Tool",options:ke.value,placeholder:"Select a tool...",disabled:Re.value||!ce.value,"outer-class":"$reset"},null,8,["modelValue","options","disabled"]),ue.value?(r(),Y(I(Ne),{key:0,class:"text-red-600 dark:text-red-400"},{default:W(()=>[ve(C(ue.value),1)]),_:1})):(r(),Y(I(Ne),{key:1},{default:W(()=>[...se[50]||(se[50]=[ve(" Agent stops when this tool is called ",-1)])]),_:1})),me.value?(r(),o("div",hm,[k(Ee,{type:"selectSearch",modelValue:Q.value,"onUpdate:modelValue":se[22]||(se[22]=Oe=>Q.value=Oe),label:"Response Property",options:Ue.value,placeholder:"Select property...","outer-class":"$reset"},null,8,["modelValue","options"]),G.value?(r(),Y(I(Ne),{key:0,class:"mt-1 text-red-600 dark:text-red-400"},{default:W(()=>[ve(C(G.value),1)]),_:1})):(r(),Y(I(Ne),{key:1,class:"mt-1"},{default:W(()=>[...se[51]||(se[51]=[ve(" Property from tool arguments to return as final response ",-1)])]),_:1}))])):S("",!0)])):S("",!0)])]),t("div",bm,[t("div",null,[k(Ee,{type:"number",name:"side_b_max_steps",modelValue:ae.value,"onUpdate:modelValue":se[23]||(se[23]=Oe=>ae.value=Oe),label:"Max Steps",placeholder:"Unlimited","outer-class":"$reset"},null,8,["modelValue"]),ie.value?(r(),Y(I(Ne),{key:0,class:"mt-1 text-red-600 dark:text-red-400"},{default:W(()=>[ve(C(ie.value),1)]),_:1})):(r(),Y(I(Ne),{key:1,class:"mt-1"},{default:W(()=>[...se[52]||(se[52]=[ve(" Safety limit before yielding ",-1)])]),_:1}))]),t("div",null,[k(Ee,{type:"selectSearch",modelValue:xe.value,"onUpdate:modelValue":se[24]||(se[24]=Oe=>xe.value=Oe),label:"End Conversation Tool",options:ke.value,placeholder:"Select a tool...",disabled:Re.value||!ce.value,"outer-class":"$reset"},null,8,["modelValue","options","disabled"]),X.value?(r(),Y(I(Ne),{key:0,class:"mt-1 text-red-600 dark:text-red-400"},{default:W(()=>[ve(C(X.value),1)]),_:1})):(r(),Y(I(Ne),{key:1,class:"mt-1"},{default:W(()=>[...se[53]||(se[53]=[ve(" Ends entire conversation when called ",-1)])]),_:1}))])])],64))])]),_:1},8,["title","icon"]),k(I(bt),{id:"section-variables",title:"Variables",icon:I(Jt)},{default:W(()=>[t("div",xm,[se[54]||(se[54]=t("p",{class:"text-sm text-neutral-500 dark:text-neutral-400"}," Set optional agent-level overrides for declared variables used by this agent's prompts and tools. ",-1)),B.value?(r(),o("span",ym,"Scanning variables...")):S("",!0),k(en,{modelValue:be.value,"onUpdate:modelValue":se[25]||(se[25]=Oe=>be.value=Oe),scanned:he.value,"allow-declaration-edit":!1,"allow-secret-values":!1,"allow-secret-declarations":!0,"require-required-values":!1,disabled:e.readonly||i.value},null,8,["modelValue","scanned","disabled"])])]),_:1},8,["icon"])])],512)]),t("div",km,[t("div",wm,[k(I(Qe),{variant:"ghost",size:"sm",disabled:e.saving,onClick:st},{default:W(()=>[ve(C(e.readonly?"Close":"Cancel"),1)]),_:1},8,["disabled"]),e.readonly?S("",!0):(r(),o("div",_m,[k(I(Er),{node:Ce.value||void 0},null,8,["node"]),k(I(Qe),{variant:"primary",size:"sm",disabled:e.saving,loading:e.saving,type:"submit",form:"agent-form"},{default:W(()=>[ve(C(u.value?"Update Agent":"Create Agent"),1)]),_:1},8,["disabled","loading"])]))])])]),_:1},8,["disabled"]))]),_:1},8,["model-value","title"])}}}),tn=Se({__name:"ExtractCopyToggle",props:{value:{},disabled:{type:Boolean}},emits:["update:value"],setup(e,{emit:n}){const a=n,s=l=>{a("update:value",l)};return(l,u)=>{const i=at("FormKit");return r(),Y(i,{type:"toggle",value:e.value,"on-value":"extract","off-value":"copy","on-value-label":"extract","off-value-label":"copy",disabled:e.disabled,classes:{outer:"$remove:mb-4",wrapper:"$remove:items-center flex-row-reverse justify-end items-center",inner:"h-5",track:"h-5 w-10 rounded-full",thumb:"h-4 w-4",valueLabel:"text-xs text-neutral-600 dark:text-neutral-400 mr-2 flex items-center font-normal"},onInput:s},null,8,["value","disabled"])}}}),Cm={class:"font-mono text-sm"},Sm={class:"flex items-center gap-2 py-1.5"},Im={class:"text-neutral-600 dark:text-neutral-400"},Tm={class:"ml-auto"},rn=Se({name:"TreeChildren",props:{children:{type:Array,required:!0},getSelection:{type:Function,required:!0},setSelection:{type:Function,required:!0},isShared:{type:Function,required:!0},getTypeColor:{type:Function,required:!0}},setup(e){return()=>e.children.length===0?null:tt("div",{class:"ml-4"},e.children.map((n,a)=>tt("div",{class:"relative",key:n.uid},[a<e.children.length-1?tt("div",{class:"absolute left-0 top-0 bottom-0 border-l border-neutral-300 dark:border-neutral-700"}):tt("div",{class:"absolute left-0 top-0 h-3 border-l border-neutral-300 dark:border-neutral-700"}),tt("div",{class:"absolute left-0 top-3 w-4 border-t border-neutral-300 dark:border-neutral-700"}),tt("div",{class:"pl-5"},[tt("div",{class:"flex items-center gap-2 py-1.5"},[tt("span",{class:"text-neutral-600 dark:text-neutral-400"},n.name),tt(Ut,{variant:e.getTypeColor(n.type),size:"sm"},()=>n.type),e.isShared(n)?tt("span",{class:"text-xs text-amber-600 dark:text-amber-400",title:`Used by: ${n.sharedWith.join(", ")}`},`(used in ${n.sharedWith.length} other${n.sharedWith.length>1?"s":""})`):null,n.isDuplicate?null:tt("div",{class:"ml-auto"},[tt(tn,{value:e.getSelection(n),disabled:e.isShared(n),"onUpdate:value":s=>e.setSelection(n,s),title:e.isShared(n)?"Cannot extract items shared with other agents":""})])]),n.children.length>0?tt(rn,{children:n.children,getSelection:e.getSelection,setSelection:e.setSelection,isShared:e.isShared,getTypeColor:e.getTypeColor}):null])])))}}),Mm=Se({__name:"DependencyTree",props:{analysis:{},selections:{}},emits:["update:selection"],setup(e,{emit:n}){const a=e,s=n,l=F(()=>{const x=a.analysis,b=[];let y=0;const $=(_,P)=>{for(const V of _){const E=`${P}:${V.name}`;b.push({...V,type:P,uid:`${E}:${y++}`})}};$(x.constituents.agents,"agent"),$(x.constituents.prompts,"prompt"),$(x.constituents.tools,"tool"),$(x.constituents.models,"model"),$(x.constituents.hooks,"hook");const g=new Map,d=`agent:${x.agent}`;for(const _ of b){const P=_.parentKey||d;`${_.type}:${_.name}`===d&&!_.parentKey||(g.has(P)||g.set(P,[]),g.get(P).push(_))}const w=new Set,m=_=>{const P=`${_.type}:${_.name}`,V=w.has(P);w.add(P);const E=[],z=g.get(P)||[];for(const A of z)E.push(m(A));return{name:_.name,type:_.type,filePath:_.filePath,sharedWith:_.sharedWith,discoveredVia:_.discoveredVia,children:E,uid:_.uid,isDuplicate:V}},v=b.find(_=>_.type==="agent"&&_.name===x.agent&&!_.parentKey);return v?m(v):{name:x.agent,type:"agent",filePath:"",sharedWith:[],discoveredVia:"static",children:[],uid:"root",isDuplicate:!1}}),u=x=>`${x.type}:${x.name}`,i=x=>a.selections.get(u(x))||"extract",c=(x,b)=>{s("update:selection",u(x),b)},f=x=>x.sharedWith.length>0,h=x=>{switch(x){case"agent":return"accent";case"prompt":return"secondary";case"tool":return"success";case"model":return"warning";case"hook":return"default"}};return(x,b)=>(r(),o("div",Cm,[t("div",Sm,[t("span",Im,C(l.value.name),1),k(I(Ut),{variant:h(l.value.type),size:"sm"},{default:W(()=>[ve(C(l.value.type),1)]),_:1},8,["variant"]),t("div",Tm,[k(tn,{value:i(l.value),"onUpdate:value":b[0]||(b[0]=y=>c(l.value,y))},null,8,["value"])])]),(r(),Y(rt(I(rn)),{children:l.value.children,"get-selection":i,"set-selection":c,"is-shared":f,"get-type-color":h},null,8,["children"]))]))}}),zm={key:0,class:"flex items-center justify-center py-12"},Vm={key:1,class:"py-4"},Em={key:2,class:"py-4 space-y-4"},Lm={class:"space-y-2"},Am={class:"text-sm opacity-80"},Pm={class:"text-sm opacity-80"},Om={key:3,class:"space-y-6"},Rm={class:"space-y-4"},jm={class:"grid grid-cols-2 gap-4"},Dm={class:"col-span-2"},Um=["value"],Bm={class:"col-span-2"},Nm={class:"col-span-2"},qm={key:0,class:"mt-3 space-y-3"},Fm={class:"flex gap-2 border-b border-neutral-200 dark:border-neutral-700"},Hm={key:0},Wm=["innerHTML"],Km={class:"space-y-4"},Jm={class:"list-disc list-inside space-y-1"},Gm={class:"border border-neutral-200 dark:border-neutral-700 rounded-lg p-4 bg-neutral-50 dark:bg-neutral-900/50"},Ym={class:"flex justify-between"},Zm=Se({__name:"PackModal",props:{modelValue:{type:Boolean},agent:{}},emits:["update:modelValue","packed"],setup(e,{emit:n}){ir.setOptions({gfm:!0,breaks:!0});const a=[{value:"MIT",label:"MIT"},{value:"Apache-2.0",label:"Apache 2.0"},{value:"ISC",label:"ISC"},{value:"GPL-3.0",label:"GPL 3.0"},{value:"BSD-3-Clause",label:"BSD 3-Clause"},{value:"Unlicensed",label:"Unlicensed / Proprietary"}],s=e,l=n,u=F({get:()=>s.modelValue,set:Z=>l("update:modelValue",Z)}),i=p(null),c=p(!1),f=p(!1),h=p(null),x=p(null),b=p(""),y=p("1.0.0"),$=p("MIT"),g=p(""),d=p(""),w=p("edit"),m=p(!1),v=p(null),_=p(null),P=F(()=>d.value?ir(d.value):""),V=p(new Map);Ve(()=>s.modelValue,async Z=>{Z&&s.agent?await Promise.all([z(),A()]):E()});const E=()=>{i.value=null,h.value=null,x.value=null,V.value=new Map,b.value="",y.value="1.0.0",$.value="MIT",g.value="",d.value="",w.value="edit",m.value=!1,v.value=null,_.value=null},z=async()=>{if(s.agent){c.value=!0,h.value=null;try{const Z=await fetch(ze(`/api/pack/${s.agent.id}/analyze`)),U=await Z.json();if(!Z.ok){h.value=U.error||"Failed to analyze agent";return}if(i.value=U,U.generatedReadme)d.value=U.generatedReadme;else{const K=oe(s.agent?.id||"agent");d.value=ne(K,s.agent?.id||"agent",U.agentDescription)}ye(U)}catch(Z){h.value=Z instanceof Error?Z.message:"Failed to analyze agent"}finally{c.value=!1}}},A=async()=>{if(s.agent)try{const Z=await fetch(ze(`/api/pack/${s.agent.id}/metadata`));if(Z.ok){const U=await Z.json();b.value=U.packageName,y.value=fe(U.version),$.value=U.license||"MIT",g.value=U.licenseOwner||""}else b.value=oe(s.agent.id),y.value="1.0.0",$.value="MIT",g.value=""}catch{b.value=oe(s.agent?.id||"agent"),y.value="1.0.0",$.value="MIT",g.value=""}},oe=Z=>`standardagent-${Z.toLowerCase().replace(/_/g,"-")}`,ne=(Z,U,K)=>`# ${Z}
6
6
 
7
- ${W||"A Standard Agent package."}
7
+ ${K||"A Standard Agent package."}
8
8
 
9
9
  ## Installation
10
10
 
11
11
  \`\`\`bash
12
- npm install ${X}
12
+ npm install ${Z}
13
13
  \`\`\`
14
14
 
15
15
  ## Usage
@@ -22,39 +22,39 @@ This is a [Standard Agent](https://standardagentbuilder.com) package. To use it:
22
22
  \`\`\`typescript
23
23
  // Create a thread with this agent
24
24
  const thread = await client.createThread({
25
- agent_id: '${X}/${D}'
25
+ agent_id: '${Z}/${U}'
26
26
  });
27
27
  \`\`\`
28
28
 
29
29
  ## License
30
30
 
31
31
  MIT
32
- `,ie=X=>{const D=X.split(".");if(D.length<3)return`${X}.1`;const W=parseInt(D[2],10);return`${D[0]}.${D[1]}.${W+1}`},be=X=>{const D=new Map,W=new Set;for(const me of X.constituents.agents){const ue=`agent:${me.name}`;W.has(ue)||(W.add(ue),D.set(ue,me.sharedWith.length>0?"copy":"extract"))}for(const me of X.constituents.prompts){const ue=`prompt:${me.name}`;W.has(ue)||(W.add(ue),D.set(ue,me.sharedWith.length>0?"copy":"extract"))}for(const me of X.constituents.tools){const ue=`tool:${me.name}`;W.has(ue)||(W.add(ue),D.set(ue,me.sharedWith.length>0?"copy":"extract"))}for(const me of X.constituents.models){const ue=`model:${me.name}`;W.has(ue)||(W.add(ue),D.set(ue,me.sharedWith.length>0?"copy":"extract"))}for(const me of X.constituents.hooks){const ue=`hook:${me.name}`;W.has(ue)||(W.add(ue),D.set(ue,me.sharedWith.length>0?"copy":"extract"))}E.value=D},Q=(X,D)=>{E.value.set(X,D),E.value=new Map(E.value)},U=X=>X?X.length>214?"Package name must be 214 characters or less":X.startsWith(".")||X.startsWith("_")?"Cannot start with . or _":X!==X.toLowerCase()?"Must be lowercase":/^(@[a-z0-9-~][a-z0-9-._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/.test(X)?null:"Only lowercase letters, numbers, hyphens, underscores, and dots":"Package name is required",R=X=>/^\d+\.\d+\.\d+(-[a-zA-Z0-9.-]+)?$/.test(X)?null:"Invalid version format (use X.Y.Z)";Ee(g,X=>{f.value=U(X)}),Ee(y,X=>{$.value=R(X)});const K=q(()=>!U(g.value)&&!R(y.value)),H=async()=>{if(!(!s.agent||!i.value)&&(f.value=U(g.value),$.value=R(y.value),!(f.value||$.value))){x.value=!0,k.value=null,h.value=null;try{const X=Array.from(E.value.entries()).map(([me,ue])=>{const[te,Y]=me.split(":");let ae="";const ye=te==="agent"?"agents":te+"s",ne=(i.value?.constituents[ye]||[]).find(ke=>ke.name===Y);return ne&&(ae=ne.filePath),{name:Y,type:te,filePath:ae,mode:ue}}),D=await fetch(Ve(`/api/pack/${s.agent.id}`),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({itemSelections:X,packageName:g.value,version:y.value,license:_.value,licenseOwner:v.value,readme:d.value})}),W=await D.json();if(!D.ok){k.value=W.error||"Failed to pack agent";return}h.value={success:!0,outputPath:W.outputPath,filesCreated:W.filesCreated,packageId:W.packageId},setTimeout(()=>{l("packed",{outputPath:W.outputPath,packageId:W.packageId})},1500)}catch(X){k.value=X instanceof Error?X.message:"Failed to pack agent"}finally{x.value=!1}}},ve=()=>{u.value=!1};return(X,D)=>(r(),J(st,{modelValue:u.value,"onUpdate:modelValue":D[8]||(D[8]=W=>u.value=W),title:`Pack Agent: ${t.agent?.title||t.agent?.id||""}`,width:"max-w-2xl","min-height":"min-h-[20rem]"},{footer:F(()=>[e("div",Am,[w(I(Je),{variant:"ghost",onClick:ve},{default:F(()=>[...D[15]||(D[15]=[de(" Cancel ",-1)])]),_:1}),w(I(Je),{variant:"primary",disabled:p.value||x.value||!i.value||h.value?.success||!K.value,onClick:H},{default:F(()=>[x.value?(r(),o(we,{key:0},[w(Be,{size:"sm",class:"mr-2"}),D[16]||(D[16]=de(" Packing... ",-1))],64)):(r(),o(we,{key:1},[de(" Pack Agent ")],64))]),_:1},8,["disabled"])])]),default:F(()=>[p.value?(r(),o("div",vm,[w(Be,{size:"lg"})])):k.value&&!i.value?(r(),o("div",fm,[w(I(at),{variant:"error"},{default:F(()=>[de(C(k.value),1)]),_:1})])):h.value?.success?(r(),o("div",gm,[w(I(at),{variant:"success"},{default:F(()=>[e("div",hm,[D[9]||(D[9]=e("p",{class:"font-medium"},"Agent packed successfully!",-1)),e("p",bm," Output: "+C(h.value.outputPath),1),e("p",xm,C(h.value.filesCreated?.length)+" files created ",1)])]),_:1})])):i.value?(r(),o("div",ym,[e("div",km,[D[11]||(D[11]=e("h3",{class:"text-sm font-semibold text-neutral-700 dark:text-neutral-300 uppercase tracking-wider"}," Package Details ",-1)),e("div",wm,[e("div",_m,[w(I(Vt),{label:"Package Name",error:f.value||void 0,"help-text":"npm package name (lowercase, no spaces)",required:""},{default:F(()=>[He(e("input",{"onUpdate:modelValue":D[0]||(D[0]=W=>g.value=W),type:"text",class:ce(["w-full px-3 py-2 rounded-md border text-sm bg-white dark:bg-neutral-800 border-neutral-300 dark:border-neutral-600 text-neutral-900 dark:text-neutral-100 placeholder-neutral-400 dark:placeholder-neutral-500 focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-transparent disabled:opacity-50 disabled:cursor-not-allowed",{"border-red-500 dark:border-red-500":f.value}]),placeholder:"standardagent-my-agent"},null,2),[[ht,g.value]])]),_:1},8,["error"])]),w(I(Vt),{label:"Version",error:$.value||void 0,"help-text":"Semver format (X.Y.Z)",required:""},{default:F(()=>[He(e("input",{"onUpdate:modelValue":D[1]||(D[1]=W=>y.value=W),type:"text",class:ce(["w-full px-3 py-2 rounded-md border text-sm bg-white dark:bg-neutral-800 border-neutral-300 dark:border-neutral-600 text-neutral-900 dark:text-neutral-100 placeholder-neutral-400 dark:placeholder-neutral-500 focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-transparent disabled:opacity-50 disabled:cursor-not-allowed",{"border-red-500 dark:border-red-500":$.value}]),placeholder:"1.0.0"},null,2),[[ht,y.value]])]),_:1},8,["error"]),w(I(Vt),{label:"License"},{default:F(()=>[He(e("select",{"onUpdate:modelValue":D[2]||(D[2]=W=>_.value=W),class:"w-full px-3 py-2 rounded-md border text-sm bg-white dark:bg-neutral-800 border-neutral-300 dark:border-neutral-600 text-neutral-900 dark:text-neutral-100 focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-transparent"},[(r(),o(we,null,Ae(a,W=>e("option",{key:W.value,value:W.value},C(W.label),9,$m)),64))],512),[[ga,_.value]])]),_:1}),e("div",Cm,[w(I(Vt),{label:"License Owner","help-text":"Copyright holder name (e.g., your name or company)"},{default:F(()=>[He(e("input",{"onUpdate:modelValue":D[3]||(D[3]=W=>v.value=W),type:"text",class:"w-full px-3 py-2 rounded-md border text-sm bg-white dark:bg-neutral-800 border-neutral-300 dark:border-neutral-600 text-neutral-900 dark:text-neutral-100 placeholder-neutral-400 dark:placeholder-neutral-500 focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-transparent",placeholder:"Your Name or Company"},null,512),[[ht,v.value]])]),_:1})]),e("div",Sm,[e("button",{type:"button",class:"flex items-center gap-2 text-sm font-medium text-neutral-700 dark:text-neutral-300 hover:text-neutral-900 dark:hover:text-neutral-100",onClick:D[4]||(D[4]=W=>c.value=!c.value)},[(r(),J(Qe(c.value?I(gt):I(_t)),{class:"w-4 h-4"})),D[10]||(D[10]=de(" README ",-1))]),c.value?(r(),o("div",Im,[e("div",Tm,[e("button",{type:"button",class:ce(["px-3 py-1.5 text-sm font-medium border-b-2 -mb-px transition-colors",b.value==="edit"?"border-primary-500 text-primary-600 dark:text-primary-400":"border-transparent text-neutral-500 hover:text-neutral-700 dark:hover:text-neutral-300"]),onClick:D[5]||(D[5]=W=>b.value="edit")}," Edit ",2),e("button",{type:"button",class:ce(["px-3 py-1.5 text-sm font-medium border-b-2 -mb-px transition-colors",b.value==="preview"?"border-primary-500 text-primary-600 dark:text-primary-400":"border-transparent text-neutral-500 hover:text-neutral-700 dark:hover:text-neutral-300"]),onClick:D[6]||(D[6]=W=>b.value="preview")}," Preview ",2)]),b.value==="edit"?(r(),o("div",Mm,[He(e("textarea",{"onUpdate:modelValue":D[7]||(D[7]=W=>d.value=W),rows:"10",class:"w-full px-3 py-2 rounded-md border text-sm font-mono bg-white dark:bg-neutral-800 border-neutral-300 dark:border-neutral-600 text-neutral-900 dark:text-neutral-100 placeholder-neutral-400 dark:placeholder-neutral-500 focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-transparent resize-y",placeholder:`# Package Name
32
+ `,fe=Z=>{const U=Z.split(".");if(U.length<3)return`${Z}.1`;const K=parseInt(U[2],10);return`${U[0]}.${U[1]}.${K+1}`},ye=Z=>{const U=new Map,K=new Set;for(const me of Z.constituents.agents){const ue=`agent:${me.name}`;K.has(ue)||(K.add(ue),U.set(ue,me.sharedWith.length>0?"copy":"extract"))}for(const me of Z.constituents.prompts){const ue=`prompt:${me.name}`;K.has(ue)||(K.add(ue),U.set(ue,me.sharedWith.length>0?"copy":"extract"))}for(const me of Z.constituents.tools){const ue=`tool:${me.name}`;K.has(ue)||(K.add(ue),U.set(ue,me.sharedWith.length>0?"copy":"extract"))}for(const me of Z.constituents.models){const ue=`model:${me.name}`;K.has(ue)||(K.add(ue),U.set(ue,me.sharedWith.length>0?"copy":"extract"))}for(const me of Z.constituents.hooks){const ue=`hook:${me.name}`;K.has(ue)||(K.add(ue),U.set(ue,me.sharedWith.length>0?"copy":"extract"))}V.value=U},te=(Z,U)=>{V.value.set(Z,U),V.value=new Map(V.value)},q=Z=>Z?Z.length>214?"Package name must be 214 characters or less":Z.startsWith(".")||Z.startsWith("_")?"Cannot start with . or _":Z!==Z.toLowerCase()?"Must be lowercase":/^(@[a-z0-9-~][a-z0-9-._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/.test(Z)?null:"Only lowercase letters, numbers, hyphens, underscores, and dots":"Package name is required",j=Z=>/^\d+\.\d+\.\d+(-[a-zA-Z0-9.-]+)?$/.test(Z)?null:"Invalid version format (use X.Y.Z)";Ve(b,Z=>{v.value=q(Z)}),Ve(y,Z=>{_.value=j(Z)});const J=F(()=>!q(b.value)&&!j(y.value)),H=async()=>{if(!(!s.agent||!i.value)&&(v.value=q(b.value),_.value=j(y.value),!(v.value||_.value))){f.value=!0,h.value=null,x.value=null;try{const Z=Array.from(V.value.entries()).map(([me,ue])=>{const[Q,G]=me.split(":");let ae="";const ie=Q==="agent"?"agents":Q+"s",X=(i.value?.constituents[ie]||[]).find(he=>he.name===G);return X&&(ae=X.filePath),{name:G,type:Q,filePath:ae,mode:ue}}),U=await fetch(ze(`/api/pack/${s.agent.id}`),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({itemSelections:Z,packageName:b.value,version:y.value,license:$.value,licenseOwner:g.value,readme:d.value})}),K=await U.json();if(!U.ok){h.value=K.error||"Failed to pack agent";return}x.value={success:!0,outputPath:K.outputPath,filesCreated:K.filesCreated,packageId:K.packageId},setTimeout(()=>{l("packed",{outputPath:K.outputPath,packageId:K.packageId})},1500)}catch(Z){h.value=Z instanceof Error?Z.message:"Failed to pack agent"}finally{f.value=!1}}},ce=()=>{u.value=!1};return(Z,U)=>(r(),Y(dt,{modelValue:u.value,"onUpdate:modelValue":U[8]||(U[8]=K=>u.value=K),title:`Pack Agent: ${e.agent?.title||e.agent?.id||""}`,width:"max-w-2xl","min-height":"min-h-[20rem]"},{footer:W(()=>[t("div",Ym,[k(I(Qe),{variant:"ghost",onClick:ce},{default:W(()=>[...U[15]||(U[15]=[ve(" Cancel ",-1)])]),_:1}),k(I(Qe),{variant:"primary",disabled:c.value||f.value||!i.value||x.value?.success||!J.value,onClick:H},{default:W(()=>[f.value?(r(),o($e,{key:0},[k(Be,{size:"sm",class:"mr-2"}),U[16]||(U[16]=ve(" Packing... ",-1))],64)):(r(),o($e,{key:1},[ve(" Pack Agent ")],64))]),_:1},8,["disabled"])])]),default:W(()=>[c.value?(r(),o("div",zm,[k(Be,{size:"lg"})])):h.value&&!i.value?(r(),o("div",Vm,[k(I(ot),{variant:"error"},{default:W(()=>[ve(C(h.value),1)]),_:1})])):x.value?.success?(r(),o("div",Em,[k(I(ot),{variant:"success"},{default:W(()=>[t("div",Lm,[U[9]||(U[9]=t("p",{class:"font-medium"},"Agent packed successfully!",-1)),t("p",Am," Output: "+C(x.value.outputPath),1),t("p",Pm,C(x.value.filesCreated?.length)+" files created ",1)])]),_:1})])):i.value?(r(),o("div",Om,[t("div",Rm,[U[11]||(U[11]=t("h3",{class:"text-sm font-semibold text-neutral-700 dark:text-neutral-300 uppercase tracking-wider"}," Package Details ",-1)),t("div",jm,[t("div",Dm,[k(I(At),{label:"Package Name",error:v.value||void 0,"help-text":"npm package name (lowercase, no spaces)",required:""},{default:W(()=>[Je(t("input",{"onUpdate:modelValue":U[0]||(U[0]=K=>b.value=K),type:"text",class:pe(["w-full px-3 py-2 rounded-md border text-sm bg-white dark:bg-neutral-800 border-neutral-300 dark:border-neutral-600 text-neutral-900 dark:text-neutral-100 placeholder-neutral-400 dark:placeholder-neutral-500 focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-transparent disabled:opacity-50 disabled:cursor-not-allowed",{"border-red-500 dark:border-red-500":v.value}]),placeholder:"standardagent-my-agent"},null,2),[[yt,b.value]])]),_:1},8,["error"])]),k(I(At),{label:"Version",error:_.value||void 0,"help-text":"Semver format (X.Y.Z)",required:""},{default:W(()=>[Je(t("input",{"onUpdate:modelValue":U[1]||(U[1]=K=>y.value=K),type:"text",class:pe(["w-full px-3 py-2 rounded-md border text-sm bg-white dark:bg-neutral-800 border-neutral-300 dark:border-neutral-600 text-neutral-900 dark:text-neutral-100 placeholder-neutral-400 dark:placeholder-neutral-500 focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-transparent disabled:opacity-50 disabled:cursor-not-allowed",{"border-red-500 dark:border-red-500":_.value}]),placeholder:"1.0.0"},null,2),[[yt,y.value]])]),_:1},8,["error"]),k(I(At),{label:"License"},{default:W(()=>[Je(t("select",{"onUpdate:modelValue":U[2]||(U[2]=K=>$.value=K),class:"w-full px-3 py-2 rounded-md border text-sm bg-white dark:bg-neutral-800 border-neutral-300 dark:border-neutral-600 text-neutral-900 dark:text-neutral-100 focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-transparent"},[(r(),o($e,null,Le(a,K=>t("option",{key:K.value,value:K.value},C(K.label),9,Um)),64))],512),[[Ca,$.value]])]),_:1}),t("div",Bm,[k(I(At),{label:"License Owner","help-text":"Copyright holder name (e.g., your name or company)"},{default:W(()=>[Je(t("input",{"onUpdate:modelValue":U[3]||(U[3]=K=>g.value=K),type:"text",class:"w-full px-3 py-2 rounded-md border text-sm bg-white dark:bg-neutral-800 border-neutral-300 dark:border-neutral-600 text-neutral-900 dark:text-neutral-100 placeholder-neutral-400 dark:placeholder-neutral-500 focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-transparent",placeholder:"Your Name or Company"},null,512),[[yt,g.value]])]),_:1})]),t("div",Nm,[t("button",{type:"button",class:"flex items-center gap-2 text-sm font-medium text-neutral-700 dark:text-neutral-300 hover:text-neutral-900 dark:hover:text-neutral-100",onClick:U[4]||(U[4]=K=>m.value=!m.value)},[(r(),Y(rt(m.value?I(xt):I(St)),{class:"w-4 h-4"})),U[10]||(U[10]=ve(" README ",-1))]),m.value?(r(),o("div",qm,[t("div",Fm,[t("button",{type:"button",class:pe(["px-3 py-1.5 text-sm font-medium border-b-2 -mb-px transition-colors",w.value==="edit"?"border-primary-500 text-primary-600 dark:text-primary-400":"border-transparent text-neutral-500 hover:text-neutral-700 dark:hover:text-neutral-300"]),onClick:U[5]||(U[5]=K=>w.value="edit")}," Edit ",2),t("button",{type:"button",class:pe(["px-3 py-1.5 text-sm font-medium border-b-2 -mb-px transition-colors",w.value==="preview"?"border-primary-500 text-primary-600 dark:text-primary-400":"border-transparent text-neutral-500 hover:text-neutral-700 dark:hover:text-neutral-300"]),onClick:U[6]||(U[6]=K=>w.value="preview")}," Preview ",2)]),w.value==="edit"?(r(),o("div",Hm,[Je(t("textarea",{"onUpdate:modelValue":U[7]||(U[7]=K=>d.value=K),rows:"10",class:"w-full px-3 py-2 rounded-md border text-sm font-mono bg-white dark:bg-neutral-800 border-neutral-300 dark:border-neutral-600 text-neutral-900 dark:text-neutral-100 placeholder-neutral-400 dark:placeholder-neutral-500 focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-transparent resize-y",placeholder:`# Package Name
33
33
 
34
- Description...`},null,512),[[ht,d.value]])])):(r(),o("div",{key:1,class:"prose prose-sm dark:prose-invert max-w-none p-4 rounded-md border border-neutral-200 dark:border-neutral-700 bg-white dark:bg-neutral-800 min-h-[200px] max-h-[400px] overflow-y-auto",innerHTML:N.value},null,8,zm))])):S("",!0)])])]),D[14]||(D[14]=e("hr",{class:"border-neutral-200 dark:border-neutral-700"},null,-1)),e("div",Vm,[D[13]||(D[13]=e("h3",{class:"text-sm font-semibold text-neutral-700 dark:text-neutral-300 uppercase tracking-wider"}," Items to Include ",-1)),w(I(at),{variant:"info"},{default:F(()=>[...D[12]||(D[12]=[e("div",{class:"space-y-1"},[e("p",null,[e("strong",null,"Extract"),de(": Moves the file into the package and removes it from your workspace. Use this for items only used by this agent. ")]),e("p",null,[e("strong",null,"Copy"),de(": Copies the file into the package but keeps the original. Required for items shared with other agents. ")])],-1)])]),_:1}),k.value?(r(),J(I(at),{key:0,variant:"error"},{default:F(()=>[de(C(k.value),1)]),_:1})):S("",!0),i.value.warnings.length>0?(r(),J(I(at),{key:1,variant:"warning"},{default:F(()=>[e("ul",Em,[(r(!0),o(we,null,Ae(i.value.warnings,W=>(r(),o("li",{key:W},C(W),1))),128))])]),_:1})):S("",!0),e("div",Lm,[w(mm,{analysis:i.value,selections:E.value,"onUpdate:selection":Q},null,8,["analysis","selections"])])])])):S("",!0)]),_:1},8,["modelValue","title"]))}}),jm={class:"font-mono text-sm"},Rm={class:"mb-3 text-xs text-neutral-500 dark:text-neutral-400"},Om={class:"flex items-center gap-2 py-1.5"},Dm={class:"text-neutral-600 dark:text-neutral-400"},Um={key:0,class:"ml-auto text-xs text-amber-600 dark:text-amber-400"},Bm={key:1,class:"ml-auto text-xs text-emerald-600 dark:text-emerald-400"},Nm={key:0,class:"text-center py-8 text-neutral-500 dark:text-neutral-400"},Ja=Ce({name:"TreeChildren",props:{children:{type:Array,required:!0},getTypeColor:{type:Function,required:!0}},setup(t){return()=>t.children.length===0?null:Xe("div",{class:"ml-4"},t.children.map((n,a)=>Xe("div",{class:"relative",key:n.uid},[a<t.children.length-1?Xe("div",{class:"absolute left-0 top-0 bottom-0 border-l border-neutral-300 dark:border-neutral-700"}):Xe("div",{class:"absolute left-0 top-0 h-3 border-l border-neutral-300 dark:border-neutral-700"}),Xe("div",{class:"absolute left-0 top-3 w-4 border-t border-neutral-300 dark:border-neutral-700"}),Xe("div",{class:"pl-5"},[Xe("div",{class:"flex items-center gap-2 py-1.5"},[Xe("span",{class:"text-neutral-600 dark:text-neutral-400"},n.name),Xe(Pt,{variant:t.getTypeColor(n.type),size:"sm"},()=>n.type),n.isDuplicate?null:n.existsGlobally?Xe("span",{class:"ml-auto text-xs text-amber-600 dark:text-amber-400"},"already exists"):Xe("span",{class:"ml-auto text-xs text-emerald-600 dark:text-emerald-400"},"will unpack")]),n.children.length>0?Xe(Ja,{children:n.children,getTypeColor:t.getTypeColor}):null])])))}}),qm=Ce({__name:"UnpackTree",props:{analysis:{}},setup(t){const n=t,a=q(()=>{const i=n.analysis,p=[];let x=0;for(const v of i.items)p.push({...v,uid:`${v.type}:${v.name}:${x++}`});const k=new Map,h=[];for(const v of p)v.parentKey?(k.has(v.parentKey)||k.set(v.parentKey,[]),k.get(v.parentKey).push(v)):h.push(v);const g=new Set,y=v=>{const d=`${v.type}:${v.name}`,b=g.has(d);g.add(d);const c=[],f=k.get(d)||[];for(const $ of f)c.push(y($));return{name:v.name,type:v.type,existsGlobally:v.existsGlobally,action:v.action,children:c,uid:v.uid,isDuplicate:b}},_=[];for(const v of h)v.type==="agent"&&_.push(y(v));if(_.length===0)for(const v of h)_.push(y(v));return _}),s=i=>{switch(i){case"agent":return"accent";case"prompt":return"secondary";case"tool":return"success";case"model":return"warning";case"hook":return"default"}},l=q(()=>{const i=new Set;for(const p of n.analysis.items)i.add(`${p.type}:${p.name}`);return i.size}),u=q(()=>{const i=new Set;let p=0;for(const x of n.analysis.items){const k=`${x.type}:${x.name}`;i.has(k)||(i.add(k),x.existsGlobally||p++)}return p});return(i,p)=>(r(),o("div",jm,[e("div",Rm,C(u.value)+" of "+C(l.value)+" items will be unpacked ",1),(r(!0),o(we,null,Ae(a.value,x=>(r(),o("div",{key:x.uid},[e("div",Om,[e("span",Dm,C(x.name),1),w(I(Pt),{variant:s(x.type),size:"sm"},{default:F(()=>[de(C(x.type),1)]),_:2},1032,["variant"]),x.existsGlobally?(r(),o("span",Um," already exists ")):(r(),o("span",Bm," will unpack "))]),(r(),J(Qe(I(Ja)),{children:x.children,"get-type-color":s},null,8,["children"]))]))),128)),a.value.length===0?(r(),o("div",Nm," No items found in this package. ")):S("",!0)]))}}),Fm={key:0,class:"flex items-center justify-center py-12"},Hm={key:1,class:"py-4"},Wm={key:2,class:"py-4"},Km={class:"space-y-2"},Jm={class:"text-sm opacity-80"},Gm={key:0,class:"text-sm opacity-80"},Ym={key:1,class:"text-sm opacity-80"},Zm={key:3,class:"space-y-4"},Xm={class:"text-sm text-neutral-600 dark:text-neutral-400"},Qm={class:"font-mono"},ev={class:"list-disc list-inside space-y-1"},tv={class:"border border-neutral-200 dark:border-neutral-700 rounded-lg p-4 bg-neutral-50 dark:bg-neutral-900/50 max-h-80 overflow-y-auto"},rv={key:2,class:"flex items-center gap-2"},av={class:"flex items-center gap-2 cursor-pointer"},nv={class:"flex justify-between"},ov=Ce({__name:"UnpackModal",props:{modelValue:{type:Boolean},agent:{}},emits:["update:modelValue","unpacked"],setup(t,{emit:n}){const a=t,s=n,l=q({get:()=>a.modelValue,set:b=>s("update:modelValue",b)}),u=m(null),i=m(!1),p=m(!1),x=m(null),k=m(null),h=m(!1);Ee(()=>a.modelValue,async b=>{b&&a.agent?.packageId?await g():(u.value=null,x.value=null,k.value=null,h.value=!1)});const g=async()=>{if(a.agent?.packageId){i.value=!0,x.value=null;try{const b=await fetch(Ve(`/api/unpack/${encodeURIComponent(a.agent.packageId)}/analyze`)),c=await b.json();if(!b.ok){x.value=c.error||"Failed to analyze package";return}u.value=c}catch(b){x.value=b instanceof Error?b.message:"Failed to analyze package"}finally{i.value=!1}}},y=async()=>{if(!(!a.agent?.packageId||!u.value)){p.value=!0,x.value=null,k.value=null;try{const b=u.value.items.filter(($,N,E)=>E.findIndex(L=>L.type===$.type&&L.name===$.name)===N).map($=>({name:$.name,type:$.type,action:$.existsGlobally?"skip":"generate"})),c=await fetch(Ve(`/api/unpack/${encodeURIComponent(a.agent.packageId)}`),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({itemSelections:b,deletePackage:h.value})}),f=await c.json();if(!c.ok){x.value=f.error||"Failed to unpack agent";return}k.value={success:!0,filesGenerated:f.filesGenerated,filesSkipped:f.filesSkipped,packageDeleted:f.packageDeleted},setTimeout(()=>{s("unpacked")},1500)}catch(b){x.value=b instanceof Error?b.message:"Failed to unpack agent"}finally{p.value=!1}}},_=()=>{l.value=!1},v=q(()=>{if(!u.value)return 0;const b=new Set;let c=0;for(const f of u.value.items){const $=`${f.type}:${f.name}`;b.has($)||(b.add($),f.existsGlobally||c++)}return c}),d=q(()=>u.value?.source==="local");return(b,c)=>(r(),J(st,{modelValue:l.value,"onUpdate:modelValue":c[1]||(c[1]=f=>l.value=f),title:`Unpack: ${t.agent?.title||t.agent?.id||""}`,width:"max-w-2xl","min-height":"min-h-[20rem]"},{footer:F(()=>[e("div",nv,[w(I(Je),{variant:"ghost",onClick:_},{default:F(()=>[...c[6]||(c[6]=[de(" Cancel ",-1)])]),_:1}),w(I(Je),{variant:"primary",disabled:i.value||p.value||!u.value||k.value?.success||v.value===0,onClick:y},{default:F(()=>[p.value?(r(),o(we,{key:0},[w(Be,{size:"sm",class:"mr-2"}),c[7]||(c[7]=de(" Unpacking... ",-1))],64)):(r(),o(we,{key:1},[de(" Unpack "+C(v.value)+" "+C(v.value===1?"item":"items"),1)],64))]),_:1},8,["disabled"])])]),default:F(()=>[i.value?(r(),o("div",Fm,[w(Be,{size:"lg"})])):x.value&&!u.value?(r(),o("div",Hm,[w(I(at),{variant:"error"},{default:F(()=>[de(C(x.value),1)]),_:1})])):k.value?.success?(r(),o("div",Wm,[w(I(at),{variant:"success"},{default:F(()=>[e("div",Km,[c[2]||(c[2]=e("p",{class:"font-medium"},"Agent unpacked successfully!",-1)),e("p",Jm,C(k.value.filesGenerated?.length||0)+" files unpacked ",1),(k.value.filesSkipped?.length||0)>0?(r(),o("p",Gm,C(k.value.filesSkipped?.length)+" files skipped (already exist) ",1)):S("",!0),k.value.packageDeleted?(r(),o("p",Ym," Package was deleted from agents/packed/ ")):S("",!0)])]),_:1})])):u.value?(r(),o("div",Zm,[e("div",Xm,[e("p",null,[c[3]||(c[3]=de("Package: ",-1)),e("span",Qm,C(u.value.packageId),1),de(" v"+C(u.value.version),1)]),e("p",null,"Source: "+C(u.value.source==="npm"?"npm package":"local (agents/packed/)"),1)]),x.value?(r(),J(I(at),{key:0,variant:"error"},{default:F(()=>[de(C(x.value),1)]),_:1})):S("",!0),u.value.warnings.length>0?(r(),J(I(at),{key:1,variant:"warning"},{default:F(()=>[e("ul",ev,[(r(!0),o(we,null,Ae(u.value.warnings,f=>(r(),o("li",{key:f},C(f),1))),128))])]),_:1})):S("",!0),e("div",tv,[w(qm,{analysis:u.value},null,8,["analysis"])]),d.value?(r(),o("div",rv,[e("label",av,[He(e("input",{"onUpdate:modelValue":c[0]||(c[0]=f=>h.value=f),type:"checkbox",class:"w-4 h-4 rounded border-neutral-300 dark:border-neutral-600 text-primary-600 focus:ring-primary-500"},null,512),[[Ir,h.value]]),c[4]||(c[4]=e("span",{class:"text-sm text-neutral-700 dark:text-neutral-300"},"Delete package after unpacking",-1))]),c[5]||(c[5]=e("span",{class:"text-xs text-neutral-500"},"(removes from agents/packed/)",-1))])):S("",!0)])):S("",!0)]),_:1},8,["modelValue","title"]))}}),lv={key:0,class:"space-y-4"},sv={class:"space-y-2"},iv={class:"font-medium"},uv={key:0,class:"text-sm opacity-80"},dv={key:1,class:"text-sm opacity-70"},cv={key:2,class:"text-sm"},pv=["href"],mv={key:0,class:"space-y-2"},vv={class:"text-xs bg-neutral-100 dark:bg-neutral-800 p-3 rounded-md overflow-x-auto max-h-40 whitespace-pre-wrap"},fv={key:1,class:"space-y-4"},gv={class:"space-y-3"},hv={key:0,class:"flex items-center gap-2 text-neutral-500"},bv={key:2,class:"p-4 rounded-lg border border-neutral-200 dark:border-neutral-700 bg-neutral-50 dark:bg-neutral-900/50"},xv={class:"flex items-center gap-3 mb-3"},yv={class:"text-lg font-semibold text-neutral-900 dark:text-neutral-100"},kv={key:0,class:"text-sm text-neutral-600 dark:text-neutral-400 mb-3"},wv={key:1,class:"mt-3"},_v=["innerHTML"],$v={key:0,class:"border-neutral-200 dark:border-neutral-700"},Cv={key:1,class:"flex items-center gap-2 text-neutral-500"},Sv={class:"space-y-2 text-sm"},Iv={class:"bg-neutral-200 dark:bg-neutral-700 px-1 rounded"},Tv={class:"list-decimal list-inside space-y-1 ml-2"},Mv={class:"whitespace-pre-wrap text-sm"},zv={class:"space-y-2"},Vv={class:"flex items-center gap-4"},Ev={class:"flex items-center gap-2 cursor-pointer"},Lv={class:"flex items-center gap-2 cursor-pointer"},Av={key:0},Pv={key:0,class:"mt-1 text-xs text-red-500"},jv={class:"flex items-center gap-2 cursor-pointer"},Rv={class:"flex justify-between"},Ov="https://registry.npmjs.org",Dv=Ce({__name:"PublishModal",props:{modelValue:{type:Boolean},packageId:{},outputPath:{}},emits:["update:modelValue","published"],setup(t,{emit:n}){ar.setOptions({gfm:!0,breaks:!0});const a=t,s=n,l=q({get:()=>a.modelValue,set:U=>s("update:modelValue",U)}),u=m(null),i=m(!1),p=m(null),x=m(!1),k=m(null),h=m(!1),g=q(()=>u.value?.readme?ar(u.value.readme):""),y=m(""),_=m("default"),v=m(""),d=m(!1),b=m(!1),c=m(null),f=m(null),$=m(null),N=m(null),E=async()=>{i.value=!0,p.value=null;try{const U=await fetch(Ve(`/api/pack/${encodeURIComponent(a.packageId)}/packed-info`));if(U.ok)u.value=await U.json();else{const R=await U.json();p.value=R.error||"Failed to load package info"}}catch(U){console.error("Failed to fetch package info:",U),p.value=U instanceof Error?U.message:"Failed to load package info"}finally{i.value=!1}},L=async()=>{h.value=!0;try{const U=await fetch(Ve("/api/pack/npm-token-status"));U.ok&&(k.value=await U.json())}catch(U){console.error("Failed to fetch npm token status:",U)}finally{h.value=!1}};Ee(()=>a.modelValue,U=>{U&&(y.value="",_.value="default",v.value="",d.value=!1,c.value=null,f.value=null,$.value=null,N.value=null,k.value=null,u.value=null,p.value=null,x.value=!1,E(),L())});const V=U=>k.value?.hasToken?null:!U||U.trim().length===0?"npm token is required":U.trim().length<10?"Token appears to be too short":null,A=U=>{if(!U)return null;try{return new URL(U).protocol!=="https:"?"Registry must use HTTPS":null}catch{return"Invalid URL format"}};Ee(y,U=>{U&&($.value=V(U))}),Ee(v,U=>{_.value==="custom"&&U&&(N.value=A(U))}),Ee(_,U=>{U==="default"?N.value=null:v.value&&(N.value=A(v.value))});const G=q(()=>_.value==="default"?Ov:v.value),ee=q(()=>{const U=k.value?.hasToken||!V(y.value),R=_.value==="default"||!A(v.value);return U&&R}),ie=async()=>{if(k.value?.hasToken||($.value=V(y.value)),_.value==="custom"&&(N.value=A(v.value)),!($.value||N.value)){b.value=!0,c.value=null,f.value=null;try{const U={registry:G.value,dryRun:d.value};y.value.trim()&&(U.token=y.value.trim());const R=await fetch(Ve(`/api/pack/${encodeURIComponent(a.packageId)}/publish`),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(U)}),K=await R.json();if(!R.ok){c.value=K.error||"Failed to publish package",K.output&&(c.value+=`
34
+ Description...`},null,512),[[yt,d.value]])])):(r(),o("div",{key:1,class:"prose prose-sm dark:prose-invert max-w-none p-4 rounded-md border border-neutral-200 dark:border-neutral-700 bg-white dark:bg-neutral-800 min-h-[200px] max-h-[400px] overflow-y-auto",innerHTML:P.value},null,8,Wm))])):S("",!0)])])]),U[14]||(U[14]=t("hr",{class:"border-neutral-200 dark:border-neutral-700"},null,-1)),t("div",Km,[U[13]||(U[13]=t("h3",{class:"text-sm font-semibold text-neutral-700 dark:text-neutral-300 uppercase tracking-wider"}," Items to Include ",-1)),k(I(ot),{variant:"info"},{default:W(()=>[...U[12]||(U[12]=[t("div",{class:"space-y-1"},[t("p",null,[t("strong",null,"Extract"),ve(": Moves the file into the package and removes it from your workspace. Use this for items only used by this agent. ")]),t("p",null,[t("strong",null,"Copy"),ve(": Copies the file into the package but keeps the original. Required for items shared with other agents. ")])],-1)])]),_:1}),h.value?(r(),Y(I(ot),{key:0,variant:"error"},{default:W(()=>[ve(C(h.value),1)]),_:1})):S("",!0),i.value.warnings.length>0?(r(),Y(I(ot),{key:1,variant:"warning"},{default:W(()=>[t("ul",Jm,[(r(!0),o($e,null,Le(i.value.warnings,K=>(r(),o("li",{key:K},C(K),1))),128))])]),_:1})):S("",!0),t("div",Gm,[k(Mm,{analysis:i.value,selections:V.value,"onUpdate:selection":te},null,8,["analysis","selections"])])])])):S("",!0)]),_:1},8,["modelValue","title"]))}}),Xm={class:"font-mono text-sm"},Qm={class:"mb-3 text-xs text-neutral-500 dark:text-neutral-400"},ev={class:"flex items-center gap-2 py-1.5"},tv={class:"text-neutral-600 dark:text-neutral-400"},rv={key:0,class:"ml-auto text-xs text-amber-600 dark:text-amber-400"},av={key:1,class:"ml-auto text-xs text-emerald-600 dark:text-emerald-400"},nv={key:0,class:"text-center py-8 text-neutral-500 dark:text-neutral-400"},an=Se({name:"TreeChildren",props:{children:{type:Array,required:!0},getTypeColor:{type:Function,required:!0}},setup(e){return()=>e.children.length===0?null:tt("div",{class:"ml-4"},e.children.map((n,a)=>tt("div",{class:"relative",key:n.uid},[a<e.children.length-1?tt("div",{class:"absolute left-0 top-0 bottom-0 border-l border-neutral-300 dark:border-neutral-700"}):tt("div",{class:"absolute left-0 top-0 h-3 border-l border-neutral-300 dark:border-neutral-700"}),tt("div",{class:"absolute left-0 top-3 w-4 border-t border-neutral-300 dark:border-neutral-700"}),tt("div",{class:"pl-5"},[tt("div",{class:"flex items-center gap-2 py-1.5"},[tt("span",{class:"text-neutral-600 dark:text-neutral-400"},n.name),tt(Ut,{variant:e.getTypeColor(n.type),size:"sm"},()=>n.type),n.isDuplicate?null:n.existsGlobally?tt("span",{class:"ml-auto text-xs text-amber-600 dark:text-amber-400"},"already exists"):tt("span",{class:"ml-auto text-xs text-emerald-600 dark:text-emerald-400"},"will unpack")]),n.children.length>0?tt(an,{children:n.children,getTypeColor:e.getTypeColor}):null])])))}}),ov=Se({__name:"UnpackTree",props:{analysis:{}},setup(e){const n=e,a=F(()=>{const i=n.analysis,c=[];let f=0;for(const g of i.items)c.push({...g,uid:`${g.type}:${g.name}:${f++}`});const h=new Map,x=[];for(const g of c)g.parentKey?(h.has(g.parentKey)||h.set(g.parentKey,[]),h.get(g.parentKey).push(g)):x.push(g);const b=new Set,y=g=>{const d=`${g.type}:${g.name}`,w=b.has(d);b.add(d);const m=[],v=h.get(d)||[];for(const _ of v)m.push(y(_));return{name:g.name,type:g.type,existsGlobally:g.existsGlobally,action:g.action,children:m,uid:g.uid,isDuplicate:w}},$=[];for(const g of x)g.type==="agent"&&$.push(y(g));if($.length===0)for(const g of x)$.push(y(g));return $}),s=i=>{switch(i){case"agent":return"accent";case"prompt":return"secondary";case"tool":return"success";case"model":return"warning";case"hook":return"default"}},l=F(()=>{const i=new Set;for(const c of n.analysis.items)i.add(`${c.type}:${c.name}`);return i.size}),u=F(()=>{const i=new Set;let c=0;for(const f of n.analysis.items){const h=`${f.type}:${f.name}`;i.has(h)||(i.add(h),f.existsGlobally||c++)}return c});return(i,c)=>(r(),o("div",Xm,[t("div",Qm,C(u.value)+" of "+C(l.value)+" items will be unpacked ",1),(r(!0),o($e,null,Le(a.value,f=>(r(),o("div",{key:f.uid},[t("div",ev,[t("span",tv,C(f.name),1),k(I(Ut),{variant:s(f.type),size:"sm"},{default:W(()=>[ve(C(f.type),1)]),_:2},1032,["variant"]),f.existsGlobally?(r(),o("span",rv," already exists ")):(r(),o("span",av," will unpack "))]),(r(),Y(rt(I(an)),{children:f.children,"get-type-color":s},null,8,["children"]))]))),128)),a.value.length===0?(r(),o("div",nv," No items found in this package. ")):S("",!0)]))}}),lv={key:0,class:"flex items-center justify-center py-12"},sv={key:1,class:"py-4"},iv={key:2,class:"py-4"},uv={class:"space-y-2"},dv={class:"text-sm opacity-80"},cv={key:0,class:"text-sm opacity-80"},pv={key:1,class:"text-sm opacity-80"},mv={key:3,class:"space-y-4"},vv={class:"text-sm text-neutral-600 dark:text-neutral-400"},fv={class:"font-mono"},gv={class:"list-disc list-inside space-y-1"},hv={class:"border border-neutral-200 dark:border-neutral-700 rounded-lg p-4 bg-neutral-50 dark:bg-neutral-900/50 max-h-80 overflow-y-auto"},bv={key:2,class:"flex items-center gap-2"},xv={class:"flex items-center gap-2 cursor-pointer"},yv={class:"flex justify-between"},kv=Se({__name:"UnpackModal",props:{modelValue:{type:Boolean},agent:{}},emits:["update:modelValue","unpacked"],setup(e,{emit:n}){const a=e,s=n,l=F({get:()=>a.modelValue,set:w=>s("update:modelValue",w)}),u=p(null),i=p(!1),c=p(!1),f=p(null),h=p(null),x=p(!1);Ve(()=>a.modelValue,async w=>{w&&a.agent?.packageId?await b():(u.value=null,f.value=null,h.value=null,x.value=!1)});const b=async()=>{if(a.agent?.packageId){i.value=!0,f.value=null;try{const w=await fetch(ze(`/api/unpack/${encodeURIComponent(a.agent.packageId)}/analyze`)),m=await w.json();if(!w.ok){f.value=m.error||"Failed to analyze package";return}u.value=m}catch(w){f.value=w instanceof Error?w.message:"Failed to analyze package"}finally{i.value=!1}}},y=async()=>{if(!(!a.agent?.packageId||!u.value)){c.value=!0,f.value=null,h.value=null;try{const w=u.value.items.filter((_,P,V)=>V.findIndex(E=>E.type===_.type&&E.name===_.name)===P).map(_=>({name:_.name,type:_.type,action:_.existsGlobally?"skip":"generate"})),m=await fetch(ze(`/api/unpack/${encodeURIComponent(a.agent.packageId)}`),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({itemSelections:w,deletePackage:x.value})}),v=await m.json();if(!m.ok){f.value=v.error||"Failed to unpack agent";return}h.value={success:!0,filesGenerated:v.filesGenerated,filesSkipped:v.filesSkipped,packageDeleted:v.packageDeleted},setTimeout(()=>{s("unpacked")},1500)}catch(w){f.value=w instanceof Error?w.message:"Failed to unpack agent"}finally{c.value=!1}}},$=()=>{l.value=!1},g=F(()=>{if(!u.value)return 0;const w=new Set;let m=0;for(const v of u.value.items){const _=`${v.type}:${v.name}`;w.has(_)||(w.add(_),v.existsGlobally||m++)}return m}),d=F(()=>u.value?.source==="local");return(w,m)=>(r(),Y(dt,{modelValue:l.value,"onUpdate:modelValue":m[1]||(m[1]=v=>l.value=v),title:`Unpack: ${e.agent?.title||e.agent?.id||""}`,width:"max-w-2xl","min-height":"min-h-[20rem]"},{footer:W(()=>[t("div",yv,[k(I(Qe),{variant:"ghost",onClick:$},{default:W(()=>[...m[6]||(m[6]=[ve(" Cancel ",-1)])]),_:1}),k(I(Qe),{variant:"primary",disabled:i.value||c.value||!u.value||h.value?.success||g.value===0,onClick:y},{default:W(()=>[c.value?(r(),o($e,{key:0},[k(Be,{size:"sm",class:"mr-2"}),m[7]||(m[7]=ve(" Unpacking... ",-1))],64)):(r(),o($e,{key:1},[ve(" Unpack "+C(g.value)+" "+C(g.value===1?"item":"items"),1)],64))]),_:1},8,["disabled"])])]),default:W(()=>[i.value?(r(),o("div",lv,[k(Be,{size:"lg"})])):f.value&&!u.value?(r(),o("div",sv,[k(I(ot),{variant:"error"},{default:W(()=>[ve(C(f.value),1)]),_:1})])):h.value?.success?(r(),o("div",iv,[k(I(ot),{variant:"success"},{default:W(()=>[t("div",uv,[m[2]||(m[2]=t("p",{class:"font-medium"},"Agent unpacked successfully!",-1)),t("p",dv,C(h.value.filesGenerated?.length||0)+" files unpacked ",1),(h.value.filesSkipped?.length||0)>0?(r(),o("p",cv,C(h.value.filesSkipped?.length)+" files skipped (already exist) ",1)):S("",!0),h.value.packageDeleted?(r(),o("p",pv," Package was deleted from agents/packed/ ")):S("",!0)])]),_:1})])):u.value?(r(),o("div",mv,[t("div",vv,[t("p",null,[m[3]||(m[3]=ve("Package: ",-1)),t("span",fv,C(u.value.packageId),1),ve(" v"+C(u.value.version),1)]),t("p",null,"Source: "+C(u.value.source==="npm"?"npm package":"local (agents/packed/)"),1)]),f.value?(r(),Y(I(ot),{key:0,variant:"error"},{default:W(()=>[ve(C(f.value),1)]),_:1})):S("",!0),u.value.warnings.length>0?(r(),Y(I(ot),{key:1,variant:"warning"},{default:W(()=>[t("ul",gv,[(r(!0),o($e,null,Le(u.value.warnings,v=>(r(),o("li",{key:v},C(v),1))),128))])]),_:1})):S("",!0),t("div",hv,[k(ov,{analysis:u.value},null,8,["analysis"])]),d.value?(r(),o("div",bv,[t("label",xv,[Je(t("input",{"onUpdate:modelValue":m[0]||(m[0]=v=>x.value=v),type:"checkbox",class:"w-4 h-4 rounded border-neutral-300 dark:border-neutral-600 text-primary-600 focus:ring-primary-500"},null,512),[[Lr,x.value]]),m[4]||(m[4]=t("span",{class:"text-sm text-neutral-700 dark:text-neutral-300"},"Delete package after unpacking",-1))]),m[5]||(m[5]=t("span",{class:"text-xs text-neutral-500"},"(removes from agents/packed/)",-1))])):S("",!0)])):S("",!0)]),_:1},8,["modelValue","title"]))}}),wv={key:0,class:"space-y-4"},_v={class:"space-y-2"},$v={class:"font-medium"},Cv={key:0,class:"text-sm opacity-80"},Sv={key:1,class:"text-sm opacity-70"},Iv={key:2,class:"text-sm"},Tv=["href"],Mv={key:0,class:"space-y-2"},zv={class:"text-xs bg-neutral-100 dark:bg-neutral-800 p-3 rounded-md overflow-x-auto max-h-40 whitespace-pre-wrap"},Vv={key:1,class:"space-y-4"},Ev={class:"space-y-3"},Lv={key:0,class:"flex items-center gap-2 text-neutral-500"},Av={key:2,class:"p-4 rounded-lg border border-neutral-200 dark:border-neutral-700 bg-neutral-50 dark:bg-neutral-900/50"},Pv={class:"flex items-center gap-3 mb-3"},Ov={class:"text-lg font-semibold text-neutral-900 dark:text-neutral-100"},Rv={key:0,class:"text-sm text-neutral-600 dark:text-neutral-400 mb-3"},jv={key:1,class:"mt-3"},Dv=["innerHTML"],Uv={key:0,class:"border-neutral-200 dark:border-neutral-700"},Bv={key:1,class:"flex items-center gap-2 text-neutral-500"},Nv={class:"space-y-2 text-sm"},qv={class:"bg-neutral-200 dark:bg-neutral-700 px-1 rounded"},Fv={class:"list-decimal list-inside space-y-1 ml-2"},Hv={class:"whitespace-pre-wrap text-sm"},Wv={class:"space-y-2"},Kv={class:"flex items-center gap-4"},Jv={class:"flex items-center gap-2 cursor-pointer"},Gv={class:"flex items-center gap-2 cursor-pointer"},Yv={key:0},Zv={key:0,class:"mt-1 text-xs text-red-500"},Xv={class:"flex items-center gap-2 cursor-pointer"},Qv={class:"flex justify-between"},ef="https://registry.npmjs.org",tf=Se({__name:"PublishModal",props:{modelValue:{type:Boolean},packageId:{},outputPath:{}},emits:["update:modelValue","published"],setup(e,{emit:n}){ir.setOptions({gfm:!0,breaks:!0});const a=e,s=n,l=F({get:()=>a.modelValue,set:q=>s("update:modelValue",q)}),u=p(null),i=p(!1),c=p(null),f=p(!1),h=p(null),x=p(!1),b=F(()=>u.value?.readme?ir(u.value.readme):""),y=p(""),$=p("default"),g=p(""),d=p(!1),w=p(!1),m=p(null),v=p(null),_=p(null),P=p(null),V=async()=>{i.value=!0,c.value=null;try{const q=await fetch(ze(`/api/pack/${encodeURIComponent(a.packageId)}/packed-info`));if(q.ok)u.value=await q.json();else{const j=await q.json();c.value=j.error||"Failed to load package info"}}catch(q){console.error("Failed to fetch package info:",q),c.value=q instanceof Error?q.message:"Failed to load package info"}finally{i.value=!1}},E=async()=>{x.value=!0;try{const q=await fetch(ze("/api/pack/npm-token-status"));q.ok&&(h.value=await q.json())}catch(q){console.error("Failed to fetch npm token status:",q)}finally{x.value=!1}};Ve(()=>a.modelValue,q=>{q&&(y.value="",$.value="default",g.value="",d.value=!1,m.value=null,v.value=null,_.value=null,P.value=null,h.value=null,u.value=null,c.value=null,f.value=!1,V(),E())});const z=q=>h.value?.hasToken?null:!q||q.trim().length===0?"npm token is required":q.trim().length<10?"Token appears to be too short":null,A=q=>{if(!q)return null;try{return new URL(q).protocol!=="https:"?"Registry must use HTTPS":null}catch{return"Invalid URL format"}};Ve(y,q=>{q&&(_.value=z(q))}),Ve(g,q=>{$.value==="custom"&&q&&(P.value=A(q))}),Ve($,q=>{q==="default"?P.value=null:g.value&&(P.value=A(g.value))});const oe=F(()=>$.value==="default"?ef:g.value),ne=F(()=>{const q=h.value?.hasToken||!z(y.value),j=$.value==="default"||!A(g.value);return q&&j}),fe=async()=>{if(h.value?.hasToken||(_.value=z(y.value)),$.value==="custom"&&(P.value=A(g.value)),!(_.value||P.value)){w.value=!0,m.value=null,v.value=null;try{const q={registry:oe.value,dryRun:d.value};y.value.trim()&&(q.token=y.value.trim());const j=await fetch(ze(`/api/pack/${encodeURIComponent(a.packageId)}/publish`),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(q)}),J=await j.json();if(!j.ok){m.value=J.error||"Failed to publish package",J.output&&(m.value+=`
35
35
 
36
- `+K.output);return}f.value={success:!0,packageName:K.packageName,version:K.version,output:K.output,url:K.url,tokenSource:K.tokenSource},d.value||s("published",{packageName:K.packageName,version:K.version,url:K.url})}catch(U){c.value=U instanceof Error?U.message:"Failed to publish package"}finally{b.value=!1}}},be=()=>{l.value=!1},Q=()=>d.value?"Dry run completed successfully!":"Package published successfully!";return(U,R)=>(r(),J(st,{modelValue:l.value,"onUpdate:modelValue":R[6]||(R[6]=K=>l.value=K),title:"Publish to npm",width:"max-w-lg","min-height":"min-h-[16rem]"},{footer:F(()=>[e("div",Rv,[w(I(Je),{variant:"ghost",onClick:be},{default:F(()=>[de(C(f.value?.success?"Close":"Cancel"),1)]),_:1}),f.value?.success?S("",!0):(r(),J(I(Je),{key:0,variant:"primary",disabled:b.value||h.value||!ee.value,onClick:ie},{default:F(()=>[b.value?(r(),o(we,{key:0},[w(Be,{size:"sm",class:"mr-2"}),R[22]||(R[22]=de(" Publishing... ",-1))],64)):(r(),o(we,{key:1},[de(C(d.value?"Validate":"Publish"),1)],64))]),_:1},8,["disabled"]))])]),default:F(()=>[f.value?.success?(r(),o("div",lv,[w(I(at),{variant:d.value?"info":"success"},{default:F(()=>[e("div",sv,[e("p",iv,C(Q()),1),f.value.packageName?(r(),o("p",uv," Package: "+C(f.value.packageName)+"@"+C(f.value.version),1)):S("",!0),f.value.tokenSource==="environment"?(r(),o("p",dv," Token: from NPM_TOKEN environment variable ")):S("",!0),f.value.url&&!d.value?(r(),o("p",cv,[e("a",{href:f.value.url,target:"_blank",rel:"noopener noreferrer",class:"text-primary-600 dark:text-primary-400 hover:underline"}," View on npm ",8,pv)])):S("",!0)])]),_:1},8,["variant"]),f.value.output?(r(),o("div",mv,[R[7]||(R[7]=e("p",{class:"text-sm font-medium text-neutral-700 dark:text-neutral-300"},"Output:",-1)),e("pre",vv,C(f.value.output),1)])):S("",!0)])):(r(),o("div",fv,[e("div",gv,[i.value?(r(),o("div",hv,[w(Be,{size:"sm"}),R[8]||(R[8]=e("span",{class:"text-sm"},"Loading package info...",-1))])):p.value?(r(),J(I(at),{key:1,variant:"error"},{default:F(()=>[de(C(p.value),1)]),_:1})):u.value?(r(),o("div",bv,[e("div",xv,[e("h3",yv,C(u.value.packageName),1),w(I(Pt),{variant:"secondary"},{default:F(()=>[de("v"+C(u.value.version),1)]),_:1}),u.value.license?(r(),J(I(Pt),{key:0,variant:"default"},{default:F(()=>[de(C(u.value.license),1)]),_:1})):S("",!0)]),u.value.author?(r(),o("p",kv," by "+C(u.value.author),1)):S("",!0),u.value.readme?(r(),o("div",wv,[e("button",{type:"button",class:"flex items-center gap-2 text-sm font-medium text-neutral-600 dark:text-neutral-400 hover:text-neutral-800 dark:hover:text-neutral-200",onClick:R[0]||(R[0]=K=>x.value=!x.value)},[(r(),J(Qe(x.value?I(gt):I(_t)),{class:"w-4 h-4"})),R[9]||(R[9]=de(" README ",-1))]),x.value?(r(),o("div",{key:0,class:"mt-2 prose prose-sm dark:prose-invert max-w-none p-3 rounded-md border border-neutral-200 dark:border-neutral-700 bg-white dark:bg-neutral-800 max-h-[200px] overflow-y-auto",innerHTML:g.value},null,8,_v)):S("",!0)])):S("",!0)])):S("",!0)]),u.value?(r(),o("hr",$v)):S("",!0),h.value?(r(),o("div",Cv,[w(Be,{size:"sm"}),R[10]||(R[10]=e("span",{class:"text-sm"},"Checking npm token configuration...",-1))])):k.value?.hasToken?(r(),J(I(at),{key:2,variant:"success"},{default:F(()=>[...R[11]||(R[11]=[e("p",{class:"text-sm"},[e("strong",null,"NPM_TOKEN found"),de(" in your environment. Your token will be used automatically. ")],-1)])]),_:1})):k.value&&!k.value.hasToken?(r(),J(I(at),{key:3,variant:"warning"},{default:F(()=>[e("div",Sv,[R[17]||(R[17]=e("p",null,[e("strong",null,"No NPM_TOKEN configured.")],-1)),e("p",null,[R[12]||(R[12]=de("To publish packages, create an npm token and add it to your ",-1)),e("code",Iv,C(k.value.envFile),1),R[13]||(R[13]=de(" file:",-1))]),e("ol",Tv,[R[15]||(R[15]=e("li",null,[de("Run: "),e("code",{class:"bg-neutral-200 dark:bg-neutral-700 px-1 rounded"},"npm token create")],-1)),e("li",null,[de("Add to "+C(k.value.envFile)+": ",1),R[14]||(R[14]=e("code",{class:"bg-neutral-200 dark:bg-neutral-700 px-1 rounded"},"NPM_TOKEN=npm_xxxxx",-1))]),R[16]||(R[16]=e("li",null,"Restart the dev server",-1))]),R[18]||(R[18]=e("p",{class:"pt-2"},"Or enter a token below for this session only:",-1))])]),_:1})):S("",!0),c.value?(r(),J(I(at),{key:4,variant:"error"},{default:F(()=>[e("pre",Mv,C(c.value),1)]),_:1})):S("",!0),!k.value?.hasToken&&!h.value?(r(),J(I(Vt),{key:5,label:"npm Token",error:$.value||void 0,"help-text":"Create a token at npmjs.com/settings/tokens",required:!k.value?.hasToken},{default:F(()=>[He(e("input",{"onUpdate:modelValue":R[1]||(R[1]=K=>y.value=K),type:"password",autocomplete:"off",class:ce(["w-full px-3 py-2 rounded-md border text-sm font-mono bg-white dark:bg-neutral-800 border-neutral-300 dark:border-neutral-600 text-neutral-900 dark:text-neutral-100 placeholder-neutral-400 dark:placeholder-neutral-500 focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-transparent",{"border-red-500 dark:border-red-500":$.value}]),placeholder:"npm_xxxxxxxxxxxx"},null,2),[[ht,y.value]])]),_:1},8,["error","required"])):S("",!0),w(I(Vt),{label:"Registry"},{default:F(()=>[e("div",zv,[e("div",Vv,[e("label",Ev,[He(e("input",{"onUpdate:modelValue":R[2]||(R[2]=K=>_.value=K),type:"radio",value:"default",class:"text-primary-500 focus:ring-primary-500"},null,512),[[Pr,_.value]]),R[19]||(R[19]=e("span",{class:"text-sm text-neutral-700 dark:text-neutral-300"},"npm (default)",-1))]),e("label",Lv,[He(e("input",{"onUpdate:modelValue":R[3]||(R[3]=K=>_.value=K),type:"radio",value:"custom",class:"text-primary-500 focus:ring-primary-500"},null,512),[[Pr,_.value]]),R[20]||(R[20]=e("span",{class:"text-sm text-neutral-700 dark:text-neutral-300"},"Custom registry",-1))])]),_.value==="custom"?(r(),o("div",Av,[He(e("input",{"onUpdate:modelValue":R[4]||(R[4]=K=>v.value=K),type:"url",class:ce(["w-full px-3 py-2 rounded-md border text-sm bg-white dark:bg-neutral-800 border-neutral-300 dark:border-neutral-600 text-neutral-900 dark:text-neutral-100 placeholder-neutral-400 dark:placeholder-neutral-500 focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-transparent",{"border-red-500 dark:border-red-500":N.value}]),placeholder:"https://registry.example.com"},null,2),[[ht,v.value]]),N.value?(r(),o("p",Pv,C(N.value),1)):S("",!0)])):S("",!0)])]),_:1}),e("label",jv,[He(e("input",{"onUpdate:modelValue":R[5]||(R[5]=K=>d.value=K),type:"checkbox",class:"rounded text-primary-500 focus:ring-primary-500"},null,512),[[Ir,d.value]]),R[21]||(R[21]=e("span",{class:"text-sm text-neutral-700 dark:text-neutral-300"}," Dry run (validate without publishing) ",-1))])]))]),_:1},8,["modelValue"]))}});function Bt(t,n=0){if(!t||n>4||typeof t!="object")return null;const a=t;return typeof a.clearErrors=="function"&&typeof a.setErrors=="function"?t:"value"in a?Bt(a.value,n+1):"node"in a?Bt(a.node,n+1):"formNode"in a?Bt(a.formNode,n+1):null}function Ft(t,n){const a=Bt(n);return a?(a.clearErrors(!0),t.fieldErrors&&Object.keys(t.fieldErrors).length>0?(a.setErrors([],t.fieldErrors),!0):t.error?(a.setErrors([t.error]),!0):!1):!1}function Uv(t){Bt(t)?.clearErrors(!0)}const Bv={},Nv={class:"p-8 w-full max-w-7xl mx-auto"};function qv(t,n){return r(),o("div",Nv,[We(t.$slots,"default")])}const Et=ct(Bv,[["render",qv]]),Fv={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Hv(t,n){return r(),o("svg",Fv,[...n[0]||(n[0]=[e("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M5 12h14m-7-7v14"},null,-1)])])}const cr=De({name:"lucide-plus",render:Hv}),Wv={key:0,class:"mb-5 rounded-lg border border-amber-200 dark:border-amber-800 bg-amber-50 dark:bg-amber-950/30 px-4 py-3 text-sm text-amber-800 dark:text-amber-200"},Kv=Ce({__name:"AgentsView",setup(t){const n=Ot(),a=Tt(),s=dr(),l=m(!1),u=m("add"),i=m(null),p=m(null),x=m(null),k=m(null),h=m(!1),g=m(null),y=m(!1),_=m(null),v=m(!1),d=m(null);Ee(()=>a.query.refresh,()=>{a.query.refresh&&(p.value?.refresh(),n.replace({path:"/agents",query:{}}))});const b=()=>{u.value="add",i.value=null,k.value=null,l.value=!0},c=G=>{u.value="edit",i.value=G,k.value=null,l.value=!0},f=async G=>{k.value=null;try{const ee=u.value==="edit"&&i.value?.id,{originalName:ie,...be}=G,Q=Ve(ee?`/api/agents/${encodeURIComponent(i.value.id)}`:"/api/agents"),R=await fetch(Q,{method:ee?"PUT":"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(be)});if(R.ok)p.value?.refresh(),l.value=!1,i.value=null;else{const K=await R.json();Ft(K,x.value?.formNode)||(k.value=K.error||`Failed to ${ee?"update":"create"} agent`)}}catch(ee){console.error(`Error ${u.value==="edit"?"updating":"creating"} agent:`,ee),k.value=`Failed to ${u.value==="edit"?"update":"create"} agent`}},$=G=>{g.value=G,h.value=!0},N=()=>{h.value=!1,g.value=null,p.value?.refresh()},E=G=>{_.value=G,y.value=!0},L=()=>{y.value=!1,_.value=null,p.value?.refresh()},V=G=>{d.value=G,v.value=!0},A=()=>{v.value=!1,d.value=null};return(G,ee)=>(r(),J(Et,null,{default:F(()=>[I(s)?S("",!0):(r(),o("div",Wv," Configuration is read-only in production. To make changes, edit your configuration files locally and deploy. ")),w(Qp,{ref_key:"dataTableRef",ref:p,title:"Agents",description:"Configure and manage your AI agents.","primary-action":I(s)?{label:"Create Agent",icon:I(cr),handler:b}:void 0,readonly:!I(s),onAdd:b,onEdit:c,onPack:$,onUnpack:E,onPublish:V},null,8,["primary-action","readonly"]),w(im,{ref_key:"agentModalRef",ref:x,modelValue:l.value,"onUpdate:modelValue":ee[0]||(ee[0]=ie=>l.value=ie),mode:u.value,editAgent:i.value,apiError:k.value,readonly:!I(s),onSave:f},null,8,["modelValue","mode","editAgent","apiError","readonly"]),I(s)?(r(),o(we,{key:1},[w(Pm,{modelValue:h.value,"onUpdate:modelValue":ee[1]||(ee[1]=ie=>h.value=ie),agent:g.value,onPacked:N},null,8,["modelValue","agent"]),w(ov,{modelValue:y.value,"onUpdate:modelValue":ee[2]||(ee[2]=ie=>y.value=ie),agent:_.value,onUnpacked:L},null,8,["modelValue","agent"]),w(Dv,{modelValue:v.value,"onUpdate:modelValue":ee[3]||(ee[3]=ie=>v.value=ie),"package-id":d.value?.packageId??"","output-path":"agents/packed/"+(d.value?.packageId??""),onPublished:A},null,8,["modelValue","package-id","output-path"])],64)):S("",!0)]),_:1}))}});function Jv(t){const{limit:n=50,offset:a=0,agentId:s=null,userId:l=null,search:u=null,startDate:i=null,endDate:p=null,autoFetch:x=!0}=t||{},k=q(()=>{const $=new URLSearchParams,N=typeof n=="number"?n:n.value,E=typeof a=="number"?a:a.value,L=typeof s=="string"?s:s?.value,V=typeof l=="string"?l:l?.value,A=typeof u=="string"?u:u?.value,G=typeof i=="number"?i:i?.value,ee=typeof p=="number"?p:p?.value;return $.append("limit",N.toString()),$.append("offset",E.toString()),L&&$.append("agent_id",L),V&&$.append("user_id",V),A&&$.append("search",A),G&&$.append("startDate",G.toString()),ee&&$.append("endDate",ee.toString()),Ve(`/api/threads?${$.toString()}`)}),{data:h,error:g,isFetching:y,isFinished:_,execute:v,abort:d}=ot(k,{immediate:x,refetch:!0}).get().json(),b=q(()=>h.value?.threads||[]),c=q(()=>h.value?.total||0),f=q(()=>h.value?.hasMore||!1);return{threads:b,total:c,hasMore:f,error:g,isFetching:y,isFinished:_,refetch:v,abort:d}}function Vr(t){const n=q(()=>!!(typeof t=="string"?t:t?.value)),a=q(()=>{const h=typeof t=="string"?t:t?.value;return Ve(h?`/api/threads/${h}`:"/api/threads/placeholder")}),{data:s,error:l,isFetching:u,isFinished:i,execute:p,abort:x}=ot(a,{immediate:!1,refetch:!0}).get().json();return Ee(n,h=>{h&&p()},{immediate:!0}),{thread:q(()=>s.value?{id:s.value.thread.id,agent_id:s.value.thread.agent_id,user_id:s.value.thread.user_id,tags:s.value.thread.tags||[],parent:s.value.thread.parent??null,terminated:s.value.thread.terminated??null,created_at:s.value.thread.created_at,agent:s.value.agent||{id:"",title:"Unknown",type:"unknown"},stats:s.value.stats}:null),error:l,isFetching:u,isFinished:i,refetch:p,abort:x}}function Ga(){const t=Ve("/api/agents"),{data:n,error:a,isFetching:s,isFinished:l,execute:u}=ot(t,{immediate:!0}).get().json();return{agents:q(()=>n.value?.agents||[]),error:a,isFetching:s,isFinished:l,refetch:u}}function Gv(t){const{autoConnect:n=!0,onEvent:a}=t||{},s=m(null),l=m(!1),u=m(null);let i=0,p=null,x=null,k=!0;const h=3e4,g=3e4,y=()=>{p&&(clearTimeout(p),p=null),x&&(clearInterval(x),x=null)},_=()=>{x&&clearInterval(x),x=setInterval(()=>{s.value&&s.value.readyState===WebSocket.OPEN&&s.value.send("ping")},g)},v=()=>{if(!k)return;const f=Math.min(1e3*Math.pow(2,i),h);i++,console.log(`[AgentBuilderEvents] Scheduling reconnect in ${f}ms (attempt ${i})`),p=setTimeout(()=>{k&&d()},f)},d=()=>{s.value&&s.value.close();const f=window.location.protocol==="https:"?"wss:":"ws:",$=window.location.host;let N=`${f}//${$}${Ve("/api/events")}`;const E=localStorage.getItem("auth_token");E&&(N+=`?token=${encodeURIComponent(E)}`);try{s.value=new WebSocket(N),s.value.onopen=()=>{l.value=!0,u.value=null,i=0,_(),console.log("[AgentBuilderEvents] WebSocket connected")},s.value.onmessage=L=>{try{if(typeof L.data=="string"&&L.data==="pong")return;const V=JSON.parse(L.data);a&&a(V)}catch(V){console.error("[AgentBuilderEvents] Failed to parse WebSocket message:",V)}},s.value.onerror=L=>{u.value="WebSocket connection error",console.error("[AgentBuilderEvents] WebSocket error:",L)},s.value.onclose=()=>{l.value=!1,y(),console.log("[AgentBuilderEvents] WebSocket disconnected"),v()}}catch(L){u.value=L.message||"Failed to create WebSocket",console.error("[AgentBuilderEvents] WebSocket creation error:",L),v()}},b=()=>{k=!0,i=0,d()},c=()=>{k=!1,y(),s.value&&(s.value.close(),s.value=null),l.value=!1,i=0};return n&&b(),ut(()=>{c()}),{wsConnected:l,wsError:u,connect:b,disconnect:c}}function Yv(t){const a=Date.now()*1e3-t,s=Math.floor(a/1e6);if(s<60)return s===1?"1 second ago":`${s} seconds ago`;const l=Math.floor(s/60);if(l<60)return l===1?"1 minute ago":`${l} minutes ago`;const u=Math.floor(l/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 x=Math.floor(p/12);return x===1?"1 year ago":`${x} years ago`}function Zv(t){const n=m("");let a=null;const s=()=>typeof t=="function"?t():typeof t=="number"?t:t.value,l=()=>{const u=s();n.value=Yv(u);const p=Date.now()*1e3-u,x=Math.floor(p/1e6);a!==null&&(clearInterval(a),a=null),x<60?a=setInterval(l,1e3):x<3600?a=setInterval(l,6e4):x<86400&&(a=setInterval(l,6e5))};return l(),ut(()=>{a!==null&&clearInterval(a)}),n}const Nt=Ce({__name:"TimeAgo",props:{timestamp:{}},setup(t){const n=t,a=Zv(()=>n.timestamp);return(s,l)=>(r(),o("span",null,C(I(a)),1))}}),Xv={class:"relative inline-flex items-center"},Qv={key:0,class:"inline-block w-2 h-2 rounded-full bg-green-500 dark:bg-green-400"},ef={key:1,class:"inline-block w-2 h-2 rounded-full bg-neutral-400 dark:bg-neutral-600"},tf={key:0},rf={key:1},Er=Ce({__name:"StatusDot",props:{connected:{type:Boolean},error:{type:Boolean}},setup(t){const n=m(!1),a=m(null);return(s,l)=>(r(),o("div",Xv,[e("span",{class:"p-0.5 cursor-default outline-none",tabindex:"-1",onMouseenter:l[0]||(l[0]=u=>n.value=!0),onMouseleave:l[1]||(l[1]=u=>n.value=!1)},[t.connected?(r(),o("span",Qv)):(r(),o("span",ef))],32),w(bt,{"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:F(()=>[n.value?(r(),o("div",{key:0,ref_key:"popoverRef",ref:a,class:ce(["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-neutral-50 dark:bg-neutral-900 border-neutral-200 dark:border-neutral-700 text-neutral-600 dark:text-neutral-400":!t.connected}])},[t.connected?(r(),o("span",tf,"Live - Connected")):(r(),o("span",rf,"Offline"))],2)):S("",!0)]),_:1})]))}}),af={class:"relative min-w-0"},nf={class:"truncate flex-1 text-left"},of={key:0},lf=["onClick"],sf={class:"border-t border-neutral-200 dark:border-neutral-700"},uf={class:"flex items-center justify-between"},df={class:"space-y-4 date-filter-inputs"},cf=Ce({__name:"DateFilterDropdown",props:{startDate:{},endDate:{}},emits:["update:startDate","update:endDate"],setup(t,{emit:n}){const a=t,s=n,l=m(!1),u=m(!1),i=m(null),p=m(null),x=m(""),k=m(""),h=[{label:"All time",value:"all",getRange:()=>({startDate:null,endDate:null})},{label:"Today",value:"today",getRange:()=>{const V=new Date,A=new Date(V.getFullYear(),V.getMonth(),V.getDate());return{startDate:Math.floor(A.getTime()/1e3),endDate:null}}},{label:"Last 3 days",value:"3days",getRange:()=>{const V=new Date,A=new Date(V.getFullYear(),V.getMonth(),V.getDate()-2);return{startDate:Math.floor(A.getTime()/1e3),endDate:null}}},{label:"Last 7 days",value:"7days",getRange:()=>{const V=new Date,A=new Date(V.getFullYear(),V.getMonth(),V.getDate()-6);return{startDate:Math.floor(A.getTime()/1e3),endDate:null}}},{label:"Last 30 days",value:"30days",getRange:()=>{const V=new Date,A=new Date(V.getFullYear(),V.getMonth(),V.getDate()-29);return{startDate:Math.floor(A.getTime()/1e3),endDate:null}}}],g=q(()=>{if(!a.startDate&&!a.endDate)return"all";for(const V of h){const A=V.getRange();if(A.startDate===a.startDate&&A.endDate===a.endDate)return V.value}return"custom"}),y=q(()=>{if(!a.startDate&&!a.endDate)return"All time";const V=h.find(G=>G.value===g.value);if(V&&g.value!=="custom")return V.label;const A=G=>new Date(G*1e3).toLocaleDateString("en-US",{month:"short",day:"numeric"});return a.startDate&&a.endDate?`${A(a.startDate)} - ${A(a.endDate)}`:a.startDate?`From ${A(a.startDate)}`:a.endDate?`Until ${A(a.endDate)}`:"Custom"}),_=q(()=>a.startDate!==null||a.endDate!==null);function v(){if(!i.value||!p.value)return;const V=i.value.getBoundingClientRect();p.value.style.position="fixed",p.value.style.top=`${V.bottom+8}px`,p.value.style.left=`${V.left}px`;const A=u.value?280:180;p.value.style.minWidth=`${V.width}px`,p.value.style.maxWidth=`${Math.max(V.width,A)}px`,p.value.style.width="auto",p.value.style.margin="0"}function d(){l.value?b():(l.value=!0,Ne(()=>{if(p.value&&(p.value.setAttribute("popover","auto"),p.value.addEventListener("toggle",c),"showPopover"in p.value))try{p.value.showPopover()}catch{}v()}))}function b(){if(p.value){if("hidePopover"in p.value)try{p.value.hidePopover()}catch{}p.value.removeEventListener("toggle",c)}l.value=!1,u.value=!1}function c(V){V.target===p.value&&(l.value=V.newState==="open",l.value&&v())}function f(V){const A=V.getRange();s("update:startDate",A.startDate),s("update:endDate",A.endDate),b()}function $(){const V=x.value?Math.floor(new Date(x.value).getTime()/1e3):null,A=k.value?Math.floor(new Date(k.value+"T23:59:59").getTime()/1e3):null;s("update:startDate",V),s("update:endDate",A),b()}function N(V){V.stopPropagation(),s("update:startDate",null),s("update:endDate",null)}const E=V=>{const A=V.target;p.value&&!p.value.contains(A)&&i.value&&!i.value.contains(A)&&b()},L=V=>{V.key==="Escape"&&l.value&&(b(),i.value?.focus())};return qe(()=>{document.addEventListener("click",E),document.addEventListener("keydown",L),window.addEventListener("resize",v),window.addEventListener("scroll",v,!0)}),ut(()=>{document.removeEventListener("click",E),document.removeEventListener("keydown",L),window.removeEventListener("resize",v),window.removeEventListener("scroll",v,!0)}),Ee(u,V=>{V&&(a.startDate&&(x.value=new Date(a.startDate*1e3).toISOString().split("T")[0]),a.endDate?k.value=new Date(a.endDate*1e3).toISOString().split("T")[0]:k.value=new Date().toISOString().split("T")[0]),Ne(v)}),(V,A)=>{const G=tt("FormKit");return r(),o("div",af,[e("button",{ref_key:"triggerRef",ref:i,type:"button",onClick:d,class:ce(["w-full flex items-center gap-1 px-2 py-1 text-xs rounded-sm border transition-colors min-w-0 focus:outline-none focus:ring-2 focus:ring-accent-500/30",[_.value?"border-accent-500 bg-accent-50 dark:bg-accent-950/50 text-accent-700 dark:text-accent-300":"border-zinc-300 dark:border-zinc-600 hover:border-accent-400 dark:hover:border-accent-500 bg-white dark:bg-transparent text-zinc-700 dark:text-zinc-300"]])},[w(I(mn),{size:14,class:"shrink-0 text-zinc-400"}),e("span",nf,C(y.value),1),_.value?(r(),J(I(Tr),{key:0,size:14,class:"shrink-0 text-zinc-400 hover:text-zinc-600 dark:hover:text-zinc-200",onClick:N})):(r(),J(I(gt),{key:1,size:14,class:ce(["shrink-0 text-zinc-400",l.value?"rotate-180":""])},null,8,["class"]))],2),l.value?(r(),o("div",{key:0,ref_key:"popoverRef",ref:p,class:"dropdown-popover z-[9999]"},[w(I(ur),{"max-height":u.value?void 0:"max-h-48",shadow:{offsetX:4,offsetY:4,intensity:.3}},{default:F(()=>[u.value?(r(),o("div",{key:1,class:"p-2.5 space-y-2.5",onClick:A[4]||(A[4]=Ge(()=>{},["stop"]))},[e("div",uf,[A[6]||(A[6]=e("span",{class:"text-xs font-medium"},"Custom range",-1)),e("button",{type:"button",onClick:A[1]||(A[1]=Ge(ee=>u.value=!1,["stop"])),class:"text-[10px] text-neutral-500 hover:text-black dark:hover:text-white"}," ← Back ")]),e("div",df,[w(G,{modelValue:x.value,"onUpdate:modelValue":A[2]||(A[2]=ee=>x.value=ee),type:"datepicker",label:"From","picker-only":"",popover:"",format:"MMM D, YYYY","value-format":"YYYY-MM-DD",sequence:["day"]},null,8,["modelValue"]),w(G,{modelValue:k.value,"onUpdate:modelValue":A[3]||(A[3]=ee=>k.value=ee),type:"datepicker",label:"To","picker-only":"",popover:"",format:"MMM D, YYYY","value-format":"YYYY-MM-DD",sequence:["day"]},null,8,["modelValue"])]),e("button",{type:"button",onClick:$,class:"w-full py-1.5 text-xs font-medium bg-black dark:bg-white text-white dark:text-black rounded-sm hover:opacity-90 transition-opacity"}," Apply ")])):(r(),o("div",of,[(r(),o(we,null,Ae(h,ee=>e("button",{key:ee.value,type:"button",onClick:ie=>f(ee),class:ce(["w-full px-2.5 py-1.5 text-left text-xs hover:bg-neutral-100 dark:hover:bg-neutral-800 transition-colors flex items-center gap-2",g.value===ee.value?"bg-accent-50 dark:bg-accent-950/30":""])},[e("span",{class:ce(["w-1.5 h-1.5 rounded-full border border-accent-500",g.value===ee.value?"bg-accent-500":""])},null,2),de(" "+C(ee.label),1)],10,lf)),64)),e("div",sf,[e("button",{type:"button",onClick:A[0]||(A[0]=Ge(ee=>u.value=!0,["stop"])),class:ce(["w-full px-2.5 py-1.5 text-left text-xs hover:bg-neutral-100 dark:hover:bg-neutral-800 transition-colors flex items-center gap-2",g.value==="custom"?"bg-accent-50 dark:bg-accent-950/30":""])},[e("span",{class:ce(["w-1.5 h-1.5 rounded-full border border-accent-500",g.value==="custom"?"bg-accent-500":""])},null,2),A[5]||(A[5]=de(" Custom range... ",-1))],2)])]))]),_:1},8,["max-height"])],512)):S("",!0)])}}}),pf=ct(cf,[["__scopeId","data-v-88032ecc"]]),mf={class:"flex flex-col flex-1 min-h-0 overflow-visible"},vf={class:"px-4 py-3 border-b border-neutral-300 dark:border-neutral-700"},ff={class:"flex items-center justify-between"},gf={class:"flex items-center gap-2"},hf={key:0,class:"text-xs font-mono text-neutral-500 dark:text-neutral-400"},bf={class:"flex items-center gap-2"},xf=["title"],yf={key:0,class:"absolute -top-1 -right-1 w-3.5 h-3.5 flex items-center justify-center text-[8px] font-bold font-mono bg-accent-500 text-white rounded-full"},kf={key:0,class:"bg-neutral-100 dark:bg-neutral-950 border-b border-neutral-200 dark:border-neutral-800"},wf={class:"p-2"},_f={class:"bg-white dark:bg-neutral-900 rounded-lg border border-neutral-200 dark:border-neutral-800 p-2.5 space-y-2"},$f={class:"flex items-center gap-2 w-full"},Cf={class:"flex-1 min-w-0"},Sf={key:0,class:"flex justify-end"},If={key:0,class:"p-4 flex justify-center"},Tf={key:1,class:"p-4 text-red-600 dark:text-red-400"},Mf={key:2,class:"text-neutral-500 dark:text-neutral-400 text-center py-12"},zf={key:1,class:"text-base"},Vf={key:3},Ef=["id","onClick"],Lf={class:"flex-shrink-0 text-neutral-400 dark:text-neutral-500 text-[10px]"},Af={key:0,class:"mb-1 text-[10px] text-neutral-400 dark:text-neutral-500 truncate"},Pf={key:1,class:"flex items-center gap-2"},jf={class:"text-[10px] text-neutral-400 dark:text-neutral-500 font-mono truncate max-w-[80px]"},Rf={key:0,class:"flex flex-wrap gap-1 flex-1 min-w-0"},Of={key:0,class:"text-[10px] text-neutral-400"},Df={key:2,class:"flex items-center gap-1"},Uf={key:0,class:"text-[10px] text-neutral-400"},Bf=["onClick"],Nf={class:"flex items-center gap-2"},qf={key:0,class:"p-3 flex justify-center"},Ff={key:1,class:"p-3 text-center text-[10px] text-neutral-400 dark:text-neutral-500"},Hf=50,Zr=1800,hr="name:",Wf=Ce({__name:"ThreadListPane",props:{selectedThreadId:{}},emits:["selectThread","collapse","createThread","threadsLoaded"],setup(t,{expose:n,emit:a}){const s=a,l=m(!1),u=m(""),i=m(null),p=m(null),x=m(null),k=m(null),{agents:h,isFetching:g}=Ga(),y=q(()=>h.value.map(Z=>({value:Z.name,label:Z.title||Z.name}))),_=m(0),v=m([]),d=m(!1),b=va(Z=>{i.value=Z||null},300);Ee(u,Z=>{b(Z)});const c=q(()=>{let Z=0;return i.value&&Z++,p.value&&Z++,(x.value||k.value)&&Z++,Z});function f(){u.value="",i.value=null,p.value=null,x.value=null,k.value=null}const{threads:$,total:N,hasMore:E,isFetching:L,isFinished:V,error:A,refetch:G}=Jv({limit:Hf,offset:_,search:i,agentId:p,startDate:x,endDate:k});Ee([i,p,x,k],()=>{_.value=0,v.value=[],d.value=!1}),Ee($,Z=>{if(_.value===0)v.value=[...Z];else{const oe=new Set(v.value.map($e=>$e.id)),Le=Z.filter($e=>!oe.has($e.id));v.value=[...v.value,...Le]}d.value=!1});const ee=m([]),ie=m(new Set),be=(Z,oe)=>oe.created_at-Z.created_at,Q=m({}),U=m({}),R=m({}),K=(Z,oe)=>`${Z}::${oe}`,H=Z=>Q.value[Z]??!1,ve=Z=>{Q.value[Z]=!H(Z)},X=Z=>{U.value[Z]=!0,setTimeout(()=>{delete U.value[Z]},Zr)},D=Z=>{R.value[Z]=!0,setTimeout(()=>{delete R.value[Z]},Zr)},W=Z=>U.value[Z]===!0,me=Z=>R.value[Z]===!0,ue=Z=>{const oe=Z.tags.find($e=>$e.startsWith(hr));if(!oe)return null;const Le=oe.slice(hr.length).trim();return Le.length>0?Le:null},te=Z=>Z.tags.filter(oe=>!oe.startsWith(hr)),Y=Z=>ue(Z)||Z.agent.title||Z.agent.name,ae=Z=>ue(Z)?Z.agent.title||Z.agent.name:null,ye=Z=>{if(p.value&&Z.agent_id!==p.value||x.value&&Z.created_at<x.value||k.value&&Z.created_at>k.value)return!1;if(i.value){const oe=i.value.toLowerCase(),Le=Z.id.toLowerCase().includes(oe),$e=Z.tags.some(Ye=>Ye.toLowerCase().includes(oe));if(!Le&&!$e)return!1}return!0},Te=Z=>{if(Z.length===0)return[];const oe=new Map(Z.map(Me=>[Me.id,Me])),Le=new Map,$e=[];for(const Me of Z){const Fe=Me.parent;if(Fe&&oe.has(Fe)){const Ze=Le.get(Fe)??[];Ze.push(Me),Le.set(Fe,Ze);continue}$e.push(Me)}$e.sort(be);for(const Me of Le.values())Me.sort(be);const Ye=[],et=new Set,Se=Me=>{if(et.has(Me.id))return;et.add(Me.id);const Fe=Le.get(Me.id);if(Fe)for(const Ze of Fe)Se(Ze)},xe=(Me,Fe,Ze)=>{if(et.has(Me.id))return;et.add(Me.id),Ye.push({kind:"thread",thread:Me,depth:Fe,isNested:Fe>0,clusterId:Ze});const Ke=Le.get(Me.id);if(!Ke)return;const nt=new Map;for(const je of Ke){const le=je.agent_id||je.agent?.name||je.id,T=nt.get(le);T?T.push(je):nt.set(le,[je])}for(const[je,le]of nt.entries()){if(le.length>1){const T=K(Me.id,je),B=H(T);if(Ye.push({kind:"directory",key:T,depth:Fe+1,label:le[0]?.agent?.title||le[0]?.agent?.name||je,count:le.length,open:B,clusterId:Ze}),!B){for(const fe of le)Se(fe);continue}for(const fe of le)xe(fe,Fe+2,Ze);continue}xe(le[0],Fe+1,Ze)}};for(const Me of $e)xe(Me,0,Me.id);const Pe=Z.filter(Me=>!et.has(Me.id)).sort(be);for(const Me of Pe)xe(Me,Me.parent?1:0,Me.parent??Me.id);return Ye},ne=q(()=>{const Z=v.value.filter($e=>!ie.value.has($e.id)),oe=new Set(Z.map($e=>$e.id));return[...ee.value.filter($e=>!oe.has($e.id)&&!ie.value.has($e.id)),...Z].sort(be)}),ke=q(()=>Te(ne.value)),_e=Z=>{const oe=ke.value[Z],Le=ke.value[Z+1];return oe?Le?oe.clusterId!==Le.clusterId:!0:!1},O=Z=>{const oe=ke.value[Z],Le=ke.value[Z-1];if(!oe||!Le||oe.clusterId!==Le.clusterId)return!1;const $e=oe.kind==="directory"||oe.kind==="thread"&&oe.isNested,Ye=Le.kind==="thread"&&!Le.isNested;return $e&&Ye},j=q(()=>{const Z={};for(const oe of ke.value)if(!Z[oe.clusterId]){if(oe.kind==="directory"){Z[oe.clusterId]=!0;continue}if(oe.kind==="thread"&&oe.isNested){Z[oe.clusterId]=!0;continue}Z[oe.clusterId]=!1}return Z}),z=m(null);function M(){d.value||L.value||!E.value||(d.value=!0,_.value=v.value.length)}const{arrivedState:P}=vn(z,{offset:{bottom:100}});Ee(()=>P.bottom,Z=>{Z&&E.value&&!L.value&&!d.value&&M()});const re=Z=>{const oe=h.value.find($e=>$e.name===Z.agent_name),Le=Z.agent;return{id:Z.id,agent_id:Z.agent_name,user_id:Z.user_id,tags:Z.tags||[],parent:Z.parent??null,terminated:Z.terminated??null,created_at:Z.created_at,agent:{name:Z.agent_name,title:Le?.title||oe?.title,type:Le?.type||oe?.type||"ai_human"}}},se=async Z=>{if(Z.type==="thread_created"){const oe=re(Z.thread);if(!ye(oe))return;if(oe.parent)if(ne.value.filter($e=>$e.parent===oe.parent&&$e.agent_id===oe.agent_id).length+1>1){const $e=K(oe.parent,oe.agent_id);D($e),H($e)&&X(oe.id)}else X(oe.id);ee.value.unshift(oe)}else if(Z.type==="thread_updated"){const oe=re(Z.thread),Le=ne.value.find(Se=>Se.id===oe.id);if(!ye(oe)){ee.value=ee.value.filter(Se=>Se.id!==oe.id),v.value=v.value.filter(Se=>Se.id!==oe.id);return}ie.value.delete(oe.id);const $e=ee.value.findIndex(Se=>Se.id===oe.id);$e>=0&&(ee.value[$e]=oe);const Ye=v.value.findIndex(Se=>Se.id===oe.id);if(Ye>=0?v.value[Ye]=oe:$e===-1&&ee.value.unshift(oe),!!oe.terminated&&!Le?.terminated)if(oe.parent)if((ne.value.filter(xe=>xe.parent===oe.parent&&xe.agent_id===oe.agent_id).length||1)>1){const xe=K(oe.parent,oe.agent_id);D(xe),H(xe)&&X(oe.id)}else X(oe.id);else X(oe.id)}else Z.type==="thread_deleted"&&(ie.value.add(Z.threadId),ee.value=ee.value.filter(oe=>oe.id!==Z.threadId))},{wsConnected:Ie,wsError:he}=Gv({onEvent:se});Ee(()=>_.value,Z=>{Z===0&&(ee.value=[])});const ge=m(!1);Ee(()=>({rows:ke.value,finished:V.value}),({rows:Z,finished:oe})=>{const Le=Z.find($e=>$e.kind==="thread");oe&&!ge.value&&Le&&(ge.value=!0,s("threadsLoaded",Le.thread.id))},{immediate:!0}),n({refetch:G});const Oe=Z=>{s("selectThread",Z)};return(Z,oe)=>{const Le=tt("FormKit");return r(),o("div",mf,[e("div",vf,[e("div",ff,[e("div",gf,[w(I(ha),{size:18,class:"shrink-0"}),oe[7]||(oe[7]=e("h2",{class:"text-base font-bold"},"Threads",-1)),!I(L)&&I(N)>0?(r(),o("span",hf," ("+C(I(N))+") ",1)):S("",!0),w(Er,{connected:I(Ie),error:I(he)},null,8,["connected","error"])]),e("div",bf,[e("button",{onClick:oe[0]||(oe[0]=$e=>l.value=!l.value),type:"button",class:ce(["relative p-1 rounded transition-colors hover:bg-neutral-100 dark:hover:bg-neutral-900",[l.value||c.value>0?"text-accent-600 dark:text-accent-400":""]]),title:l.value?"Hide filters":"Show filters"},[w(I(fn),{size:18}),c.value>0?(r(),o("span",yf,C(c.value),1)):S("",!0)],10,xf),e("button",{onClick:oe[1]||(oe[1]=$e=>s("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:oe[2]||(oe[2]=$e=>s("collapse")),type:"button",class:"p-1 hover:bg-neutral-100 dark:hover:bg-neutral-900 rounded transition-colors",title:"Collapse pane"},[w(I(ba),{size:20})])])])]),w(bt,{"enter-active-class":"transition-all duration-200 ease-out","enter-from-class":"opacity-0 -translate-y-2 max-h-0","enter-to-class":"opacity-100 translate-y-0 max-h-60","leave-active-class":"transition-all duration-150 ease-in","leave-from-class":"opacity-100 translate-y-0 max-h-60","leave-to-class":"opacity-0 -translate-y-2 max-h-0"},{default:F(()=>[l.value?(r(),o("div",kf,[e("div",wf,[e("div",_f,[w(Le,{type:"searchInput",modelValue:u.value,"onUpdate:modelValue":oe[3]||(oe[3]=$e=>u.value=$e),placeholder:"Search by tag or thread ID...",size:"sm"},null,8,["modelValue"]),e("div",$f,[e("div",Cf,[w(Le,{type:"selectSearch",size:"sm","active-highlight":"",value:p.value||"",options:y.value,placeholder:"All agents","search-placeholder":"Search agents...",loading:I(g),onInput:oe[4]||(oe[4]=$e=>p.value=$e||null)},null,8,["value","options","loading"])]),w(pf,{startDate:x.value,"onUpdate:startDate":oe[5]||(oe[5]=$e=>x.value=$e),endDate:k.value,"onUpdate:endDate":oe[6]||(oe[6]=$e=>k.value=$e),class:"flex-1 min-w-0"},null,8,["startDate","endDate"])]),c.value>0?(r(),o("div",Sf,[e("button",{onClick:f,type:"button",class:"text-xs font-mono text-neutral-500 hover:text-neutral-900 dark:hover:text-neutral-100 transition-colors"}," Clear all ")])):S("",!0)])])])):S("",!0)]),_:1}),e("div",{ref_key:"scrollContainerRef",ref:z,class:"flex-1 overflow-y-auto text-xs min-h-0"},[I(L)&&v.value.length===0?(r(),o("div",If,[w(Be)])):I(A)?(r(),o("div",Tf," Error: "+C(I(A)),1)):ke.value.length===0?(r(),o("div",Mf,[c.value>0?(r(),o(we,{key:0},[oe[8]||(oe[8]=e("p",{class:"text-base mb-2"},"No matching threads",-1)),e("button",{onClick:f,type:"button",class:"text-xs text-accent-600 dark:text-accent-400 hover:underline"}," Clear filters ")],64)):(r(),o("p",zf,"No threads found"))])):(r(),o("div",Vf,[(r(!0),o(we,null,Ae(ke.value,($e,Ye)=>(r(),o(we,{key:$e.kind==="thread"?$e.thread.id:$e.key},[$e.kind==="thread"?(r(),o("button",{key:0,id:`thread-${$e.thread.id}`,class:ce(["w-full text-left px-3 cursor-pointer transition-colors relative hover:bg-neutral-50 dark:hover:bg-neutral-800/50",[$e.isNested?"py-1.5 bg-neutral-50/40 dark:bg-neutral-900/20":"py-2.5",O(Ye)?"pt-3":"",_e(Ye)&&j.value[$e.clusterId]?"pb-3":"",_e(Ye)?"border-b border-neutral-200 dark:border-neutral-800":"border-0",$e.thread.terminated?"opacity-50 text-neutral-500 dark:text-neutral-500":"",t.selectedThreadId===$e.thread.id?"bg-accent-50 dark:bg-accent-950/50 border-l-2 border-l-accent-500":""]]),style:yt($e.depth>0?{paddingLeft:`${12+Math.min($e.depth,6)*14}px`}:void 0),onClick:et=>Oe($e.thread.id)},[e("div",{class:ce(["flex items-center gap-2",!$e.isNested||te($e.thread).length>0||ae($e.thread)?"mb-1":""])},[$e.thread.terminated?(r(),J(I(er),{key:0,size:12,class:"shrink-0 text-neutral-500 dark:text-neutral-400"})):S("",!0),e("span",{class:ce(["font-medium truncate flex-1 min-w-0",[t.selectedThreadId===$e.thread.id?"text-accent-700 dark:text-accent-300":"",W($e.thread.id)?"thread-list-green-flash":""]])},C(Y($e.thread)),3),e("span",Lf,[w(Nt,{timestamp:$e.thread.created_at*1e6},null,8,["timestamp"])])],2),ae($e.thread)?(r(),o("div",Af,C(ae($e.thread)),1)):S("",!0),$e.isNested?te($e.thread).length>0?(r(),o("div",Df,[(r(!0),o(we,null,Ae(te($e.thread).slice(0,3),et=>(r(),o("span",{key:et,class:"inline-block px-1.5 py-0.5 rounded text-[10px] truncate max-w-[120px] bg-neutral-200 dark:bg-neutral-800 text-neutral-600 dark:text-neutral-400"},C(et),1))),128)),te($e.thread).length>3?(r(),o("span",Uf," +"+C(te($e.thread).length-3),1)):S("",!0)])):S("",!0):(r(),o("div",Pf,[e("span",jf,C($e.thread.id.slice(0,8)),1),te($e.thread).length>0?(r(),o("div",Rf,[(r(!0),o(we,null,Ae(te($e.thread).slice(0,3),et=>(r(),o("span",{key:et,class:ce(["inline-block px-1.5 py-0.5 rounded text-[10px] truncate max-w-[60px]",t.selectedThreadId===$e.thread.id?"bg-accent-200 dark:bg-accent-900 text-accent-800 dark:text-accent-200":"bg-neutral-200 dark:bg-neutral-800 text-neutral-600 dark:text-neutral-400"])},C(et),3))),128)),te($e.thread).length>3?(r(),o("span",Of," +"+C(te($e.thread).length-3),1)):S("",!0)])):S("",!0)]))],14,Ef)):(r(),o("button",{key:1,type:"button",class:ce(["w-full text-left px-3 py-1 bg-neutral-50/25 dark:bg-neutral-900/10 hover:bg-neutral-100 dark:hover:bg-neutral-800/40 transition-colors",[O(Ye)?"pt-3":"",_e(Ye)?"border-b border-neutral-200 dark:border-neutral-800":"border-0",_e(Ye)&&j.value[$e.clusterId]?"pb-3":""]]),style:yt({paddingLeft:`${12+Math.min($e.depth,6)*14}px`}),onClick:et=>ve($e.key)},[e("div",Nf,[w(I(tr),{size:13,class:"text-neutral-500 dark:text-neutral-400 shrink-0"}),e("span",{class:ce(["truncate flex-1 min-w-0 text-[11px] font-medium text-neutral-600 dark:text-neutral-300",me($e.key)?"thread-list-green-flash":""])},C($e.label)+" ("+C($e.count)+") ",3),$e.open?(r(),J(I(gt),{key:0,size:14,class:"text-neutral-500 dark:text-neutral-400 shrink-0"})):(r(),J(I(_t),{key:1,size:14,class:"text-neutral-500 dark:text-neutral-400 shrink-0"}))])],14,Bf))],64))),128)),d.value||I(L)&&v.value.length>0?(r(),o("div",qf,[w(Be)])):!I(E)&&ke.value.length>0?(r(),o("div",Ff," All "+C(I(N))+" threads loaded ",1)):S("",!0)]))],512)])}}}),Kf=ct(Wf,[["__scopeId","data-v-a0b133c8"]]);function Jf(t,n={}){const a=m(null),s=m(!1),l=m(null);let u=null;try{u=Ma()}catch{}const i=u?.messages??m([]),p=q(()=>u?.groupedMessages?.value?u.groupedMessages.value:u?.workblocks?.value?u.workblocks.value:i.value),x=q(()=>u?.status.value==="connected"),k=m(null);u?.loading??m(!1);const h=q(()=>i.value.some(Y=>Y.status==="pending")),g=m(!1),y=m(0),_=m(!1);function v(Y){if(!a.value?.agent)return null;const ae=a.value.agent,ye=Y==="assistant"?"A":"B";return ye==="A"&&ae.side_a_label?ae.side_a_label:ye==="B"&&ae.side_b_label?ae.side_b_label:null}function d(Y){return{id:Y.id||`att-${Y.path||Y.name||Math.random().toString(36).slice(2)}`,type:"file",path:Y.path||"",name:Y.name||Y.path?.split("/").pop()||"attachment",mimeType:Y.mimeType||Y.mediaType||"application/octet-stream",width:Y.width,height:Y.height,description:Y.description}}function b(Y){if(Y){if(Array.isArray(Y))return Y.length>0?Y.map(d):void 0;try{const ae=JSON.parse(Y);return Array.isArray(ae)&&ae.length>0?ae.map(d):void 0}catch(ae){console.error("Failed to parse attachments:",ae);return}}}function c(Y,ae){const ye=[];Y.reasoning_content&&ye.push({id:`${Y.id}-reasoning`,type:"reasoning",content:Y.reasoning_content,created_at:Y.created_at}),Y.content&&ye.push({id:`${Y.id}-content`,type:"content",content:Y.content,created_at:Y.created_at});const Te=Y.workItems.filter(j=>j.type==="tool_call"),ne=Y.workItems.filter(j=>j.type==="tool_result"),ke=new Map;for(const j of ne)j.tool_call_id&&ke.set(j.tool_call_id,j);for(const j of Te){const z=j.tool_call_id||j.id,M=ke.get(z);let P="pending";if(M){const re=(M.content||"").toLowerCase(),se=re.includes("failed")||re.includes("error"),Ie=re.length<500;P=M.status==="error"||se&&Ie?"failed":"success"}ye.push({id:j.id,type:"tool_call",content:j.name||"",created_at:Y.created_at,tool_name:j.name,tool_call_id:z,tool_arguments:j.content||void 0,response:M?.content||null,response_status:P,response_log_id:null,log_id:null})}const _e=ye.some(j=>j.type==="tool_call"&&j.response_status==="pending"),O=Y.status!=="pending"&&!_e;return{type:"work",id:Y.id,role:"assistant",items:ye,created_at:Y.created_at,updated_at:Y.created_at,isComplete:O,sideLabel:v("assistant"),status:Y.status}}function f(Y){return Y==="assistant"?"assistant":"user"}function $(Y){for(let ae=Y.length-1;ae>=0;ae--){const ye=(Y[ae].content||"").trim();if(ye.length>0)return ye}return""}function N(Y){const ae=new Set,ye=[];for(const Te of Y){const ne=b(Te.attachments);if(ne?.length)for(const ke of ne)ae.has(ke.path)||(ae.add(ke.path),ye.push(ke))}return ye.length>0?ye:void 0}function E(Y){if(!Y)return!1;if(Y.tool_status==="error"||Y.status==="failed")return!0;const ae=(Y.content||"").toLowerCase();return ae?ae.includes("failed to execute tool")||ae.includes("has reported a failure")||ae.includes("execution stopped before completion"):!1}function L(Y){const ae=Y.messages||[],ye=ae[ae.length-1],Te=ye?f(ye.role):"assistant",ne=ye?.log_id??null,ke=(Y.subagent_status||"").toLowerCase(),_e=E(ye)||ke.includes("error")||ke.includes("failed"),O=$(ae),j=N(ae),z=ae.filter(M=>{const P=b(M.attachments);return!!M.content||!!M.status||!!(P&&P.length>0)}).map(M=>({id:M.id,role:M.role,content:M.content||"",created_at:M.created_at,silent:M.silent,attachments:b(M.attachments)}));return{type:"subagent",id:Y.id,role:Te,created_at:Y.created_at,updated_at:Y.updated_at,subagentId:Y.subagent_id,subagentName:Y.subagent_name??null,subagentTitle:Y.subagent_title??null,subagentThreadName:Y.subagent_thread_name??null,subagentStatus:Y.subagent_status??null,subagentHasError:_e,subagentResumable:Y.subagent_resumable??null,subagentBlocking:Y.subagent_blocking??null,messages:z,messageCount:ae.length,latestContent:O,attachments:j,log_id:ne,sideLabel:v(Te),silent:ae.length>0&&ae.every(M=>!!M.silent)}}function V(Y){const ae=(Y.subagents||[]).map(Te=>L(Te)),ye=ae.reduce((Te,ne)=>Te?ne.updated_at>Te.updated_at?ne:Te:ne,null);return{type:"subagent_group",id:Y.id,role:ye?.role??"assistant",created_at:Y.created_at,updated_at:Y.updated_at,subagents:ae,count:ae.length,log_id:ye?.log_id??null,sideLabel:ye?.sideLabel??v("assistant"),silent:ae.every(Te=>!!Te.silent)}}function A(Y){return{type:"status",id:Y.id,role:"system",content:Y.content,created_at:Y.created_at,statusKind:Y.status_kind??null,subagentId:Y.subagent_id??null}}const G=q(()=>{const Y=[],ye=p.value.filter(ne=>(ne.depth??0)===0);let Te=[];for(let ne=0;ne<ye.length;ne++){const ke=ye[ne];if(Y[Y.length-1]?.role,ke.type==="workblock"){const P=c(ke);Y.push(P);const re=ke;re.attachments&&re.attachments.length>0&&Te.push(...re.attachments.map(d));continue}if(ke.type==="subagent_block"){Te=[],Y.push(L(ke));continue}if(ke.type==="subagent_group_block"){Te=[],Y.push(V(ke));continue}if(ke.type==="status"){Te=[],Y.push(A(ke));continue}const O=ke,j=O.role;if(O.role==="tool")continue;const z=b(O.attachments);let M;if((Te.length>0||z)&&(M=[...Te,...z||[]],Te=[]),O.content||j==="system"||O.status==="pending"||M?.length){const P={type:"text",id:O.id,role:j,content:O.content||"",attachments:M?.length?M:void 0,created_at:O.created_at,log_id:O.log_id||null,sideLabel:v(j),isOptimistic:O.isOptimistic,status:O.status,silent:O.silent};Y.push(P)}}return Y});async function ee(){if(!t.value){a.value=null;return}try{const Y=await fetch(Ve(`/api/threads/${t.value}`));Y.ok&&(a.value=await Y.json())}catch(Y){console.error("Error fetching thread info:",Y)}}async function ie(Y){if(t.value){if(u?.deleteMessage){await u.deleteMessage(Y);return}try{if(!(await fetch(Ve(`/api/threads/${t.value}/messages/${Y}`),{method:"DELETE"})).ok)throw new Error("Failed to delete message")}catch(ae){throw ae}}}async function be(Y,ae){if(t.value)try{if(!(await fetch(Ve(`/api/threads/${t.value}/messages/${Y}`),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:ae})})).ok)throw new Error("Failed to update message")}catch(ye){throw ye}}Ee(t,async Y=>{Y?(s.value=!0,await ee(),s.value=!1):a.value=null},{immediate:!0});const Q=u?.sendMessage,U=u?.stopExecution,R=u?.attachments??m([]),K=u?.addAttachment??(()=>{}),H=u?.removeAttachment??(()=>{}),ve=u?.clearAttachments??(()=>{});function X(){console.warn("loadMoreMessages is deprecated - SDK handles all messages")}function D(){console.warn("connectWebSocket is deprecated - SDK handles WebSocket")}function W(){console.warn("disconnectWebSocket is deprecated - SDK handles WebSocket")}function me(){console.warn("addOptimisticMessage is deprecated - SDK handles optimistic updates")}function ue(){console.warn("removeOptimisticMessage is deprecated - SDK handles optimistic updates")}async function te(){console.warn("refetch is deprecated - SDK handles message loading")}return{messages:G,threadInfo:a,isFetching:s,isLoadingMore:_,error:l,wsConnected:x,wsError:k,isExecuting:h,hasMore:g,totalMessages:y,sendMessage:Q,stopThread:U,attachments:R,addAttachment:K,removeAttachment:H,clearAttachments:ve,deleteMessageById:ie,updateMessageContent:be,refetch:te,loadMoreMessages:X,connectWebSocket:D,disconnectWebSocket:W,addOptimisticMessage:me,removeOptimisticMessage:ue}}const Gf={key:0,class:"absolute inset-0 flex items-center justify-center bg-neutral-100 dark:bg-neutral-800"},Yf={key:1,class:"absolute inset-0 flex items-center justify-center bg-neutral-100 dark:bg-neutral-800 text-neutral-400"},Zf=["src","alt"],Xf={class:"absolute inset-0 bg-black/50 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center"},Qf={key:0,class:"text-white text-[10px]"},eg={class:"text-xs text-neutral-600 dark:text-neutral-300 truncate max-w-[100px]"},br=Ce({__name:"FileAttachment",props:{attachment:{},threadId:{},showRemove:{type:Boolean}},emits:["remove"],setup(t,{emit:n}){const a=t,s=n,l=m(!0),u=m(!1),i=q(()=>a.attachment.mimeType.startsWith("image/")),p=q(()=>!!a.attachment.thumbnailBase64),x=q(()=>{if(!a.threadId||!a.attachment.path)return"";const v=a.attachment.path.startsWith("/")?a.attachment.path.slice(1):a.attachment.path;return Ve(`/api/threads/${a.threadId}/fs/${v}`)}),k=q(()=>i.value?a.attachment.thumbnailBase64?`data:image/webp;base64,${a.attachment.thumbnailBase64}`:x.value:"");function h(){l.value=!1,u.value=!1}function g(){l.value=!1,u.value=!0}function y(){s("remove",a.attachment.id)}function _(){x.value&&window.open(x.value,"_blank")}return(v,d)=>(r(),o("div",{class:ce(["relative group inline-flex items-center rounded-lg overflow-hidden border border-neutral-200 dark:border-neutral-700",{"w-[104px] h-[104px]":i.value,"px-2 py-1 bg-neutral-100 dark:bg-neutral-800":!i.value,"cursor-pointer":i.value&&x.value}]),onClick:d[0]||(d[0]=b=>i.value&&x.value?_():void 0)},[i.value?(r(),o(we,{key:0},[l.value&&!u.value&&!p.value?(r(),o("div",Gf,[...d[1]||(d[1]=[e("div",{class:"w-4 h-4 border-2 border-neutral-300 border-t-neutral-600 rounded-full animate-spin"},null,-1)])])):S("",!0),u.value&&!p.value?(r(),o("div",Yf,[w(I(xa),{size:24})])):S("",!0),He(e("img",{src:k.value||x.value,alt:t.attachment.name,class:"w-full h-full object-cover",onLoad:h,onError:g},null,40,Zf),[[dt,!l.value&&!u.value||p.value]]),e("div",Xf,[x.value?(r(),o("span",Qf,"Click to view")):S("",!0)])],64)):(r(),o(we,{key:1},[w(I(ya),{size:14,class:"text-neutral-500 mr-1 flex-shrink-0"}),e("span",eg,C(t.attachment.name),1)],64)),t.showRemove?(r(),o("button",{key:2,onClick:Ge(y,["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"},[w(I(Tr),{size:10})])):S("",!0)],2))}}),tg=["onMouseenter","onMouseleave","onClick"],rg=["onClick"],ag={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"},ng={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"},og={key:0,class:"w-full text-center text-xs text-neutral-400 dark:text-neutral-500 py-1"},lg=["contenteditable","onInput"],sg={key:1,class:"flex gap-1 items-center min-h-[1.5rem]"},ig={key:0,class:"opacity-50"},ug={key:1,class:"italic font-medium text-neutral-700 dark:text-neutral-700"},dg={key:0,class:"flex flex-wrap gap-2"},cg=["onClick","onMouseenter"],pg={key:0,class:"space-y-1"},mg={class:"flex items-start gap-2"},vg={class:"flex-1 min-w-0"},fg={key:0,class:"truncate opacity-80"},gg={key:1,class:"italic opacity-60"},hg={class:"flex items-center gap-2 pl-5 opacity-60"},bg={class:"text-[10px]"},xg={class:"text-[10px]"},yg={key:1,class:"space-y-2"},kg={class:"flex items-center gap-2 pb-1 border-b border-current opacity-70"},wg={class:"text-[10px] italic"},_g={class:"text-[10px] ml-auto"},$g={key:0,class:"space-y-1"},Cg=["onClick","onMouseenter"],Sg={class:"font-mono text-[11px] flex-shrink-0"},Ig={key:2,class:"text-[10px] opacity-60 px-2 truncate flex-1 min-w-0"},Tg={key:3,class:"text-[10px] text-green-600 dark:text-green-400 ml-auto flex-shrink-0"},Mg={key:0,class:"pl-4 space-y-2 text-[10px]"},zg={key:0},Vg={class:"w-full border-collapse"},Eg={class:"py-0.5 pr-2 opacity-65 align-top"},Lg={class:"py-0.5 opacity-85 break-all"},Ag={key:1},Pg=["onClick","onMouseenter"],jg={class:"whitespace-pre-wrap break-all"},Rg={key:1,class:"text-[10px]"},Og=["onClick"],Dg={key:0,class:"mt-1 pl-4 whitespace-pre-wrap break-words opacity-80"},Ug={key:2,class:"text-[10px] opacity-80 pl-4 pb-2 break-words"},Bg={class:"text-[10px] px-3 py-1.5 opacity-75 border-b border-current/20"},Ng={class:"divide-y divide-current/20"},qg=["onClick"],Fg={class:"min-w-0 flex-1 font-medium truncate"},Hg={class:"inline-flex items-center rounded-full bg-neutral-200/70 dark:bg-neutral-700/70 px-1.5 py-0.5 text-[10px] leading-none text-neutral-700 dark:text-neutral-200 flex-shrink-0"},Wg={key:0,class:"mt-2 pt-2 border-t border-current/15 space-y-2"},Kg={class:"text-[10px] opacity-75"},Jg={class:"flex items-center gap-2 text-[10px] opacity-70"},Gg={class:"font-medium uppercase"},Yg={key:0,class:"italic"},Zg={key:0,class:"text-[11px] mt-1 whitespace-pre-wrap break-words"},Xg={key:1,class:"mt-2 flex flex-wrap gap-2"},Qg=["onClick"],eh={class:"min-w-0 flex-1 font-medium truncate"},th={class:"inline-flex items-center rounded-full bg-neutral-200/70 dark:bg-neutral-700/70 px-1.5 py-0.5 text-[10px] leading-none text-neutral-700 dark:text-neutral-200 flex-shrink-0"},rh={key:0,class:"mt-2 space-y-2"},ah={class:"text-[10px] opacity-75"},nh={class:"flex items-center gap-2 text-[10px] opacity-70"},oh={class:"font-medium uppercase"},lh={key:0,class:"italic"},sh={key:0,class:"text-[11px] mt-1 whitespace-pre-wrap break-words"},ih={key:1,class:"mt-2 flex flex-wrap gap-2"},uh=Ce({__name:"AgentMessages",props:{messages:{},threadId:{},selectedMessageId:{},selectedLogId:{},hoveredLogId:{},isEditMode:{type:Boolean},selectedForDelete:{},editedMessages:{}},emits:["messageClick","messageHover","selectionChange","messageEdit"],setup(t,{expose:n,emit:a}){const s=t,l=a;function u(z){const M=s.selectedForDelete?.has(z)??!1;l("selectionChange",z,!M)}function i(z,M){const re=z.target.innerText;l("messageEdit",M,re)}function p(z){return s.editedMessages?.has(z)??!1}const x=m(new Map);function k(z,M){M?x.value.set(z,M):x.value.delete(z)}function h(z){const M=s.messages.findIndex(P=>P.log_id===z);if(M<=0)return-1;for(let P=M-1;P>=0;P--){const re=s.messages[P];if(re.role==="user")return P;if(re.role==="assistant"&&re.log_id)break}return-1}function g(z){for(let M=0;M<s.messages.length;M++){const P=s.messages[M];if(P.log_id===z||P.type==="work"&&P.items&&P.items.some(Ie=>Ie.log_id===z||Ie.response_log_id===z))return M}return-1}function y(z,M){const re=g(z);if(re===-1)return!1;const se=x.value.get(re);if(!se)return!1;const Ie=s.messages[re];let he=null;if(Ie.role==="assistant"&&Ie.log_id){const Z=h(Ie.log_id);he=Z!==-1?x.value.get(Z):null}const ge=M.getBoundingClientRect(),Oe=se.getBoundingClientRect();if(Oe.top<ge.top){const Le=(he||se).getBoundingClientRect().top-ge.top-10;M.scrollBy({top:Le,behavior:"smooth"})}else if(Oe.bottom>ge.bottom){const Z=Oe.bottom-ge.bottom+10;M.scrollBy({top:Z,behavior:"smooth"})}else if(he){const Z=he.getBoundingClientRect();if(Z.top<ge.top){const oe=Z.top-ge.top-10;M.scrollBy({top:oe,behavior:"smooth"})}}return!0}function _(z){for(const M of s.messages){if(M.type!=="work")continue;if(M.items.some(se=>se.log_id===z||se.response_log_id===z))return!0}return!1}n({scrollToLogId:y,hasWorkblockForLogId:_});function v(z){const M=s.messages[z];if(M.log_id)return M.log_id;if(M.role==="user")for(let P=z+1;P<s.messages.length;P++){const re=s.messages[P];if(re.log_id)return re.log_id;if(re.role==="user")break}return null}function d(z,M){return M?v(z)===M:!1}function b(z){const M=v(z);M&&l("messageHover",M)}function c(z){v(z)&&l("messageHover",null)}function f(z){const M=s.messages[z],P=v(z);P&&l("messageClick",M.id,P)}const $=m(new Set),N=m(new Set),E=m(new Set),L=m(new Set);function V(z){$.value.has(z)?$.value.delete(z):$.value.add(z)}function A(z){N.value.has(z)?N.value.delete(z):N.value.add(z)}function G(z){E.value.has(z)?E.value.delete(z):E.value.add(z)}function ee(z){L.value.has(z)?L.value.delete(z):L.value.add(z)}function ie(z){if(!z)return{};try{return JSON.parse(z)}catch{return{raw:z}}}function be(z){if(!z)return null;const M=ie(z),P=Object.keys(M);if(P.length===0)return null;const re=M[P[0]];return typeof re=="string"?re:JSON.stringify(re)}function Q(z){return new Date(z/1e3).toLocaleTimeString()}function U(z){const M=Math.round(z/1e6);if(M<1)return"< 1s";if(M<60)return`${M}s`;const P=Math.floor(M/60),re=M%60;return`${P}m ${re}s`}function R(z){if(z.status==="pending")return"...";if(!z.isComplete)return"Working...";let M;return z.request_sent_at&&z.response_completed_at?M=z.response_completed_at-z.request_sent_at:M=z.updated_at-z.created_at,`Worked for ${U(M)}`}function K(z){const M=z.filter(P=>P.type==="content");if(M.length===0){const P=z.filter(re=>re.type==="reasoning");return P.length>0?P[P.length-1].content:null}return M[M.length-1].content}function H(z){const P=z.trim().split(`
37
- `)[0];return P.length>60?P.substring(0,60):P}function ve(z){return s.selectedMessageId===z.id?!0:s.selectedLogId?z.items.some(M=>M.log_id===s.selectedLogId||M.response_log_id===s.selectedLogId):!1}function X(z){return!!(s.selectedLogId&&(z.log_id===s.selectedLogId||z.response_log_id===s.selectedLogId))}function D(z){return s.hoveredLogId?z.items.some(M=>M.log_id===s.hoveredLogId||M.response_log_id===s.hoveredLogId):!1}function W(z){return!!(s.hoveredLogId&&(z.log_id===s.hoveredLogId||z.response_log_id===s.hoveredLogId))}function me(z){const M=[];for(const P of z.items)P.log_id&&M.push(P.log_id),P.response_log_id&&M.push(P.response_log_id);return M}function ue(z){return z?z.trim():""}function te(z,M){if(z.type!=="text")return;const P=z.attachments;if(!P?.length)return;if(z.silent)return P;const re=s.messages[M-1];if(!re||re.type!=="text"||!re.silent||!(re.content||"").trim().startsWith("Initial asset attachment path:"))return P;const Ie=new Set((re.attachments||[]).map(ge=>ge.path));if(Ie.size===0)return P;const he=P.filter(ge=>!Ie.has(ge.path));return he.length>0?he:void 0}function Y(z){return z.subagentThreadName||z.subagentTitle||z.subagentName||"Subagent"}function ae(z){return(z.subagentStatus||"running").toLowerCase()}function ye(z){const M=ae(z);return M==="pending"||M==="queued"}function Te(z){return z==="tool"?"Initialization":z==="user"?"Subagent":z==="assistant"?"Assistant":"System"}function ne(z){const M=z.subagentResumable===!0?"resumable":z.subagentResumable===!1?"non-resumable":"resumable?",P=z.subagentBlocking===!0?"blocking":z.subagentBlocking===!1?"non-blocking":"blocking?";return`${M} · ${P}`}function ke(z){return z.subagentHasError===!0}function _e(z){if(ke(z)||ye(z))return!1;const M=ae(z);return M!=="idle"&&M!=="terminated"}function O(z){return ke(z)||_e(z)?!1:z.subagentBlocking===!0}function j(z){if(z.type==="status")return!0;if(z.type!=="text"||z.role!=="system")return!1;const M=z.content||"";return M.includes("Execution stopped")?!0:/subagents?\s+started:/i.test(M)}return(z,M)=>(r(),o("div",null,[(r(!0),o(we,null,Ae(t.messages,(P,re)=>(r(),o("div",{key:P.id,ref_for:!0,ref:se=>k(re,se),class:"flex items-center gap-2 pb-3",onMouseenter:se=>b(re),onMouseleave:se=>c(re),onClick:se=>t.isEditMode?u(P.id):f(re)},[t.isEditMode&&P.role!=="system"?(r(),o("button",{key:0,onClick:Ge(se=>u(P.id),["stop"]),class:ce(["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(P.id),"border-green-500 bg-green-500":!t.selectedForDelete?.has(P.id)&&p(P.id),"border-neutral-400 dark:border-neutral-500 bg-transparent hover:border-neutral-500 dark:hover:border-neutral-400":!t.selectedForDelete?.has(P.id)&&!p(P.id)}])},[t.selectedForDelete?.has(P.id)?(r(),o("svg",ag,[...M[4]||(M[4]=[e("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M4.5 12.75l6 6 9-13.5"},null,-1)])])):p(P.id)?(r(),o("svg",ng,[...M[5]||(M[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)])])):S("",!0)],10,rg)):S("",!0),e("div",{class:ce(["flex-1 flex items-center gap-2 min-w-0",{"justify-start":P.type==="subagent"||P.type==="subagent_group"||P.role==="assistant","justify-end":P.type!=="subagent"&&P.type!=="subagent_group"&&P.role==="user","justify-center":P.type==="status"||P.role==="system","cursor-pointer":v(re)&&!t.isEditMode}])},[j(P)?(r(),o("div",og,C(P.content),1)):P.type==="text"?(r(),o("div",{key:1,class:ce(["max-w-[80%] flex flex-col gap-2",{"items-start":P.role==="assistant","items-end":P.role==="user"}])},[e("div",{class:ce(["rounded-2xl px-4 py-2 text-sm transition-all min-h-[2.5rem]",[P.silent?"bg-transparent text-neutral-700 border-2 border-dashed border-neutral-400 text-[11px] leading-4 dark:bg-transparent dark:text-neutral-200 dark:border-neutral-600":!t.isEditMode&&P.role!=="user"&&d(re,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":P.role==="assistant"?"bg-neutral-800 text-white dark:bg-neutral-300 dark:text-black":P.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":P.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&&P.role!=="user"&&v(re)&&!P.silent&&!d(re,t.selectedLogId)&&d(re,t.hoveredLogId)},{"ring-2 ring-green-500 dark:ring-green-400":t.isEditMode&&p(P.id),"border border-dashed border-neutral-400 dark:border-neutral-500":t.isEditMode&&P.role!=="system"&&!p(P.id)}]])},[P.content||t.isEditMode?(r(),o("div",{key:0,class:ce(["whitespace-pre-wrap break-words outline-none",P.silent?"text-[11px] leading-4":"text-sm"]),contenteditable:t.isEditMode&&P.role!=="system",onInput:se=>i(se,P.id),onClick:M[0]||(M[0]=se=>t.isEditMode&&se.stopPropagation())},C(ue(P.content)),43,lg)):P.status==="pending"?(r(),o("div",sg,[...M[6]||(M[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)])])):S("",!0),P.status!=="pending"?(r(),o("div",{key:2,class:ce(["text-[10px] mt-1 flex gap-2",{"opacity-80":P.silent,"opacity-50":!P.silent,"justify-start":P.role==="assistant","justify-end":P.role==="user","justify-center":P.role==="system"}])},[P.sideLabel&&!P.silent?(r(),o("span",ig,C(P.sideLabel),1)):S("",!0),e("span",null,C(Q(P.created_at)),1),P.silent?(r(),o("span",ug," silent ")):S("",!0)],2)):S("",!0)],2),te(P,re)?.length&&t.threadId?(r(),o("div",dg,[(r(!0),o(we,null,Ae(te(P,re),se=>(r(),J(br,{key:se.id,attachment:se,threadId:t.threadId},null,8,["attachment","threadId"]))),128))])):S("",!0)],2)):P.type==="work"?(r(),o("div",{key:2,class:ce(["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":P.role==="assistant"&&!P.silent,"bg-accent-50 text-accent-700 border-accent-200 dark:bg-accent-50 dark:text-accent-700 dark:border-accent-200":P.role==="user"&&!P.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":P.silent,"ring-2 ring-accent-500":!t.isEditMode&&ve(P),"ring-2 ring-accent-400":!t.isEditMode&&!ve(P)&&D(P)}]),onClick:se=>!t.isEditMode&&(V(P.id),me(P)[0]&&l("messageClick",P.id,me(P)[0])),onMouseenter:se=>!t.isEditMode&&me(P)[0]&&l("messageHover",me(P)[0]),onMouseleave:M[3]||(M[3]=se=>!t.isEditMode&&l("messageHover",null))},[$.value.has(P.id)?(r(),o("div",yg,[e("div",kg,[w(I(gt),{size:14,class:"flex-shrink-0"}),e("span",wg,C(R(P)),1),e("span",_g,C(P.items.length)+" operation"+C(P.items.length!==1?"s":""),1)]),(r(!0),o(we,null,Ae(P.items,se=>(r(),o("div",{key:se.id,class:"mb-1"},[se.type==="tool_call"?(r(),o("div",$g,[e("div",{onClick:Ge(Ie=>{A(se.id),se.log_id&&l("messageClick",P.id,se.log_id)},["stop"]),onMouseenter:Ge(Ie=>se.log_id&&l("messageHover",se.log_id),["stop"]),onMouseleave:M[1]||(M[1]=Ge(Ie=>l("messageHover",null),["stop"])),class:ce(["flex items-center gap-2 cursor-pointer hover:opacity-70 transition-opacity min-w-0",{"ring-1 ring-accent-500":X(se),"ring-1 ring-accent-400":!X(se)&&W(se)}])},[N.value.has(se.id)?(r(),J(I(gt),{key:1,size:12,class:"flex-shrink-0 opacity-50"})):(r(),J(I(_t),{key:0,size:12,class:"flex-shrink-0 opacity-50"})),e("span",Sg,C(se.tool_name),1),be(se.tool_arguments)?(r(),o("span",Ig,C(be(se.tool_arguments)),1)):S("",!0),se.response_status==="success"?(r(),o("span",Tg,"✓")):se.response_status==="failed"?(r(),J(I(Xt),{key:4,size:12,class:"ml-auto text-red-600 dark:text-red-400"})):S("",!0)],42,Cg),N.value.has(se.id)?(r(),o("div",Mg,[se.tool_arguments?(r(),o("div",zg,[M[7]||(M[7]=e("div",{class:"font-semibold mb-1 opacity-70"},"Arguments:",-1)),e("table",Vg,[e("tbody",null,[(r(!0),o(we,null,Ae(ie(se.tool_arguments),(Ie,he)=>(r(),o("tr",{key:he,class:"border-b border-current border-opacity-10"},[e("td",Eg,C(he),1),e("td",Lg,C(typeof Ie=="object"?JSON.stringify(Ie):Ie),1)]))),128))])])])):S("",!0),se.response?(r(),o("div",Ag,[M[8]||(M[8]=e("div",{class:"font-semibold mb-1 opacity-70"},"Response:",-1)),e("div",{class:ce(["opacity-80 cursor-pointer hover:opacity-100",{"ring-1 ring-accent-500":t.selectedLogId&&se.response_log_id===t.selectedLogId,"ring-1 ring-accent-400":t.hoveredLogId&&se.response_log_id===t.hoveredLogId&&se.response_log_id!==t.selectedLogId}]),onClick:Ge(Ie=>se.response_log_id&&l("messageClick",P.id,se.response_log_id),["stop"]),onMouseenter:Ge(Ie=>se.response_log_id&&l("messageHover",se.response_log_id),["stop"]),onMouseleave:M[2]||(M[2]=Ge(Ie=>l("messageHover",null),["stop"]))},[e("div",jg,C(ue(se.response)),1)],42,Pg)])):S("",!0)])):S("",!0)])):se.type==="reasoning"?(r(),o("div",Rg,[e("button",{onClick:Ge(Ie=>G(se.id),["stop"]),class:"flex items-center gap-1 opacity-70 hover:opacity-100 transition-opacity"},[E.value.has(se.id)?(r(),J(I(gt),{key:1,size:12,class:"flex-shrink-0"})):(r(),J(I(_t),{key:0,size:12,class:"flex-shrink-0"})),M[9]||(M[9]=e("span",{class:"font-semibold"},"Reasoning",-1))],8,Og),E.value.has(se.id)?(r(),o("div",Dg,C(ue(se.content)),1)):S("",!0)])):se.type==="content"?(r(),o("div",Ug,C(ue(se.content)),1)):S("",!0)]))),128))])):(r(),o("div",pg,[e("div",mg,[w(I(_t),{size:14,class:"flex-shrink-0 mt-0.5 opacity-50"}),e("div",vg,[K(P.items)?(r(),o("div",fg,C(H(K(P.items)))+"... ",1)):(r(),o("div",gg,C(R(P)),1))])]),e("div",hg,[e("span",bg,C(P.items.length)+" operation"+C(P.items.length!==1?"s":""),1),e("span",xg,"• "+C(R(P)),1)])]))],42,cg)):P.type==="subagent_group"?(r(),o("div",{key:3,class:ce(["w-full rounded-lg text-xs transition-all border overflow-hidden",{"bg-accent-100 text-accent-950 border-accent-300 dark:bg-accent-900/40 dark:text-accent-50 dark:border-accent-700":!P.silent,"bg-transparent text-neutral-700 border-dashed border-neutral-400 dark:text-neutral-200 dark:border-neutral-600":P.silent,"ring-2 ring-accent-500":!t.isEditMode&&d(re,t.selectedLogId),"ring-2 ring-accent-400":!t.isEditMode&&!d(re,t.selectedLogId)&&d(re,t.hoveredLogId)}])},[e("div",Bg,C(P.count)+" subagent"+C(P.count===1?"":"s"),1),e("div",Ng,[(r(!0),o(we,null,Ae(P.subagents,se=>(r(),o("div",{key:se.id,class:"px-3 py-1.5"},[e("button",{type:"button",class:"w-full flex items-center gap-2 text-left hover:opacity-85 transition-opacity",onClick:Ge(Ie=>ee(se.id),["stop"])},[ye(se)?(r(),J(I(jr),{key:0,size:14,class:"text-neutral-500 dark:text-neutral-400 flex-shrink-0"})):ke(se)?(r(),J(I(Xt),{key:1,size:13,class:"text-red-600 dark:text-red-400 flex-shrink-0",title:"Subagent returned an error"})):_e(se)?(r(),J(I(rr),{key:2,size:14,class:"animate-spin text-accent-700 dark:text-accent-300 flex-shrink-0"})):O(se)?(r(),J(I(er),{key:3,size:14,class:"text-green-700 dark:text-green-300 flex-shrink-0"})):(r(),J(I(Rr),{key:4,size:12,class:"text-neutral-500 dark:text-neutral-400 flex-shrink-0"})),e("span",Fg,C(Y(se)),1),e("span",Hg,C(se.messageCount),1),L.value.has(se.id)?(r(),J(I(gt),{key:5,size:13,class:"ml-1 opacity-70 flex-shrink-0"})):(r(),J(I(_t),{key:6,size:13,class:"ml-1 opacity-70 flex-shrink-0"}))],8,qg),L.value.has(se.id)?(r(),o("div",Wg,[e("div",Kg,C(ne(se)),1),(r(!0),o(we,null,Ae(se.messages,Ie=>(r(),o("div",{key:Ie.id,class:"rounded border border-current/20 bg-white/40 dark:bg-black/20 px-2 py-1"},[e("div",Jg,[e("span",Gg,C(Te(Ie.role)),1),e("span",null,C(Q(Ie.created_at)),1),Ie.silent?(r(),o("span",Yg,"silent")):S("",!0)]),Ie.content?(r(),o("div",Zg,C(ue(Ie.content)),1)):S("",!0),Ie.attachments?.length&&t.threadId?(r(),o("div",Xg,[(r(!0),o(we,null,Ae(Ie.attachments,he=>(r(),J(br,{key:he.id,attachment:he,threadId:t.threadId},null,8,["attachment","threadId"]))),128))])):S("",!0)]))),128))])):S("",!0)]))),128))])],2)):P.type==="subagent"?(r(),o("div",{key:4,class:ce(["w-full rounded-lg px-3 py-2 text-xs transition-all border overflow-hidden",{"bg-accent-100 text-accent-950 border-accent-300 dark:bg-accent-900/40 dark:text-accent-50 dark:border-accent-700":!P.silent,"bg-transparent text-neutral-700 border-dashed border-neutral-400 dark:text-neutral-200 dark:border-neutral-600":P.silent,"ring-2 ring-accent-500":!t.isEditMode&&d(re,t.selectedLogId),"ring-2 ring-accent-400":!t.isEditMode&&!d(re,t.selectedLogId)&&d(re,t.hoveredLogId)}])},[e("button",{type:"button",class:"w-full flex items-center gap-2 text-left",onClick:Ge(se=>ee(P.id),["stop"])},[ye(P)?(r(),J(I(jr),{key:0,size:14,class:"text-neutral-500 dark:text-neutral-400 flex-shrink-0"})):ke(P)?(r(),J(I(Xt),{key:1,size:13,class:"text-red-600 dark:text-red-400 flex-shrink-0",title:"Subagent returned an error"})):_e(P)?(r(),J(I(rr),{key:2,size:14,class:"animate-spin text-accent-700 dark:text-accent-300 flex-shrink-0"})):O(P)?(r(),J(I(er),{key:3,size:14,class:"text-green-700 dark:text-green-300 flex-shrink-0"})):(r(),J(I(Rr),{key:4,size:12,class:"text-neutral-500 dark:text-neutral-400 flex-shrink-0"})),e("span",eh,C(Y(P)),1),e("span",th,C(P.messageCount),1),L.value.has(P.id)?(r(),J(I(gt),{key:5,size:13,class:"ml-1 opacity-70 flex-shrink-0"})):(r(),J(I(_t),{key:6,size:13,class:"ml-1 opacity-70 flex-shrink-0"}))],8,Qg),L.value.has(P.id)?(r(),o("div",rh,[e("div",ah,C(ne(P)),1),(r(!0),o(we,null,Ae(P.messages,se=>(r(),o("div",{key:se.id,class:"rounded border border-current/20 bg-white/50 dark:bg-black/30 px-2 py-1"},[e("div",nh,[e("span",oh,C(Te(se.role)),1),e("span",null,C(Q(se.created_at)),1),se.silent?(r(),o("span",lh,"silent")):S("",!0)]),se.content?(r(),o("div",sh,C(ue(se.content)),1)):S("",!0),se.attachments?.length&&t.threadId?(r(),o("div",ih,[(r(!0),o(we,null,Ae(se.attachments,Ie=>(r(),J(br,{key:Ie.id,attachment:Ie,threadId:t.threadId},null,8,["attachment","threadId"]))),128))])):S("",!0)]))),128))])):S("",!0)],2)):S("",!0)],2)],40,tg))),128))]))}}),dh=ct(uh,[["__scopeId","data-v-d182a948"]]),ch=["onClick"],ph=["value","placeholder","disabled"],mh=Ce({__name:"TagInput",props:{modelValue:{},placeholder:{},disabled:{type:Boolean}},emits:["update:modelValue"],setup(t,{emit:n}){const a=t,s=n,l=m(""),u=m(null),i=g=>{const y=g.trim().toLowerCase();y&&!a.modelValue.includes(y)&&s("update:modelValue",[...a.modelValue,y]),l.value="",Ne(()=>u.value?.focus())},p=g=>{const y=[...a.modelValue];y.splice(g,1),s("update:modelValue",y)},x=g=>{const y=g.target.value;if(y.includes(",")){const _=y.split(",");_.forEach((v,d)=>{d<_.length-1?i(v):l.value=v})}else l.value=y},k=g=>{g.key==="Enter"?(g.preventDefault(),i(l.value)):g.key==="Backspace"&&!l.value&&a.modelValue.length>0&&p(a.modelValue.length-1)},h=()=>{u.value?.focus()};return(g,y)=>(r(),o("div",{class:ce(["flex flex-wrap items-center gap-1.5 min-h-[32px] px-2 py-1.5 bg-white dark:bg-neutral-950 border border-neutral-200 dark:border-neutral-800 rounded-md cursor-text focus-within:ring-2 focus-within:ring-accent-500/20 focus-within:border-accent-500 transition-colors",{"opacity-50 cursor-not-allowed":t.disabled}]),onClick:h},[(r(!0),o(we,null,Ae(t.modelValue,(_,v)=>(r(),o("span",{key:_,class:"inline-flex items-center gap-1 px-2 py-0.5 text-xs font-medium bg-accent-100 dark:bg-accent-900/30 text-accent-700 dark:text-accent-300 rounded"},[de(C(_)+" ",1),t.disabled?S("",!0):(r(),o("button",{key:0,type:"button",onClick:Ge(d=>p(v),["stop"]),class:"hover:text-accent-900 dark:hover:text-accent-100 transition-colors"},[w(I(Tr),{size:12})],8,ch))]))),128)),e("input",{ref_key:"inputRef",ref:u,type:"text",value:l.value,placeholder:t.modelValue.length===0?t.placeholder:"",disabled:t.disabled,class:"flex-1 min-w-[60px] bg-transparent border-none outline-none text-xs text-neutral-900 dark:text-neutral-100 placeholder:text-neutral-400 disabled:cursor-not-allowed",onInput:x,onKeydown:k},null,40,ph)],2))}}),vh={key:0,class:"overflow-hidden bg-neutral-100 dark:bg-neutral-950"},fh={class:"max-h-[500px] overflow-y-auto p-3 space-y-3"},gh={key:0,class:"flex justify-center py-6"},hh={key:1,class:"text-red-600 dark:text-red-400 text-center py-4 text-xs"},bh={class:"bg-white dark:bg-neutral-900 rounded-lg border border-neutral-200 dark:border-neutral-800 overflow-hidden"},xh={class:"p-3 space-y-2"},yh={class:"text-[10px] text-neutral-500 dark:text-neutral-400"},kh=["title"],wh={class:"flex-1 text-[11px] font-mono text-neutral-600 dark:text-neutral-400 truncate"},_h={class:"flex items-center gap-2"},$h={class:"flex-1 flex items-center gap-1.5"},Ch={key:1,class:"text-xs text-neutral-700 dark:text-neutral-200"},Sh={class:"text-[9px] px-1.5 py-0.5 rounded bg-neutral-100 dark:bg-neutral-800 text-neutral-500 dark:text-neutral-400 uppercase tracking-wide shrink-0"},Ih={class:"flex items-start gap-2"},Th={class:"bg-white dark:bg-neutral-900 rounded-lg border border-neutral-200 dark:border-neutral-800 overflow-hidden"},Mh={class:"p-3"},zh={key:0,class:"text-xs text-neutral-500 dark:text-neutral-400"},Vh={key:1,class:"text-xs text-neutral-500 dark:text-neutral-400"},Eh={key:2,class:"space-y-2"},Lh={class:"min-w-0"},Ah={class:"flex items-center gap-1.5"},Ph={class:"text-[11px] font-mono text-neutral-700 dark:text-neutral-200 truncate"},jh={key:0,class:"text-[9px] px-1 py-0.5 rounded bg-red-100 dark:bg-red-900 text-red-700 dark:text-red-300 uppercase tracking-wide"},Rh={class:"text-[10px] text-neutral-500 dark:text-neutral-400"},Oh={key:0,class:"text-[10px] text-neutral-500 dark:text-neutral-400"},Dh={class:"bg-white dark:bg-neutral-900 rounded-lg border border-neutral-200 dark:border-neutral-800 overflow-hidden"},Uh=["disabled"],Bh={key:0,class:"overflow-hidden border-t border-neutral-100 dark:border-neutral-800"},Nh={class:"p-3 space-y-3"},qh={class:"flex gap-4 text-xs"},Fh={class:"ml-1 font-mono font-semibold text-neutral-800 dark:text-neutral-100"},Hh={class:"ml-1 font-mono text-neutral-600 dark:text-neutral-400"},Wh={key:0,class:"w-full text-[11px]"},Kh=["title"],Jh={class:"text-right py-1.5 font-mono text-neutral-600 dark:text-neutral-400"},Gh={class:"text-right py-1.5 font-mono text-neutral-600 dark:text-neutral-400"},Yh={class:"bg-white dark:bg-neutral-900 rounded-lg border border-neutral-200 dark:border-neutral-800 overflow-hidden"},Zh={key:0,class:"overflow-hidden border-t border-neutral-100 dark:border-neutral-800"},Xh={class:"p-3 space-y-3"},Qh={class:"flex items-center gap-2"},eb=["disabled"],tb={class:"pt-2 border-t border-neutral-100 dark:border-neutral-800"},rb=["disabled"],ab=Ce({__name:"MetadataSlidePane",props:{threadId:{},show:{type:Boolean}},emits:["close","threadDeleted","editThread","threadUpdated"],setup(t,{emit:n}){const a=t,s=n,{thread:l,isFetching:u,error:i,refetch:p}=Vr(q(()=>a.threadId)),{agents:x,isFetching:k}=Ga(),h=m(!1),g=m(!1),y=m(!1),_=m(!1),v=m(!1),d=m(!1),b=m(!1),c=m(!1),f=m("a"),$=m(!1),N=m(!1),E=m([]),L=m(""),V=m([]),A=m(!1),G=m(null),ee=q(()=>x.value?x.value.filter(ue=>ue.type==="ai_human").map(ue=>({value:ue.id,label:ue.title})):[]),ie=q(()=>l.value?.agent.type==="ai_human"),be=q(()=>l.value?.agent.type==="dual_ai"),Q=ue=>new Date(ue*1e3).toLocaleString("en-US",{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}),U=async()=>{l.value&&(await navigator.clipboard.writeText(l.value.id),$.value=!0,setTimeout(()=>{$.value=!1},2e3))},R=async ue=>{if(!(!a.threadId||!ue||ue===l.value?.agent.id)){y.value=!0;try{const te=await fetch(Ve(`/api/threads/${a.threadId}`),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({agent_id:ue})});if(!te.ok){const Y=await te.json();throw new Error(Y.error||"Failed to update agent")}await p(),s("threadUpdated")}catch(te){console.error("Error updating agent:",te),L.value=l.value?.agent.id||""}finally{y.value=!1}}},K=async ue=>{if(a.threadId){V.value=ue,A.value=!0,_.value=!0;try{const te=await fetch(Ve(`/api/threads/${a.threadId}`),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({tags:ue})});if(!te.ok){const Y=await te.json();throw new Error(Y.error||"Failed to update tags")}s("threadUpdated")}catch(te){console.error("Error updating tags:",te),V.value=l.value?.tags||[]}finally{_.value=!1,A.value=!1}}},H=async()=>{if(v.value){v.value=!1;return}if(a.threadId){b.value=!0,v.value=!0;try{const ue=await fetch(Ve(`/api/threads/${a.threadId}/cost`));if(!ue.ok){const te=await ue.json();throw new Error(te.error||"Failed to fetch cost breakdown")}G.value=await ue.json()}catch(ue){console.error("Error fetching cost breakdown:",ue),v.value=!1}finally{b.value=!1}}},ve=ue=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:4,maximumFractionDigits:6}).format(ue),X=ue=>ue.defined?(ue.defined.type==="agent"||ue.defined.type==="prompt")&&ue.defined.name?`${ue.defined.type}:${ue.defined.name}`:ue.defined.type:"missing",D=async()=>{if(!a.threadId||!l.value?.agent?.id){E.value=[];return}N.value=!0;try{const ue=await fetch(Ve(`/api/variables/agents/${encodeURIComponent(l.value.agent.id)}?thread_id=${encodeURIComponent(a.threadId)}`));if(!ue.ok){E.value=[];return}const te=await ue.json();E.value=te.variables||[]}catch(ue){console.error("Error fetching thread variables:",ue),E.value=[]}finally{N.value=!1}},W=async()=>{if(a.threadId){c.value=!0;try{const ue=await fetch(Ve(`/api/threads/${a.threadId}/continue`),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({side:f.value})});if(!ue.ok){const te=await ue.json();throw new Error(te.error||"Failed to continue execution")}}catch(ue){console.error("Error continuing execution:",ue)}finally{c.value=!1}}},me=async()=>{if(a.threadId){g.value=!0;try{const ue=await fetch(Ve(`/api/threads/${a.threadId}`),{method:"DELETE"});if(!ue.ok){const te=await ue.json();throw new Error(te.error||"Failed to delete thread")}s("threadDeleted",a.threadId)}catch(ue){console.error("Error deleting thread:",ue)}finally{g.value=!1}}};return Ee(()=>l.value,ue=>{ue&&(L.value=ue.agent.id,A.value||(V.value=ue.tags||[]))},{immediate:!0}),Ee(()=>a.show,ue=>{ue?D():(v.value=!1,d.value=!1,G.value=null,E.value=[],N.value=!1)}),Ee(()=>a.threadId,()=>{v.value=!1,d.value=!1,G.value=null,E.value=[],a.show&&D()}),Ee(()=>l.value?.agent?.id,()=>{a.show&&D()}),(ue,te)=>{const Y=tt("FormKit");return r(),J(bt,{"enter-active-class":"transition-all duration-300 ease-out","enter-from-class":"max-h-0 opacity-0","enter-to-class":"max-h-[500px] opacity-100","leave-active-class":"transition-all duration-200 ease-in","leave-from-class":"max-h-[500px] opacity-100","leave-to-class":"max-h-0 opacity-0"},{default:F(()=>[t.show&&t.threadId?(r(),o("div",vh,[e("div",fh,[I(u)?(r(),o("div",gh,[w(Be)])):I(i)?(r(),o("div",hh," Error: "+C(I(i)),1)):I(l)?(r(),o(we,{key:2},[e("div",bh,[e("div",xh,[e("div",yh,[te[5]||(te[5]=e("span",{class:"font-medium uppercase tracking-wide"},"Created",-1)),te[6]||(te[6]=e("span",{class:"mx-1"},"·",-1)),de(" "+C(Q(I(l).created_at)),1)]),e("div",{class:"flex items-center gap-1 px-2 py-1.5 bg-neutral-50 dark:bg-neutral-950 rounded border border-neutral-200 dark:border-neutral-800 cursor-pointer hover:border-neutral-300 dark:hover:border-neutral-700 transition-colors group",onClick:U,title:$.value?"Copied!":"Click to copy"},[e("code",wh,C(I(l).id),1),e("span",{class:ce(["shrink-0 transition-colors",$.value?"text-green-600 dark:text-green-400":"text-neutral-400 group-hover:text-neutral-600 dark:group-hover:text-neutral-300"])},[$.value?(r(),J(I(er),{key:0,size:12})):(r(),J(I(gn),{key:1,size:12}))],2)],8,kh),e("div",_h,[te[7]||(te[7]=e("label",{class:"shrink-0 text-[10px] font-medium text-neutral-500 dark:text-neutral-400 uppercase tracking-wide w-10"},"Agent",-1)),e("div",$h,[ie.value?(r(),J(Y,{key:0,type:"selectSearch",modelValue:L.value,"onUpdate:modelValue":te[0]||(te[0]=ae=>L.value=ae),options:ee.value,loading:I(k)||y.value,disabled:y.value,size:"sm",placeholder:"Select...",onInput:R,"outer-class":"!mb-0 flex-1"},null,8,["modelValue","options","loading","disabled"])):(r(),o("span",Ch,C(I(l).agent.title),1)),e("span",Sh,C(I(l).agent.type.replace("_"," ")),1)])]),e("div",Ih,[te[8]||(te[8]=e("label",{class:"shrink-0 text-[10px] font-medium text-neutral-500 dark:text-neutral-400 uppercase tracking-wide w-10 pt-2"},"Tags",-1)),w(mh,{"model-value":V.value,"onUpdate:modelValue":K,disabled:_.value,placeholder:"Add tags...",class:"flex-1"},null,8,["model-value","disabled"])])])]),e("div",Th,[te[9]||(te[9]=e("div",{class:"px-3 py-2.5 border-b border-neutral-100 dark:border-neutral-800"},[e("div",{class:"text-xs font-medium text-neutral-700 dark:text-neutral-200"}," Variables ")],-1)),e("div",Mh,[N.value?(r(),o("div",zh," Loading variables... ")):E.value.length===0?(r(),o("div",Vh," No declared variables for this thread. ")):(r(),o("div",Eh,[(r(!0),o(we,null,Ae(E.value.slice(0,6),ae=>(r(),o("div",{key:ae.property,class:"flex items-center justify-between gap-2"},[e("div",Lh,[e("div",Ah,[e("span",Ph,C(ae.property),1),ae.required?(r(),o("span",jh," required ")):S("",!0)]),e("div",Rh,C(X(ae)),1)]),e("span",{class:ce(["text-[9px] px-1 py-0.5 rounded uppercase tracking-wide",ae.type==="secret"?"bg-amber-100 dark:bg-amber-900 text-amber-700 dark:text-amber-300":"bg-blue-100 dark:bg-blue-900 text-blue-700 dark:text-blue-300"])},C(ae.type),3)]))),128)),E.value.length>6?(r(),o("div",Oh," +"+C(E.value.length-6)+" more ",1)):S("",!0)]))])]),e("div",Dh,[e("button",{onClick:H,disabled:b.value,type:"button",class:"w-full flex items-center gap-2 px-3 py-2.5 text-left hover:bg-neutral-50 dark:hover:bg-neutral-800 transition-colors disabled:opacity-50"},[w(I(hn),{size:14,class:"shrink-0 text-neutral-400"}),te[10]||(te[10]=e("span",{class:"flex-1 text-xs font-medium text-neutral-700 dark:text-neutral-200"},"Usage & Cost",-1)),b.value?(r(),J(Be,{key:0,size:"xs"})):(r(),J(I(gt),{key:1,size:14,class:ce(["shrink-0 text-neutral-400 transition-transform duration-200",{"-rotate-180":v.value}])},null,8,["class"]))],8,Uh),w(bt,{"enter-active-class":"transition-all duration-200 ease-out","enter-from-class":"opacity-0 max-h-0","enter-to-class":"opacity-100 max-h-[250px]","leave-active-class":"transition-all duration-150 ease-in","leave-from-class":"opacity-100 max-h-[250px]","leave-to-class":"opacity-0 max-h-0"},{default:F(()=>[v.value&&G.value?(r(),o("div",Bh,[e("div",Nh,[e("div",qh,[e("div",null,[te[11]||(te[11]=e("span",{class:"text-neutral-500 dark:text-neutral-400"},"Total:",-1)),e("span",Fh,C(ve(G.value.totalCost)),1)]),e("div",null,[te[12]||(te[12]=e("span",{class:"text-neutral-500 dark:text-neutral-400"},"Per msg:",-1)),e("span",Hh,C(ve(G.value.avgCostPerMessage)),1)])]),G.value.modelBreakdown.length>0?(r(),o("table",Wh,[te[13]||(te[13]=e("thead",null,[e("tr",{class:"border-b border-neutral-200 dark:border-neutral-800"},[e("th",{class:"text-left py-1.5 font-medium text-neutral-500 dark:text-neutral-400 uppercase text-[10px]"},"Model"),e("th",{class:"text-right py-1.5 font-medium text-neutral-500 dark:text-neutral-400 uppercase text-[10px] w-14"},"Reqs"),e("th",{class:"text-right py-1.5 font-medium text-neutral-500 dark:text-neutral-400 uppercase text-[10px]"},"Cost")])],-1)),e("tbody",null,[(r(!0),o(we,null,Ae(G.value.modelBreakdown,ae=>(r(),o("tr",{key:ae.modelName},[e("td",{class:"py-1.5 truncate max-w-[120px] text-neutral-700 dark:text-neutral-300",title:ae.modelName},C(ae.modelName),9,Kh),e("td",Jh,C(ae.requestCount),1),e("td",Gh,C(ve(ae.totalCost)),1)]))),128))])])):S("",!0)])])):S("",!0)]),_:1})]),e("div",Yh,[e("button",{onClick:te[1]||(te[1]=ae=>d.value=!d.value),type:"button",class:"w-full flex items-center gap-2 px-3 py-2.5 text-left hover:bg-neutral-50 dark:hover:bg-neutral-800 transition-colors"},[w(I(bn),{size:14,class:"shrink-0 text-neutral-400"}),te[14]||(te[14]=e("span",{class:"flex-1 text-xs font-medium text-neutral-700 dark:text-neutral-200"},"Developer Tools",-1)),w(I(gt),{size:14,class:ce(["shrink-0 text-neutral-400 transition-transform duration-200",{"-rotate-180":d.value}])},null,8,["class"])]),w(bt,{"enter-active-class":"transition-all duration-200 ease-out","enter-from-class":"opacity-0 max-h-0","enter-to-class":"opacity-100 max-h-[150px]","leave-active-class":"transition-all duration-150 ease-in","leave-from-class":"opacity-100 max-h-[150px]","leave-to-class":"opacity-0 max-h-0"},{default:F(()=>[d.value?(r(),o("div",Zh,[e("div",Xh,[e("div",Qh,[be.value?He((r(),o("select",{key:0,"onUpdate:modelValue":te[2]||(te[2]=ae=>f.value=ae),class:"text-xs px-2 py-1.5 border border-neutral-200 dark:border-neutral-700 rounded bg-white dark:bg-neutral-800 text-neutral-700 dark:text-neutral-300"},[...te[15]||(te[15]=[e("option",{value:"a"},"Side A",-1),e("option",{value:"b"},"Side B",-1)])],512)),[[ga,f.value]]):S("",!0),e("button",{onClick:W,disabled:c.value,class:"flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium bg-neutral-800 dark:bg-neutral-200 text-white dark:text-neutral-900 rounded hover:bg-neutral-700 dark:hover:bg-neutral-300 transition-colors disabled:opacity-50"},[w(I(xn),{size:12}),e("span",null,C(c.value?"Running...":"Continue"),1)],8,eb),te[16]||(te[16]=e("span",{class:"text-[10px] text-neutral-500 dark:text-neutral-400"},"Resume without new message",-1))]),e("div",tb,[e("button",{onClick:te[3]||(te[3]=ae=>h.value=!0),disabled:g.value,class:"flex items-center gap-1.5 text-xs font-medium text-red-600 dark:text-red-400 hover:text-red-700 dark:hover:text-red-300 transition-colors disabled:opacity-50"},[w(I(yn),{size:12}),e("span",null,C(g.value?"Deleting...":"Delete Thread"),1)],8,rb)])])])):S("",!0)]),_:1})])],64)):S("",!0)]),w(zr,{modelValue:h.value,"onUpdate:modelValue":te[4]||(te[4]=ae=>h.value=ae),title:"Delete Thread?",message:"This will permanently delete all messages, logs, and associated data. This action cannot be undone.","confirm-text":"Delete","cancel-text":"Cancel",onConfirm:me},null,8,["modelValue"])])):S("",!0)]),_:1})}}}),nb=ct(ab,[["__scopeId","data-v-07e96d1b"]]),ob={key:0,class:"overflow-hidden bg-neutral-100 dark:bg-neutral-950"},lb={class:"max-h-[400px] overflow-y-auto p-3 space-y-3"},sb={class:"bg-white dark:bg-neutral-900 rounded-lg border border-neutral-200 dark:border-neutral-800 overflow-hidden"},ib={class:"flex items-center justify-between px-3 py-2 border-b border-neutral-100 dark:border-neutral-800"},ub={class:"flex items-center gap-2"},db={class:"text-[10px] text-neutral-400"},cb={class:"flex items-center gap-1"},pb={class:"p-2"},mb={key:0,class:"px-2 py-4 text-center text-neutral-400 text-xs"},vb=["onClick"],fb={class:"text-xs text-neutral-700 dark:text-neutral-300 truncate"},gb={class:"text-[10px] text-neutral-400 ml-auto"},hb=["href","onMouseenter"],bb={class:"shrink-0 text-neutral-400"},xb={class:"flex-1 min-w-0"},yb={class:"shrink-0 text-[10px] text-neutral-400 ml-auto"},kb={key:0,class:"text-blue-500"},wb={key:1,class:"text-red-500"},_b={key:2},$b=["href","onMouseenter"],Cb={class:"shrink-0 text-neutral-400"},Sb={class:"flex-1 min-w-0"},Ib={class:"shrink-0 text-[10px] text-neutral-400 ml-auto"},Tb={key:0,class:"text-blue-500"},Mb={key:1,class:"text-red-500"},zb={key:2},Vb=["src","alt"],Eb=Ce({__name:"FilesSlidePane",props:{threadId:{},show:{type:Boolean}},emits:["close"],setup(t,{emit:n}){const a=t;let s=null;try{s=Ma()}catch{}const l=s?.files??m([]),u=s?.addFiles??(()=>{}),i=m(null),p=m(new Set(["/attachments"])),x=m(null),k=m({x:0,y:0});function h(N){if(N===0)return"0 B";const E=1024,L=["B","KB","MB","GB"],V=Math.floor(Math.log(N)/Math.log(E));return parseFloat((N/Math.pow(E,V)).toFixed(1))+" "+L[V]}function g(N){const E=N.startsWith("/")?N.slice(1):N;return Ve(`/api/threads/${a.threadId}/fs/${E}`)}function y(N,E){return E?xa:N.startsWith("audio/")?_n:N.startsWith("video/")?$n:N.startsWith("text/")?Cn:N.includes("javascript")||N.includes("json")||N.includes("xml")?Sn:ya}function _(N){const E=N.target;E.files?.length&&(u(E.files),E.value="")}function v(){i.value?.click()}function d(N){p.value.has(N)?p.value.delete(N):p.value.add(N),p.value=new Set(p.value)}function b(N){k.value={x:N.clientX,y:N.clientY}}function c(N){x.value=N}const f=q(()=>{const N=[],E=new Map,L=[...l.value].sort((V,A)=>V.status==="uploading"&&A.status!=="uploading"?-1:A.status==="uploading"&&V.status!=="uploading"?1:(V.path||V.name).localeCompare(A.path||A.name));for(const V of L){const A=V.path||`/${V.name}`,G=A.split("/").filter(Boolean);if(G.length===1)N.push({type:"file",name:V.name,path:A,file:V});else{const ee="/"+G.slice(0,-1).join("/"),ie=G[G.length-2];if(!E.has(ee)){const be={type:"directory",name:ie,path:ee,children:[]};E.set(ee,be),N.push(be)}E.get(ee).children.push({type:"file",name:V.name,path:A,file:V})}}return N}),$=q(()=>l.value.length);return qe(()=>{document.addEventListener("mousemove",b)}),ut(()=>{document.removeEventListener("mousemove",b)}),(N,E)=>(r(),J(bt,{"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:F(()=>[t.show?(r(),o("div",ob,[e("div",lb,[e("div",sb,[e("div",ib,[e("div",ub,[w(I(tr),{size:14,class:"text-neutral-400"}),E[3]||(E[3]=e("span",{class:"text-xs font-medium text-neutral-700 dark:text-neutral-200"},"Files",-1)),e("span",db,C($.value),1)]),e("div",cb,[e("input",{ref_key:"fileInput",ref:i,type:"file",multiple:"",class:"hidden",onChange:_},null,544),e("button",{onClick:v,type:"button",class:"p-1 hover:bg-neutral-100 dark:hover:bg-neutral-700 rounded transition-colors text-neutral-400 hover:text-neutral-600 dark:hover:text-neutral-300",title:"Upload files"},[w(I(kn),{size:14})])])]),e("div",pb,[f.value.length===0?(r(),o("div",mb," No files yet ")):S("",!0),(r(!0),o(we,null,Ae(f.value,L=>(r(),o(we,{key:L.path},[L.type==="directory"?(r(),o(we,{key:0},[e("button",{onClick:V=>d(L.path),type:"button",class:"w-full flex items-center gap-1.5 px-2 py-1.5 hover:bg-neutral-50 dark:hover:bg-neutral-700/50 rounded transition-colors text-left"},[w(I(_t),{size:12,class:ce(["shrink-0 text-neutral-400 transition-transform",{"rotate-90":p.value.has(L.path)}])},null,8,["class"]),(r(),J(Qe(p.value.has(L.path)?I(wn):I(tr)),{size:14,class:"shrink-0",style:{color:"var(--accent-500)"}})),e("span",fb,C(L.name),1),e("span",gb,C(L.children?.length),1)],8,vb),p.value.has(L.path)?(r(!0),o(we,{key:0},Ae(L.children,V=>(r(),o("a",{key:V.path,href:V.path?g(V.path):void 0,target:"_blank",rel:"noopener noreferrer",class:ce(["flex items-center gap-2 pl-7 pr-2 py-1 hover:bg-neutral-50 dark:hover:bg-neutral-700/50 rounded transition-colors cursor-pointer",{"pointer-events-none":V.file?.status==="uploading"}]),onMouseenter:A=>V.file?.isImage?c(V.path):null,onMouseleave:E[0]||(E[0]=A=>c(null))},[e("div",bb,[V.file?.status==="uploading"?(r(),J(I(rr),{key:0,size:12,class:"animate-spin"})):(r(),J(Qe(y(V.file?.mimeType||"",V.file?.isImage||!1)),{key:1,size:12}))]),e("div",xb,[e("div",{class:ce(["text-[11px] text-neutral-600 dark:text-neutral-400 truncate",{"opacity-50":V.file?.status==="uploading"}])},C(V.name),3)]),e("div",yb,[V.file?.status==="uploading"?(r(),o("span",kb,"...")):V.file?.status==="error"?(r(),o("span",wb,"err")):(r(),o("span",_b,C(h(V.file?.size||0)),1))])],42,hb))),128)):S("",!0)],64)):(r(),o("a",{key:1,href:L.path?g(L.path):void 0,target:"_blank",rel:"noopener noreferrer",class:ce(["flex items-center gap-2 px-2 py-1.5 hover:bg-neutral-50 dark:hover:bg-neutral-700/50 rounded transition-colors cursor-pointer",{"pointer-events-none":L.file?.status==="uploading"}]),onMouseenter:V=>L.file?.isImage?c(L.path):null,onMouseleave:E[1]||(E[1]=V=>c(null))},[e("div",Cb,[L.file?.status==="uploading"?(r(),J(I(rr),{key:0,size:14,class:"animate-spin"})):(r(),J(Qe(y(L.file?.mimeType||"",L.file?.isImage||!1)),{key:1,size:14}))]),e("div",Sb,[e("div",{class:ce(["text-xs text-neutral-600 dark:text-neutral-400 truncate",{"opacity-50":L.file?.status==="uploading"}])},C(L.name),3)]),e("div",Ib,[L.file?.status==="uploading"?(r(),o("span",Tb,"...")):L.file?.status==="error"?(r(),o("span",Mb,"err")):(r(),o("span",zb,C(h(L.file?.size||0)),1))])],42,$b))],64))),128))])])]),(r(),J(Ht,{to:"body"},[x.value?(r(),o("div",{key:0,class:"fixed z-50 bg-white dark:bg-neutral-800 border border-neutral-200 dark:border-neutral-700 rounded-lg shadow-lg p-1 pointer-events-none",style:yt({left:`${k.value.x+16}px`,top:`${k.value.y-80}px`})},[e("img",{src:g(x.value),alt:x.value,class:"max-w-[200px] max-h-[150px] rounded object-contain",onError:E[2]||(E[2]=L=>L.target.style.display="none")},null,40,Vb)],4)):S("",!0)]))])):S("",!0)]),_:1}))}}),Lb=["accept"],Ab=["disabled"],Pb=Ce({__name:"FileUpload",props:{isProcessing:{type:Boolean},accept:{}},emits:["filesSelected"],setup(t,{expose:n,emit:a}){const s=t,l=a,u=m(null),i=q(()=>s.accept||"image/*,.pdf,.txt,.md,.json,.csv");function p(){u.value?.click()}function x(h){const g=h.target;g.files&&g.files.length>0&&(l("filesSelected",g.files),g.value="")}function k(h){const g=h.clipboardData?.items;if(!g)return;const y=[];for(let _=0;_<g.length;_++){const v=g[_];if(v.kind==="file"){const d=v.getAsFile();d&&y.push(d)}}if(y.length>0){const _=new DataTransfer;y.forEach(v=>_.items.add(v)),l("filesSelected",_.files)}}return n({handlePaste:k}),(h,g)=>(r(),o(we,null,[e("input",{ref_key:"fileInputRef",ref:u,type:"file",accept:i.value,multiple:"",class:"hidden",onChange:x},null,40,Lb),e("button",{type:"button",onClick:p,class:ce(["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"},[w(I(In),{size:18})],10,Ab)],64))}}),jb={class:"flex flex-col h-full"},Rb={class:"px-4 py-3 border-b border-neutral-300 dark:border-neutral-700"},Ob={class:"flex items-center justify-between"},Db={class:"flex items-center gap-2"},Ub={class:"flex items-center gap-2"},Bb={class:"flex-1 flex flex-col overflow-hidden relative"},Nb={key:0,class:"text-neutral-500 dark:text-neutral-400 text-center py-8"},qb={key:1,class:"flex justify-center py-2"},Fb={key:2,class:"flex justify-center py-8"},Hb={key:3,class:"text-red-600 dark:text-red-400 text-center py-8"},Wb={key:4,class:"text-neutral-500 dark:text-neutral-400 text-center py-8"},Kb={key:1,class:"p-3 bg-white dark:bg-neutral-900 border-t border-neutral-300 dark:border-neutral-700"},Jb={class:"flex items-center justify-end gap-2"},Gb=["disabled"],Yb={key:2,class:"p-3 bg-white dark:bg-neutral-900 border-t border-neutral-300 dark:border-neutral-700"},Zb={key:0,class:"mb-2 flex flex-wrap gap-2"},Xb={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"},Qb=["src","alt"],e1={key:1,class:"w-full h-full flex items-center justify-center"},t1={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"},r1=["title"],a1=["onClick"],n1={class:"flex items-start gap-2"},o1={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"},l1=["disabled"],s1=["disabled"],i1={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"},u1={key:1,class:"w-4 h-4"},Xr=Ce({__name:"MessagesPane",props:{threadId:{},selectedMessageId:{},selectedLogId:{},hoveredLogId:{}},emits:["collapse","messageClick","messageHover","threadDeleted","editThread","logsDeleted","threadUpdated"],setup(t,{expose:n,emit:a}){const s=t,l=a,u=m(!1),i=()=>{u.value||(p.value=!1),u.value=!u.value},p=m(!1),x=()=>{p.value||(u.value=!1),p.value=!p.value},k=m(!1),h=m(new Set),g=m(new Map),y=()=>{k.value=!k.value,k.value||(h.value=new Set,g.value=new Map)},_=(Z,oe)=>{const Le=new Set(h.value);oe?Le.add(Z):Le.delete(Z),h.value=Le},v=(Z,oe)=>{const Le=new Map(g.value);Le.set(Z,oe),g.value=Le},d=()=>{k.value=!1,h.value=new Set,g.value=new Map},b=q(()=>h.value.size),c=q(()=>{let Z=0;for(const[oe]of g.value)h.value.has(oe)||Z++;return Z}),f=q(()=>{const Z=b.value,oe=c.value;return Z>0&&oe>0?`Delete (${Z}), Update (${oe})`:Z>0?`Delete (${Z})`:oe>0?`Save changes (${oe})`:"Delete"}),$=q(()=>b.value>0||c.value>0),N=async()=>{if(!s.threadId||!$.value)return;const Z=[];for(const oe of h.value){const Le=E.value.find($e=>$e.id===oe);Le&&"log_id"in Le&&Le.log_id&&Z.push(Le.log_id)}try{for(const[oe,Le]of g.value)h.value.has(oe)||await K(oe,Le);for(const oe of h.value)await R(oe);Z.length>0&&l("logsDeleted",Z)}catch(oe){console.error("Error applying changes:",oe)}finally{d()}},{messages:E,threadInfo:L,isFetching:V,isLoadingMore:A,error:G,wsConnected:ee,wsError:ie,isExecuting:be,hasMore:Q,loadMoreMessages:U,deleteMessageById:R,updateMessageContent:K,stopThread:H,sendMessage:ve,attachments:X,addAttachment:D,removeAttachment:W}=Jf(q(()=>s.threadId),{}),{thread:me}=Vr(q(()=>s.threadId)),ue=q(()=>X.value.length>0),te=q(()=>!1),Y=m(null),ae=Z=>{D(Z)},ye=m(null),Te=m(null);n({scrollToLogId:Z=>Te.value&&ye.value?Te.value.scrollToLogId(Z,ye.value):!1,hasWorkblockForLogId:Z=>Te.value?Te.value.hasWorkblockForLogId(Z):!1}),typeof window<"u"&&(window.__testLoadMoreMessages=U);const _e=m(""),O=m(null),j=m("B"),z=m(!1),M=m(!1),P=async()=>{await Ne(),ye.value&&(ye.value.scrollTop=ye.value.scrollHeight)},re=async Z=>{Z.target.scrollTop<100&&Q.value&&!A.value&&!M.value&&(M.value=!0,await U(),M.value=!1)};Ee(()=>E.value.length,async()=>{!A.value&&!M.value&&await P()}),Ee(()=>s.threadId,async Z=>{Z&&await P()}),Ee(V,async(Z,oe)=>{oe&&!Z&&await P()});const se=q(()=>{const Z=L.value?.agent||me.value?.agent;if(!Z)return"ai A";const oe=Z.type;return j.value==="A"&&Z.side_a_label?Z.side_a_label:j.value==="B"&&Z.side_b_label?Z.side_b_label:oe==="ai_human"?j.value==="A"?"ai":"human":j.value==="A"?"ai A":"ai B"}),Ie=()=>{j.value=j.value==="A"?"B":"A"},he=async()=>{const Z=_e.value.trim().length>0,oe=ue.value;if(!Z&&!oe||!s.threadId||z.value||!ve)return;const Le=_e.value,$e=j.value==="A"?"assistant":"user";_e.value="",O.value&&(O.value.style.height="auto",O.value.style.height="24px"),z.value=!0;try{await ve({role:$e,content:Le}),await P()}catch(Ye){console.error("Error sending message:",Ye)}finally{z.value=!1,await Ne(),O.value&&O.value.focus()}},ge=Z=>{Z.key==="Enter"&&!Z.shiftKey&&(Z.preventDefault(),he())},Oe=async()=>{if(s.threadId)try{await H()}catch(Z){console.error("Error stopping thread:",Z)}};return(Z,oe)=>(r(),o("div",jb,[e("div",Rb,[e("div",Ob,[e("div",Db,[w(I(ka),{size:18,class:"shrink-0"}),oe[11]||(oe[11]=e("h2",{class:"text-base font-bold"},"Messages",-1)),t.threadId?(r(),J(Er,{key:0,connected:I(ee),error:I(ie)},null,8,["connected","error"])):S("",!0)]),e("div",Ub,[t.threadId?(r(),o("button",{key:0,onClick:x,type:"button",class:ce(["p-1 hover:bg-neutral-100 dark:hover:bg-neutral-900 rounded transition-colors",[p.value?"text-accent-600 dark:text-accent-400":""]]),title:"Toggle files"},[w(I(tr),{size:20})],2)):S("",!0),t.threadId?(r(),o("button",{key:1,onClick:i,type:"button",class:ce(["p-1 hover:bg-neutral-100 dark:hover:bg-neutral-900 rounded transition-colors",[u.value?"text-accent-600 dark:text-accent-400":""]]),title:"Toggle thread info"},[w(I(ca),{size:20})],2)):S("",!0),t.threadId&&I(E).length>0?(r(),o("button",{key:2,onClick:y,type:"button",class:ce(["p-1 hover:bg-neutral-100 dark:hover:bg-neutral-900 rounded transition-colors",{"bg-neutral-200 dark:bg-neutral-800":k.value}]),title:"Edit messages"},[w(I(Tn),{size:20})],2)):S("",!0),e("button",{onClick:oe[0]||(oe[0]=Le=>l("collapse")),type:"button",class:"p-1 hover:bg-neutral-100 dark:hover:bg-neutral-900 rounded transition-colors",title:"Collapse pane"},[w(I(ba),{size:20})])])])]),e("div",Bb,[w(nb,{"thread-id":t.threadId,show:u.value,onClose:oe[1]||(oe[1]=Le=>u.value=!1),onThreadDeleted:oe[2]||(oe[2]=Le=>l("threadDeleted",Le)),onEditThread:oe[3]||(oe[3]=Le=>l("editThread")),onThreadUpdated:oe[4]||(oe[4]=Le=>l("threadUpdated"))},null,8,["thread-id","show"]),t.threadId?(r(),J(Eb,{key:0,"thread-id":t.threadId,show:p.value,onClose:oe[5]||(oe[5]=Le=>p.value=!1)},null,8,["thread-id","show"])):S("",!0),e("div",{ref_key:"messagesContainer",ref:ye,class:"flex-1 overflow-y-auto overflow-x-hidden p-4 space-y-4",onScroll:re},[t.threadId?S("",!0):(r(),o("div",Nb," Select a thread to view messages ")),I(A)?(r(),o("div",qb,[w(Be,{size:"sm"}),oe[12]||(oe[12]=e("span",{class:"ml-2 text-xs text-neutral-500"},"Loading older messages...",-1))])):I(V)?(r(),o("div",Fb,[w(Be)])):I(G)?(r(),o("div",Hb," Error loading messages: "+C(I(G)),1)):t.threadId&&I(E).length===0?(r(),o("div",Wb," No messages yet ")):(r(),J(dh,{key:5,ref_key:"agentMessagesRef",ref:Te,messages:I(E),threadId:t.threadId,selectedMessageId:t.selectedMessageId,selectedLogId:t.selectedLogId,hoveredLogId:t.hoveredLogId,isEditMode:k.value,selectedForDelete:h.value,editedMessages:g.value,onMessageClick:oe[6]||(oe[6]=(Le,$e)=>l("messageClick",Le,$e)),onMessageHover:oe[7]||(oe[7]=Le=>l("messageHover",Le)),onSelectionChange:_,onMessageEdit:v},null,8,["messages","threadId","selectedMessageId","selectedLogId","hoveredLogId","isEditMode","selectedForDelete","editedMessages"]))],544),t.threadId&&k.value?(r(),o("div",Kb,[e("div",Jb,[e("button",{onClick:d,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:N,disabled:!$.value,class:ce(["px-4 py-2 rounded-lg font-medium text-sm transition-colors",{"bg-red-600 text-white hover:bg-red-700":$.value&&b.value>0,"bg-black text-white hover:bg-neutral-800 dark:bg-white dark:text-black dark:hover:bg-neutral-200":$.value&&b.value===0,"bg-neutral-200 text-neutral-400 dark:bg-neutral-700 dark:text-neutral-500 cursor-not-allowed":!$.value}])},C(f.value),11,Gb)])])):t.threadId?(r(),o("div",Yb,[I(X).length>0?(r(),o("div",Zb,[(r(!0),o(we,null,Ae(I(X),Le=>(r(),o("div",{key:Le.id,class:"relative group"},[Le.isImage?(r(),o("div",Xb,[Le.previewUrl?(r(),o("img",{key:0,src:Le.previewUrl,alt:Le.name,class:"w-full h-full object-cover"},null,8,Qb)):(r(),o("div",e1,[...oe[13]||(oe[13]=[e("div",{class:"w-4 h-4 border-2 border-neutral-300 border-t-neutral-600 rounded-full animate-spin"},null,-1)])]))])):(r(),o("div",t1,[e("span",{class:"text-xs text-neutral-600 dark:text-neutral-300 max-w-[80px] truncate",title:Le.name},C(Le.name),9,r1)])),e("button",{onClick:Ge($e=>I(W)(Le.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"},[...oe[14]||(oe[14]=[e("span",{class:"text-[10px] font-bold leading-none"},"x",-1)])],8,a1)]))),128))])):S("",!0),e("div",n1,[e("button",{onClick:Ie,class:ce(["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":j.value==="A","bg-neutral-300 text-black dark:bg-neutral-600 dark:text-white":j.value==="B"}]),title:"Toggle between sides"},C(se.value),3),e("div",o1,[w(Pb,{ref_key:"fileUploadRef",ref:Y,"is-processing":!1,onFilesSelected:ae},null,512),He(e("textarea",{ref_key:"messageTextarea",ref:O,"onUpdate:modelValue":oe[8]||(oe[8]=Le=>_e.value=Le),onKeydown:ge,onPaste:oe[9]||(oe[9]=Le=>Y.value?.handlePaste(Le)),disabled:z.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:oe[10]||(oe[10]=Le=>{const $e=Le.target;$e.style.height="auto",$e.style.height=Math.min($e.scrollHeight,120)+"px"})},null,40,l1),[[ht,_e.value]]),I(be)?(r(),o("button",{key:1,id:"stop-thread-button",onClick:Oe,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"},[...oe[16]||(oe[16]=[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)])])):(r(),o("button",{key:0,id:"send-message-button",onClick:he,disabled:!_e.value.trim()&&!ue.value||z.value||te.value,class:ce(["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":(_e.value.trim()||ue.value)&&!z.value&&!te.value,"bg-neutral-200 text-neutral-400 dark:bg-neutral-700 dark:text-neutral-600":!_e.value.trim()&&!ue.value||z.value||te.value}]),title:"Send message (Enter)"},[z.value?(r(),o("div",u1,[w(Be)])):(r(),o("svg",i1,[...oe[15]||(oe[15]=[e("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M4.5 10.5 12 3m0 0 7.5 7.5M12 3v18"},null,-1)])]))],10,s1))])])])):S("",!0)])]))}});function d1(t,n){const{limit:a=100,offset:s=0,order:l="desc",autoFetch:u=!0,enableWebSocket:i=!1}=n||{};q(()=>!!(typeof t=="string"?t:t?.value));const p=q(()=>{const W=typeof t=="string"?t:t?.value;if(!W)return Ve("/api/threads/placeholder/logs");const me=new URLSearchParams,ue=typeof a=="number"?a:a.value,te=typeof s=="number"?s:s.value,Y=typeof l=="string"?l:l.value;return me.append("limit",ue.toString()),me.append("offset",te.toString()),me.append("order",Y),Ve(`/api/threads/${W}/logs?${me.toString()}`)}),{data:x,error:k,isFetching:h,isFinished:g,execute:y,abort:_}=ot(p,{immediate:!1}).get().json();Ee([p,()=>u],([W,me])=>{W&&!W.includes("placeholder")&&me&&y()},{immediate:!0});const v=q(()=>!k.value||k.value.toString().includes("aborted")||k.value.toString().includes("abort")?null:k.value),d=q(()=>x.value?.logs||[]),b=q(()=>x.value?.total||0),c=q(()=>x.value?.hasMore||!1),f=m(null),$=m(!1),N=m(null),E=m([]),L=new Map;let V=0,A=null,G=null,ee=!0,ie=null;const be=3e4,Q=3e4,U=()=>{A&&(clearTimeout(A),A=null),G&&(clearInterval(G),G=null)},R=()=>{G&&clearInterval(G),G=setInterval(()=>{f.value&&f.value.readyState===WebSocket.OPEN&&f.value.send("ping")},Q)},K=()=>{if(!ee||!i)return;const W=Math.min(1e3*Math.pow(2,V),be);V++,console.log(`[Logs WebSocket] Scheduling reconnect in ${W}ms (attempt ${V})`),A=setTimeout(()=>{ee&&H()},W)},H=()=>{const W=typeof t=="string"?t:t?.value;if(!W||!i)return;f.value&&(ie=null,f.value.close()),V===0&&(E.value=[]);const me=window.location.protocol==="https:"?"wss:":"ws:",ue=window.location.host;let te=`${me}//${ue}${Ve(`/api/threads/${W}/logs`)}`;const Y=localStorage.getItem("auth_token");Y&&(te+=`?token=${encodeURIComponent(Y)}`);try{const ae=new WebSocket(te);f.value=ae,ie=ae,ae.onopen=()=>{ie===ae&&($.value=!0,N.value=null,V=0,R(),console.log("[Logs WebSocket] Connected"))},ae.onmessage=ye=>{if(ie===ae&&ye.data!=="pong")try{const Te=JSON.parse(ye.data);if(Te.type==="log_data"){const ne=E.value.findIndex(_e=>_e.id===Te.log_id),ke=d.value.find(_e=>_e.id===Te.log_id);if(ne>=0){E.value[ne]={...E.value[ne],...Te.data};const _e=L.get(Te.log_id);_e&&(E.value[ne].queued_tools=_e,L.delete(Te.log_id))}else if(ke){const _e={...ke,...Te.data},O=L.get(Te.log_id);O&&(_e.queued_tools=O,L.delete(Te.log_id)),E.value.push(_e)}else{const _e={id:Te.log_id,...Te.data},O=L.get(Te.log_id);O&&(_e.queued_tools=O,L.delete(Te.log_id)),E.value.push(_e)}}else if(Te.type==="log_queued_tools"){const ne=E.value.findIndex(_e=>_e.id===Te.log_id),ke=d.value.find(_e=>_e.id===Te.log_id);ne>=0?E.value[ne]={...E.value[ne],queued_tools:Te.queued_tools}:ke?E.value.push({...ke,queued_tools:Te.queued_tools}):L.set(Te.log_id,Te.queued_tools)}}catch(Te){console.error("[Logs WebSocket] Failed to parse message:",Te)}},ae.onerror=ye=>{ie===ae&&(N.value="WebSocket connection error",console.error("[Logs WebSocket] Error:",ye))},ae.onclose=()=>{ie===ae&&($.value=!1,U(),console.log("[Logs WebSocket] Disconnected"),K())}}catch(ae){N.value=ae.message||"Failed to create WebSocket",console.error("[Logs WebSocket] Creation error:",ae),K()}},ve=()=>{ee=!1,U(),ie=null,f.value&&(f.value.close(),f.value=null),$.value=!1,V=0,E.value=[],L.clear()},X=()=>{ee=!0,V=0,H()};return ut(()=>{ve()}),{logs:q(()=>{if(!i)return d.value;const W=new Map;d.value.forEach(te=>W.set(te.id,te)),E.value.forEach(te=>W.set(te.id,te));const me=typeof l=="string"?l:l.value;return Array.from(W.values()).sort((te,Y)=>me==="desc"?Y.created_at-te.created_at:te.created_at-Y.created_at)}),total:b,hasMore:c,error:v,isFetching:h,isFinished:g,refetch:y,abort:_,wsConnected:$,wsError:N,connectWebSocket:X,disconnectWebSocket:ve}}function c1(t,n){const a=q(()=>{const p=t.value,x=n.value;return!p||!x?null:Ve(`/api/threads/${p}/logs/${x}`)}),{data:s,error:l,isFetching:u,execute:i}=ot(a,{immediate:!1}).get().json();return Ee([t,n],([p,x])=>{p&&x&&i()},{immediate:!0}),{logDetails:s,error:l,isFetching:u,refetch:i}}const p1=["disabled","title"],m1={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"},v1={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"},f1={key:3},Ya=Ce({__name:"CopyButton",props:{content:{},variant:{},size:{},disabled:{type:Boolean}},setup(t){const n=t,a=m(!1),s=m(!1),l=async()=>{a.value=!0;try{await navigator.clipboard.writeText(n.content),s.value=!0,setTimeout(()=>{s.value=!1},2e3)}catch(p){console.error("Failed to copy:",p),alert(`Failed to copy: ${p instanceof Error?p.message:"Unknown error"}`)}finally{a.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,x)=>(r(),o("button",{onClick:l,disabled:a.value||t.disabled,class:ce([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":s.value?"Copied!":"Copy to clipboard"},[a.value?(r(),J(Be,{key:0,size:"xs"})):t.variant==="ghost"&&!s.value?(r(),o("svg",m1,[...x[0]||(x[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"&&s.value?(r(),o("svg",v1,[...x[1]||(x[1]=[e("polyline",{points:"20 6 9 17 4 12"},null,-1)])])):(r(),o("span",f1,C(s.value?"Copied!":"Copy"),1))],10,p1))}}),xr="__shiki_highlighter__";let Gt=null;async function g1(){return typeof window<"u"&&window[xr]?window[xr]:Gt||(Gt=Nn({themes:["min-light","github-dark-high-contrast"],langs:["json","markdown"]}).then(t=>(typeof window<"u"&&(window[xr]=t),t)),Gt)}const h1={class:"code-block"},b1={key:0,class:"text-xs text-neutral-500 p-2"},x1=["innerHTML"],yr=Ce({__name:"CodeBlock",props:{code:{},language:{}},setup(t){const n=t,a=m(""),s=m(!0),l=async()=>{const u=n.code??"";if(!u){a.value='<pre class="shiki"><code></code></pre>',s.value=!1;return}try{const i=await g1();if(n.language==="json"||n.language==="markdown")a.value=i.codeToHtml(u,{lang:n.language,themes:{light:"min-light",dark:"github-dark-high-contrast"}});else{const p=u.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");a.value=`<pre class="shiki shiki-text"><code>${p}</code></pre>`}}catch{const p=u.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");a.value=`<pre class="shiki"><code>${p}</code></pre>`}finally{s.value=!1}};return qe(()=>{l()}),Ee(()=>n.code,()=>{l()}),(u,i)=>(r(),o("div",h1,[s.value?(r(),o("div",b1,"Loading...")):(r(),o("div",{key:1,innerHTML:a.value,class:"code-content"},null,8,x1))]))}}),y1={class:"json-viewer relative bg-white dark:bg-neutral-900"},k1={key:0,class:"absolute top-[5px] right-[5px] z-10"},w1=["innerHTML"],_1=["src","alt"],$1=Ce({__name:"JsonViewer",props:{json:{},threadId:{},showCopyButton:{type:Boolean}},setup(t){const n=t,a=m(null),s=m(null),l=y=>[".jpg",".jpeg",".png",".gif",".webp",".svg",".bmp"].some(v=>y.toLowerCase().endsWith(v)),u=y=>n.threadId?Ve(`/api/threads/${n.threadId}/fs${y}`):null,i=q(()=>{if(!n.json)return"";if(typeof n.json=="string")try{return JSON.stringify(JSON.parse(n.json),null,2)}catch{return n.json}return JSON.stringify(n.json,null,2)}),p=y=>y.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),x=(y,_=0)=>{const v=" ".repeat(_),d=b=>`<span class="json-punct">${b}</span>`;if(y===null)return'<span class="json-null">null</span>';if(typeof y=="boolean")return`<span class="json-boolean">${y}</span>`;if(typeof y=="number")return`<span class="json-number">${y}</span>`;if(typeof y=="string"){const b=p(y);return n.threadId&&l(y)&&y.startsWith("/attachments/")?`${d('"')}<span class="json-image-path" data-path="${p(y)}">${b}</span>${d('"')}`:`${d('"')}<span class="json-string">${b}</span>${d('"')}`}if(Array.isArray(y)){if(y.length===0)return`${d("[")}${d("]")}`;const b=y.map((c,f)=>{const $=f<y.length-1?d(","):"";return`${v} ${x(c,_+1)}${$}`});return`${d("[")}
38
- ${b.join(`
36
+ `+J.output);return}v.value={success:!0,packageName:J.packageName,version:J.version,output:J.output,url:J.url,tokenSource:J.tokenSource},d.value||s("published",{packageName:J.packageName,version:J.version,url:J.url})}catch(q){m.value=q instanceof Error?q.message:"Failed to publish package"}finally{w.value=!1}}},ye=()=>{l.value=!1},te=()=>d.value?"Dry run completed successfully!":"Package published successfully!";return(q,j)=>(r(),Y(dt,{modelValue:l.value,"onUpdate:modelValue":j[6]||(j[6]=J=>l.value=J),title:"Publish to npm",width:"max-w-lg","min-height":"min-h-[16rem]"},{footer:W(()=>[t("div",Qv,[k(I(Qe),{variant:"ghost",onClick:ye},{default:W(()=>[ve(C(v.value?.success?"Close":"Cancel"),1)]),_:1}),v.value?.success?S("",!0):(r(),Y(I(Qe),{key:0,variant:"primary",disabled:w.value||x.value||!ne.value,onClick:fe},{default:W(()=>[w.value?(r(),o($e,{key:0},[k(Be,{size:"sm",class:"mr-2"}),j[22]||(j[22]=ve(" Publishing... ",-1))],64)):(r(),o($e,{key:1},[ve(C(d.value?"Validate":"Publish"),1)],64))]),_:1},8,["disabled"]))])]),default:W(()=>[v.value?.success?(r(),o("div",wv,[k(I(ot),{variant:d.value?"info":"success"},{default:W(()=>[t("div",_v,[t("p",$v,C(te()),1),v.value.packageName?(r(),o("p",Cv," Package: "+C(v.value.packageName)+"@"+C(v.value.version),1)):S("",!0),v.value.tokenSource==="environment"?(r(),o("p",Sv," Token: from NPM_TOKEN environment variable ")):S("",!0),v.value.url&&!d.value?(r(),o("p",Iv,[t("a",{href:v.value.url,target:"_blank",rel:"noopener noreferrer",class:"text-primary-600 dark:text-primary-400 hover:underline"}," View on npm ",8,Tv)])):S("",!0)])]),_:1},8,["variant"]),v.value.output?(r(),o("div",Mv,[j[7]||(j[7]=t("p",{class:"text-sm font-medium text-neutral-700 dark:text-neutral-300"},"Output:",-1)),t("pre",zv,C(v.value.output),1)])):S("",!0)])):(r(),o("div",Vv,[t("div",Ev,[i.value?(r(),o("div",Lv,[k(Be,{size:"sm"}),j[8]||(j[8]=t("span",{class:"text-sm"},"Loading package info...",-1))])):c.value?(r(),Y(I(ot),{key:1,variant:"error"},{default:W(()=>[ve(C(c.value),1)]),_:1})):u.value?(r(),o("div",Av,[t("div",Pv,[t("h3",Ov,C(u.value.packageName),1),k(I(Ut),{variant:"secondary"},{default:W(()=>[ve("v"+C(u.value.version),1)]),_:1}),u.value.license?(r(),Y(I(Ut),{key:0,variant:"default"},{default:W(()=>[ve(C(u.value.license),1)]),_:1})):S("",!0)]),u.value.author?(r(),o("p",Rv," by "+C(u.value.author),1)):S("",!0),u.value.readme?(r(),o("div",jv,[t("button",{type:"button",class:"flex items-center gap-2 text-sm font-medium text-neutral-600 dark:text-neutral-400 hover:text-neutral-800 dark:hover:text-neutral-200",onClick:j[0]||(j[0]=J=>f.value=!f.value)},[(r(),Y(rt(f.value?I(xt):I(St)),{class:"w-4 h-4"})),j[9]||(j[9]=ve(" README ",-1))]),f.value?(r(),o("div",{key:0,class:"mt-2 prose prose-sm dark:prose-invert max-w-none p-3 rounded-md border border-neutral-200 dark:border-neutral-700 bg-white dark:bg-neutral-800 max-h-[200px] overflow-y-auto",innerHTML:b.value},null,8,Dv)):S("",!0)])):S("",!0)])):S("",!0)]),u.value?(r(),o("hr",Uv)):S("",!0),x.value?(r(),o("div",Bv,[k(Be,{size:"sm"}),j[10]||(j[10]=t("span",{class:"text-sm"},"Checking npm token configuration...",-1))])):h.value?.hasToken?(r(),Y(I(ot),{key:2,variant:"success"},{default:W(()=>[...j[11]||(j[11]=[t("p",{class:"text-sm"},[t("strong",null,"NPM_TOKEN found"),ve(" in your environment. Your token will be used automatically. ")],-1)])]),_:1})):h.value&&!h.value.hasToken?(r(),Y(I(ot),{key:3,variant:"warning"},{default:W(()=>[t("div",Nv,[j[17]||(j[17]=t("p",null,[t("strong",null,"No NPM_TOKEN configured.")],-1)),t("p",null,[j[12]||(j[12]=ve("To publish packages, create an npm token and add it to your ",-1)),t("code",qv,C(h.value.envFile),1),j[13]||(j[13]=ve(" file:",-1))]),t("ol",Fv,[j[15]||(j[15]=t("li",null,[ve("Run: "),t("code",{class:"bg-neutral-200 dark:bg-neutral-700 px-1 rounded"},"npm token create")],-1)),t("li",null,[ve("Add to "+C(h.value.envFile)+": ",1),j[14]||(j[14]=t("code",{class:"bg-neutral-200 dark:bg-neutral-700 px-1 rounded"},"NPM_TOKEN=npm_xxxxx",-1))]),j[16]||(j[16]=t("li",null,"Restart the dev server",-1))]),j[18]||(j[18]=t("p",{class:"pt-2"},"Or enter a token below for this session only:",-1))])]),_:1})):S("",!0),m.value?(r(),Y(I(ot),{key:4,variant:"error"},{default:W(()=>[t("pre",Hv,C(m.value),1)]),_:1})):S("",!0),!h.value?.hasToken&&!x.value?(r(),Y(I(At),{key:5,label:"npm Token",error:_.value||void 0,"help-text":"Create a token at npmjs.com/settings/tokens",required:!h.value?.hasToken},{default:W(()=>[Je(t("input",{"onUpdate:modelValue":j[1]||(j[1]=J=>y.value=J),type:"password",autocomplete:"off",class:pe(["w-full px-3 py-2 rounded-md border text-sm font-mono bg-white dark:bg-neutral-800 border-neutral-300 dark:border-neutral-600 text-neutral-900 dark:text-neutral-100 placeholder-neutral-400 dark:placeholder-neutral-500 focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-transparent",{"border-red-500 dark:border-red-500":_.value}]),placeholder:"npm_xxxxxxxxxxxx"},null,2),[[yt,y.value]])]),_:1},8,["error","required"])):S("",!0),k(I(At),{label:"Registry"},{default:W(()=>[t("div",Wv,[t("div",Kv,[t("label",Jv,[Je(t("input",{"onUpdate:modelValue":j[2]||(j[2]=J=>$.value=J),type:"radio",value:"default",class:"text-primary-500 focus:ring-primary-500"},null,512),[[Nr,$.value]]),j[19]||(j[19]=t("span",{class:"text-sm text-neutral-700 dark:text-neutral-300"},"npm (default)",-1))]),t("label",Gv,[Je(t("input",{"onUpdate:modelValue":j[3]||(j[3]=J=>$.value=J),type:"radio",value:"custom",class:"text-primary-500 focus:ring-primary-500"},null,512),[[Nr,$.value]]),j[20]||(j[20]=t("span",{class:"text-sm text-neutral-700 dark:text-neutral-300"},"Custom registry",-1))])]),$.value==="custom"?(r(),o("div",Yv,[Je(t("input",{"onUpdate:modelValue":j[4]||(j[4]=J=>g.value=J),type:"url",class:pe(["w-full px-3 py-2 rounded-md border text-sm bg-white dark:bg-neutral-800 border-neutral-300 dark:border-neutral-600 text-neutral-900 dark:text-neutral-100 placeholder-neutral-400 dark:placeholder-neutral-500 focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-transparent",{"border-red-500 dark:border-red-500":P.value}]),placeholder:"https://registry.example.com"},null,2),[[yt,g.value]]),P.value?(r(),o("p",Zv,C(P.value),1)):S("",!0)])):S("",!0)])]),_:1}),t("label",Xv,[Je(t("input",{"onUpdate:modelValue":j[5]||(j[5]=J=>d.value=J),type:"checkbox",class:"rounded text-primary-500 focus:ring-primary-500"},null,512),[[Lr,d.value]]),j[21]||(j[21]=t("span",{class:"text-sm text-neutral-700 dark:text-neutral-300"}," Dry run (validate without publishing) ",-1))])]))]),_:1},8,["modelValue"]))}});function Wt(e,n=0){if(!e||n>4||typeof e!="object")return null;const a=e;return typeof a.clearErrors=="function"&&typeof a.setErrors=="function"?e:"value"in a?Wt(a.value,n+1):"node"in a?Wt(a.node,n+1):"formNode"in a?Wt(a.formNode,n+1):null}function Gt(e,n){const a=Wt(n);return a?(a.clearErrors(!0),e.fieldErrors&&Object.keys(e.fieldErrors).length>0?(a.setErrors([],e.fieldErrors),!0):e.error?(a.setErrors([e.error]),!0):!1):!1}function rf(e){Wt(e)?.clearErrors(!0)}const af={},nf={class:"p-8 w-full max-w-7xl mx-auto"};function of(e,n){return r(),o("div",nf,[Ye(e.$slots,"default")])}const Pt=mt(af,[["render",of]]),lf={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function sf(e,n){return r(),o("svg",lf,[...n[0]||(n[0]=[t("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M5 12h14m-7-7v14"},null,-1)])])}const Rr=je({name:"lucide-plus",render:sf}),uf={key:0,class:"mb-5 rounded-lg border border-amber-200 dark:border-amber-800 bg-amber-50 dark:bg-amber-950/30 px-4 py-3 text-sm text-amber-800 dark:text-amber-200"},df=Se({__name:"AgentsView",setup(e){const n=qt(),a=Vt(),s=fr(),l=p(!1),u=p("add"),i=p(null),c=p(null),f=p(null),h=p(null),x=p(!1),b=p(!1),y=p(null),$=p(!1),g=p(null),d=p(!1),w=p(null);Ve(()=>a.query.refresh,()=>{a.query.refresh&&(c.value?.refresh(),n.replace({path:"/agents",query:{}}))});const m=()=>{u.value="add",i.value=null,h.value=null,l.value=!0},v=ne=>{u.value="edit",i.value=ne,h.value=null,l.value=!0},_=async ne=>{h.value=null,x.value=!0;try{const fe=u.value==="edit"&&i.value?.id,{originalName:ye,...te}=ne,q=ze(fe?`/api/agents/${encodeURIComponent(i.value.id)}`:"/api/agents"),J=await fetch(q,{method:fe?"PUT":"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(te)});if(J.ok)c.value?.refresh(),l.value=!1,i.value=null;else{const H=await J.json();Gt(H,f.value?.formNode)||(h.value=H.error||`Failed to ${fe?"update":"create"} agent`)}}catch(fe){console.error(`Error ${u.value==="edit"?"updating":"creating"} agent:`,fe),h.value=`Failed to ${u.value==="edit"?"update":"create"} agent`}finally{x.value=!1}},P=ne=>{y.value=ne,b.value=!0},V=()=>{b.value=!1,y.value=null,c.value?.refresh()},E=ne=>{g.value=ne,$.value=!0},z=()=>{$.value=!1,g.value=null,c.value?.refresh()},A=ne=>{w.value=ne,d.value=!0},oe=()=>{d.value=!1,w.value=null};return(ne,fe)=>(r(),Y(Pt,null,{default:W(()=>[I(s)?S("",!0):(r(),o("div",uf," Configuration is read-only in production. To make changes, edit your configuration files locally and deploy. ")),k(f0,{ref_key:"dataTableRef",ref:c,title:"Agents",description:"Configure and manage your AI agents.","primary-action":I(s)?{label:"Create Agent",icon:I(Rr),handler:m}:void 0,readonly:!I(s),onAdd:m,onEdit:v,onPack:P,onUnpack:E,onPublish:A},null,8,["primary-action","readonly"]),k($m,{ref_key:"agentModalRef",ref:f,modelValue:l.value,"onUpdate:modelValue":fe[0]||(fe[0]=ye=>l.value=ye),mode:u.value,editAgent:i.value,apiError:h.value,readonly:!I(s),saving:x.value,onSave:_},null,8,["modelValue","mode","editAgent","apiError","readonly","saving"]),I(s)?(r(),o($e,{key:1},[k(Zm,{modelValue:b.value,"onUpdate:modelValue":fe[1]||(fe[1]=ye=>b.value=ye),agent:y.value,onPacked:V},null,8,["modelValue","agent"]),k(kv,{modelValue:$.value,"onUpdate:modelValue":fe[2]||(fe[2]=ye=>$.value=ye),agent:g.value,onUnpacked:z},null,8,["modelValue","agent"]),k(tf,{modelValue:d.value,"onUpdate:modelValue":fe[3]||(fe[3]=ye=>d.value=ye),"package-id":w.value?.packageId??"","output-path":"agents/packed/"+(w.value?.packageId??""),onPublished:oe},null,8,["modelValue","package-id","output-path"])],64)):S("",!0)]),_:1}))}});function cf(e){const{limit:n=50,offset:a=0,agentId:s=null,userId:l=null,search:u=null,startDate:i=null,endDate:c=null,autoFetch:f=!0}=e||{},h=F(()=>{const _=new URLSearchParams,P=typeof n=="number"?n:n.value,V=typeof a=="number"?a:a.value,E=typeof s=="string"?s:s?.value,z=typeof l=="string"?l:l?.value,A=typeof u=="string"?u:u?.value,oe=typeof i=="number"?i:i?.value,ne=typeof c=="number"?c:c?.value;return _.append("limit",P.toString()),_.append("offset",V.toString()),E&&_.append("agent_id",E),z&&_.append("user_id",z),A&&_.append("search",A),oe&&_.append("startDate",oe.toString()),ne&&_.append("endDate",ne.toString()),ze(`/api/threads?${_.toString()}`)}),{data:x,error:b,isFetching:y,isFinished:$,execute:g,abort:d}=it(h,{immediate:f,refetch:!0}).get().json(),w=F(()=>x.value?.threads||[]),m=F(()=>x.value?.total||0),v=F(()=>x.value?.hasMore||!1);return{threads:w,total:m,hasMore:v,error:b,isFetching:y,isFinished:$,refetch:g,abort:d}}function jr(e){const n=F(()=>!!(typeof e=="string"?e:e?.value)),a=F(()=>{const x=typeof e=="string"?e:e?.value;return ze(x?`/api/threads/${x}`:"/api/threads/placeholder")}),{data:s,error:l,isFetching:u,isFinished:i,execute:c,abort:f}=it(a,{immediate:!1,refetch:!0}).get().json();return Ve(n,x=>{x&&c()},{immediate:!0}),{thread:F(()=>s.value?{id:s.value.thread.id,agent_id:s.value.thread.agent_id,user_id:s.value.thread.user_id,tags:s.value.thread.tags||[],parent:s.value.thread.parent??null,terminated:s.value.thread.terminated??null,created_at:s.value.thread.created_at,agent:s.value.agent||{id:"",title:"Unknown",type:"unknown"},stats:s.value.stats}:null),error:l,isFetching:u,isFinished:i,refetch:c,abort:f}}function nn(){const e=ze("/api/agents"),{data:n,error:a,isFetching:s,isFinished:l,execute:u}=it(e,{immediate:!0}).get().json();return{agents:F(()=>n.value?.agents||[]),error:a,isFetching:s,isFinished:l,refetch:u}}function pf(e){const{autoConnect:n=!0,onEvent:a}=e||{},s=p(null),l=p(!1),u=p(null);let i=0,c=null,f=null,h=!0;const x=3e4,b=3e4,y=()=>{c&&(clearTimeout(c),c=null),f&&(clearInterval(f),f=null)},$=()=>{f&&clearInterval(f),f=setInterval(()=>{s.value&&s.value.readyState===WebSocket.OPEN&&s.value.send("ping")},b)},g=()=>{if(!h)return;const v=Math.min(1e3*Math.pow(2,i),x);i++,console.log(`[AgentBuilderEvents] Scheduling reconnect in ${v}ms (attempt ${i})`),c=setTimeout(()=>{h&&d()},v)},d=()=>{s.value&&s.value.close();const v=window.location.protocol==="https:"?"wss:":"ws:",_=window.location.host;let P=`${v}//${_}${ze("/api/events")}`;const V=localStorage.getItem("auth_token");V&&(P+=`?token=${encodeURIComponent(V)}`);try{s.value=new WebSocket(P),s.value.onopen=()=>{l.value=!0,u.value=null,i=0,$(),console.log("[AgentBuilderEvents] WebSocket connected")},s.value.onmessage=E=>{try{if(typeof E.data=="string"&&E.data==="pong")return;const z=JSON.parse(E.data);a&&a(z)}catch(z){console.error("[AgentBuilderEvents] Failed to parse WebSocket message:",z)}},s.value.onerror=E=>{u.value="WebSocket connection error",console.error("[AgentBuilderEvents] WebSocket error:",E)},s.value.onclose=()=>{l.value=!1,y(),console.log("[AgentBuilderEvents] WebSocket disconnected"),g()}}catch(E){u.value=E.message||"Failed to create WebSocket",console.error("[AgentBuilderEvents] WebSocket creation error:",E),g()}},w=()=>{h=!0,i=0,d()},m=()=>{h=!1,y(),s.value&&(s.value.close(),s.value=null),l.value=!1,i=0};return n&&w(),ct(()=>{m()}),{wsConnected:l,wsError:u,connect:w,disconnect:m}}function mf(e){const a=Date.now()*1e3-e,s=Math.floor(a/1e6);if(s<60)return s===1?"1 second ago":`${s} seconds ago`;const l=Math.floor(s/60);if(l<60)return l===1?"1 minute ago":`${l} minutes ago`;const u=Math.floor(l/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 c=Math.floor(i/30);if(c<12)return c===1?"1 month ago":`${c} months ago`;const f=Math.floor(c/12);return f===1?"1 year ago":`${f} years ago`}function vf(e){const n=p("");let a=null;const s=()=>typeof e=="function"?e():typeof e=="number"?e:e.value,l=()=>{const u=s();n.value=mf(u);const c=Date.now()*1e3-u,f=Math.floor(c/1e6);a!==null&&(clearInterval(a),a=null),f<60?a=setInterval(l,1e3):f<3600?a=setInterval(l,6e4):f<86400&&(a=setInterval(l,6e5))};return l(),ct(()=>{a!==null&&clearInterval(a)}),n}const Kt=Se({__name:"TimeAgo",props:{timestamp:{}},setup(e){const n=e,a=vf(()=>n.timestamp);return(s,l)=>(r(),o("span",null,C(I(a)),1))}}),ff={class:"relative inline-flex items-center"},gf={key:0,class:"inline-block w-2 h-2 rounded-full bg-green-500 dark:bg-green-400"},hf={key:1,class:"inline-block w-2 h-2 rounded-full bg-neutral-400 dark:bg-neutral-600"},bf={key:0},xf={key:1},Dr=Se({__name:"StatusDot",props:{connected:{type:Boolean},error:{type:Boolean}},setup(e){const n=p(!1),a=p(null);return(s,l)=>(r(),o("div",ff,[t("span",{class:"p-0.5 cursor-default outline-none",tabindex:"-1",onMouseenter:l[0]||(l[0]=u=>n.value=!0),onMouseleave:l[1]||(l[1]=u=>n.value=!1)},[e.connected?(r(),o("span",gf)):(r(),o("span",hf))],32),k(kt,{"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:W(()=>[n.value?(r(),o("div",{key:0,ref_key:"popoverRef",ref:a,class:pe(["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":e.connected,"bg-neutral-50 dark:bg-neutral-900 border-neutral-200 dark:border-neutral-700 text-neutral-600 dark:text-neutral-400":!e.connected}])},[e.connected?(r(),o("span",bf,"Live - Connected")):(r(),o("span",xf,"Offline"))],2)):S("",!0)]),_:1})]))}}),yf={class:"relative min-w-0"},kf={class:"truncate flex-1 text-left"},wf={key:0},_f=["onClick"],$f={class:"border-t border-neutral-200 dark:border-neutral-700"},Cf={class:"flex items-center justify-between"},Sf={class:"space-y-4 date-filter-inputs"},If=Se({__name:"DateFilterDropdown",props:{startDate:{},endDate:{}},emits:["update:startDate","update:endDate"],setup(e,{emit:n}){const a=e,s=n,l=p(!1),u=p(!1),i=p(null),c=p(null),f=p(""),h=p(""),x=[{label:"All time",value:"all",getRange:()=>({startDate:null,endDate:null})},{label:"Today",value:"today",getRange:()=>{const z=new Date,A=new Date(z.getFullYear(),z.getMonth(),z.getDate());return{startDate:Math.floor(A.getTime()/1e3),endDate:null}}},{label:"Last 3 days",value:"3days",getRange:()=>{const z=new Date,A=new Date(z.getFullYear(),z.getMonth(),z.getDate()-2);return{startDate:Math.floor(A.getTime()/1e3),endDate:null}}},{label:"Last 7 days",value:"7days",getRange:()=>{const z=new Date,A=new Date(z.getFullYear(),z.getMonth(),z.getDate()-6);return{startDate:Math.floor(A.getTime()/1e3),endDate:null}}},{label:"Last 30 days",value:"30days",getRange:()=>{const z=new Date,A=new Date(z.getFullYear(),z.getMonth(),z.getDate()-29);return{startDate:Math.floor(A.getTime()/1e3),endDate:null}}}],b=F(()=>{if(!a.startDate&&!a.endDate)return"all";for(const z of x){const A=z.getRange();if(A.startDate===a.startDate&&A.endDate===a.endDate)return z.value}return"custom"}),y=F(()=>{if(!a.startDate&&!a.endDate)return"All time";const z=x.find(oe=>oe.value===b.value);if(z&&b.value!=="custom")return z.label;const A=oe=>new Date(oe*1e3).toLocaleDateString("en-US",{month:"short",day:"numeric"});return a.startDate&&a.endDate?`${A(a.startDate)} - ${A(a.endDate)}`:a.startDate?`From ${A(a.startDate)}`:a.endDate?`Until ${A(a.endDate)}`:"Custom"}),$=F(()=>a.startDate!==null||a.endDate!==null);function g(){if(!i.value||!c.value)return;const z=i.value.getBoundingClientRect();c.value.style.position="fixed",c.value.style.top=`${z.bottom+8}px`,c.value.style.left=`${z.left}px`;const A=u.value?280:180;c.value.style.minWidth=`${z.width}px`,c.value.style.maxWidth=`${Math.max(z.width,A)}px`,c.value.style.width="auto",c.value.style.margin="0"}function d(){l.value?w():(l.value=!0,Fe(()=>{if(c.value&&(c.value.setAttribute("popover","auto"),c.value.addEventListener("toggle",m),"showPopover"in c.value))try{c.value.showPopover()}catch{}g()}))}function w(){if(c.value){if("hidePopover"in c.value)try{c.value.hidePopover()}catch{}c.value.removeEventListener("toggle",m)}l.value=!1,u.value=!1}function m(z){z.target===c.value&&(l.value=z.newState==="open",l.value&&g())}function v(z){const A=z.getRange();s("update:startDate",A.startDate),s("update:endDate",A.endDate),w()}function _(){const z=f.value?Math.floor(new Date(f.value).getTime()/1e3):null,A=h.value?Math.floor(new Date(h.value+"T23:59:59").getTime()/1e3):null;s("update:startDate",z),s("update:endDate",A),w()}function P(z){z.stopPropagation(),s("update:startDate",null),s("update:endDate",null)}const V=z=>{const A=z.target;c.value&&!c.value.contains(A)&&i.value&&!i.value.contains(A)&&w()},E=z=>{z.key==="Escape"&&l.value&&(w(),i.value?.focus())};return He(()=>{document.addEventListener("click",V),document.addEventListener("keydown",E),window.addEventListener("resize",g),window.addEventListener("scroll",g,!0)}),ct(()=>{document.removeEventListener("click",V),document.removeEventListener("keydown",E),window.removeEventListener("resize",g),window.removeEventListener("scroll",g,!0)}),Ve(u,z=>{z&&(a.startDate&&(f.value=new Date(a.startDate*1e3).toISOString().split("T")[0]),a.endDate?h.value=new Date(a.endDate*1e3).toISOString().split("T")[0]:h.value=new Date().toISOString().split("T")[0]),Fe(g)}),(z,A)=>{const oe=at("FormKit");return r(),o("div",yf,[t("button",{ref_key:"triggerRef",ref:i,type:"button",onClick:d,class:pe(["w-full flex items-center gap-1 px-2 py-1 text-xs rounded-sm border transition-colors min-w-0 focus:outline-none focus:ring-2 focus:ring-accent-500/30",[$.value?"border-accent-500 bg-accent-50 dark:bg-accent-950/50 text-accent-700 dark:text-accent-300":"border-zinc-300 dark:border-zinc-600 hover:border-accent-400 dark:hover:border-accent-500 bg-white dark:bg-transparent text-zinc-700 dark:text-zinc-300"]])},[k(I(wn),{size:14,class:"shrink-0 text-zinc-400"}),t("span",kf,C(y.value),1),$.value?(r(),Y(I(Ar),{key:0,size:14,class:"shrink-0 text-zinc-400 hover:text-zinc-600 dark:hover:text-zinc-200",onClick:P})):(r(),Y(I(xt),{key:1,size:14,class:pe(["shrink-0 text-zinc-400",l.value?"rotate-180":""])},null,8,["class"]))],2),l.value?(r(),o("div",{key:0,ref_key:"popoverRef",ref:c,class:"dropdown-popover z-[9999]"},[k(I(vr),{"max-height":u.value?void 0:"max-h-48",shadow:{offsetX:4,offsetY:4,intensity:.3}},{default:W(()=>[u.value?(r(),o("div",{key:1,class:"p-2.5 space-y-2.5",onClick:A[4]||(A[4]=Xe(()=>{},["stop"]))},[t("div",Cf,[A[6]||(A[6]=t("span",{class:"text-xs font-medium"},"Custom range",-1)),t("button",{type:"button",onClick:A[1]||(A[1]=Xe(ne=>u.value=!1,["stop"])),class:"text-[10px] text-neutral-500 hover:text-black dark:hover:text-white"}," ← Back ")]),t("div",Sf,[k(oe,{modelValue:f.value,"onUpdate:modelValue":A[2]||(A[2]=ne=>f.value=ne),type:"datepicker",label:"From","picker-only":"",popover:"",format:"MMM D, YYYY","value-format":"YYYY-MM-DD",sequence:["day"]},null,8,["modelValue"]),k(oe,{modelValue:h.value,"onUpdate:modelValue":A[3]||(A[3]=ne=>h.value=ne),type:"datepicker",label:"To","picker-only":"",popover:"",format:"MMM D, YYYY","value-format":"YYYY-MM-DD",sequence:["day"]},null,8,["modelValue"])]),t("button",{type:"button",onClick:_,class:"w-full py-1.5 text-xs font-medium bg-black dark:bg-white text-white dark:text-black rounded-sm hover:opacity-90 transition-opacity"}," Apply ")])):(r(),o("div",wf,[(r(),o($e,null,Le(x,ne=>t("button",{key:ne.value,type:"button",onClick:fe=>v(ne),class:pe(["w-full px-2.5 py-1.5 text-left text-xs hover:bg-neutral-100 dark:hover:bg-neutral-800 transition-colors flex items-center gap-2",b.value===ne.value?"bg-accent-50 dark:bg-accent-950/30":""])},[t("span",{class:pe(["w-1.5 h-1.5 rounded-full border border-accent-500",b.value===ne.value?"bg-accent-500":""])},null,2),ve(" "+C(ne.label),1)],10,_f)),64)),t("div",$f,[t("button",{type:"button",onClick:A[0]||(A[0]=Xe(ne=>u.value=!0,["stop"])),class:pe(["w-full px-2.5 py-1.5 text-left text-xs hover:bg-neutral-100 dark:hover:bg-neutral-800 transition-colors flex items-center gap-2",b.value==="custom"?"bg-accent-50 dark:bg-accent-950/30":""])},[t("span",{class:pe(["w-1.5 h-1.5 rounded-full border border-accent-500",b.value==="custom"?"bg-accent-500":""])},null,2),A[5]||(A[5]=ve(" Custom range... ",-1))],2)])]))]),_:1},8,["max-height"])],512)):S("",!0)])}}}),Tf=mt(If,[["__scopeId","data-v-88032ecc"]]),Mf={class:"flex flex-col flex-1 min-h-0 overflow-visible"},zf={class:"px-4 py-3 border-b border-neutral-300 dark:border-neutral-700"},Vf={class:"flex items-center justify-between"},Ef={class:"flex items-center gap-2"},Lf={key:0,class:"text-xs font-mono text-neutral-500 dark:text-neutral-400"},Af={class:"flex items-center gap-2"},Pf=["title"],Of={key:0,class:"absolute -top-1 -right-1 w-3.5 h-3.5 flex items-center justify-center text-[8px] font-bold font-mono bg-accent-500 text-white rounded-full"},Rf={key:0,class:"bg-neutral-100 dark:bg-neutral-950 border-b border-neutral-200 dark:border-neutral-800"},jf={class:"p-2"},Df={class:"bg-white dark:bg-neutral-900 rounded-lg border border-neutral-200 dark:border-neutral-800 p-2.5 space-y-2"},Uf={class:"flex items-center gap-2 w-full"},Bf={class:"flex-1 min-w-0"},Nf={key:0,class:"flex justify-end"},qf={key:0,class:"p-4 flex justify-center"},Ff={key:1,class:"p-4 text-red-600 dark:text-red-400"},Hf={key:2,class:"text-neutral-500 dark:text-neutral-400 text-center py-12"},Wf={key:1,class:"text-base"},Kf={key:3},Jf=["id","onClick"],Gf={class:"flex-shrink-0 text-neutral-400 dark:text-neutral-500 text-[10px]"},Yf={key:0,class:"mb-1 text-[10px] text-neutral-400 dark:text-neutral-500 truncate"},Zf={key:1,class:"flex items-center gap-2"},Xf={class:"text-[10px] text-neutral-400 dark:text-neutral-500 font-mono truncate max-w-[80px]"},Qf={key:0,class:"flex flex-wrap gap-1 flex-1 min-w-0"},eg={key:0,class:"text-[10px] text-neutral-400"},tg={key:2,class:"flex items-center gap-1"},rg={key:0,class:"text-[10px] text-neutral-400"},ag=["onClick"],ng={class:"flex items-center gap-2"},og={key:0,class:"p-3 flex justify-center"},lg={key:1,class:"p-3 text-center text-[10px] text-neutral-400 dark:text-neutral-500"},sg=50,la=1800,wr="name:",ig=Se({__name:"ThreadListPane",props:{selectedThreadId:{}},emits:["selectThread","collapse","createThread","threadsLoaded"],setup(e,{expose:n,emit:a}){const s=a,l=p(!1),u=p(""),i=p(null),c=p(null),f=p(null),h=p(null),{agents:x,isFetching:b}=nn(),y=F(()=>x.value.map(R=>({value:R.name,label:R.title||R.name}))),$=p(0),g=p([]),d=p(!1),w=_a(R=>{i.value=R||null},300);Ve(u,R=>{w(R)});const m=F(()=>{let R=0;return i.value&&R++,c.value&&R++,(f.value||h.value)&&R++,R});function v(){u.value="",i.value=null,c.value=null,f.value=null,h.value=null}const{threads:_,total:P,hasMore:V,isFetching:E,isFinished:z,error:A,refetch:oe}=cf({limit:sg,offset:$,search:i,agentId:c,startDate:f,endDate:h});Ve([i,c,f,h],()=>{$.value=0,g.value=[],d.value=!1}),Ve(_,R=>{if($.value===0)g.value=[...R];else{const O=new Set(g.value.map(de=>de.id)),ke=R.filter(de=>!O.has(de.id));g.value=[...g.value,...ke]}d.value=!1});const ne=p([]),fe=p(new Set),ye=(R,O)=>O.created_at-R.created_at,te=p({}),q=p({}),j=p({}),J=(R,O)=>`${R}::${O}`,H=R=>te.value[R]??!1,ce=R=>{te.value[R]=!H(R)},Z=R=>{q.value[R]=!0,setTimeout(()=>{delete q.value[R]},la)},U=R=>{j.value[R]=!0,setTimeout(()=>{delete j.value[R]},la)},K=R=>q.value[R]===!0,me=R=>j.value[R]===!0,ue=R=>{const O=R.tags.find(de=>de.startsWith(wr));if(!O)return null;const ke=O.slice(wr.length).trim();return ke.length>0?ke:null},Q=R=>R.tags.filter(O=>!O.startsWith(wr)),G=R=>ue(R)||R.agent.title||R.agent.name,ae=R=>ue(R)?R.agent.title||R.agent.name:null,ie=R=>{if(c.value&&R.agent_id!==c.value||f.value&&R.created_at<f.value||h.value&&R.created_at>h.value)return!1;if(i.value){const O=i.value.toLowerCase(),ke=R.id.toLowerCase().includes(O),de=R.tags.some(Ue=>Ue.toLowerCase().includes(O));if(!ke&&!de)return!1}return!0},xe=R=>{if(R.length===0)return[];const O=new Map(R.map(Te=>[Te.id,Te])),ke=new Map,de=[];for(const Te of R){const Ke=Te.parent;if(Ke&&O.has(Ke)){const et=ke.get(Ke)??[];et.push(Te),ke.set(Ke,et);continue}de.push(Te)}de.sort(ye);for(const Te of ke.values())Te.sort(ye);const Ue=[],Ge=new Set,Ce=Te=>{if(Ge.has(Te.id))return;Ge.add(Te.id);const Ke=ke.get(Te.id);if(Ke)for(const et of Ke)Ce(et)},we=(Te,Ke,et)=>{if(Ge.has(Te.id))return;Ge.add(Te.id),Ue.push({kind:"thread",thread:Te,depth:Ke,isNested:Ke>0,clusterId:et});const Ze=ke.get(Te.id);if(!Ze)return;const st=new Map;for(const Pe of Ze){const se=Pe.agent_id||Pe.agent?.name||Pe.id,Ee=st.get(se);Ee?Ee.push(Pe):st.set(se,[Pe])}for(const[Pe,se]of st.entries()){if(se.length>1){const Ee=J(Te.id,Pe),Oe=H(Ee);if(Ue.push({kind:"directory",key:Ee,depth:Ke+1,label:se[0]?.agent?.title||se[0]?.agent?.name||Pe,count:se.length,open:Oe,clusterId:et}),!Oe){for(const nt of se)Ce(nt);continue}for(const nt of se)we(nt,Ke+2,et);continue}we(se[0],Ke+1,et)}};for(const Te of de)we(Te,0,Te.id);const Ae=R.filter(Te=>!Ge.has(Te.id)).sort(ye);for(const Te of Ae)we(Te,Te.parent?1:0,Te.parent??Te.id);return Ue},X=F(()=>{const R=g.value.filter(de=>!fe.value.has(de.id)),O=new Set(R.map(de=>de.id));return[...ne.value.filter(de=>!O.has(de.id)&&!fe.value.has(de.id)),...R].sort(ye)}),he=F(()=>xe(X.value)),be=R=>{const O=he.value[R],ke=he.value[R+1];return O?ke?O.clusterId!==ke.clusterId:!0:!1},B=R=>{const O=he.value[R],ke=he.value[R-1];if(!O||!ke||O.clusterId!==ke.clusterId)return!1;const de=O.kind==="directory"||O.kind==="thread"&&O.isNested,Ue=ke.kind==="thread"&&!ke.isNested;return de&&Ue},D=F(()=>{const R={};for(const O of he.value)if(!R[O.clusterId]){if(O.kind==="directory"){R[O.clusterId]=!0;continue}if(O.kind==="thread"&&O.isNested){R[O.clusterId]=!0;continue}R[O.clusterId]=!1}return R}),M=p(null);function T(){d.value||E.value||!V.value||(d.value=!0,$.value=g.value.length)}const{arrivedState:L}=_n(M,{offset:{bottom:100}});Ve(()=>L.bottom,R=>{R&&V.value&&!E.value&&!d.value&&T()});const ee=R=>{const O=x.value.find(de=>de.name===R.agent_name),ke=R.agent;return{id:R.id,agent_id:R.agent_name,user_id:R.user_id,tags:R.tags||[],parent:R.parent??null,terminated:R.terminated??null,created_at:R.created_at,agent:{name:R.agent_name,title:ke?.title||O?.title,type:ke?.type||O?.type||"ai_human"}}},le=async R=>{if(R.type==="thread_created"){const O=ee(R.thread);if(!ie(O))return;if(O.parent)if(X.value.filter(de=>de.parent===O.parent&&de.agent_id===O.agent_id).length+1>1){const de=J(O.parent,O.agent_id);U(de),H(de)&&Z(O.id)}else Z(O.id);ne.value.unshift(O)}else if(R.type==="thread_updated"){const O=ee(R.thread),ke=X.value.find(Ce=>Ce.id===O.id);if(!ie(O)){ne.value=ne.value.filter(Ce=>Ce.id!==O.id),g.value=g.value.filter(Ce=>Ce.id!==O.id);return}fe.value.delete(O.id);const de=ne.value.findIndex(Ce=>Ce.id===O.id);de>=0&&(ne.value[de]=O);const Ue=g.value.findIndex(Ce=>Ce.id===O.id);if(Ue>=0?g.value[Ue]=O:de===-1&&ne.value.unshift(O),!!O.terminated&&!ke?.terminated)if(O.parent)if((X.value.filter(we=>we.parent===O.parent&&we.agent_id===O.agent_id).length||1)>1){const we=J(O.parent,O.agent_id);U(we),H(we)&&Z(O.id)}else Z(O.id);else Z(O.id)}else R.type==="thread_deleted"&&(fe.value.add(R.threadId),ne.value=ne.value.filter(O=>O.id!==R.threadId))},{wsConnected:Ie,wsError:Re}=pf({onEvent:le});Ve(()=>$.value,R=>{R===0&&(ne.value=[])});const qe=p(!1);Ve(()=>({rows:he.value,finished:z.value}),({rows:R,finished:O})=>{const ke=R.find(de=>de.kind==="thread");O&&!qe.value&&ke&&(qe.value=!0,s("threadsLoaded",ke.thread.id))},{immediate:!0}),n({refetch:oe});const We=R=>{s("selectThread",R)};return(R,O)=>{const ke=at("FormKit");return r(),o("div",Mf,[t("div",zf,[t("div",Vf,[t("div",Ef,[k(I(Sa),{size:18,class:"shrink-0"}),O[7]||(O[7]=t("h2",{class:"text-base font-bold"},"Threads",-1)),!I(E)&&I(P)>0?(r(),o("span",Lf," ("+C(I(P))+") ",1)):S("",!0),k(Dr,{connected:I(Ie),error:I(Re)},null,8,["connected","error"])]),t("div",Af,[t("button",{onClick:O[0]||(O[0]=de=>l.value=!l.value),type:"button",class:pe(["relative p-1 rounded transition-colors hover:bg-neutral-100 dark:hover:bg-neutral-900",[l.value||m.value>0?"text-accent-600 dark:text-accent-400":""]]),title:l.value?"Hide filters":"Show filters"},[k(I($n),{size:18}),m.value>0?(r(),o("span",Of,C(m.value),1)):S("",!0)],10,Pf),t("button",{onClick:O[1]||(O[1]=de=>s("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 "),t("button",{onClick:O[2]||(O[2]=de=>s("collapse")),type:"button",class:"p-1 hover:bg-neutral-100 dark:hover:bg-neutral-900 rounded transition-colors",title:"Collapse pane"},[k(I(Ia),{size:20})])])])]),k(kt,{"enter-active-class":"transition-all duration-200 ease-out","enter-from-class":"opacity-0 -translate-y-2 max-h-0","enter-to-class":"opacity-100 translate-y-0 max-h-60","leave-active-class":"transition-all duration-150 ease-in","leave-from-class":"opacity-100 translate-y-0 max-h-60","leave-to-class":"opacity-0 -translate-y-2 max-h-0"},{default:W(()=>[l.value?(r(),o("div",Rf,[t("div",jf,[t("div",Df,[k(ke,{type:"searchInput",modelValue:u.value,"onUpdate:modelValue":O[3]||(O[3]=de=>u.value=de),placeholder:"Search by tag or thread ID...",size:"sm"},null,8,["modelValue"]),t("div",Uf,[t("div",Bf,[k(ke,{type:"selectSearch",size:"sm","active-highlight":"",value:c.value||"",options:y.value,placeholder:"All agents","search-placeholder":"Search agents...",loading:I(b),onInput:O[4]||(O[4]=de=>c.value=de||null)},null,8,["value","options","loading"])]),k(Tf,{startDate:f.value,"onUpdate:startDate":O[5]||(O[5]=de=>f.value=de),endDate:h.value,"onUpdate:endDate":O[6]||(O[6]=de=>h.value=de),class:"flex-1 min-w-0"},null,8,["startDate","endDate"])]),m.value>0?(r(),o("div",Nf,[t("button",{onClick:v,type:"button",class:"text-xs font-mono text-neutral-500 hover:text-neutral-900 dark:hover:text-neutral-100 transition-colors"}," Clear all ")])):S("",!0)])])])):S("",!0)]),_:1}),t("div",{ref_key:"scrollContainerRef",ref:M,class:"flex-1 overflow-y-auto text-xs min-h-0"},[I(E)&&g.value.length===0?(r(),o("div",qf,[k(Be)])):I(A)?(r(),o("div",Ff," Error: "+C(I(A)),1)):he.value.length===0?(r(),o("div",Hf,[m.value>0?(r(),o($e,{key:0},[O[8]||(O[8]=t("p",{class:"text-base mb-2"},"No matching threads",-1)),t("button",{onClick:v,type:"button",class:"text-xs text-accent-600 dark:text-accent-400 hover:underline"}," Clear filters ")],64)):(r(),o("p",Wf,"No threads found"))])):(r(),o("div",Kf,[(r(!0),o($e,null,Le(he.value,(de,Ue)=>(r(),o($e,{key:de.kind==="thread"?de.thread.id:de.key},[de.kind==="thread"?(r(),o("button",{key:0,id:`thread-${de.thread.id}`,class:pe(["w-full text-left px-3 cursor-pointer transition-colors relative hover:bg-neutral-50 dark:hover:bg-neutral-800/50",[de.isNested?"py-1.5 bg-neutral-50/40 dark:bg-neutral-900/20":"py-2.5",B(Ue)?"pt-3":"",be(Ue)&&D.value[de.clusterId]?"pb-3":"",be(Ue)?"border-b border-neutral-200 dark:border-neutral-800":"border-0",de.thread.terminated?"opacity-50 text-neutral-500 dark:text-neutral-500":"",e.selectedThreadId===de.thread.id?"bg-accent-50 dark:bg-accent-950/50 border-l-2 border-l-accent-500":""]]),style:_t(de.depth>0?{paddingLeft:`${12+Math.min(de.depth,6)*14}px`}:void 0),onClick:Ge=>We(de.thread.id)},[t("div",{class:pe(["flex items-center gap-2",!de.isNested||Q(de.thread).length>0||ae(de.thread)?"mb-1":""])},[de.thread.terminated?(r(),Y(I(or),{key:0,size:12,class:"shrink-0 text-neutral-500 dark:text-neutral-400"})):S("",!0),t("span",{class:pe(["font-medium truncate flex-1 min-w-0",[e.selectedThreadId===de.thread.id?"text-accent-700 dark:text-accent-300":"",K(de.thread.id)?"thread-list-green-flash":""]])},C(G(de.thread)),3),t("span",Gf,[k(Kt,{timestamp:de.thread.created_at*1e6},null,8,["timestamp"])])],2),ae(de.thread)?(r(),o("div",Yf,C(ae(de.thread)),1)):S("",!0),de.isNested?Q(de.thread).length>0?(r(),o("div",tg,[(r(!0),o($e,null,Le(Q(de.thread).slice(0,3),Ge=>(r(),o("span",{key:Ge,class:"inline-block px-1.5 py-0.5 rounded text-[10px] truncate max-w-[120px] bg-neutral-200 dark:bg-neutral-800 text-neutral-600 dark:text-neutral-400"},C(Ge),1))),128)),Q(de.thread).length>3?(r(),o("span",rg," +"+C(Q(de.thread).length-3),1)):S("",!0)])):S("",!0):(r(),o("div",Zf,[t("span",Xf,C(de.thread.id.slice(0,8)),1),Q(de.thread).length>0?(r(),o("div",Qf,[(r(!0),o($e,null,Le(Q(de.thread).slice(0,3),Ge=>(r(),o("span",{key:Ge,class:pe(["inline-block px-1.5 py-0.5 rounded text-[10px] truncate max-w-[60px]",e.selectedThreadId===de.thread.id?"bg-accent-200 dark:bg-accent-900 text-accent-800 dark:text-accent-200":"bg-neutral-200 dark:bg-neutral-800 text-neutral-600 dark:text-neutral-400"])},C(Ge),3))),128)),Q(de.thread).length>3?(r(),o("span",eg," +"+C(Q(de.thread).length-3),1)):S("",!0)])):S("",!0)]))],14,Jf)):(r(),o("button",{key:1,type:"button",class:pe(["w-full text-left px-3 py-1 bg-neutral-50/25 dark:bg-neutral-900/10 hover:bg-neutral-100 dark:hover:bg-neutral-800/40 transition-colors",[B(Ue)?"pt-3":"",be(Ue)?"border-b border-neutral-200 dark:border-neutral-800":"border-0",be(Ue)&&D.value[de.clusterId]?"pb-3":""]]),style:_t({paddingLeft:`${12+Math.min(de.depth,6)*14}px`}),onClick:Ge=>ce(de.key)},[t("div",ng,[k(I(lr),{size:13,class:"text-neutral-500 dark:text-neutral-400 shrink-0"}),t("span",{class:pe(["truncate flex-1 min-w-0 text-[11px] font-medium text-neutral-600 dark:text-neutral-300",me(de.key)?"thread-list-green-flash":""])},C(de.label)+" ("+C(de.count)+") ",3),de.open?(r(),Y(I(xt),{key:0,size:14,class:"text-neutral-500 dark:text-neutral-400 shrink-0"})):(r(),Y(I(St),{key:1,size:14,class:"text-neutral-500 dark:text-neutral-400 shrink-0"}))])],14,ag))],64))),128)),d.value||I(E)&&g.value.length>0?(r(),o("div",og,[k(Be)])):!I(V)&&he.value.length>0?(r(),o("div",lg," All "+C(I(P))+" threads loaded ",1)):S("",!0)]))],512)])}}}),ug=mt(ig,[["__scopeId","data-v-a0b133c8"]]);function dg(e,n={}){const a=p(null),s=p(!1),l=p(null);let u=null;try{u=ja()}catch{}const i=u?.messages??p([]),c=F(()=>u?.groupedMessages?.value?u.groupedMessages.value:u?.workblocks?.value?u.workblocks.value:i.value),f=F(()=>u?.status.value==="connected"),h=p(null);u?.loading??p(!1);const x=F(()=>i.value.some(G=>G.status==="pending")),b=p(!1),y=p(0),$=p(!1);function g(G){if(!a.value?.agent)return null;const ae=a.value.agent,ie=G==="assistant"?"A":"B";return ie==="A"&&ae.side_a_label?ae.side_a_label:ie==="B"&&ae.side_b_label?ae.side_b_label:null}function d(G){return{id:G.id||`att-${G.path||G.name||Math.random().toString(36).slice(2)}`,type:"file",path:G.path||"",name:G.name||G.path?.split("/").pop()||"attachment",mimeType:G.mimeType||G.mediaType||"application/octet-stream",width:G.width,height:G.height,description:G.description}}function w(G){if(G){if(Array.isArray(G))return G.length>0?G.map(d):void 0;try{const ae=JSON.parse(G);return Array.isArray(ae)&&ae.length>0?ae.map(d):void 0}catch(ae){console.error("Failed to parse attachments:",ae);return}}}function m(G,ae){const ie=[];G.reasoning_content&&ie.push({id:`${G.id}-reasoning`,type:"reasoning",content:G.reasoning_content,created_at:G.created_at}),G.content&&ie.push({id:`${G.id}-content`,type:"content",content:G.content,created_at:G.created_at});const xe=G.workItems.filter(D=>D.type==="tool_call"),X=G.workItems.filter(D=>D.type==="tool_result"),he=new Map;for(const D of X)D.tool_call_id&&he.set(D.tool_call_id,D);for(const D of xe){const M=D.tool_call_id||D.id,T=he.get(M);let L="pending";if(T){const ee=(T.content||"").toLowerCase(),le=ee.includes("failed")||ee.includes("error"),Ie=ee.length<500;L=T.status==="error"||le&&Ie?"failed":"success"}ie.push({id:D.id,type:"tool_call",content:D.name||"",created_at:G.created_at,tool_name:D.name,tool_call_id:M,tool_arguments:D.content||void 0,response:T?.content||null,response_status:L,response_log_id:null,log_id:null})}const be=ie.some(D=>D.type==="tool_call"&&D.response_status==="pending"),B=G.status!=="pending"&&!be;return{type:"work",id:G.id,role:"assistant",items:ie,created_at:G.created_at,updated_at:G.created_at,isComplete:B,sideLabel:g("assistant"),status:G.status}}function v(G){return G==="assistant"?"assistant":"user"}function _(G){for(let ae=G.length-1;ae>=0;ae--){const ie=(G[ae].content||"").trim();if(ie.length>0)return ie}return""}function P(G){const ae=new Set,ie=[];for(const xe of G){const X=w(xe.attachments);if(X?.length)for(const he of X)ae.has(he.path)||(ae.add(he.path),ie.push(he))}return ie.length>0?ie:void 0}function V(G){if(!G)return!1;if(G.tool_status==="error"||G.status==="failed")return!0;const ae=(G.content||"").toLowerCase();return ae?ae.includes("failed to execute tool")||ae.includes("has reported a failure")||ae.includes("execution stopped before completion"):!1}function E(G){const ae=G.messages||[],ie=ae[ae.length-1],xe=ie?v(ie.role):"assistant",X=ie?.log_id??null,he=(G.subagent_status||"").toLowerCase(),be=V(ie)||he.includes("error")||he.includes("failed"),B=_(ae),D=P(ae),M=ae.filter(T=>{const L=w(T.attachments);return!!T.content||!!T.status||!!(L&&L.length>0)}).map(T=>({id:T.id,role:T.role,content:T.content||"",created_at:T.created_at,silent:T.silent,attachments:w(T.attachments)}));return{type:"subagent",id:G.id,role:xe,created_at:G.created_at,updated_at:G.updated_at,subagentId:G.subagent_id,subagentName:G.subagent_name??null,subagentTitle:G.subagent_title??null,subagentThreadName:G.subagent_thread_name??null,subagentStatus:G.subagent_status??null,subagentHasError:be,subagentResumable:G.subagent_resumable??null,subagentBlocking:G.subagent_blocking??null,messages:M,messageCount:ae.length,latestContent:B,attachments:D,log_id:X,sideLabel:g(xe),silent:ae.length>0&&ae.every(T=>!!T.silent)}}function z(G){const ae=(G.subagents||[]).map(xe=>E(xe)),ie=ae.reduce((xe,X)=>xe?X.updated_at>xe.updated_at?X:xe:X,null);return{type:"subagent_group",id:G.id,role:ie?.role??"assistant",created_at:G.created_at,updated_at:G.updated_at,subagents:ae,count:ae.length,log_id:ie?.log_id??null,sideLabel:ie?.sideLabel??g("assistant"),silent:ae.every(xe=>!!xe.silent)}}function A(G){return{type:"status",id:G.id,role:"system",content:G.content,created_at:G.created_at,statusKind:G.status_kind??null,subagentId:G.subagent_id??null}}const oe=F(()=>{const G=[],ie=c.value.filter(X=>(X.depth??0)===0);let xe=[];for(let X=0;X<ie.length;X++){const he=ie[X];if(G[G.length-1]?.role,he.type==="workblock"){const L=m(he);G.push(L);const ee=he;ee.attachments&&ee.attachments.length>0&&xe.push(...ee.attachments.map(d));continue}if(he.type==="subagent_block"){xe=[],G.push(E(he));continue}if(he.type==="subagent_group_block"){xe=[],G.push(z(he));continue}if(he.type==="status"){xe=[],G.push(A(he));continue}const B=he,D=B.role;if(B.role==="tool")continue;const M=w(B.attachments);let T;if((xe.length>0||M)&&(T=[...xe,...M||[]],xe=[]),B.content||D==="system"||B.status==="pending"||T?.length){const L={type:"text",id:B.id,role:D,content:B.content||"",attachments:T?.length?T:void 0,created_at:B.created_at,log_id:B.log_id||null,sideLabel:g(D),isOptimistic:B.isOptimistic,status:B.status,silent:B.silent};G.push(L)}}return G});async function ne(){if(!e.value){a.value=null;return}try{const G=await fetch(ze(`/api/threads/${e.value}`));G.ok&&(a.value=await G.json())}catch(G){console.error("Error fetching thread info:",G)}}async function fe(G){if(e.value){if(u?.deleteMessage){await u.deleteMessage(G);return}try{if(!(await fetch(ze(`/api/threads/${e.value}/messages/${G}`),{method:"DELETE"})).ok)throw new Error("Failed to delete message")}catch(ae){throw ae}}}async function ye(G,ae){if(e.value)try{if(!(await fetch(ze(`/api/threads/${e.value}/messages/${G}`),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:ae})})).ok)throw new Error("Failed to update message")}catch(ie){throw ie}}Ve(e,async G=>{G?(s.value=!0,await ne(),s.value=!1):a.value=null},{immediate:!0});const te=u?.sendMessage,q=u?.stopExecution,j=u?.attachments??p([]),J=u?.addAttachment??(()=>{}),H=u?.removeAttachment??(()=>{}),ce=u?.clearAttachments??(()=>{});function Z(){console.warn("loadMoreMessages is deprecated - SDK handles all messages")}function U(){console.warn("connectWebSocket is deprecated - SDK handles WebSocket")}function K(){console.warn("disconnectWebSocket is deprecated - SDK handles WebSocket")}function me(){console.warn("addOptimisticMessage is deprecated - SDK handles optimistic updates")}function ue(){console.warn("removeOptimisticMessage is deprecated - SDK handles optimistic updates")}async function Q(){console.warn("refetch is deprecated - SDK handles message loading")}return{messages:oe,threadInfo:a,isFetching:s,isLoadingMore:$,error:l,wsConnected:f,wsError:h,isExecuting:x,hasMore:b,totalMessages:y,sendMessage:te,stopThread:q,attachments:j,addAttachment:J,removeAttachment:H,clearAttachments:ce,deleteMessageById:fe,updateMessageContent:ye,refetch:Q,loadMoreMessages:Z,connectWebSocket:U,disconnectWebSocket:K,addOptimisticMessage:me,removeOptimisticMessage:ue}}const cg={key:0,class:"absolute inset-0 flex items-center justify-center bg-neutral-100 dark:bg-neutral-800"},pg={key:1,class:"absolute inset-0 flex items-center justify-center bg-neutral-100 dark:bg-neutral-800 text-neutral-400"},mg=["src","alt"],vg={class:"absolute inset-0 bg-black/50 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center"},fg={key:0,class:"text-white text-[10px]"},gg={class:"text-xs text-neutral-600 dark:text-neutral-300 truncate max-w-[100px]"},_r=Se({__name:"FileAttachment",props:{attachment:{},threadId:{},showRemove:{type:Boolean}},emits:["remove"],setup(e,{emit:n}){const a=e,s=n,l=p(!0),u=p(!1),i=F(()=>a.attachment.mimeType.startsWith("image/")),c=F(()=>!!a.attachment.thumbnailBase64),f=F(()=>{if(!a.threadId||!a.attachment.path)return"";const g=a.attachment.path.startsWith("/")?a.attachment.path.slice(1):a.attachment.path;return ze(`/api/threads/${a.threadId}/fs/${g}`)}),h=F(()=>i.value?a.attachment.thumbnailBase64?`data:image/webp;base64,${a.attachment.thumbnailBase64}`:f.value:"");function x(){l.value=!1,u.value=!1}function b(){l.value=!1,u.value=!0}function y(){s("remove",a.attachment.id)}function $(){f.value&&window.open(f.value,"_blank")}return(g,d)=>(r(),o("div",{class:pe(["relative group inline-flex items-center rounded-lg overflow-hidden border border-neutral-200 dark:border-neutral-700",{"w-[104px] h-[104px]":i.value,"px-2 py-1 bg-neutral-100 dark:bg-neutral-800":!i.value,"cursor-pointer":i.value&&f.value}]),onClick:d[0]||(d[0]=w=>i.value&&f.value?$():void 0)},[i.value?(r(),o($e,{key:0},[l.value&&!u.value&&!c.value?(r(),o("div",cg,[...d[1]||(d[1]=[t("div",{class:"w-4 h-4 border-2 border-neutral-300 border-t-neutral-600 rounded-full animate-spin"},null,-1)])])):S("",!0),u.value&&!c.value?(r(),o("div",pg,[k(I(Ta),{size:24})])):S("",!0),Je(t("img",{src:h.value||f.value,alt:e.attachment.name,class:"w-full h-full object-cover",onLoad:x,onError:b},null,40,mg),[[pt,!l.value&&!u.value||c.value]]),t("div",vg,[f.value?(r(),o("span",fg,"Click to view")):S("",!0)])],64)):(r(),o($e,{key:1},[k(I(Ma),{size:14,class:"text-neutral-500 mr-1 flex-shrink-0"}),t("span",gg,C(e.attachment.name),1)],64)),e.showRemove?(r(),o("button",{key:2,onClick:Xe(y,["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"},[k(I(Ar),{size:10})])):S("",!0)],2))}}),hg=["onMouseenter","onMouseleave","onClick"],bg=["onClick"],xg={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"},yg={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"},kg={key:0,class:"w-full text-center text-xs text-neutral-400 dark:text-neutral-500 py-1"},wg=["contenteditable","onInput"],_g={key:1,class:"flex gap-1 items-center min-h-[1.5rem]"},$g={key:0,class:"opacity-50"},Cg={key:1,class:"italic font-medium text-neutral-700 dark:text-neutral-700"},Sg={key:0,class:"flex flex-wrap gap-2"},Ig=["onClick","onMouseenter"],Tg={key:0,class:"space-y-1"},Mg={class:"flex items-start gap-2"},zg={class:"flex-1 min-w-0"},Vg={key:0,class:"truncate opacity-80"},Eg={key:1,class:"italic opacity-60"},Lg={class:"flex items-center gap-2 pl-5 opacity-60"},Ag={class:"text-[10px]"},Pg={class:"text-[10px]"},Og={key:1,class:"space-y-2"},Rg={class:"flex items-center gap-2 pb-1 border-b border-current opacity-70"},jg={class:"text-[10px] italic"},Dg={class:"text-[10px] ml-auto"},Ug={key:0,class:"space-y-1"},Bg=["onClick","onMouseenter"],Ng={class:"font-mono text-[11px] flex-shrink-0"},qg={key:2,class:"text-[10px] opacity-60 px-2 truncate flex-1 min-w-0"},Fg={key:3,class:"text-[10px] text-green-600 dark:text-green-400 ml-auto flex-shrink-0"},Hg={key:0,class:"pl-4 space-y-2 text-[10px]"},Wg={key:0},Kg={class:"w-full border-collapse"},Jg={class:"py-0.5 pr-2 opacity-65 align-top"},Gg={class:"py-0.5 opacity-85 break-all"},Yg={key:1},Zg=["onClick","onMouseenter"],Xg={class:"whitespace-pre-wrap break-all"},Qg={key:1,class:"text-[10px]"},eh=["onClick"],th={key:0,class:"mt-1 pl-4 whitespace-pre-wrap break-words opacity-80"},rh={key:2,class:"text-[10px] opacity-80 pl-4 pb-2 break-words"},ah={class:"text-[10px] px-3 py-1.5 opacity-75 border-b border-current/20"},nh={class:"divide-y divide-current/20"},oh=["onClick"],lh={class:"min-w-0 flex-1 font-medium truncate"},sh={class:"inline-flex items-center rounded-full bg-neutral-200/70 dark:bg-neutral-700/70 px-1.5 py-0.5 text-[10px] leading-none text-neutral-700 dark:text-neutral-200 flex-shrink-0"},ih={key:0,class:"mt-2 pt-2 border-t border-current/15 space-y-2"},uh={class:"text-[10px] opacity-75"},dh={class:"flex items-center gap-2 text-[10px] opacity-70"},ch={class:"font-medium uppercase"},ph={key:0,class:"italic"},mh={key:0,class:"text-[11px] mt-1 whitespace-pre-wrap break-words"},vh={key:1,class:"mt-2 flex flex-wrap gap-2"},fh=["onClick"],gh={class:"min-w-0 flex-1 font-medium truncate"},hh={class:"inline-flex items-center rounded-full bg-neutral-200/70 dark:bg-neutral-700/70 px-1.5 py-0.5 text-[10px] leading-none text-neutral-700 dark:text-neutral-200 flex-shrink-0"},bh={key:0,class:"mt-2 space-y-2"},xh={class:"text-[10px] opacity-75"},yh={class:"flex items-center gap-2 text-[10px] opacity-70"},kh={class:"font-medium uppercase"},wh={key:0,class:"italic"},_h={key:0,class:"text-[11px] mt-1 whitespace-pre-wrap break-words"},$h={key:1,class:"mt-2 flex flex-wrap gap-2"},Ch=Se({__name:"AgentMessages",props:{messages:{},threadId:{},selectedMessageId:{},selectedLogId:{},hoveredLogId:{},isEditMode:{type:Boolean},selectedForDelete:{},editedMessages:{}},emits:["messageClick","messageHover","selectionChange","messageEdit"],setup(e,{expose:n,emit:a}){const s=e,l=a;function u(M){const T=s.selectedForDelete?.has(M)??!1;l("selectionChange",M,!T)}function i(M,T){const ee=M.target.innerText;l("messageEdit",T,ee)}function c(M){return s.editedMessages?.has(M)??!1}const f=p(new Map);function h(M,T){T?f.value.set(M,T):f.value.delete(M)}function x(M){const T=s.messages.findIndex(L=>L.log_id===M);if(T<=0)return-1;for(let L=T-1;L>=0;L--){const ee=s.messages[L];if(ee.role==="user")return L;if(ee.role==="assistant"&&ee.log_id)break}return-1}function b(M){for(let T=0;T<s.messages.length;T++){const L=s.messages[T];if(L.log_id===M||L.type==="work"&&L.items&&L.items.some(Ie=>Ie.log_id===M||Ie.response_log_id===M))return T}return-1}function y(M,T){const ee=b(M);if(ee===-1)return!1;const le=f.value.get(ee);if(!le)return!1;const Ie=s.messages[ee];let Re=null;if(Ie.role==="assistant"&&Ie.log_id){const R=x(Ie.log_id);Re=R!==-1?f.value.get(R):null}const qe=T.getBoundingClientRect(),We=le.getBoundingClientRect();if(We.top<qe.top){const ke=(Re||le).getBoundingClientRect().top-qe.top-10;T.scrollBy({top:ke,behavior:"smooth"})}else if(We.bottom>qe.bottom){const R=We.bottom-qe.bottom+10;T.scrollBy({top:R,behavior:"smooth"})}else if(Re){const R=Re.getBoundingClientRect();if(R.top<qe.top){const O=R.top-qe.top-10;T.scrollBy({top:O,behavior:"smooth"})}}return!0}function $(M){for(const T of s.messages){if(T.type!=="work")continue;if(T.items.some(le=>le.log_id===M||le.response_log_id===M))return!0}return!1}n({scrollToLogId:y,hasWorkblockForLogId:$});function g(M){const T=s.messages[M];if(T.log_id)return T.log_id;if(T.role==="user")for(let L=M+1;L<s.messages.length;L++){const ee=s.messages[L];if(ee.log_id)return ee.log_id;if(ee.role==="user")break}return null}function d(M,T){return T?g(M)===T:!1}function w(M){const T=g(M);T&&l("messageHover",T)}function m(M){g(M)&&l("messageHover",null)}function v(M){const T=s.messages[M],L=g(M);L&&l("messageClick",T.id,L)}const _=p(new Set),P=p(new Set),V=p(new Set),E=p(new Set);function z(M){_.value.has(M)?_.value.delete(M):_.value.add(M)}function A(M){P.value.has(M)?P.value.delete(M):P.value.add(M)}function oe(M){V.value.has(M)?V.value.delete(M):V.value.add(M)}function ne(M){E.value.has(M)?E.value.delete(M):E.value.add(M)}function fe(M){if(!M)return{};try{return JSON.parse(M)}catch{return{raw:M}}}function ye(M){if(!M)return null;const T=fe(M),L=Object.keys(T);if(L.length===0)return null;const ee=T[L[0]];return typeof ee=="string"?ee:JSON.stringify(ee)}function te(M){return new Date(M/1e3).toLocaleTimeString()}function q(M){const T=Math.round(M/1e6);if(T<1)return"< 1s";if(T<60)return`${T}s`;const L=Math.floor(T/60),ee=T%60;return`${L}m ${ee}s`}function j(M){if(M.status==="pending")return"...";if(!M.isComplete)return"Working...";let T;return M.request_sent_at&&M.response_completed_at?T=M.response_completed_at-M.request_sent_at:T=M.updated_at-M.created_at,`Worked for ${q(T)}`}function J(M){const T=M.filter(L=>L.type==="content");if(T.length===0){const L=M.filter(ee=>ee.type==="reasoning");return L.length>0?L[L.length-1].content:null}return T[T.length-1].content}function H(M){const L=M.trim().split(`
37
+ `)[0];return L.length>60?L.substring(0,60):L}function ce(M){return s.selectedMessageId===M.id?!0:s.selectedLogId?M.items.some(T=>T.log_id===s.selectedLogId||T.response_log_id===s.selectedLogId):!1}function Z(M){return!!(s.selectedLogId&&(M.log_id===s.selectedLogId||M.response_log_id===s.selectedLogId))}function U(M){return s.hoveredLogId?M.items.some(T=>T.log_id===s.hoveredLogId||T.response_log_id===s.hoveredLogId):!1}function K(M){return!!(s.hoveredLogId&&(M.log_id===s.hoveredLogId||M.response_log_id===s.hoveredLogId))}function me(M){const T=[];for(const L of M.items)L.log_id&&T.push(L.log_id),L.response_log_id&&T.push(L.response_log_id);return T}function ue(M){return M?M.trim():""}function Q(M,T){if(M.type!=="text")return;const L=M.attachments;if(!L?.length)return;if(M.silent)return L;const ee=s.messages[T-1];if(!ee||ee.type!=="text"||!ee.silent||!(ee.content||"").trim().startsWith("Initial asset attachment path:"))return L;const Ie=new Set((ee.attachments||[]).map(qe=>qe.path));if(Ie.size===0)return L;const Re=L.filter(qe=>!Ie.has(qe.path));return Re.length>0?Re:void 0}function G(M){return M.subagentThreadName||M.subagentTitle||M.subagentName||"Subagent"}function ae(M){return(M.subagentStatus||"running").toLowerCase()}function ie(M){const T=ae(M);return T==="pending"||T==="queued"}function xe(M){return M==="tool"?"Initialization":M==="user"?"Subagent":M==="assistant"?"Assistant":"System"}function X(M){const T=M.subagentResumable===!0?"resumable":M.subagentResumable===!1?"non-resumable":"resumable?",L=M.subagentBlocking===!0?"blocking":M.subagentBlocking===!1?"non-blocking":"blocking?";return`${T} · ${L}`}function he(M){return M.subagentHasError===!0}function be(M){if(he(M)||ie(M))return!1;const T=ae(M);return T!=="idle"&&T!=="terminated"}function B(M){return he(M)||be(M)?!1:M.subagentBlocking===!0}function D(M){if(M.type==="status")return!0;if(M.type!=="text"||M.role!=="system")return!1;const T=M.content||"";return T.includes("Execution stopped")?!0:/subagents?\s+started:/i.test(T)}return(M,T)=>(r(),o("div",null,[(r(!0),o($e,null,Le(e.messages,(L,ee)=>(r(),o("div",{key:L.id,ref_for:!0,ref:le=>h(ee,le),class:"flex items-center gap-2 pb-3",onMouseenter:le=>w(ee),onMouseleave:le=>m(ee),onClick:le=>e.isEditMode?u(L.id):v(ee)},[e.isEditMode&&L.role!=="system"?(r(),o("button",{key:0,onClick:Xe(le=>u(L.id),["stop"]),class:pe(["flex-shrink-0 w-6 h-6 rounded-full border-2 flex items-center justify-center transition-all",{"border-red-500 bg-red-500":e.selectedForDelete?.has(L.id),"border-green-500 bg-green-500":!e.selectedForDelete?.has(L.id)&&c(L.id),"border-neutral-400 dark:border-neutral-500 bg-transparent hover:border-neutral-500 dark:hover:border-neutral-400":!e.selectedForDelete?.has(L.id)&&!c(L.id)}])},[e.selectedForDelete?.has(L.id)?(r(),o("svg",xg,[...T[4]||(T[4]=[t("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M4.5 12.75l6 6 9-13.5"},null,-1)])])):c(L.id)?(r(),o("svg",yg,[...T[5]||(T[5]=[t("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)])])):S("",!0)],10,bg)):S("",!0),t("div",{class:pe(["flex-1 flex items-center gap-2 min-w-0",{"justify-start":L.type==="subagent"||L.type==="subagent_group"||L.role==="assistant","justify-end":L.type!=="subagent"&&L.type!=="subagent_group"&&L.role==="user","justify-center":L.type==="status"||L.role==="system","cursor-pointer":g(ee)&&!e.isEditMode}])},[D(L)?(r(),o("div",kg,C(L.content),1)):L.type==="text"?(r(),o("div",{key:1,class:pe(["max-w-[80%] flex flex-col gap-2",{"items-start":L.role==="assistant","items-end":L.role==="user"}])},[t("div",{class:pe(["rounded-2xl px-4 py-2 text-sm transition-all min-h-[2.5rem]",[L.silent?"bg-transparent text-neutral-700 border-2 border-dashed border-neutral-400 text-[11px] leading-4 dark:bg-transparent dark:text-neutral-200 dark:border-neutral-600":!e.isEditMode&&L.role!=="user"&&d(ee,e.selectedLogId)?"bg-accent-200 text-accent-950 dark:bg-accent-200 dark:text-accent-950 ring-2 ring-accent-400 dark:ring-accent-400":L.role==="assistant"?"bg-neutral-800 text-white dark:bg-neutral-300 dark:text-black":L.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":L.isOptimistic},{"ring-2 ring-accent-400 dark:ring-accent-400 !bg-accent-200 !text-accent-950 dark:!bg-accent-200 dark:!text-accent-950":!e.isEditMode&&L.role!=="user"&&g(ee)&&!L.silent&&!d(ee,e.selectedLogId)&&d(ee,e.hoveredLogId)},{"ring-2 ring-green-500 dark:ring-green-400":e.isEditMode&&c(L.id),"border border-dashed border-neutral-400 dark:border-neutral-500":e.isEditMode&&L.role!=="system"&&!c(L.id)}]])},[L.content||e.isEditMode?(r(),o("div",{key:0,class:pe(["whitespace-pre-wrap break-words outline-none",L.silent?"text-[11px] leading-4":"text-sm"]),contenteditable:e.isEditMode&&L.role!=="system",onInput:le=>i(le,L.id),onClick:T[0]||(T[0]=le=>e.isEditMode&&le.stopPropagation())},C(ue(L.content)),43,wg)):L.status==="pending"?(r(),o("div",_g,[...T[6]||(T[6]=[t("span",{class:"typing-dot",style:{"animation-delay":"0ms"}},null,-1),t("span",{class:"typing-dot",style:{"animation-delay":"150ms"}},null,-1),t("span",{class:"typing-dot",style:{"animation-delay":"300ms"}},null,-1)])])):S("",!0),L.status!=="pending"?(r(),o("div",{key:2,class:pe(["text-[10px] mt-1 flex gap-2",{"opacity-80":L.silent,"opacity-50":!L.silent,"justify-start":L.role==="assistant","justify-end":L.role==="user","justify-center":L.role==="system"}])},[L.sideLabel&&!L.silent?(r(),o("span",$g,C(L.sideLabel),1)):S("",!0),t("span",null,C(te(L.created_at)),1),L.silent?(r(),o("span",Cg," silent ")):S("",!0)],2)):S("",!0)],2),Q(L,ee)?.length&&e.threadId?(r(),o("div",Sg,[(r(!0),o($e,null,Le(Q(L,ee),le=>(r(),Y(_r,{key:le.id,attachment:le,threadId:e.threadId},null,8,["attachment","threadId"]))),128))])):S("",!0)],2)):L.type==="work"?(r(),o("div",{key:2,class:pe(["w-full rounded-lg px-3 py-2 text-xs transition-all border overflow-hidden",{"cursor-pointer":!e.isEditMode,"bg-neutral-50 text-neutral-700 border-neutral-200 dark:bg-neutral-900 dark:text-neutral-300 dark:border-neutral-700":L.role==="assistant"&&!L.silent,"bg-accent-50 text-accent-700 border-accent-200 dark:bg-accent-50 dark:text-accent-700 dark:border-accent-200":L.role==="user"&&!L.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":L.silent,"ring-2 ring-accent-500":!e.isEditMode&&ce(L),"ring-2 ring-accent-400":!e.isEditMode&&!ce(L)&&U(L)}]),onClick:le=>!e.isEditMode&&(z(L.id),me(L)[0]&&l("messageClick",L.id,me(L)[0])),onMouseenter:le=>!e.isEditMode&&me(L)[0]&&l("messageHover",me(L)[0]),onMouseleave:T[3]||(T[3]=le=>!e.isEditMode&&l("messageHover",null))},[_.value.has(L.id)?(r(),o("div",Og,[t("div",Rg,[k(I(xt),{size:14,class:"flex-shrink-0"}),t("span",jg,C(j(L)),1),t("span",Dg,C(L.items.length)+" operation"+C(L.items.length!==1?"s":""),1)]),(r(!0),o($e,null,Le(L.items,le=>(r(),o("div",{key:le.id,class:"mb-1"},[le.type==="tool_call"?(r(),o("div",Ug,[t("div",{onClick:Xe(Ie=>{A(le.id),le.log_id&&l("messageClick",L.id,le.log_id)},["stop"]),onMouseenter:Xe(Ie=>le.log_id&&l("messageHover",le.log_id),["stop"]),onMouseleave:T[1]||(T[1]=Xe(Ie=>l("messageHover",null),["stop"])),class:pe(["flex items-center gap-2 cursor-pointer hover:opacity-70 transition-opacity min-w-0",{"ring-1 ring-accent-500":Z(le),"ring-1 ring-accent-400":!Z(le)&&K(le)}])},[P.value.has(le.id)?(r(),Y(I(xt),{key:1,size:12,class:"flex-shrink-0 opacity-50"})):(r(),Y(I(St),{key:0,size:12,class:"flex-shrink-0 opacity-50"})),t("span",Ng,C(le.tool_name),1),ye(le.tool_arguments)?(r(),o("span",qg,C(ye(le.tool_arguments)),1)):S("",!0),le.response_status==="success"?(r(),o("span",Fg,"✓")):le.response_status==="failed"?(r(),Y(I(ar),{key:4,size:12,class:"ml-auto text-red-600 dark:text-red-400"})):S("",!0)],42,Bg),P.value.has(le.id)?(r(),o("div",Hg,[le.tool_arguments?(r(),o("div",Wg,[T[7]||(T[7]=t("div",{class:"font-semibold mb-1 opacity-70"},"Arguments:",-1)),t("table",Kg,[t("tbody",null,[(r(!0),o($e,null,Le(fe(le.tool_arguments),(Ie,Re)=>(r(),o("tr",{key:Re,class:"border-b border-current border-opacity-10"},[t("td",Jg,C(Re),1),t("td",Gg,C(typeof Ie=="object"?JSON.stringify(Ie):Ie),1)]))),128))])])])):S("",!0),le.response?(r(),o("div",Yg,[T[8]||(T[8]=t("div",{class:"font-semibold mb-1 opacity-70"},"Response:",-1)),t("div",{class:pe(["opacity-80 cursor-pointer hover:opacity-100",{"ring-1 ring-accent-500":e.selectedLogId&&le.response_log_id===e.selectedLogId,"ring-1 ring-accent-400":e.hoveredLogId&&le.response_log_id===e.hoveredLogId&&le.response_log_id!==e.selectedLogId}]),onClick:Xe(Ie=>le.response_log_id&&l("messageClick",L.id,le.response_log_id),["stop"]),onMouseenter:Xe(Ie=>le.response_log_id&&l("messageHover",le.response_log_id),["stop"]),onMouseleave:T[2]||(T[2]=Xe(Ie=>l("messageHover",null),["stop"]))},[t("div",Xg,C(ue(le.response)),1)],42,Zg)])):S("",!0)])):S("",!0)])):le.type==="reasoning"?(r(),o("div",Qg,[t("button",{onClick:Xe(Ie=>oe(le.id),["stop"]),class:"flex items-center gap-1 opacity-70 hover:opacity-100 transition-opacity"},[V.value.has(le.id)?(r(),Y(I(xt),{key:1,size:12,class:"flex-shrink-0"})):(r(),Y(I(St),{key:0,size:12,class:"flex-shrink-0"})),T[9]||(T[9]=t("span",{class:"font-semibold"},"Reasoning",-1))],8,eh),V.value.has(le.id)?(r(),o("div",th,C(ue(le.content)),1)):S("",!0)])):le.type==="content"?(r(),o("div",rh,C(ue(le.content)),1)):S("",!0)]))),128))])):(r(),o("div",Tg,[t("div",Mg,[k(I(St),{size:14,class:"flex-shrink-0 mt-0.5 opacity-50"}),t("div",zg,[J(L.items)?(r(),o("div",Vg,C(H(J(L.items)))+"... ",1)):(r(),o("div",Eg,C(j(L)),1))])]),t("div",Lg,[t("span",Ag,C(L.items.length)+" operation"+C(L.items.length!==1?"s":""),1),t("span",Pg,"• "+C(j(L)),1)])]))],42,Ig)):L.type==="subagent_group"?(r(),o("div",{key:3,class:pe(["w-full rounded-lg text-xs transition-all border overflow-hidden",{"bg-accent-100 text-accent-950 border-accent-300 dark:bg-accent-900/40 dark:text-accent-50 dark:border-accent-700":!L.silent,"bg-transparent text-neutral-700 border-dashed border-neutral-400 dark:text-neutral-200 dark:border-neutral-600":L.silent,"ring-2 ring-accent-500":!e.isEditMode&&d(ee,e.selectedLogId),"ring-2 ring-accent-400":!e.isEditMode&&!d(ee,e.selectedLogId)&&d(ee,e.hoveredLogId)}])},[t("div",ah,C(L.count)+" subagent"+C(L.count===1?"":"s"),1),t("div",nh,[(r(!0),o($e,null,Le(L.subagents,le=>(r(),o("div",{key:le.id,class:"px-3 py-1.5"},[t("button",{type:"button",class:"w-full flex items-center gap-2 text-left hover:opacity-85 transition-opacity",onClick:Xe(Ie=>ne(le.id),["stop"])},[ie(le)?(r(),Y(I(qr),{key:0,size:14,class:"text-neutral-500 dark:text-neutral-400 flex-shrink-0"})):he(le)?(r(),Y(I(ar),{key:1,size:13,class:"text-red-600 dark:text-red-400 flex-shrink-0",title:"Subagent returned an error"})):be(le)?(r(),Y(I(sr),{key:2,size:14,class:"animate-spin text-accent-700 dark:text-accent-300 flex-shrink-0"})):B(le)?(r(),Y(I(or),{key:3,size:14,class:"text-green-700 dark:text-green-300 flex-shrink-0"})):(r(),Y(I(Fr),{key:4,size:12,class:"text-neutral-500 dark:text-neutral-400 flex-shrink-0"})),t("span",lh,C(G(le)),1),t("span",sh,C(le.messageCount),1),E.value.has(le.id)?(r(),Y(I(xt),{key:5,size:13,class:"ml-1 opacity-70 flex-shrink-0"})):(r(),Y(I(St),{key:6,size:13,class:"ml-1 opacity-70 flex-shrink-0"}))],8,oh),E.value.has(le.id)?(r(),o("div",ih,[t("div",uh,C(X(le)),1),(r(!0),o($e,null,Le(le.messages,Ie=>(r(),o("div",{key:Ie.id,class:"rounded border border-current/20 bg-white/40 dark:bg-black/20 px-2 py-1"},[t("div",dh,[t("span",ch,C(xe(Ie.role)),1),t("span",null,C(te(Ie.created_at)),1),Ie.silent?(r(),o("span",ph,"silent")):S("",!0)]),Ie.content?(r(),o("div",mh,C(ue(Ie.content)),1)):S("",!0),Ie.attachments?.length&&e.threadId?(r(),o("div",vh,[(r(!0),o($e,null,Le(Ie.attachments,Re=>(r(),Y(_r,{key:Re.id,attachment:Re,threadId:e.threadId},null,8,["attachment","threadId"]))),128))])):S("",!0)]))),128))])):S("",!0)]))),128))])],2)):L.type==="subagent"?(r(),o("div",{key:4,class:pe(["w-full rounded-lg px-3 py-2 text-xs transition-all border overflow-hidden",{"bg-accent-100 text-accent-950 border-accent-300 dark:bg-accent-900/40 dark:text-accent-50 dark:border-accent-700":!L.silent,"bg-transparent text-neutral-700 border-dashed border-neutral-400 dark:text-neutral-200 dark:border-neutral-600":L.silent,"ring-2 ring-accent-500":!e.isEditMode&&d(ee,e.selectedLogId),"ring-2 ring-accent-400":!e.isEditMode&&!d(ee,e.selectedLogId)&&d(ee,e.hoveredLogId)}])},[t("button",{type:"button",class:"w-full flex items-center gap-2 text-left",onClick:Xe(le=>ne(L.id),["stop"])},[ie(L)?(r(),Y(I(qr),{key:0,size:14,class:"text-neutral-500 dark:text-neutral-400 flex-shrink-0"})):he(L)?(r(),Y(I(ar),{key:1,size:13,class:"text-red-600 dark:text-red-400 flex-shrink-0",title:"Subagent returned an error"})):be(L)?(r(),Y(I(sr),{key:2,size:14,class:"animate-spin text-accent-700 dark:text-accent-300 flex-shrink-0"})):B(L)?(r(),Y(I(or),{key:3,size:14,class:"text-green-700 dark:text-green-300 flex-shrink-0"})):(r(),Y(I(Fr),{key:4,size:12,class:"text-neutral-500 dark:text-neutral-400 flex-shrink-0"})),t("span",gh,C(G(L)),1),t("span",hh,C(L.messageCount),1),E.value.has(L.id)?(r(),Y(I(xt),{key:5,size:13,class:"ml-1 opacity-70 flex-shrink-0"})):(r(),Y(I(St),{key:6,size:13,class:"ml-1 opacity-70 flex-shrink-0"}))],8,fh),E.value.has(L.id)?(r(),o("div",bh,[t("div",xh,C(X(L)),1),(r(!0),o($e,null,Le(L.messages,le=>(r(),o("div",{key:le.id,class:"rounded border border-current/20 bg-white/50 dark:bg-black/30 px-2 py-1"},[t("div",yh,[t("span",kh,C(xe(le.role)),1),t("span",null,C(te(le.created_at)),1),le.silent?(r(),o("span",wh,"silent")):S("",!0)]),le.content?(r(),o("div",_h,C(ue(le.content)),1)):S("",!0),le.attachments?.length&&e.threadId?(r(),o("div",$h,[(r(!0),o($e,null,Le(le.attachments,Ie=>(r(),Y(_r,{key:Ie.id,attachment:Ie,threadId:e.threadId},null,8,["attachment","threadId"]))),128))])):S("",!0)]))),128))])):S("",!0)],2)):S("",!0)],2)],40,hg))),128))]))}}),Sh=mt(Ch,[["__scopeId","data-v-d182a948"]]),Ih=["onClick"],Th=["value","placeholder","disabled"],Mh=Se({__name:"TagInput",props:{modelValue:{},placeholder:{},disabled:{type:Boolean}},emits:["update:modelValue"],setup(e,{emit:n}){const a=e,s=n,l=p(""),u=p(null),i=b=>{const y=b.trim().toLowerCase();y&&!a.modelValue.includes(y)&&s("update:modelValue",[...a.modelValue,y]),l.value="",Fe(()=>u.value?.focus())},c=b=>{const y=[...a.modelValue];y.splice(b,1),s("update:modelValue",y)},f=b=>{const y=b.target.value;if(y.includes(",")){const $=y.split(",");$.forEach((g,d)=>{d<$.length-1?i(g):l.value=g})}else l.value=y},h=b=>{b.key==="Enter"?(b.preventDefault(),i(l.value)):b.key==="Backspace"&&!l.value&&a.modelValue.length>0&&c(a.modelValue.length-1)},x=()=>{u.value?.focus()};return(b,y)=>(r(),o("div",{class:pe(["flex flex-wrap items-center gap-1.5 min-h-[32px] px-2 py-1.5 bg-white dark:bg-neutral-950 border border-neutral-200 dark:border-neutral-800 rounded-md cursor-text focus-within:ring-2 focus-within:ring-accent-500/20 focus-within:border-accent-500 transition-colors",{"opacity-50 cursor-not-allowed":e.disabled}]),onClick:x},[(r(!0),o($e,null,Le(e.modelValue,($,g)=>(r(),o("span",{key:$,class:"inline-flex items-center gap-1 px-2 py-0.5 text-xs font-medium bg-accent-100 dark:bg-accent-900/30 text-accent-700 dark:text-accent-300 rounded"},[ve(C($)+" ",1),e.disabled?S("",!0):(r(),o("button",{key:0,type:"button",onClick:Xe(d=>c(g),["stop"]),class:"hover:text-accent-900 dark:hover:text-accent-100 transition-colors"},[k(I(Ar),{size:12})],8,Ih))]))),128)),t("input",{ref_key:"inputRef",ref:u,type:"text",value:l.value,placeholder:e.modelValue.length===0?e.placeholder:"",disabled:e.disabled,class:"flex-1 min-w-[60px] bg-transparent border-none outline-none text-xs text-neutral-900 dark:text-neutral-100 placeholder:text-neutral-400 disabled:cursor-not-allowed",onInput:f,onKeydown:h},null,40,Th)],2))}}),zh={key:0,class:"overflow-hidden bg-neutral-100 dark:bg-neutral-950"},Vh={class:"max-h-[500px] overflow-y-auto p-3 space-y-3"},Eh={key:0,class:"flex justify-center py-6"},Lh={key:1,class:"text-red-600 dark:text-red-400 text-center py-4 text-xs"},Ah={class:"bg-white dark:bg-neutral-900 rounded-lg border border-neutral-200 dark:border-neutral-800 overflow-hidden"},Ph={class:"p-3 space-y-2"},Oh={class:"text-[10px] text-neutral-500 dark:text-neutral-400"},Rh=["title"],jh={class:"flex-1 text-[11px] font-mono text-neutral-600 dark:text-neutral-400 truncate"},Dh={class:"flex items-center gap-2"},Uh={class:"flex-1 flex items-center gap-1.5"},Bh={key:1,class:"text-xs text-neutral-700 dark:text-neutral-200"},Nh={class:"text-[9px] px-1.5 py-0.5 rounded bg-neutral-100 dark:bg-neutral-800 text-neutral-500 dark:text-neutral-400 uppercase tracking-wide shrink-0"},qh={class:"flex items-start gap-2"},Fh={class:"bg-white dark:bg-neutral-900 rounded-lg border border-neutral-200 dark:border-neutral-800 overflow-hidden"},Hh={class:"p-3"},Wh={key:0,class:"text-xs text-neutral-500 dark:text-neutral-400"},Kh={key:1,class:"text-xs text-neutral-500 dark:text-neutral-400"},Jh={key:2,class:"space-y-2"},Gh={class:"min-w-0"},Yh={class:"flex items-center gap-1.5"},Zh={class:"text-[11px] font-mono text-neutral-700 dark:text-neutral-200 truncate"},Xh={key:0,class:"text-[9px] px-1 py-0.5 rounded bg-red-100 dark:bg-red-900 text-red-700 dark:text-red-300 uppercase tracking-wide"},Qh={class:"text-[10px] text-neutral-500 dark:text-neutral-400"},eb={key:0,class:"text-[10px] text-neutral-500 dark:text-neutral-400"},tb={class:"bg-white dark:bg-neutral-900 rounded-lg border border-neutral-200 dark:border-neutral-800 overflow-hidden"},rb=["disabled"],ab={key:0,class:"overflow-hidden border-t border-neutral-100 dark:border-neutral-800"},nb={class:"p-3 space-y-3"},ob={class:"flex gap-4 text-xs"},lb={class:"ml-1 font-mono font-semibold text-neutral-800 dark:text-neutral-100"},sb={class:"ml-1 font-mono text-neutral-600 dark:text-neutral-400"},ib={key:0,class:"w-full text-[11px]"},ub=["title"],db={class:"text-right py-1.5 font-mono text-neutral-600 dark:text-neutral-400"},cb={class:"text-right py-1.5 font-mono text-neutral-600 dark:text-neutral-400"},pb={class:"bg-white dark:bg-neutral-900 rounded-lg border border-neutral-200 dark:border-neutral-800 overflow-hidden"},mb={key:0,class:"overflow-hidden border-t border-neutral-100 dark:border-neutral-800"},vb={class:"p-3 space-y-3"},fb={class:"flex items-center gap-2"},gb=["disabled"],hb={class:"pt-2 border-t border-neutral-100 dark:border-neutral-800"},bb=["disabled"],xb=Se({__name:"MetadataSlidePane",props:{threadId:{},show:{type:Boolean}},emits:["close","threadDeleted","editThread","threadUpdated"],setup(e,{emit:n}){const a=e,s=n,{thread:l,isFetching:u,error:i,refetch:c}=jr(F(()=>a.threadId)),{agents:f,isFetching:h}=nn(),x=p(!1),b=p(!1),y=p(!1),$=p(!1),g=p(!1),d=p(!1),w=p(!1),m=p(!1),v=p("a"),_=p(!1),P=p(!1),V=p([]),E=p(""),z=p([]),A=p(!1),oe=p(null),ne=F(()=>f.value?f.value.filter(ue=>ue.type==="ai_human").map(ue=>({value:ue.id,label:ue.title})):[]),fe=F(()=>l.value?.agent.type==="ai_human"),ye=F(()=>l.value?.agent.type==="dual_ai"),te=ue=>new Date(ue*1e3).toLocaleString("en-US",{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}),q=async()=>{l.value&&(await navigator.clipboard.writeText(l.value.id),_.value=!0,setTimeout(()=>{_.value=!1},2e3))},j=async ue=>{if(!(!a.threadId||!ue||ue===l.value?.agent.id)){y.value=!0;try{const Q=await fetch(ze(`/api/threads/${a.threadId}`),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({agent_id:ue})});if(!Q.ok){const G=await Q.json();throw new Error(G.error||"Failed to update agent")}await c(),s("threadUpdated")}catch(Q){console.error("Error updating agent:",Q),E.value=l.value?.agent.id||""}finally{y.value=!1}}},J=async ue=>{if(a.threadId){z.value=ue,A.value=!0,$.value=!0;try{const Q=await fetch(ze(`/api/threads/${a.threadId}`),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({tags:ue})});if(!Q.ok){const G=await Q.json();throw new Error(G.error||"Failed to update tags")}s("threadUpdated")}catch(Q){console.error("Error updating tags:",Q),z.value=l.value?.tags||[]}finally{$.value=!1,A.value=!1}}},H=async()=>{if(g.value){g.value=!1;return}if(a.threadId){w.value=!0,g.value=!0;try{const ue=await fetch(ze(`/api/threads/${a.threadId}/cost`));if(!ue.ok){const Q=await ue.json();throw new Error(Q.error||"Failed to fetch cost breakdown")}oe.value=await ue.json()}catch(ue){console.error("Error fetching cost breakdown:",ue),g.value=!1}finally{w.value=!1}}},ce=ue=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:4,maximumFractionDigits:6}).format(ue),Z=ue=>ue.defined?(ue.defined.type==="agent"||ue.defined.type==="prompt")&&ue.defined.name?`${ue.defined.type}:${ue.defined.name}`:ue.defined.type:"missing",U=async()=>{if(!a.threadId||!l.value?.agent?.id){V.value=[];return}P.value=!0;try{const ue=await fetch(ze(`/api/variables/agents/${encodeURIComponent(l.value.agent.id)}?thread_id=${encodeURIComponent(a.threadId)}`));if(!ue.ok){V.value=[];return}const Q=await ue.json();V.value=Q.variables||[]}catch(ue){console.error("Error fetching thread variables:",ue),V.value=[]}finally{P.value=!1}},K=async()=>{if(a.threadId){m.value=!0;try{const ue=await fetch(ze(`/api/threads/${a.threadId}/continue`),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({side:v.value})});if(!ue.ok){const Q=await ue.json();throw new Error(Q.error||"Failed to continue execution")}}catch(ue){console.error("Error continuing execution:",ue)}finally{m.value=!1}}},me=async()=>{if(a.threadId){b.value=!0;try{const ue=await fetch(ze(`/api/threads/${a.threadId}`),{method:"DELETE"});if(!ue.ok){const Q=await ue.json();throw new Error(Q.error||"Failed to delete thread")}s("threadDeleted",a.threadId)}catch(ue){console.error("Error deleting thread:",ue)}finally{b.value=!1}}};return Ve(()=>l.value,ue=>{ue&&(E.value=ue.agent.id,A.value||(z.value=ue.tags||[]))},{immediate:!0}),Ve(()=>a.show,ue=>{ue?U():(g.value=!1,d.value=!1,oe.value=null,V.value=[],P.value=!1)}),Ve(()=>a.threadId,()=>{g.value=!1,d.value=!1,oe.value=null,V.value=[],a.show&&U()}),Ve(()=>l.value?.agent?.id,()=>{a.show&&U()}),(ue,Q)=>{const G=at("FormKit");return r(),Y(kt,{"enter-active-class":"transition-all duration-300 ease-out","enter-from-class":"max-h-0 opacity-0","enter-to-class":"max-h-[500px] opacity-100","leave-active-class":"transition-all duration-200 ease-in","leave-from-class":"max-h-[500px] opacity-100","leave-to-class":"max-h-0 opacity-0"},{default:W(()=>[e.show&&e.threadId?(r(),o("div",zh,[t("div",Vh,[I(u)?(r(),o("div",Eh,[k(Be)])):I(i)?(r(),o("div",Lh," Error: "+C(I(i)),1)):I(l)?(r(),o($e,{key:2},[t("div",Ah,[t("div",Ph,[t("div",Oh,[Q[5]||(Q[5]=t("span",{class:"font-medium uppercase tracking-wide"},"Created",-1)),Q[6]||(Q[6]=t("span",{class:"mx-1"},"·",-1)),ve(" "+C(te(I(l).created_at)),1)]),t("div",{class:"flex items-center gap-1 px-2 py-1.5 bg-neutral-50 dark:bg-neutral-950 rounded border border-neutral-200 dark:border-neutral-800 cursor-pointer hover:border-neutral-300 dark:hover:border-neutral-700 transition-colors group",onClick:q,title:_.value?"Copied!":"Click to copy"},[t("code",jh,C(I(l).id),1),t("span",{class:pe(["shrink-0 transition-colors",_.value?"text-green-600 dark:text-green-400":"text-neutral-400 group-hover:text-neutral-600 dark:group-hover:text-neutral-300"])},[_.value?(r(),Y(I(or),{key:0,size:12})):(r(),Y(I(Cn),{key:1,size:12}))],2)],8,Rh),t("div",Dh,[Q[7]||(Q[7]=t("label",{class:"shrink-0 text-[10px] font-medium text-neutral-500 dark:text-neutral-400 uppercase tracking-wide w-10"},"Agent",-1)),t("div",Uh,[fe.value?(r(),Y(G,{key:0,type:"selectSearch",modelValue:E.value,"onUpdate:modelValue":Q[0]||(Q[0]=ae=>E.value=ae),options:ne.value,loading:I(h)||y.value,disabled:y.value,size:"sm",placeholder:"Select...",onInput:j,"outer-class":"!mb-0 flex-1"},null,8,["modelValue","options","loading","disabled"])):(r(),o("span",Bh,C(I(l).agent.title),1)),t("span",Nh,C(I(l).agent.type.replace("_"," ")),1)])]),t("div",qh,[Q[8]||(Q[8]=t("label",{class:"shrink-0 text-[10px] font-medium text-neutral-500 dark:text-neutral-400 uppercase tracking-wide w-10 pt-2"},"Tags",-1)),k(Mh,{"model-value":z.value,"onUpdate:modelValue":J,disabled:$.value,placeholder:"Add tags...",class:"flex-1"},null,8,["model-value","disabled"])])])]),t("div",Fh,[Q[9]||(Q[9]=t("div",{class:"px-3 py-2.5 border-b border-neutral-100 dark:border-neutral-800"},[t("div",{class:"text-xs font-medium text-neutral-700 dark:text-neutral-200"}," Variables ")],-1)),t("div",Hh,[P.value?(r(),o("div",Wh," Loading variables... ")):V.value.length===0?(r(),o("div",Kh," No declared variables for this thread. ")):(r(),o("div",Jh,[(r(!0),o($e,null,Le(V.value.slice(0,6),ae=>(r(),o("div",{key:ae.property,class:"flex items-center justify-between gap-2"},[t("div",Gh,[t("div",Yh,[t("span",Zh,C(ae.property),1),ae.required?(r(),o("span",Xh," required ")):S("",!0)]),t("div",Qh,C(Z(ae)),1)]),t("span",{class:pe(["text-[9px] px-1 py-0.5 rounded uppercase tracking-wide",ae.type==="secret"?"bg-amber-100 dark:bg-amber-900 text-amber-700 dark:text-amber-300":"bg-blue-100 dark:bg-blue-900 text-blue-700 dark:text-blue-300"])},C(ae.type),3)]))),128)),V.value.length>6?(r(),o("div",eb," +"+C(V.value.length-6)+" more ",1)):S("",!0)]))])]),t("div",tb,[t("button",{onClick:H,disabled:w.value,type:"button",class:"w-full flex items-center gap-2 px-3 py-2.5 text-left hover:bg-neutral-50 dark:hover:bg-neutral-800 transition-colors disabled:opacity-50"},[k(I(Sn),{size:14,class:"shrink-0 text-neutral-400"}),Q[10]||(Q[10]=t("span",{class:"flex-1 text-xs font-medium text-neutral-700 dark:text-neutral-200"},"Usage & Cost",-1)),w.value?(r(),Y(Be,{key:0,size:"xs"})):(r(),Y(I(xt),{key:1,size:14,class:pe(["shrink-0 text-neutral-400 transition-transform duration-200",{"-rotate-180":g.value}])},null,8,["class"]))],8,rb),k(kt,{"enter-active-class":"transition-all duration-200 ease-out","enter-from-class":"opacity-0 max-h-0","enter-to-class":"opacity-100 max-h-[250px]","leave-active-class":"transition-all duration-150 ease-in","leave-from-class":"opacity-100 max-h-[250px]","leave-to-class":"opacity-0 max-h-0"},{default:W(()=>[g.value&&oe.value?(r(),o("div",ab,[t("div",nb,[t("div",ob,[t("div",null,[Q[11]||(Q[11]=t("span",{class:"text-neutral-500 dark:text-neutral-400"},"Total:",-1)),t("span",lb,C(ce(oe.value.totalCost)),1)]),t("div",null,[Q[12]||(Q[12]=t("span",{class:"text-neutral-500 dark:text-neutral-400"},"Per msg:",-1)),t("span",sb,C(ce(oe.value.avgCostPerMessage)),1)])]),oe.value.modelBreakdown.length>0?(r(),o("table",ib,[Q[13]||(Q[13]=t("thead",null,[t("tr",{class:"border-b border-neutral-200 dark:border-neutral-800"},[t("th",{class:"text-left py-1.5 font-medium text-neutral-500 dark:text-neutral-400 uppercase text-[10px]"},"Model"),t("th",{class:"text-right py-1.5 font-medium text-neutral-500 dark:text-neutral-400 uppercase text-[10px] w-14"},"Reqs"),t("th",{class:"text-right py-1.5 font-medium text-neutral-500 dark:text-neutral-400 uppercase text-[10px]"},"Cost")])],-1)),t("tbody",null,[(r(!0),o($e,null,Le(oe.value.modelBreakdown,ae=>(r(),o("tr",{key:ae.modelName},[t("td",{class:"py-1.5 truncate max-w-[120px] text-neutral-700 dark:text-neutral-300",title:ae.modelName},C(ae.modelName),9,ub),t("td",db,C(ae.requestCount),1),t("td",cb,C(ce(ae.totalCost)),1)]))),128))])])):S("",!0)])])):S("",!0)]),_:1})]),t("div",pb,[t("button",{onClick:Q[1]||(Q[1]=ae=>d.value=!d.value),type:"button",class:"w-full flex items-center gap-2 px-3 py-2.5 text-left hover:bg-neutral-50 dark:hover:bg-neutral-800 transition-colors"},[k(I(In),{size:14,class:"shrink-0 text-neutral-400"}),Q[14]||(Q[14]=t("span",{class:"flex-1 text-xs font-medium text-neutral-700 dark:text-neutral-200"},"Developer Tools",-1)),k(I(xt),{size:14,class:pe(["shrink-0 text-neutral-400 transition-transform duration-200",{"-rotate-180":d.value}])},null,8,["class"])]),k(kt,{"enter-active-class":"transition-all duration-200 ease-out","enter-from-class":"opacity-0 max-h-0","enter-to-class":"opacity-100 max-h-[150px]","leave-active-class":"transition-all duration-150 ease-in","leave-from-class":"opacity-100 max-h-[150px]","leave-to-class":"opacity-0 max-h-0"},{default:W(()=>[d.value?(r(),o("div",mb,[t("div",vb,[t("div",fb,[ye.value?Je((r(),o("select",{key:0,"onUpdate:modelValue":Q[2]||(Q[2]=ae=>v.value=ae),class:"text-xs px-2 py-1.5 border border-neutral-200 dark:border-neutral-700 rounded bg-white dark:bg-neutral-800 text-neutral-700 dark:text-neutral-300"},[...Q[15]||(Q[15]=[t("option",{value:"a"},"Side A",-1),t("option",{value:"b"},"Side B",-1)])],512)),[[Ca,v.value]]):S("",!0),t("button",{onClick:K,disabled:m.value,class:"flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium bg-neutral-800 dark:bg-neutral-200 text-white dark:text-neutral-900 rounded hover:bg-neutral-700 dark:hover:bg-neutral-300 transition-colors disabled:opacity-50"},[k(I(Tn),{size:12}),t("span",null,C(m.value?"Running...":"Continue"),1)],8,gb),Q[16]||(Q[16]=t("span",{class:"text-[10px] text-neutral-500 dark:text-neutral-400"},"Resume without new message",-1))]),t("div",hb,[t("button",{onClick:Q[3]||(Q[3]=ae=>x.value=!0),disabled:b.value,class:"flex items-center gap-1.5 text-xs font-medium text-red-600 dark:text-red-400 hover:text-red-700 dark:hover:text-red-300 transition-colors disabled:opacity-50"},[k(I(Mn),{size:12}),t("span",null,C(b.value?"Deleting...":"Delete Thread"),1)],8,bb)])])])):S("",!0)]),_:1})])],64)):S("",!0)]),k(Or,{modelValue:x.value,"onUpdate:modelValue":Q[4]||(Q[4]=ae=>x.value=ae),title:"Delete Thread?",message:"This will permanently delete all messages, logs, and associated data. This action cannot be undone.","confirm-text":"Delete","cancel-text":"Cancel",onConfirm:me},null,8,["modelValue"])])):S("",!0)]),_:1})}}}),yb=mt(xb,[["__scopeId","data-v-07e96d1b"]]),kb={key:0,class:"overflow-hidden bg-neutral-100 dark:bg-neutral-950"},wb={class:"max-h-[400px] overflow-y-auto p-3 space-y-3"},_b={class:"bg-white dark:bg-neutral-900 rounded-lg border border-neutral-200 dark:border-neutral-800 overflow-hidden"},$b={class:"flex items-center justify-between px-3 py-2 border-b border-neutral-100 dark:border-neutral-800"},Cb={class:"flex items-center gap-2"},Sb={class:"text-[10px] text-neutral-400"},Ib={class:"flex items-center gap-1"},Tb={class:"p-2"},Mb={key:0,class:"px-2 py-4 text-center text-neutral-400 text-xs"},zb=["onClick"],Vb={class:"text-xs text-neutral-700 dark:text-neutral-300 truncate"},Eb={class:"text-[10px] text-neutral-400 ml-auto"},Lb=["href","onMouseenter"],Ab={class:"shrink-0 text-neutral-400"},Pb={class:"flex-1 min-w-0"},Ob={class:"shrink-0 text-[10px] text-neutral-400 ml-auto"},Rb={key:0,class:"text-blue-500"},jb={key:1,class:"text-red-500"},Db={key:2},Ub=["href","onMouseenter"],Bb={class:"shrink-0 text-neutral-400"},Nb={class:"flex-1 min-w-0"},qb={class:"shrink-0 text-[10px] text-neutral-400 ml-auto"},Fb={key:0,class:"text-blue-500"},Hb={key:1,class:"text-red-500"},Wb={key:2},Kb=["src","alt"],Jb=Se({__name:"FilesSlidePane",props:{threadId:{},show:{type:Boolean}},emits:["close"],setup(e,{emit:n}){const a=e;let s=null;try{s=ja()}catch{}const l=s?.files??p([]),u=s?.addFiles??(()=>{}),i=p(null),c=p(new Set(["/attachments"])),f=p(null),h=p({x:0,y:0});function x(P){if(P===0)return"0 B";const V=1024,E=["B","KB","MB","GB"],z=Math.floor(Math.log(P)/Math.log(V));return parseFloat((P/Math.pow(V,z)).toFixed(1))+" "+E[z]}function b(P){const V=P.startsWith("/")?P.slice(1):P;return ze(`/api/threads/${a.threadId}/fs/${V}`)}function y(P,V){return V?Ta:P.startsWith("audio/")?En:P.startsWith("video/")?Ln:P.startsWith("text/")?An:P.includes("javascript")||P.includes("json")||P.includes("xml")?Pn:Ma}function $(P){const V=P.target;V.files?.length&&(u(V.files),V.value="")}function g(){i.value?.click()}function d(P){c.value.has(P)?c.value.delete(P):c.value.add(P),c.value=new Set(c.value)}function w(P){h.value={x:P.clientX,y:P.clientY}}function m(P){f.value=P}const v=F(()=>{const P=[],V=new Map,E=[...l.value].sort((z,A)=>z.status==="uploading"&&A.status!=="uploading"?-1:A.status==="uploading"&&z.status!=="uploading"?1:(z.path||z.name).localeCompare(A.path||A.name));for(const z of E){const A=z.path||`/${z.name}`,oe=A.split("/").filter(Boolean);if(oe.length===1)P.push({type:"file",name:z.name,path:A,file:z});else{const ne="/"+oe.slice(0,-1).join("/"),fe=oe[oe.length-2];if(!V.has(ne)){const ye={type:"directory",name:fe,path:ne,children:[]};V.set(ne,ye),P.push(ye)}V.get(ne).children.push({type:"file",name:z.name,path:A,file:z})}}return P}),_=F(()=>l.value.length);return He(()=>{document.addEventListener("mousemove",w)}),ct(()=>{document.removeEventListener("mousemove",w)}),(P,V)=>(r(),Y(kt,{"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:W(()=>[e.show?(r(),o("div",kb,[t("div",wb,[t("div",_b,[t("div",$b,[t("div",Cb,[k(I(lr),{size:14,class:"text-neutral-400"}),V[3]||(V[3]=t("span",{class:"text-xs font-medium text-neutral-700 dark:text-neutral-200"},"Files",-1)),t("span",Sb,C(_.value),1)]),t("div",Ib,[t("input",{ref_key:"fileInput",ref:i,type:"file",multiple:"",class:"hidden",onChange:$},null,544),t("button",{onClick:g,type:"button",class:"p-1 hover:bg-neutral-100 dark:hover:bg-neutral-700 rounded transition-colors text-neutral-400 hover:text-neutral-600 dark:hover:text-neutral-300",title:"Upload files"},[k(I(zn),{size:14})])])]),t("div",Tb,[v.value.length===0?(r(),o("div",Mb," No files yet ")):S("",!0),(r(!0),o($e,null,Le(v.value,E=>(r(),o($e,{key:E.path},[E.type==="directory"?(r(),o($e,{key:0},[t("button",{onClick:z=>d(E.path),type:"button",class:"w-full flex items-center gap-1.5 px-2 py-1.5 hover:bg-neutral-50 dark:hover:bg-neutral-700/50 rounded transition-colors text-left"},[k(I(St),{size:12,class:pe(["shrink-0 text-neutral-400 transition-transform",{"rotate-90":c.value.has(E.path)}])},null,8,["class"]),(r(),Y(rt(c.value.has(E.path)?I(Vn):I(lr)),{size:14,class:"shrink-0",style:{color:"var(--accent-500)"}})),t("span",Vb,C(E.name),1),t("span",Eb,C(E.children?.length),1)],8,zb),c.value.has(E.path)?(r(!0),o($e,{key:0},Le(E.children,z=>(r(),o("a",{key:z.path,href:z.path?b(z.path):void 0,target:"_blank",rel:"noopener noreferrer",class:pe(["flex items-center gap-2 pl-7 pr-2 py-1 hover:bg-neutral-50 dark:hover:bg-neutral-700/50 rounded transition-colors cursor-pointer",{"pointer-events-none":z.file?.status==="uploading"}]),onMouseenter:A=>z.file?.isImage?m(z.path):null,onMouseleave:V[0]||(V[0]=A=>m(null))},[t("div",Ab,[z.file?.status==="uploading"?(r(),Y(I(sr),{key:0,size:12,class:"animate-spin"})):(r(),Y(rt(y(z.file?.mimeType||"",z.file?.isImage||!1)),{key:1,size:12}))]),t("div",Pb,[t("div",{class:pe(["text-[11px] text-neutral-600 dark:text-neutral-400 truncate",{"opacity-50":z.file?.status==="uploading"}])},C(z.name),3)]),t("div",Ob,[z.file?.status==="uploading"?(r(),o("span",Rb,"...")):z.file?.status==="error"?(r(),o("span",jb,"err")):(r(),o("span",Db,C(x(z.file?.size||0)),1))])],42,Lb))),128)):S("",!0)],64)):(r(),o("a",{key:1,href:E.path?b(E.path):void 0,target:"_blank",rel:"noopener noreferrer",class:pe(["flex items-center gap-2 px-2 py-1.5 hover:bg-neutral-50 dark:hover:bg-neutral-700/50 rounded transition-colors cursor-pointer",{"pointer-events-none":E.file?.status==="uploading"}]),onMouseenter:z=>E.file?.isImage?m(E.path):null,onMouseleave:V[1]||(V[1]=z=>m(null))},[t("div",Bb,[E.file?.status==="uploading"?(r(),Y(I(sr),{key:0,size:14,class:"animate-spin"})):(r(),Y(rt(y(E.file?.mimeType||"",E.file?.isImage||!1)),{key:1,size:14}))]),t("div",Nb,[t("div",{class:pe(["text-xs text-neutral-600 dark:text-neutral-400 truncate",{"opacity-50":E.file?.status==="uploading"}])},C(E.name),3)]),t("div",qb,[E.file?.status==="uploading"?(r(),o("span",Fb,"...")):E.file?.status==="error"?(r(),o("span",Hb,"err")):(r(),o("span",Wb,C(x(E.file?.size||0)),1))])],42,Ub))],64))),128))])])]),(r(),Y(Yt,{to:"body"},[f.value?(r(),o("div",{key:0,class:"fixed z-50 bg-white dark:bg-neutral-800 border border-neutral-200 dark:border-neutral-700 rounded-lg shadow-lg p-1 pointer-events-none",style:_t({left:`${h.value.x+16}px`,top:`${h.value.y-80}px`})},[t("img",{src:b(f.value),alt:f.value,class:"max-w-[200px] max-h-[150px] rounded object-contain",onError:V[2]||(V[2]=E=>E.target.style.display="none")},null,40,Kb)],4)):S("",!0)]))])):S("",!0)]),_:1}))}}),Gb=["accept"],Yb=["disabled"],Zb=Se({__name:"FileUpload",props:{isProcessing:{type:Boolean},accept:{}},emits:["filesSelected"],setup(e,{expose:n,emit:a}){const s=e,l=a,u=p(null),i=F(()=>s.accept||"image/*,.pdf,.txt,.md,.json,.csv");function c(){u.value?.click()}function f(x){const b=x.target;b.files&&b.files.length>0&&(l("filesSelected",b.files),b.value="")}function h(x){const b=x.clipboardData?.items;if(!b)return;const y=[];for(let $=0;$<b.length;$++){const g=b[$];if(g.kind==="file"){const d=g.getAsFile();d&&y.push(d)}}if(y.length>0){const $=new DataTransfer;y.forEach(g=>$.items.add(g)),l("filesSelected",$.files)}}return n({handlePaste:h}),(x,b)=>(r(),o($e,null,[t("input",{ref_key:"fileInputRef",ref:u,type:"file",accept:i.value,multiple:"",class:"hidden",onChange:f},null,40,Gb),t("button",{type:"button",onClick:c,class:pe(["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":e.isProcessing}]),disabled:e.isProcessing,title:"Attach files"},[k(I(On),{size:18})],10,Yb)],64))}}),Xb={class:"flex flex-col h-full"},Qb={class:"px-4 py-3 border-b border-neutral-300 dark:border-neutral-700"},e1={class:"flex items-center justify-between"},t1={class:"flex items-center gap-2"},r1={class:"flex items-center gap-2"},a1={class:"flex-1 flex flex-col overflow-hidden relative"},n1={key:0,class:"text-neutral-500 dark:text-neutral-400 text-center py-8"},o1={key:1,class:"flex justify-center py-2"},l1={key:2,class:"flex justify-center py-8"},s1={key:3,class:"text-red-600 dark:text-red-400 text-center py-8"},i1={key:4,class:"text-neutral-500 dark:text-neutral-400 text-center py-8"},u1={key:1,class:"p-3 bg-white dark:bg-neutral-900 border-t border-neutral-300 dark:border-neutral-700"},d1={class:"flex items-center justify-end gap-2"},c1=["disabled"],p1={key:2,class:"p-3 bg-white dark:bg-neutral-900 border-t border-neutral-300 dark:border-neutral-700"},m1={key:0,class:"mb-2 flex flex-wrap gap-2"},v1={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"},f1=["src","alt"],g1={key:1,class:"w-full h-full flex items-center justify-center"},h1={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"},b1=["title"],x1=["onClick"],y1={class:"flex items-start gap-2"},k1={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"},w1=["disabled"],_1=["disabled"],$1={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"},C1={key:1,class:"w-4 h-4"},sa=Se({__name:"MessagesPane",props:{threadId:{},selectedMessageId:{},selectedLogId:{},hoveredLogId:{}},emits:["collapse","messageClick","messageHover","threadDeleted","editThread","logsDeleted","threadUpdated"],setup(e,{expose:n,emit:a}){const s=e,l=a,u=p(!1),i=()=>{u.value||(c.value=!1),u.value=!u.value},c=p(!1),f=()=>{c.value||(u.value=!1),c.value=!c.value},h=p(!1),x=p(new Set),b=p(new Map),y=()=>{h.value=!h.value,h.value||(x.value=new Set,b.value=new Map)},$=(R,O)=>{const ke=new Set(x.value);O?ke.add(R):ke.delete(R),x.value=ke},g=(R,O)=>{const ke=new Map(b.value);ke.set(R,O),b.value=ke},d=()=>{h.value=!1,x.value=new Set,b.value=new Map},w=F(()=>x.value.size),m=F(()=>{let R=0;for(const[O]of b.value)x.value.has(O)||R++;return R}),v=F(()=>{const R=w.value,O=m.value;return R>0&&O>0?`Delete (${R}), Update (${O})`:R>0?`Delete (${R})`:O>0?`Save changes (${O})`:"Delete"}),_=F(()=>w.value>0||m.value>0),P=async()=>{if(!s.threadId||!_.value)return;const R=[];for(const O of x.value){const ke=V.value.find(de=>de.id===O);ke&&"log_id"in ke&&ke.log_id&&R.push(ke.log_id)}try{for(const[O,ke]of b.value)x.value.has(O)||await J(O,ke);for(const O of x.value)await j(O);R.length>0&&l("logsDeleted",R)}catch(O){console.error("Error applying changes:",O)}finally{d()}},{messages:V,threadInfo:E,isFetching:z,isLoadingMore:A,error:oe,wsConnected:ne,wsError:fe,isExecuting:ye,hasMore:te,loadMoreMessages:q,deleteMessageById:j,updateMessageContent:J,stopThread:H,sendMessage:ce,attachments:Z,addAttachment:U,removeAttachment:K}=dg(F(()=>s.threadId),{}),{thread:me}=jr(F(()=>s.threadId)),ue=F(()=>Z.value.length>0),Q=F(()=>!1),G=p(null),ae=R=>{U(R)},ie=p(null),xe=p(null);n({scrollToLogId:R=>xe.value&&ie.value?xe.value.scrollToLogId(R,ie.value):!1,hasWorkblockForLogId:R=>xe.value?xe.value.hasWorkblockForLogId(R):!1}),typeof window<"u"&&(window.__testLoadMoreMessages=q);const be=p(""),B=p(null),D=p("B"),M=p(!1),T=p(!1),L=async()=>{await Fe(),ie.value&&(ie.value.scrollTop=ie.value.scrollHeight)},ee=async R=>{R.target.scrollTop<100&&te.value&&!A.value&&!T.value&&(T.value=!0,await q(),T.value=!1)};Ve(()=>V.value.length,async()=>{!A.value&&!T.value&&await L()}),Ve(()=>s.threadId,async R=>{R&&await L()}),Ve(z,async(R,O)=>{O&&!R&&await L()});const le=F(()=>{const R=E.value?.agent||me.value?.agent;if(!R)return"ai A";const O=R.type;return D.value==="A"&&R.side_a_label?R.side_a_label:D.value==="B"&&R.side_b_label?R.side_b_label:O==="ai_human"?D.value==="A"?"ai":"human":D.value==="A"?"ai A":"ai B"}),Ie=()=>{D.value=D.value==="A"?"B":"A"},Re=async()=>{const R=be.value.trim().length>0,O=ue.value;if(!R&&!O||!s.threadId||M.value||!ce)return;const ke=be.value,de=D.value==="A"?"assistant":"user";be.value="",B.value&&(B.value.style.height="auto",B.value.style.height="24px"),M.value=!0;try{await ce({role:de,content:ke}),await L()}catch(Ue){console.error("Error sending message:",Ue)}finally{M.value=!1,await Fe(),B.value&&B.value.focus()}},qe=R=>{R.key==="Enter"&&!R.shiftKey&&(R.preventDefault(),Re())},We=async()=>{if(s.threadId)try{await H()}catch(R){console.error("Error stopping thread:",R)}};return(R,O)=>(r(),o("div",Xb,[t("div",Qb,[t("div",e1,[t("div",t1,[k(I(za),{size:18,class:"shrink-0"}),O[11]||(O[11]=t("h2",{class:"text-base font-bold"},"Messages",-1)),e.threadId?(r(),Y(Dr,{key:0,connected:I(ne),error:I(fe)},null,8,["connected","error"])):S("",!0)]),t("div",r1,[e.threadId?(r(),o("button",{key:0,onClick:f,type:"button",class:pe(["p-1 hover:bg-neutral-100 dark:hover:bg-neutral-900 rounded transition-colors",[c.value?"text-accent-600 dark:text-accent-400":""]]),title:"Toggle files"},[k(I(lr),{size:20})],2)):S("",!0),e.threadId?(r(),o("button",{key:1,onClick:i,type:"button",class:pe(["p-1 hover:bg-neutral-100 dark:hover:bg-neutral-900 rounded transition-colors",[u.value?"text-accent-600 dark:text-accent-400":""]]),title:"Toggle thread info"},[k(I(ya),{size:20})],2)):S("",!0),e.threadId&&I(V).length>0?(r(),o("button",{key:2,onClick:y,type:"button",class:pe(["p-1 hover:bg-neutral-100 dark:hover:bg-neutral-900 rounded transition-colors",{"bg-neutral-200 dark:bg-neutral-800":h.value}]),title:"Edit messages"},[k(I(Rn),{size:20})],2)):S("",!0),t("button",{onClick:O[0]||(O[0]=ke=>l("collapse")),type:"button",class:"p-1 hover:bg-neutral-100 dark:hover:bg-neutral-900 rounded transition-colors",title:"Collapse pane"},[k(I(Ia),{size:20})])])])]),t("div",a1,[k(yb,{"thread-id":e.threadId,show:u.value,onClose:O[1]||(O[1]=ke=>u.value=!1),onThreadDeleted:O[2]||(O[2]=ke=>l("threadDeleted",ke)),onEditThread:O[3]||(O[3]=ke=>l("editThread")),onThreadUpdated:O[4]||(O[4]=ke=>l("threadUpdated"))},null,8,["thread-id","show"]),e.threadId?(r(),Y(Jb,{key:0,"thread-id":e.threadId,show:c.value,onClose:O[5]||(O[5]=ke=>c.value=!1)},null,8,["thread-id","show"])):S("",!0),t("div",{ref_key:"messagesContainer",ref:ie,class:"flex-1 overflow-y-auto overflow-x-hidden p-4 space-y-4",onScroll:ee},[e.threadId?S("",!0):(r(),o("div",n1," Select a thread to view messages ")),I(A)?(r(),o("div",o1,[k(Be,{size:"sm"}),O[12]||(O[12]=t("span",{class:"ml-2 text-xs text-neutral-500"},"Loading older messages...",-1))])):I(z)?(r(),o("div",l1,[k(Be)])):I(oe)?(r(),o("div",s1," Error loading messages: "+C(I(oe)),1)):e.threadId&&I(V).length===0?(r(),o("div",i1," No messages yet ")):(r(),Y(Sh,{key:5,ref_key:"agentMessagesRef",ref:xe,messages:I(V),threadId:e.threadId,selectedMessageId:e.selectedMessageId,selectedLogId:e.selectedLogId,hoveredLogId:e.hoveredLogId,isEditMode:h.value,selectedForDelete:x.value,editedMessages:b.value,onMessageClick:O[6]||(O[6]=(ke,de)=>l("messageClick",ke,de)),onMessageHover:O[7]||(O[7]=ke=>l("messageHover",ke)),onSelectionChange:$,onMessageEdit:g},null,8,["messages","threadId","selectedMessageId","selectedLogId","hoveredLogId","isEditMode","selectedForDelete","editedMessages"]))],544),e.threadId&&h.value?(r(),o("div",u1,[t("div",d1,[t("button",{onClick:d,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 "),t("button",{onClick:P,disabled:!_.value,class:pe(["px-4 py-2 rounded-lg font-medium text-sm transition-colors",{"bg-red-600 text-white hover:bg-red-700":_.value&&w.value>0,"bg-black text-white hover:bg-neutral-800 dark:bg-white dark:text-black dark:hover:bg-neutral-200":_.value&&w.value===0,"bg-neutral-200 text-neutral-400 dark:bg-neutral-700 dark:text-neutral-500 cursor-not-allowed":!_.value}])},C(v.value),11,c1)])])):e.threadId?(r(),o("div",p1,[I(Z).length>0?(r(),o("div",m1,[(r(!0),o($e,null,Le(I(Z),ke=>(r(),o("div",{key:ke.id,class:"relative group"},[ke.isImage?(r(),o("div",v1,[ke.previewUrl?(r(),o("img",{key:0,src:ke.previewUrl,alt:ke.name,class:"w-full h-full object-cover"},null,8,f1)):(r(),o("div",g1,[...O[13]||(O[13]=[t("div",{class:"w-4 h-4 border-2 border-neutral-300 border-t-neutral-600 rounded-full animate-spin"},null,-1)])]))])):(r(),o("div",h1,[t("span",{class:"text-xs text-neutral-600 dark:text-neutral-300 max-w-[80px] truncate",title:ke.name},C(ke.name),9,b1)])),t("button",{onClick:Xe(de=>I(K)(ke.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"},[...O[14]||(O[14]=[t("span",{class:"text-[10px] font-bold leading-none"},"x",-1)])],8,x1)]))),128))])):S("",!0),t("div",y1,[t("button",{onClick:Ie,class:pe(["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":D.value==="A","bg-neutral-300 text-black dark:bg-neutral-600 dark:text-white":D.value==="B"}]),title:"Toggle between sides"},C(le.value),3),t("div",k1,[k(Zb,{ref_key:"fileUploadRef",ref:G,"is-processing":!1,onFilesSelected:ae},null,512),Je(t("textarea",{ref_key:"messageTextarea",ref:B,"onUpdate:modelValue":O[8]||(O[8]=ke=>be.value=ke),onKeydown:qe,onPaste:O[9]||(O[9]=ke=>G.value?.handlePaste(ke)),disabled:M.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:O[10]||(O[10]=ke=>{const de=ke.target;de.style.height="auto",de.style.height=Math.min(de.scrollHeight,120)+"px"})},null,40,w1),[[yt,be.value]]),I(ye)?(r(),o("button",{key:1,id:"stop-thread-button",onClick:We,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"},[...O[16]||(O[16]=[t("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"},[t("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)])])):(r(),o("button",{key:0,id:"send-message-button",onClick:Re,disabled:!be.value.trim()&&!ue.value||M.value||Q.value,class:pe(["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":(be.value.trim()||ue.value)&&!M.value&&!Q.value,"bg-neutral-200 text-neutral-400 dark:bg-neutral-700 dark:text-neutral-600":!be.value.trim()&&!ue.value||M.value||Q.value}]),title:"Send message (Enter)"},[M.value?(r(),o("div",C1,[k(Be)])):(r(),o("svg",$1,[...O[15]||(O[15]=[t("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M4.5 10.5 12 3m0 0 7.5 7.5M12 3v18"},null,-1)])]))],10,_1))])])])):S("",!0)])]))}});function S1(e,n){const{limit:a=100,offset:s=0,order:l="desc",autoFetch:u=!0,enableWebSocket:i=!1}=n||{};F(()=>!!(typeof e=="string"?e:e?.value));const c=F(()=>{const K=typeof e=="string"?e:e?.value;if(!K)return ze("/api/threads/placeholder/logs");const me=new URLSearchParams,ue=typeof a=="number"?a:a.value,Q=typeof s=="number"?s:s.value,G=typeof l=="string"?l:l.value;return me.append("limit",ue.toString()),me.append("offset",Q.toString()),me.append("order",G),ze(`/api/threads/${K}/logs?${me.toString()}`)}),{data:f,error:h,isFetching:x,isFinished:b,execute:y,abort:$}=it(c,{immediate:!1}).get().json();Ve([c,()=>u],([K,me])=>{K&&!K.includes("placeholder")&&me&&y()},{immediate:!0});const g=F(()=>!h.value||h.value.toString().includes("aborted")||h.value.toString().includes("abort")?null:h.value),d=F(()=>f.value?.logs||[]),w=F(()=>f.value?.total||0),m=F(()=>f.value?.hasMore||!1),v=p(null),_=p(!1),P=p(null),V=p([]),E=new Map;let z=0,A=null,oe=null,ne=!0,fe=null;const ye=3e4,te=3e4,q=()=>{A&&(clearTimeout(A),A=null),oe&&(clearInterval(oe),oe=null)},j=()=>{oe&&clearInterval(oe),oe=setInterval(()=>{v.value&&v.value.readyState===WebSocket.OPEN&&v.value.send("ping")},te)},J=()=>{if(!ne||!i)return;const K=Math.min(1e3*Math.pow(2,z),ye);z++,console.log(`[Logs WebSocket] Scheduling reconnect in ${K}ms (attempt ${z})`),A=setTimeout(()=>{ne&&H()},K)},H=()=>{const K=typeof e=="string"?e:e?.value;if(!K||!i)return;v.value&&(fe=null,v.value.close()),z===0&&(V.value=[]);const me=window.location.protocol==="https:"?"wss:":"ws:",ue=window.location.host;let Q=`${me}//${ue}${ze(`/api/threads/${K}/logs`)}`;const G=localStorage.getItem("auth_token");G&&(Q+=`?token=${encodeURIComponent(G)}`);try{const ae=new WebSocket(Q);v.value=ae,fe=ae,ae.onopen=()=>{fe===ae&&(_.value=!0,P.value=null,z=0,j(),console.log("[Logs WebSocket] Connected"))},ae.onmessage=ie=>{if(fe===ae&&ie.data!=="pong")try{const xe=JSON.parse(ie.data);if(xe.type==="log_data"){const X=V.value.findIndex(be=>be.id===xe.log_id),he=d.value.find(be=>be.id===xe.log_id);if(X>=0){V.value[X]={...V.value[X],...xe.data};const be=E.get(xe.log_id);be&&(V.value[X].queued_tools=be,E.delete(xe.log_id))}else if(he){const be={...he,...xe.data},B=E.get(xe.log_id);B&&(be.queued_tools=B,E.delete(xe.log_id)),V.value.push(be)}else{const be={id:xe.log_id,...xe.data},B=E.get(xe.log_id);B&&(be.queued_tools=B,E.delete(xe.log_id)),V.value.push(be)}}else if(xe.type==="log_queued_tools"){const X=V.value.findIndex(be=>be.id===xe.log_id),he=d.value.find(be=>be.id===xe.log_id);X>=0?V.value[X]={...V.value[X],queued_tools:xe.queued_tools}:he?V.value.push({...he,queued_tools:xe.queued_tools}):E.set(xe.log_id,xe.queued_tools)}}catch(xe){console.error("[Logs WebSocket] Failed to parse message:",xe)}},ae.onerror=ie=>{fe===ae&&(P.value="WebSocket connection error",console.error("[Logs WebSocket] Error:",ie))},ae.onclose=()=>{fe===ae&&(_.value=!1,q(),console.log("[Logs WebSocket] Disconnected"),J())}}catch(ae){P.value=ae.message||"Failed to create WebSocket",console.error("[Logs WebSocket] Creation error:",ae),J()}},ce=()=>{ne=!1,q(),fe=null,v.value&&(v.value.close(),v.value=null),_.value=!1,z=0,V.value=[],E.clear()},Z=()=>{ne=!0,z=0,H()};return ct(()=>{ce()}),{logs:F(()=>{if(!i)return d.value;const K=new Map;d.value.forEach(Q=>K.set(Q.id,Q)),V.value.forEach(Q=>K.set(Q.id,Q));const me=typeof l=="string"?l:l.value;return Array.from(K.values()).sort((Q,G)=>me==="desc"?G.created_at-Q.created_at:Q.created_at-G.created_at)}),total:w,hasMore:m,error:g,isFetching:x,isFinished:b,refetch:y,abort:$,wsConnected:_,wsError:P,connectWebSocket:Z,disconnectWebSocket:ce}}function I1(e,n){const a=F(()=>{const c=e.value,f=n.value;return!c||!f?null:ze(`/api/threads/${c}/logs/${f}`)}),{data:s,error:l,isFetching:u,execute:i}=it(a,{immediate:!1}).get().json();return Ve([e,n],([c,f])=>{c&&f&&i()},{immediate:!0}),{logDetails:s,error:l,isFetching:u,refetch:i}}const T1=["disabled","title"],M1={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"},z1={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"},V1={key:3},on=Se({__name:"CopyButton",props:{content:{},variant:{},size:{},disabled:{type:Boolean}},setup(e){const n=e,a=p(!1),s=p(!1),l=async()=>{a.value=!0;try{await navigator.clipboard.writeText(n.content),s.value=!0,setTimeout(()=>{s.value=!1},2e3)}catch(c){console.error("Failed to copy:",c),alert(`Failed to copy: ${c instanceof Error?c.message:"Unknown error"}`)}finally{a.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(c,f)=>(r(),o("button",{onClick:l,disabled:a.value||e.disabled,class:pe([u[e.size||"sm"],i[e.variant||"solid"],"font-medium rounded hover:opacity-80 disabled:opacity-50 disabled:cursor-not-allowed transition-all"]),title:e.disabled?"No content to copy":s.value?"Copied!":"Copy to clipboard"},[a.value?(r(),Y(Be,{key:0,size:"xs"})):e.variant==="ghost"&&!s.value?(r(),o("svg",M1,[...f[0]||(f[0]=[t("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"},null,-1),t("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"},null,-1)])])):e.variant==="ghost"&&s.value?(r(),o("svg",z1,[...f[1]||(f[1]=[t("polyline",{points:"20 6 9 17 4 12"},null,-1)])])):(r(),o("span",V1,C(s.value?"Copied!":"Copy"),1))],10,T1))}}),$r="__shiki_highlighter__";let er=null;async function E1(){return typeof window<"u"&&window[$r]?window[$r]:er||(er=Zn({themes:["min-light","github-dark-high-contrast"],langs:["json","markdown"]}).then(e=>(typeof window<"u"&&(window[$r]=e),e)),er)}const L1={class:"code-block"},A1={key:0,class:"text-xs text-neutral-500 p-2"},P1=["innerHTML"],Cr=Se({__name:"CodeBlock",props:{code:{},language:{}},setup(e){const n=e,a=p(""),s=p(!0),l=async()=>{const u=n.code??"";if(!u){a.value='<pre class="shiki"><code></code></pre>',s.value=!1;return}try{const i=await E1();if(n.language==="json"||n.language==="markdown")a.value=i.codeToHtml(u,{lang:n.language,themes:{light:"min-light",dark:"github-dark-high-contrast"}});else{const c=u.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");a.value=`<pre class="shiki shiki-text"><code>${c}</code></pre>`}}catch{const c=u.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");a.value=`<pre class="shiki"><code>${c}</code></pre>`}finally{s.value=!1}};return He(()=>{l()}),Ve(()=>n.code,()=>{l()}),(u,i)=>(r(),o("div",L1,[s.value?(r(),o("div",A1,"Loading...")):(r(),o("div",{key:1,innerHTML:a.value,class:"code-content"},null,8,P1))]))}}),O1={class:"json-viewer relative bg-white dark:bg-neutral-900"},R1={key:0,class:"absolute top-[5px] right-[5px] z-10"},j1=["innerHTML"],D1=["src","alt"],U1=Se({__name:"JsonViewer",props:{json:{},threadId:{},showCopyButton:{type:Boolean}},setup(e){const n=e,a=p(null),s=p(null),l=y=>[".jpg",".jpeg",".png",".gif",".webp",".svg",".bmp"].some(g=>y.toLowerCase().endsWith(g)),u=y=>n.threadId?ze(`/api/threads/${n.threadId}/fs${y}`):null,i=F(()=>{if(!n.json)return"";if(typeof n.json=="string")try{return JSON.stringify(JSON.parse(n.json),null,2)}catch{return n.json}return JSON.stringify(n.json,null,2)}),c=y=>y.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),f=(y,$=0)=>{const g=" ".repeat($),d=w=>`<span class="json-punct">${w}</span>`;if(y===null)return'<span class="json-null">null</span>';if(typeof y=="boolean")return`<span class="json-boolean">${y}</span>`;if(typeof y=="number")return`<span class="json-number">${y}</span>`;if(typeof y=="string"){const w=c(y);return n.threadId&&l(y)&&y.startsWith("/attachments/")?`${d('"')}<span class="json-image-path" data-path="${c(y)}">${w}</span>${d('"')}`:`${d('"')}<span class="json-string">${w}</span>${d('"')}`}if(Array.isArray(y)){if(y.length===0)return`${d("[")}${d("]")}`;const w=y.map((m,v)=>{const _=v<y.length-1?d(","):"";return`${g} ${f(m,$+1)}${_}`});return`${d("[")}
38
+ ${w.join(`
39
39
  `)}
40
- ${v}${d("]")}`}if(typeof y=="object"){const b=Object.entries(y);if(b.length===0)return`${d("{")}${d("}")}`;const c=b.map(([f,$],N)=>{const E=N<b.length-1?d(","):"",L=`${d('"')}<span class="json-key">${p(f)}</span>${d('"')}`;return`${v} ${L}${d(":")} ${x($,_+1)}${E}`});return`${d("{")}
41
- ${c.join(`
40
+ ${g}${d("]")}`}if(typeof y=="object"){const w=Object.entries(y);if(w.length===0)return`${d("{")}${d("}")}`;const m=w.map(([v,_],P)=>{const V=P<w.length-1?d(","):"",E=`${d('"')}<span class="json-key">${c(v)}</span>${d('"')}`;return`${g} ${E}${d(":")} ${f(_,$+1)}${V}`});return`${d("{")}
41
+ ${m.join(`
42
42
  `)}
43
- ${v}${d("}")}`}return String(y)},k=q(()=>{if(!n.json)return'<span class="json-null">null</span>';let y;if(typeof n.json=="string")try{y=JSON.parse(n.json)}catch{return p(n.json)}else y=n.json;return x(y)}),h=y=>{const _=y.target;if(_.classList.contains("json-image-path")){const v=_.dataset.path;if(v&&n.threadId){a.value=v;const d=_.getBoundingClientRect();s.value={x:d.left,y:d.top}}}},g=y=>{y.target.classList.contains("json-image-path")&&(a.value=null,s.value=null)};return(y,_)=>(r(),o("div",y1,[t.showCopyButton?(r(),o("div",k1,[w(Ya,{content:i.value,variant:"ghost",size:"xs"},null,8,["content"])])):S("",!0),e("pre",{class:"text-xs font-mono p-3 overflow-x-auto",onMouseover:h,onMouseout:g,innerHTML:k.value},null,40,w1),(r(),J(Ht,{to:"body"},[a.value&&s.value&&t.threadId?(r(),o("div",{key:0,class:"fixed z-50 bg-white dark:bg-neutral-800 border border-neutral-300 dark:border-neutral-600 rounded-lg shadow-lg p-1 pointer-events-none",style:yt({left:`${s.value.x}px`,top:`${s.value.y-160}px`})},[e("img",{src:u(a.value),alt:a.value,class:"max-w-[200px] max-h-[150px] rounded object-contain",onError:_[0]||(_[0]=v=>v.target.style.display="none")},null,40,_1)],4)):S("",!0)]))]))}}),Qt=ct($1,[["__scopeId","data-v-fc06e7bc"]]),C1={class:"text-xs font-semibold"},S1={key:0,class:"font-normal text-neutral-500 dark:text-neutral-400"},I1={class:"flex items-center gap-2"},T1={class:"text-neutral-500 text-xs"},Yt=Ce({__name:"CollapsibleSection",props:{title:{},subtitle:{},sectionId:{},expanded:{type:Boolean},scrollContainer:{}},emits:["toggle"],setup(t,{expose:n,emit:a}){const s=t,l=a,u=m(null),i=m(!1),p=()=>{Ne(()=>{if(!u.value||!s.scrollContainer){i.value=!1;return}const h=s.scrollContainer.clientHeight;i.value=u.value.scrollHeight>h*2})};Ee(()=>s.expanded,h=>{h?p():i.value=!1});const x=()=>{if(u.value&&s.scrollContainer){const y=u.value.offsetTop-88;s.scrollContainer.scrollTo({top:Math.max(0,y),behavior:"smooth"})}},k=()=>{if(u.value&&s.scrollContainer){const h=u.value.offsetTop+u.value.offsetHeight,g=s.scrollContainer.clientHeight,y=h-g+10;s.scrollContainer.scrollTo({top:Math.max(0,y),behavior:"smooth"})}};return n({checkHeight:p,contentRef:u}),(h,g)=>(r(),o("div",null,[e("div",{class:"sticky top-[27px] z-5 w-full px-3 py-2 bg-neutral-50 dark:bg-neutral-950 flex items-center justify-between border border-neutral-300 dark:border-neutral-700 rounded cursor-pointer hover:bg-neutral-100 dark:hover:bg-neutral-950 transition-colors",onClick:g[0]||(g[0]=y=>l("toggle"))},[e("span",C1,[de(C(t.title)+" ",1),t.subtitle?(r(),o("span",S1,"("+C(t.subtitle)+")",1)):S("",!0)]),e("div",I1,[i.value&&t.expanded?(r(),o(we,{key:0},[e("button",{onClick:Ge(x,["stop"]),class:"text-[10px] text-neutral-500 hover:text-neutral-700 dark:hover:text-neutral-300"},"↑ Top"),e("button",{onClick:Ge(k,["stop"]),class:"text-[10px] text-neutral-500 hover:text-neutral-700 dark:hover:text-neutral-300"},"↓ Bottom")],64)):S("",!0),e("span",T1,C(t.expanded?"▼":"▶"),1)])]),He(e("div",{ref_key:"contentRef",ref:u,class:"border-x border-b border-neutral-300 dark:border-neutral-700 rounded-b"},[We(h.$slots,"default")],512),[[dt,t.expanded]])]))}}),M1={class:"flex items-center justify-between mb-3"},z1={class:"flex items-center gap-2"},V1={class:"flex items-center gap-1"},E1=["disabled"],L1=["disabled"],A1={class:"text-lg font-bold"},P1={class:"flex items-center gap-2"},j1=["disabled","title"],R1={key:1},O1={class:"@container border-b border-neutral-300 dark:border-neutral-700 pb-3"},D1={class:"hidden @[600px]:block"},U1={class:"w-full text-xs"},B1={class:"py-1 font-mono"},N1={class:"py-1 font-mono"},q1={key:1},F1={class:"py-1 font-mono"},H1={key:1},W1={class:"py-1 font-mono"},K1={key:1},J1={class:"py-1 font-mono"},G1={key:1},Y1={class:"py-1 font-mono text-xs"},Z1={class:"@[600px]:hidden space-y-2"},X1={class:"w-full text-xs"},Q1={class:"py-1 font-mono"},ex={class:"py-1 font-mono"},tx={key:1},rx={class:"w-full text-xs"},ax={class:"py-1 font-mono"},nx={key:1},ox={class:"py-1 font-mono"},lx={key:1},sx={class:"py-1 font-mono"},ix={key:1},ux={class:"py-1 font-mono text-xs"},dx={class:"sticky -top-4 z-10 bg-white dark:bg-neutral-900 border-b border-neutral-300 dark:border-neutral-700 mb-3 pt-3 -mx-4 px-4"},cx={class:"flex gap-4"},px={key:0,class:"text-red-600 dark:text-red-400"},mx={class:"space-y-3"},vx={class:"space-y-2"},fx={class:"flex items-center gap-1 pb-2 mb-2 border-b border-neutral-200 dark:border-neutral-700"},gx=["onClick"],hx={key:1,class:"text-xs text-red-600 dark:text-red-400 ml-2"},bx={key:0,class:"mb-2 rounded border border-amber-300 dark:border-amber-700 bg-amber-50 dark:bg-amber-950/30 p-2"},xx={class:"mt-1 text-xs text-amber-700 dark:text-amber-300"},yx=["onClick"],kx={class:"font-mono"},wx={class:"text-neutral-500"},_x={class:"px-2 py-2 bg-white dark:bg-neutral-950 border-t border-neutral-200 dark:border-neutral-800"},$x={key:0,class:"text-xs text-neutral-600 dark:text-neutral-400 mb-2"},Cx={class:"relative bg-white dark:bg-neutral-900"},Sx={class:"absolute top-[5px] right-[5px]"},Ix={key:0,class:"mb-4"},Tx={class:"text-xs font-semibold text-red-600 dark:text-red-400 mb-1"},Mx={class:"space-y-2"},zx={class:"px-2 py-1 bg-red-100 dark:bg-red-900/30 text-xs font-medium text-red-800 dark:text-red-200"},Vx={class:"text-xs bg-red-50 dark:bg-red-950 p-2 overflow-x-auto text-red-900 dark:text-red-100"},Ex={key:1,class:"mb-4"},Lx={class:"text-xs font-semibold text-red-600 dark:text-red-400 mb-1"},Ax={class:"text-xs bg-red-50 dark:bg-red-950 p-2 rounded overflow-x-auto text-red-900 dark:text-red-100 border border-red-300 dark:border-red-700"},Px={key:2,class:"mb-4"},jx={class:"w-full text-xs border border-neutral-300 dark:border-neutral-700 rounded"},Rx={class:"border-b border-neutral-200 dark:border-neutral-800"},Ox={class:"py-1 px-2 font-mono"},Dx={key:1},Ux={class:"border-b border-neutral-200 dark:border-neutral-800"},Bx={class:"py-1 px-2 font-mono"},Nx={key:1},qx={key:0,class:"border-b border-neutral-200 dark:border-neutral-800"},Fx={class:"py-1 px-2 font-mono"},Hx={key:1},Wx={class:"border-b border-neutral-200 dark:border-neutral-800"},Kx={class:"py-1 px-2 font-mono"},Jx={key:1},Gx={key:1,class:"border-b border-neutral-200 dark:border-neutral-800"},Yx={class:"py-1 px-2 font-mono text-accent-600 dark:text-accent-400"},Zx={class:"border-b border-neutral-200 dark:border-neutral-800"},Xx={class:"py-1 px-2 font-mono font-semibold"},Qx={key:1},ey={class:"py-1 px-2 font-mono font-semibold"},ty={key:1},ry={key:3,class:"mb-4"},ay={class:"text-xs font-semibold mb-1"},ny={class:"border border-neutral-300 dark:border-neutral-700 rounded overflow-hidden"},oy=["onClick"],ly={class:"flex items-center gap-2"},sy={class:"font-mono"},iy={key:0,class:"px-1.5 py-0.5 text-[10px] bg-emerald-100 dark:bg-emerald-900/40 text-emerald-700 dark:text-emerald-300 rounded font-medium border border-emerald-200 dark:border-emerald-800",title:"Programmatically called with state.queueTool()"},uy={key:1,class:"px-1.5 py-0.5 text-[10px] bg-purple-100 dark:bg-purple-900/30 text-purple-700 dark:text-purple-300 rounded font-medium"},dy={class:"text-neutral-500"},cy={key:0,class:"text-xs mb-2"},py={class:"font-mono text-xs bg-white dark:bg-black p-1 rounded border border-emerald-200 dark:border-emerald-800"},my={class:"text-xs mb-2"},vy={class:"font-mono text-xs bg-white dark:bg-black p-1 rounded border border-neutral-200 dark:border-neutral-800"},fy={class:"text-xs mb-2"},gy={class:"font-mono text-xs bg-white dark:bg-black p-1 rounded border border-neutral-200 dark:border-neutral-800"},hy={class:"text-xs mb-2"},by={class:"rounded overflow-hidden border border-neutral-200 dark:border-neutral-800 bg-white dark:bg-black"},xy={key:1,class:"text-xs"},yy={class:"text-xs overflow-x-auto bg-green-50 dark:bg-green-950/20 p-2 rounded border border-green-300 dark:border-green-700 whitespace-pre-wrap"},ky={key:2,class:"text-xs"},wy={class:"text-xs mb-2"},_y={class:"font-mono text-xs bg-white dark:bg-black p-1 rounded border border-purple-200 dark:border-purple-800"},$y={key:0,class:"text-sm mt-2"},Cy={key:0,class:"text-neutral-600 dark:text-neutral-400"},Sy={key:1,class:"text-neutral-600 dark:text-neutral-400"},Iy=["href"],Ty={key:2,class:"ml-4 mt-1 space-y-0.5"},My=["href"],zy={key:0,class:"text-xs text-neutral-500"},Vy={key:1,class:"text-sm text-neutral-600 dark:text-neutral-400 mt-2"},Ey={key:0},Ly={class:"font-mono text-xs"},Ay={key:1},Py={key:2,class:"text-sm mt-2"},jy={class:"text-xs bg-white dark:bg-black p-2 rounded border border-purple-200 dark:border-purple-800 overflow-x-auto"},Ry={key:3,class:"text-sm mt-2"},Oy={class:"font-medium text-neutral-600 dark:text-neutral-400 mb-1"},Dy={key:4,class:"mb-4"},Uy={class:"text-xs font-semibold mb-1"},By={class:"border border-emerald-300 dark:border-emerald-700 rounded overflow-hidden bg-emerald-50 dark:bg-emerald-950/20"},Ny={class:"p-2 flex flex-wrap gap-2"},qy=["src","alt"],Fy={key:1,class:"w-[100px] h-[100px] flex items-center justify-center bg-emerald-100 dark:bg-emerald-900 rounded text-xs text-emerald-600 dark:text-emerald-400"},Hy={key:5,class:"mb-4"},Wy={class:"border border-accent-300 dark:border-accent-700 rounded overflow-hidden bg-accent-50 dark:bg-accent-950/20"},Ky={class:"text-accent-600 dark:text-accent-400"},Jy={key:6,class:"mb-4"},Gy={class:"border border-purple-300 dark:border-purple-700 rounded overflow-hidden bg-purple-50 dark:bg-purple-950/20"},Yy={class:"flex items-center gap-2"},Zy={class:"px-1.5 py-0.5 text-[10px] bg-purple-200 dark:bg-purple-800 text-purple-700 dark:text-purple-300 rounded"},Xy={class:"text-purple-600 dark:text-purple-400"},Qy={class:"divide-y divide-purple-200 dark:divide-purple-800 border-t border-purple-300 dark:border-purple-700"},ek={class:"flex items-center gap-2 mb-1"},tk={class:"text-xs font-semibold text-purple-700 dark:text-purple-300"},rk={key:0,class:"text-xs font-mono text-purple-600 dark:text-purple-400"},ak={key:1,class:"text-xs text-purple-500 dark:text-purple-500"},nk={key:2,class:"text-xs text-purple-500 dark:text-purple-500"},ok={key:0,class:"text-xs bg-white dark:bg-black p-2 rounded border border-purple-200 dark:border-purple-800"},lk={class:"text-purple-900 dark:text-purple-100 whitespace-pre-wrap"},sk={key:1,class:"text-xs bg-white dark:bg-black p-2 rounded border border-purple-200 dark:border-purple-800"},ik={class:"font-mono text-purple-700 dark:text-purple-300 break-all"},uk={key:2,class:"text-xs bg-white dark:bg-black p-2 rounded border border-purple-200 dark:border-purple-800"},dk={class:"text-purple-900 dark:text-purple-100 whitespace-pre-wrap"},ck={key:0,class:"mt-2 pt-2 border-t border-purple-200 dark:border-purple-800"},pk={class:"font-mono text-purple-700 dark:text-purple-300 text-xs break-all"},mk={key:3,class:"text-xs bg-white dark:bg-black p-2 rounded border border-purple-200 dark:border-purple-800"},vk={class:"text-purple-900 dark:text-purple-100 overflow-x-auto"},fk={key:7,class:"mb-4"},gk={class:"rounded overflow-hidden border border-neutral-300 dark:border-neutral-700"},hk=Ce({__name:"LogDetails",props:{log:{},threadId:{},hasPrevious:{type:Boolean},hasNext:{type:Boolean}},emits:["close","previous","next"],setup(t,{emit:n}){const a=t,s=n,l=m("request"),u=m(new Set),i=m(new Set),p=m(!1),x=m(!1),k=m(!0),h=m(!0),g=m(null),y=m(null),_=m(null),v=m(null),d=m(null),b=m(new Set(["system_prompt","request_body","tools"])),c=O=>a.threadId?O.startsWith("data:")||O.startsWith("http")?O:Ve(`/api/threads/${a.threadId}/fs${O}`):null,f=O=>{if(!O)return"N/A";try{return JSON.stringify(JSON.parse(O),null,2)}catch{return O}},$=q(()=>{if(!a.log.tools_schema)return[];try{const O=JSON.parse(a.log.tools_schema);return Array.isArray(O)?O:[]}catch{return[]}}),N=q(()=>{if(!a.log.response_body)return[];try{const j=JSON.parse(a.log.response_body)?.choices?.[0]?.message?.tool_calls;return Array.isArray(j)?j:[]}catch{return[]}}),E=q(()=>{if(!a.log.tool_results)return new Map;try{const O=JSON.parse(a.log.tool_results),j=new Map;return Array.isArray(O)&&O.forEach(z=>{z.tool_call_id&&j.set(z.tool_call_id,{content:z.content,status:z.status,tool_name:z.tool_name,timestamp:z.timestamp})}),j}catch{return new Map}}),L=q(()=>{if(!a.log.response_body)return[];try{const j=JSON.parse(a.log.response_body)?.choices?.[0]?.message?.reasoning_details;return Array.isArray(j)?j:[]}catch{return[]}}),V=q(()=>a.log.reasoning_content?a.log.reasoning_content.replace(/\\n/g,`
43
+ ${g}${d("}")}`}return String(y)},h=F(()=>{if(!n.json)return'<span class="json-null">null</span>';let y;if(typeof n.json=="string")try{y=JSON.parse(n.json)}catch{return c(n.json)}else y=n.json;return f(y)}),x=y=>{const $=y.target;if($.classList.contains("json-image-path")){const g=$.dataset.path;if(g&&n.threadId){a.value=g;const d=$.getBoundingClientRect();s.value={x:d.left,y:d.top}}}},b=y=>{y.target.classList.contains("json-image-path")&&(a.value=null,s.value=null)};return(y,$)=>(r(),o("div",O1,[e.showCopyButton?(r(),o("div",R1,[k(on,{content:i.value,variant:"ghost",size:"xs"},null,8,["content"])])):S("",!0),t("pre",{class:"text-xs font-mono p-3 overflow-x-auto",onMouseover:x,onMouseout:b,innerHTML:h.value},null,40,j1),(r(),Y(Yt,{to:"body"},[a.value&&s.value&&e.threadId?(r(),o("div",{key:0,class:"fixed z-50 bg-white dark:bg-neutral-800 border border-neutral-300 dark:border-neutral-600 rounded-lg shadow-lg p-1 pointer-events-none",style:_t({left:`${s.value.x}px`,top:`${s.value.y-160}px`})},[t("img",{src:u(a.value),alt:a.value,class:"max-w-[200px] max-h-[150px] rounded object-contain",onError:$[0]||($[0]=g=>g.target.style.display="none")},null,40,D1)],4)):S("",!0)]))]))}}),nr=mt(U1,[["__scopeId","data-v-fc06e7bc"]]),B1={class:"text-xs font-semibold"},N1={key:0,class:"font-normal text-neutral-500 dark:text-neutral-400"},q1={class:"flex items-center gap-2"},F1={class:"text-neutral-500 text-xs"},tr=Se({__name:"CollapsibleSection",props:{title:{},subtitle:{},sectionId:{},expanded:{type:Boolean},scrollContainer:{}},emits:["toggle"],setup(e,{expose:n,emit:a}){const s=e,l=a,u=p(null),i=p(!1),c=()=>{Fe(()=>{if(!u.value||!s.scrollContainer){i.value=!1;return}const x=s.scrollContainer.clientHeight;i.value=u.value.scrollHeight>x*2})};Ve(()=>s.expanded,x=>{x?c():i.value=!1});const f=()=>{if(u.value&&s.scrollContainer){const y=u.value.offsetTop-88;s.scrollContainer.scrollTo({top:Math.max(0,y),behavior:"smooth"})}},h=()=>{if(u.value&&s.scrollContainer){const x=u.value.offsetTop+u.value.offsetHeight,b=s.scrollContainer.clientHeight,y=x-b+10;s.scrollContainer.scrollTo({top:Math.max(0,y),behavior:"smooth"})}};return n({checkHeight:c,contentRef:u}),(x,b)=>(r(),o("div",null,[t("div",{class:"sticky top-[27px] z-5 w-full px-3 py-2 bg-neutral-50 dark:bg-neutral-950 flex items-center justify-between border border-neutral-300 dark:border-neutral-700 rounded cursor-pointer hover:bg-neutral-100 dark:hover:bg-neutral-950 transition-colors",onClick:b[0]||(b[0]=y=>l("toggle"))},[t("span",B1,[ve(C(e.title)+" ",1),e.subtitle?(r(),o("span",N1,"("+C(e.subtitle)+")",1)):S("",!0)]),t("div",q1,[i.value&&e.expanded?(r(),o($e,{key:0},[t("button",{onClick:Xe(f,["stop"]),class:"text-[10px] text-neutral-500 hover:text-neutral-700 dark:hover:text-neutral-300"},"↑ Top"),t("button",{onClick:Xe(h,["stop"]),class:"text-[10px] text-neutral-500 hover:text-neutral-700 dark:hover:text-neutral-300"},"↓ Bottom")],64)):S("",!0),t("span",F1,C(e.expanded?"▼":"▶"),1)])]),Je(t("div",{ref_key:"contentRef",ref:u,class:"border-x border-b border-neutral-300 dark:border-neutral-700 rounded-b"},[Ye(x.$slots,"default")],512),[[pt,e.expanded]])]))}}),H1={class:"flex items-center justify-between mb-3"},W1={class:"flex items-center gap-2"},K1={class:"flex items-center gap-1"},J1=["disabled"],G1=["disabled"],Y1={class:"text-lg font-bold"},Z1={class:"flex items-center gap-2"},X1=["disabled","title"],Q1={key:1},ex={class:"@container border-b border-neutral-300 dark:border-neutral-700 pb-3"},tx={class:"hidden @[600px]:block"},rx={class:"w-full text-xs"},ax={class:"py-1 font-mono"},nx={class:"py-1 font-mono"},ox={key:1},lx={class:"py-1 font-mono"},sx={key:1},ix={class:"py-1 font-mono"},ux={key:1},dx={class:"py-1 font-mono"},cx={key:1},px={class:"py-1 font-mono text-xs"},mx={class:"@[600px]:hidden space-y-2"},vx={class:"w-full text-xs"},fx={class:"py-1 font-mono"},gx={class:"py-1 font-mono"},hx={key:1},bx={class:"w-full text-xs"},xx={class:"py-1 font-mono"},yx={key:1},kx={class:"py-1 font-mono"},wx={key:1},_x={class:"py-1 font-mono"},$x={key:1},Cx={class:"py-1 font-mono text-xs"},Sx={class:"sticky -top-4 z-10 bg-white dark:bg-neutral-900 border-b border-neutral-300 dark:border-neutral-700 mb-3 pt-3 -mx-4 px-4"},Ix={class:"flex gap-4"},Tx={key:0,class:"text-red-600 dark:text-red-400"},Mx={class:"space-y-3"},zx={class:"space-y-2"},Vx={class:"flex items-center gap-1 pb-2 mb-2 border-b border-neutral-200 dark:border-neutral-700"},Ex=["onClick"],Lx={key:1,class:"text-xs text-red-600 dark:text-red-400 ml-2"},Ax={key:0,class:"mb-2 rounded border border-amber-300 dark:border-amber-700 bg-amber-50 dark:bg-amber-950/30 p-2"},Px={class:"mt-1 text-xs text-amber-700 dark:text-amber-300"},Ox=["onClick"],Rx={class:"font-mono"},jx={class:"text-neutral-500"},Dx={class:"px-2 py-2 bg-white dark:bg-neutral-950 border-t border-neutral-200 dark:border-neutral-800"},Ux={key:0,class:"text-xs text-neutral-600 dark:text-neutral-400 mb-2"},Bx={class:"relative bg-white dark:bg-neutral-900"},Nx={class:"absolute top-[5px] right-[5px]"},qx={key:0,class:"mb-4"},Fx={class:"text-xs font-semibold text-red-600 dark:text-red-400 mb-1"},Hx={class:"space-y-2"},Wx={class:"px-2 py-1 bg-red-100 dark:bg-red-900/30 text-xs font-medium text-red-800 dark:text-red-200"},Kx={class:"text-xs bg-red-50 dark:bg-red-950 p-2 overflow-x-auto text-red-900 dark:text-red-100"},Jx={key:1,class:"mb-4"},Gx={class:"text-xs font-semibold text-red-600 dark:text-red-400 mb-1"},Yx={class:"text-xs bg-red-50 dark:bg-red-950 p-2 rounded overflow-x-auto text-red-900 dark:text-red-100 border border-red-300 dark:border-red-700"},Zx={key:2,class:"mb-4"},Xx={class:"w-full text-xs border border-neutral-300 dark:border-neutral-700 rounded"},Qx={class:"border-b border-neutral-200 dark:border-neutral-800"},ey={class:"py-1 px-2 font-mono"},ty={key:1},ry={class:"border-b border-neutral-200 dark:border-neutral-800"},ay={class:"py-1 px-2 font-mono"},ny={key:1},oy={key:0,class:"border-b border-neutral-200 dark:border-neutral-800"},ly={class:"py-1 px-2 font-mono"},sy={key:1},iy={class:"border-b border-neutral-200 dark:border-neutral-800"},uy={class:"py-1 px-2 font-mono"},dy={key:1},cy={key:1,class:"border-b border-neutral-200 dark:border-neutral-800"},py={class:"py-1 px-2 font-mono text-accent-600 dark:text-accent-400"},my={class:"border-b border-neutral-200 dark:border-neutral-800"},vy={class:"py-1 px-2 font-mono font-semibold"},fy={key:1},gy={class:"py-1 px-2 font-mono font-semibold"},hy={key:1},by={key:3,class:"mb-4"},xy={class:"text-xs font-semibold mb-1"},yy={class:"border border-neutral-300 dark:border-neutral-700 rounded overflow-hidden"},ky=["onClick"],wy={class:"flex items-center gap-2"},_y={class:"font-mono"},$y={key:0,class:"px-1.5 py-0.5 text-[10px] bg-emerald-100 dark:bg-emerald-900/40 text-emerald-700 dark:text-emerald-300 rounded font-medium border border-emerald-200 dark:border-emerald-800",title:"Programmatically called with state.queueTool()"},Cy={key:1,class:"px-1.5 py-0.5 text-[10px] bg-purple-100 dark:bg-purple-900/30 text-purple-700 dark:text-purple-300 rounded font-medium"},Sy={class:"text-neutral-500"},Iy={key:0,class:"text-xs mb-2"},Ty={class:"font-mono text-xs bg-white dark:bg-black p-1 rounded border border-emerald-200 dark:border-emerald-800"},My={class:"text-xs mb-2"},zy={class:"font-mono text-xs bg-white dark:bg-black p-1 rounded border border-neutral-200 dark:border-neutral-800"},Vy={class:"text-xs mb-2"},Ey={class:"font-mono text-xs bg-white dark:bg-black p-1 rounded border border-neutral-200 dark:border-neutral-800"},Ly={class:"text-xs mb-2"},Ay={class:"rounded overflow-hidden border border-neutral-200 dark:border-neutral-800 bg-white dark:bg-black"},Py={key:1,class:"text-xs"},Oy={class:"text-xs overflow-x-auto bg-green-50 dark:bg-green-950/20 p-2 rounded border border-green-300 dark:border-green-700 whitespace-pre-wrap"},Ry={key:2,class:"text-xs"},jy={class:"text-xs mb-2"},Dy={class:"font-mono text-xs bg-white dark:bg-black p-1 rounded border border-purple-200 dark:border-purple-800"},Uy={key:0,class:"text-sm mt-2"},By={key:0,class:"text-neutral-600 dark:text-neutral-400"},Ny={key:1,class:"text-neutral-600 dark:text-neutral-400"},qy=["href"],Fy={key:2,class:"ml-4 mt-1 space-y-0.5"},Hy=["href"],Wy={key:0,class:"text-xs text-neutral-500"},Ky={key:1,class:"text-sm text-neutral-600 dark:text-neutral-400 mt-2"},Jy={key:0},Gy={class:"font-mono text-xs"},Yy={key:1},Zy={key:2,class:"text-sm mt-2"},Xy={class:"text-xs bg-white dark:bg-black p-2 rounded border border-purple-200 dark:border-purple-800 overflow-x-auto"},Qy={key:3,class:"text-sm mt-2"},ek={class:"font-medium text-neutral-600 dark:text-neutral-400 mb-1"},tk={key:4,class:"mb-4"},rk={class:"text-xs font-semibold mb-1"},ak={class:"border border-emerald-300 dark:border-emerald-700 rounded overflow-hidden bg-emerald-50 dark:bg-emerald-950/20"},nk={class:"p-2 flex flex-wrap gap-2"},ok=["src","alt"],lk={key:1,class:"w-[100px] h-[100px] flex items-center justify-center bg-emerald-100 dark:bg-emerald-900 rounded text-xs text-emerald-600 dark:text-emerald-400"},sk={key:5,class:"mb-4"},ik={class:"border border-accent-300 dark:border-accent-700 rounded overflow-hidden bg-accent-50 dark:bg-accent-950/20"},uk={class:"text-accent-600 dark:text-accent-400"},dk={key:6,class:"mb-4"},ck={class:"border border-purple-300 dark:border-purple-700 rounded overflow-hidden bg-purple-50 dark:bg-purple-950/20"},pk={class:"flex items-center gap-2"},mk={class:"px-1.5 py-0.5 text-[10px] bg-purple-200 dark:bg-purple-800 text-purple-700 dark:text-purple-300 rounded"},vk={class:"text-purple-600 dark:text-purple-400"},fk={class:"divide-y divide-purple-200 dark:divide-purple-800 border-t border-purple-300 dark:border-purple-700"},gk={class:"flex items-center gap-2 mb-1"},hk={class:"text-xs font-semibold text-purple-700 dark:text-purple-300"},bk={key:0,class:"text-xs font-mono text-purple-600 dark:text-purple-400"},xk={key:1,class:"text-xs text-purple-500 dark:text-purple-500"},yk={key:2,class:"text-xs text-purple-500 dark:text-purple-500"},kk={key:0,class:"text-xs bg-white dark:bg-black p-2 rounded border border-purple-200 dark:border-purple-800"},wk={class:"text-purple-900 dark:text-purple-100 whitespace-pre-wrap"},_k={key:1,class:"text-xs bg-white dark:bg-black p-2 rounded border border-purple-200 dark:border-purple-800"},$k={class:"font-mono text-purple-700 dark:text-purple-300 break-all"},Ck={key:2,class:"text-xs bg-white dark:bg-black p-2 rounded border border-purple-200 dark:border-purple-800"},Sk={class:"text-purple-900 dark:text-purple-100 whitespace-pre-wrap"},Ik={key:0,class:"mt-2 pt-2 border-t border-purple-200 dark:border-purple-800"},Tk={class:"font-mono text-purple-700 dark:text-purple-300 text-xs break-all"},Mk={key:3,class:"text-xs bg-white dark:bg-black p-2 rounded border border-purple-200 dark:border-purple-800"},zk={class:"text-purple-900 dark:text-purple-100 overflow-x-auto"},Vk={key:7,class:"mb-4"},Ek={class:"rounded overflow-hidden border border-neutral-300 dark:border-neutral-700"},Lk=Se({__name:"LogDetails",props:{log:{},threadId:{},hasPrevious:{type:Boolean},hasNext:{type:Boolean}},emits:["close","previous","next"],setup(e,{emit:n}){const a=e,s=n,l=p("request"),u=p(new Set),i=p(new Set),c=p(!1),f=p(!1),h=p(!0),x=p(!0),b=p(null),y=p(null),$=p(null),g=p(null),d=p(null),w=p(new Set(["system_prompt","request_body","tools"])),m=B=>a.threadId?B.startsWith("data:")||B.startsWith("http")?B:ze(`/api/threads/${a.threadId}/fs${B}`):null,v=B=>{if(!B)return"N/A";try{return JSON.stringify(JSON.parse(B),null,2)}catch{return B}},_=F(()=>{if(!a.log.tools_schema)return[];try{const B=JSON.parse(a.log.tools_schema);return Array.isArray(B)?B:[]}catch{return[]}}),P=F(()=>{if(!a.log.response_body)return[];try{const D=JSON.parse(a.log.response_body)?.choices?.[0]?.message?.tool_calls;return Array.isArray(D)?D:[]}catch{return[]}}),V=F(()=>{if(!a.log.tool_results)return new Map;try{const B=JSON.parse(a.log.tool_results),D=new Map;return Array.isArray(B)&&B.forEach(M=>{M.tool_call_id&&D.set(M.tool_call_id,{content:M.content,status:M.status,tool_name:M.tool_name,timestamp:M.timestamp})}),D}catch{return new Map}}),E=F(()=>{if(!a.log.response_body)return[];try{const D=JSON.parse(a.log.response_body)?.choices?.[0]?.message?.reasoning_details;return Array.isArray(D)?D:[]}catch{return[]}}),z=F(()=>a.log.reasoning_content?a.log.reasoning_content.replace(/\\n/g,`
44
44
  `).replace(/\\t/g," ").replace(/\n{3,}/g,`
45
45
 
46
- `).trim():""),A=q(()=>{if(!a.log.response_body)return[];try{const j=JSON.parse(a.log.response_body)?.choices?.[0]?.message?.images;return Array.isArray(j)?j:[]}catch{return[]}}),G=q(()=>{if(!a.log.provider_tools)return[];try{const O=JSON.parse(a.log.provider_tools);return Array.isArray(O)?O:[]}catch{return[]}}),ee=q(()=>{if(!a.log.queued_tools)return[];try{const O=JSON.parse(a.log.queued_tools);return Array.isArray(O)?O:[]}catch{return[]}}),ie=q(()=>{const O=[];for(const j of N.value)O.push({id:j.id||`tool-${O.length}`,name:j.function?.name||"Unknown",isProvider:!1,isQueued:!1,function:j.function});for(const j of ee.value)O.push({id:j.id||`queued-${O.length}`,name:j.function?.name||"Unknown",isProvider:!1,isQueued:!0,function:j.function,queuedAt:j.queued_at});for(const j of G.value)O.push({id:j.id,name:j.type,isProvider:!0,isQueued:!1,providerType:j.type,status:j.status,result:j.result});return O}),be=O=>{u.value.has(O)?u.value.delete(O):u.value.add(O)},Q=O=>{i.value.has(O)?i.value.delete(O):i.value.add(O)},U=()=>{k.value=!k.value},R=()=>{h.value=!h.value},K=O=>{b.value.has(O)?b.value.delete(O):b.value.add(O)},H=O=>!b.value.has(O),ve=q(()=>{if(!a.log.errors)return[];try{const O=JSON.parse(a.log.errors);return Array.isArray(O)?O:[]}catch{return[]}}),X=m("standard"),D=m(null),W=m(!1),me=m(null),ue=["cerebras","openai","openrouter"],te=()=>(a.log.actual_provider||a.log.provider)?.toLowerCase(),Y=()=>{const O=te();O&&ue.includes(O)?X.value=O:X.value="standard"},ae=O=>O.charAt(0).toUpperCase()+O.slice(1);Ee(X,async O=>{if(O==="standard"){D.value=null,me.value=null;return}if(!a.threadId||!a.log.id){me.value="Missing thread or log ID";return}W.value=!0,me.value=null;try{const j=await fetch(Ve(`/api/threads/${a.threadId}/logs/${a.log.id}/inspect/${O}`));if(!j.ok){const z=await j.json();throw new Error(z.error||"Failed to inspect")}D.value=await j.json()}catch(j){me.value=j.message||"Failed to fetch inspected request",D.value=null}finally{W.value=!1}}),Ee(()=>a.log.id,async()=>{if(D.value=null,me.value=null,Y(),X.value!=="standard"&&a.threadId&&a.log.id){W.value=!0;try{const O=await fetch(Ve(`/api/threads/${a.threadId}/logs/${a.log.id}/inspect/${X.value}`));if(!O.ok){const j=await O.json();throw new Error(j.error||"Failed to fetch inspected request")}D.value=await O.json()}catch(O){me.value=O.message||"Failed to fetch inspected request"}finally{W.value=!1}}},{immediate:!0});const ye=q(()=>{if(X.value==="standard"||!D.value)return a.log.message_history;const O=D.value.messagesPath,j=O?D.value.body?.[O]:D.value.body;return JSON.stringify(j,null,2)}),Te=q(()=>X.value==="standard"||!D.value?a.log.request_body:JSON.stringify(D.value.body,null,2)),ne=q(()=>X.value==="standard"||!D.value?null:`${X.value} format`),ke=q(()=>{if(!a.log.request_body)return null;try{const j=JSON.parse(a.log.request_body)?._metadata?.visionFiltering;if(!j||j.enabled!==!0)return null;const z=Number(j.removedUserImageParts||0),M=Number(j.removedToolImageAttachments||0);return{removedUserImageParts:z,removedToolImageAttachments:M,totalRemoved:z+M}}catch{return null}});Ee(()=>a.log,()=>{Ne(()=>{y.value?.checkHeight(),_.value?.checkHeight(),v.value?.checkHeight(),d.value?.checkHeight()})});const _e=async()=>{p.value=!0;try{if(!a.log.request_body||!a.log.model)throw new Error("Missing request data");const O=await fetch(Ve(`/api/models/${encodeURIComponent(a.log.model)}/curl-data`));if(!O.ok)throw new Error("Failed to fetch model data");const j=await O.json(),z=f(a.log.request_body);let M=`curl -X POST '${j.endpoint}' \\
47
- `;M+=` -H 'Content-Type: application/json' \\
48
- `,j.sdk?.toLowerCase()==="openrouter"?(M+=` -H 'Authorization: Bearer ${j.api_key}' \\
49
- `,M+=` -H 'HTTP-Referer: https://agentkit.local' \\
50
- `,M+=` -H 'X-Title: AgentKit' \\
51
- `):(j.sdk?.toLowerCase()==="openai"||j.sdk?.toLowerCase()==="cerebras")&&(M+=` -H 'Authorization: Bearer ${j.api_key}' \\
52
- `),M+=` -d '${z.replace(/'/g,"'\\''")}'`,await navigator.clipboard.writeText(M),x.value=!0,setTimeout(()=>{x.value=!1},2e3)}catch(O){console.error("Failed to copy cURL command:",O),alert(`Failed to copy cURL: ${O instanceof Error?O.message:"Unknown error"}`)}finally{p.value=!1}};return(O,j)=>(r(),o("div",{ref_key:"scrollContainer",ref:g,class:"p-4 h-full overflow-y-auto"},[e("div",M1,[e("div",z1,[e("div",V1,[e("button",{onClick:j[0]||(j[0]=z=>s("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"},[...j[10]||(j[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:"15 18 9 12 15 6"})],-1)])],8,E1),e("button",{onClick:j[1]||(j[1]=z=>s("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"},[...j[11]||(j[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("polyline",{points:"9 18 15 12 9 6"})],-1)])],8,L1)]),e("h3",A1,C(t.log.prompt_name||t.log.model_name||t.log.model),1)]),e("div",P1,[e("button",{onClick:_e,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?(r(),J(Be,{key:0,size:"xs"})):(r(),o("span",R1,C(x.value?"Copied!":"Copy cURL"),1))],8,j1),e("button",{onClick:j[2]||(j[2]=z=>s("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"},[...j[12]||(j[12]=[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",O1,[e("div",D1,[e("table",U1,[j[13]||(j[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 "),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:ce(["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",B1,C(t.log.actual_provider||t.log.provider),1),e("td",N1,[!t.log.is_complete&&!t.log.prompt_name?(r(),J(Be,{key:0,size:"xs"})):(r(),o("span",q1,C(t.log.prompt_name||"—"),1))]),e("td",F1,[!t.log.is_complete&&!t.log.latency_ms?(r(),J(Be,{key:0,size:"xs"})):(r(),o("span",H1,C(t.log.latency_ms?`${t.log.latency_ms}ms`:"—"),1))]),e("td",W1,[!t.log.is_complete&&!t.log.total_tokens?(r(),J(Be,{key:0,size:"xs"})):(r(),o("span",K1,C(t.log.total_tokens?`${t.log.input_tokens}/${t.log.output_tokens} (${t.log.total_tokens})`:"—"),1))]),e("td",J1,[!t.log.is_complete&&!t.log.cost_total?(r(),J(Be,{key:0,size:"xs"})):(r(),o("span",G1,C(t.log.cost_total?`$${t.log.cost_total.toFixed(6)}`:"—"),1))]),e("td",Y1,[w(Nt,{timestamp:t.log.created_at},null,8,["timestamp"])])])])])]),e("div",Z1,[e("table",X1,[j[14]||(j[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"}," 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:ce(["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",Q1,C(t.log.actual_provider||t.log.provider),1),e("td",ex,[!t.log.is_complete&&!t.log.prompt_name?(r(),J(Be,{key:0,size:"xs"})):(r(),o("span",tx,C(t.log.prompt_name||"—"),1))])])])]),e("table",rx,[j[15]||(j[15]=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",ax,[!t.log.is_complete&&!t.log.latency_ms?(r(),J(Be,{key:0,size:"xs"})):(r(),o("span",nx,C(t.log.latency_ms?`${t.log.latency_ms}ms`:"—"),1))]),e("td",ox,[!t.log.is_complete&&!t.log.total_tokens?(r(),J(Be,{key:0,size:"xs"})):(r(),o("span",lx,C(t.log.total_tokens?`${t.log.input_tokens}/${t.log.output_tokens} (${t.log.total_tokens})`:"—"),1))]),e("td",sx,[!t.log.is_complete&&!t.log.cost_total?(r(),J(Be,{key:0,size:"xs"})):(r(),o("span",ix,C(t.log.cost_total?`$${t.log.cost_total.toFixed(6)}`:"—"),1))]),e("td",ux,[w(Nt,{timestamp:t.log.created_at},null,8,["timestamp"])])])])])])]),e("div",dx,[e("div",cx,[e("button",{onClick:j[3]||(j[3]=z=>l.value="request"),class:ce(["pb-2 px-1 text-sm font-medium border-b-2 transition-colors",l.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:j[4]||(j[4]=z=>l.value="response"),class:ce(["pb-2 px-1 text-sm font-medium border-b-2 transition-colors flex items-center gap-1",l.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"])},[j[16]||(j[16]=de(" Response ",-1)),t.log.error||ve.value.length>0?(r(),o("span",px,"⚠")):S("",!0)],2)])]),e("div",mx,[He(e("div",vx,[e("div",fx,[j[17]||(j[17]=e("span",{class:"text-xs text-neutral-500 dark:text-neutral-400 mr-2"},"View as:",-1)),e("button",{onClick:j[5]||(j[5]=z=>X.value="standard"),class:ce(["px-2 py-1 text-xs rounded transition-colors",X.value==="standard"?"bg-black text-white dark:bg-white dark:text-black":"bg-neutral-100 dark:bg-neutral-800 text-neutral-600 dark:text-neutral-400 hover:bg-neutral-200 dark:hover:bg-neutral-700"])}," Standard Agents ",2),(r(),o(we,null,Ae(ue,z=>e("button",{key:z,onClick:M=>X.value=z,class:ce(["px-2 py-1 text-xs rounded transition-colors",X.value===z?"bg-black text-white dark:bg-white dark:text-black":"bg-neutral-100 dark:bg-neutral-800 text-neutral-600 dark:text-neutral-400 hover:bg-neutral-200 dark:hover:bg-neutral-700"])},C(ae(z)),11,gx)),64)),W.value?(r(),J(Be,{key:0,size:"xs",class:"ml-2"})):S("",!0),me.value?(r(),o("span",hx,C(me.value),1)):S("",!0)]),ke.value?(r(),o("div",bx,[j[20]||(j[20]=e("div",{class:"text-xs font-semibold text-amber-800 dark:text-amber-200"}," Vision Input Filtered For This Request ",-1)),e("div",xx,[j[18]||(j[18]=de(" This model does not support image input. ",-1)),ke.value.totalRemoved>0?(r(),o(we,{key:0},[de(" Removed "+C(ke.value.removedUserImageParts)+" user image part(s) and "+C(ke.value.removedToolImageAttachments)+" tool image attachment(s) before sending the request. ",1)],64)):(r(),o(we,{key:1},[de(" No image parts were present on this request. ")],64)),j[19]||(j[19]=de(" Stored thread messages remain unchanged. ",-1))])])):S("",!0),$.value.length>0?(r(),J(Yt,{key:1,ref_key:"toolsSectionRef",ref:y,title:`Available Tools (${$.value.length})`,"section-id":"tools",expanded:H("tools"),"scroll-container":g.value,onToggle:j[6]||(j[6]=z=>K("tools"))},{default:F(()=>[(r(!0),o(we,null,Ae($.value,(z,M)=>(r(),o("div",{key:M,class:"border-b border-neutral-200 dark:border-neutral-800 last:border-b-0"},[e("button",{onClick:P=>be(M),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",kx,C(z.function?.name||z.name||"Unknown"),1),e("span",wx,C(u.value.has(M)?"▼":"▶"),1)],8,yx),He(e("div",_x,[z.function?.description||z.description?(r(),o("div",$x,C(z.function?.description||z.description),1)):S("",!0),w(yr,{code:JSON.stringify(z,null,2),language:"json"},null,8,["code"])],512),[[dt,u.value.has(M)]])]))),128))]),_:1},8,["title","expanded","scroll-container"])):S("",!0),t.log.message_history?(r(),J(Yt,{key:2,ref_key:"messagesSectionRef",ref:_,title:`Messages (${t.log.message_history_length||0} messages)`,subtitle:ne.value,"section-id":"messages",expanded:H("messages"),"scroll-container":g.value,onToggle:j[7]||(j[7]=z=>K("messages"))},{default:F(()=>[w(Qt,{json:ye.value,"thread-id":t.threadId,"show-copy-button":""},null,8,["json","thread-id"])]),_:1},8,["title","subtitle","expanded","scroll-container"])):S("",!0),t.log.system_prompt?(r(),J(Yt,{key:3,ref_key:"systemPromptSectionRef",ref:v,title:"System Prompt","section-id":"system_prompt",expanded:H("system_prompt"),"scroll-container":g.value,onToggle:j[8]||(j[8]=z=>K("system_prompt"))},{default:F(()=>[e("div",Cx,[w(yr,{code:t.log.system_prompt,language:"markdown"},null,8,["code"]),e("div",Sx,[w(Ya,{content:t.log.system_prompt,variant:"ghost",size:"xs"},null,8,["content"])])])]),_:1},8,["expanded","scroll-container"])):S("",!0),t.log.request_body?(r(),J(Yt,{key:4,ref_key:"requestBodySectionRef",ref:d,title:"Full Request Body",subtitle:ne.value,"section-id":"request_body",expanded:H("request_body"),"scroll-container":g.value,onToggle:j[9]||(j[9]=z=>K("request_body"))},{default:F(()=>[w(Qt,{json:Te.value,"thread-id":t.threadId,"show-copy-button":""},null,8,["json","thread-id"])]),_:1},8,["subtitle","expanded","scroll-container"])):S("",!0)],512),[[dt,l.value==="request"]]),He(e("div",null,[ve.value.length>0?(r(),o("div",Ix,[e("div",Tx,C(ve.value.length>1?`Errors (${ve.value.length})`:"Error"),1),e("div",Mx,[(r(!0),o(we,null,Ae(ve.value,(z,M)=>(r(),o("div",{key:M,class:"border border-red-300 dark:border-red-700 rounded overflow-hidden"},[e("div",zx,C(z.type||"error"),1),e("pre",Vx,C(z.message),1)]))),128))])])):t.log.error?(r(),o("div",Ex,[e("div",Lx," Error "+C(t.log.error_type?`(${t.log.error_type})`:""),1),e("pre",Ax,C(t.log.error),1)])):S("",!0),t.log.is_complete||!t.log.error?(r(),o("div",Px,[j[28]||(j[28]=e("div",{class:"text-xs font-semibold mb-1"},"Response Stats",-1)),e("table",jx,[e("tbody",null,[e("tr",Rx,[j[21]||(j[21]=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",Ox,[!t.log.is_complete&&!t.log.finish_reason?(r(),J(Be,{key:0,size:"xs"})):(r(),o("span",Dx,C(t.log.finish_reason||"—"),1))])]),e("tr",Ux,[j[22]||(j[22]=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",Bx,[!t.log.is_complete&&!t.log.input_tokens?(r(),J(Be,{key:0,size:"xs"})):(r(),o("span",Nx,C(t.log.input_tokens||"—"),1))])]),t.log.cached_tokens||!t.log.is_complete?(r(),o("tr",qx,[j[23]||(j[23]=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",Fx,[!t.log.is_complete&&!t.log.cached_tokens?(r(),J(Be,{key:0,size:"xs"})):(r(),o("span",Hx,C(t.log.cached_tokens||0),1))])])):S("",!0),e("tr",Wx,[j[24]||(j[24]=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",Kx,[!t.log.is_complete&&!t.log.output_tokens?(r(),J(Be,{key:0,size:"xs"})):(r(),o("span",Jx,C(t.log.output_tokens||"—"),1))])]),t.log.reasoning_tokens&&t.log.reasoning_tokens>0?(r(),o("tr",Gx,[j[25]||(j[25]=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",Yx,C(t.log.reasoning_tokens),1)])):S("",!0),e("tr",Zx,[j[26]||(j[26]=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",Xx,[!t.log.is_complete&&!t.log.total_tokens?(r(),J(Be,{key:0,size:"xs"})):(r(),o("span",Qx,C(t.log.total_tokens||"—"),1))])]),e("tr",null,[j[27]||(j[27]=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",ey,[!t.log.is_complete&&!t.log.cost_total?(r(),J(Be,{key:0,size:"xs"})):(r(),o("span",ty,C(t.log.cost_total?`$${t.log.cost_total.toFixed(6)}`:"—"),1))])])])])])):S("",!0),ie.value.length>0?(r(),o("div",ry,[e("div",ay," Tools Called ("+C(ie.value.length)+") ",1),e("div",ny,[(r(!0),o(we,null,Ae(ie.value,z=>(r(),o("div",{key:z.id,class:"border-b border-neutral-200 dark:border-neutral-800 last:border-b-0"},[e("button",{onClick:M=>Q(z.id),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("div",ly,[e("span",sy,C(z.name),1),z.isQueued?(r(),o("span",iy," programmatically invoked ")):S("",!0),z.isProvider?(r(),o("span",uy," provider ")):S("",!0),z.isProvider&&z.status?(r(),o("span",{key:2,class:ce([z.status==="completed"?"text-green-600 dark:text-green-400":z.status==="failed"?"text-red-600 dark:text-red-400":"text-yellow-600 dark:text-yellow-400","text-[10px]"])},C(z.status),3)):S("",!0)]),e("span",dy,C(i.value.has(z.id)?"▼":"▶"),1)],8,oy),He(e("div",{class:ce(["px-2 py-2 border-t border-neutral-200 dark:border-neutral-800",z.isProvider?"bg-purple-50 dark:bg-purple-900/10":z.isQueued?"bg-emerald-50 dark:bg-emerald-900/10":"bg-white dark:bg-neutral-950"])},[z.isProvider?(r(),o(we,{key:1},[e("div",wy,[j[35]||(j[35]=e("div",{class:"font-semibold text-purple-600 dark:text-purple-400 mb-1"}," Provider Tool ID ",-1)),e("div",_y,C(z.id),1)]),z.providerType==="web_search"&&z.result?.actions?(r(),o("div",$y,[(r(!0),o(we,null,Ae(z.result.actions,(M,P)=>(r(),o("div",{key:P,class:"mb-2"},[M.type==="search"?(r(),o("div",Cy,[j[36]||(j[36]=e("span",{class:"font-medium"},"Searched:",-1)),de(' "'+C(M.query)+'" ',1)])):S("",!0),M.type==="open"?(r(),o("div",Sy,[j[37]||(j[37]=e("span",{class:"font-medium"},"Opened:",-1)),e("a",{href:M.url,target:"_blank",class:"text-blue-600 hover:underline ml-1"},C(M.url),9,Iy)])):S("",!0),M.sources?.length?(r(),o("div",Ty,[(r(!0),o(we,null,Ae(M.sources.slice(0,5),(re,se)=>(r(),o("a",{key:se,href:re.url,target:"_blank",class:"block text-blue-600 hover:underline text-xs truncate"},C(re.title||re.url),9,My))),128)),M.sources.length>5?(r(),o("span",zy," ... and "+C(M.sources.length-5)+" more ",1)):S("",!0)])):S("",!0)]))),128))])):S("",!0),z.providerType==="image_generation"?(r(),o("div",Vy,[z.result?.imagePath?(r(),o("span",Ey,[j[38]||(j[38]=de(" Stored at: ",-1)),e("span",Ly,C(z.result.imagePath),1)])):(r(),o("span",Ay," See Generated Images section below "))])):S("",!0),z.providerType==="code_interpreter"&&z.result?.output?(r(),o("div",Py,[j[39]||(j[39]=e("div",{class:"font-medium text-neutral-600 dark:text-neutral-400 mb-1"},"Output:",-1)),e("pre",jy,C(z.result.output),1)])):S("",!0),z.providerType==="file_search"&&z.result?.results?.length?(r(),o("div",Ry,[e("div",Oy," Found "+C(z.result.results.length)+" result(s) ",1)])):S("",!0)],64)):(r(),o(we,{key:0},[z.isQueued&&z.queuedAt?(r(),o("div",cy,[j[29]||(j[29]=e("div",{class:"font-semibold text-emerald-600 dark:text-emerald-400 mb-1"}," Invoked At ",-1)),e("div",py,[w(Nt,{timestamp:z.queuedAt},null,8,["timestamp"])])])):S("",!0),e("div",my,[j[30]||(j[30]=e("div",{class:"font-semibold text-neutral-600 dark:text-neutral-400 mb-1"}," Tool Call ID ",-1)),e("div",vy,C(z.id),1)]),e("div",fy,[j[31]||(j[31]=e("div",{class:"font-semibold text-neutral-600 dark:text-neutral-400 mb-1"}," Function Name ",-1)),e("div",gy,C(z.function?.name),1)]),e("div",hy,[j[32]||(j[32]=e("div",{class:"font-semibold text-neutral-600 dark:text-neutral-400 mb-1"}," Arguments ",-1)),e("div",by,[w(yr,{code:f(z.function?.arguments||"{}"),language:"json"},null,8,["code"])])]),E.value.has(z.id)?(r(),o("div",xy,[j[33]||(j[33]=e("div",{class:"font-semibold text-green-600 dark:text-green-400 mb-1"}," Result ",-1)),e("pre",yy,C(E.value.get(z.id)?.content||"No content"),1)])):(r(),o("div",ky,[...j[34]||(j[34]=[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)])]))],64))],2),[[dt,i.value.has(z.id)]])]))),128))])])):S("",!0),A.value.length>0?(r(),o("div",Dy,[e("div",Uy," Generated Images ("+C(A.value.length)+") ",1),e("div",By,[j[40]||(j[40]=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",Ny,[(r(!0),o(we,null,Ae(A.value,(z,M)=>(r(),o("div",{key:M,class:"relative"},[z.image_url?.url?(r(),o("img",{key:0,src:c(z.image_url.url)||z.image_url.url,alt:`Generated image ${M+1}`,class:"max-w-[300px] max-h-[300px] rounded border border-emerald-200 dark:border-emerald-800 object-contain"},null,8,qy)):(r(),o("div",Fy," No URL "))]))),128))])])])):S("",!0),t.log.reasoning_content?(r(),o("div",Hy,[e("div",Wy,[e("button",{onClick:U,class:"w-full px-2 py-1.5 bg-accent-100 dark:bg-accent-900/30 text-xs text-accent-800 dark:text-accent-200 flex items-center justify-between hover:bg-accent-200 dark:hover:bg-accent-900/50 transition-colors"},[j[41]||(j[41]=e("div",{class:"flex items-center gap-2"},[e("span",{class:"font-semibold"},"Reasoning Content"),e("span",{class:"text-accent-600 dark:text-accent-400 font-normal"}," Internal reasoning output (not displayed to users) ")],-1)),e("span",Ky,C(k.value?"▶":"▼"),1)]),He(e("pre",{class:"text-xs p-2 overflow-x-auto whitespace-pre-wrap max-h-96 text-accent-900 dark:text-accent-100 border-t border-accent-300 dark:border-accent-700"},C(V.value),513),[[dt,!k.value]])])])):S("",!0),L.value.length>0?(r(),o("div",Jy,[e("div",Gy,[e("button",{onClick:R,class:"w-full px-2 py-1.5 bg-purple-100 dark:bg-purple-900/30 text-xs text-purple-800 dark:text-purple-200 flex items-center justify-between hover:bg-purple-200 dark:hover:bg-purple-900/50 transition-colors"},[e("div",Yy,[j[42]||(j[42]=e("span",{class:"font-semibold"},"Reasoning Details",-1)),e("span",Zy,C(L.value.length)+" blocks ",1),j[43]||(j[43]=e("span",{class:"text-purple-600 dark:text-purple-400 font-normal"}," Structured reasoning from OpenRouter ",-1))]),e("span",Xy,C(h.value?"▶":"▼"),1)]),He(e("div",Qy,[(r(!0),o(we,null,Ae(L.value,(z,M)=>(r(),o("div",{key:M,class:"p-2"},[e("div",ek,[e("span",tk,C(z.type||"unknown"),1),z.id?(r(),o("span",rk," ID: "+C(z.id),1)):S("",!0),z.format?(r(),o("span",ak," Format: "+C(z.format),1)):S("",!0),z.index!==void 0?(r(),o("span",nk," Index: "+C(z.index),1)):S("",!0)]),z.type==="reasoning.summary"&&z.summary?(r(),o("div",ok,[j[44]||(j[44]=e("div",{class:"font-semibold text-purple-600 dark:text-purple-400 mb-1"}," Summary: ",-1)),e("div",lk,C(z.summary),1)])):S("",!0),z.type==="reasoning.encrypted"&&z.data?(r(),o("div",sk,[j[45]||(j[45]=e("div",{class:"font-semibold text-purple-600 dark:text-purple-400 mb-1"}," Encrypted Data: ",-1)),e("div",ik,C(z.data),1)])):S("",!0),z.type==="reasoning.text"&&z.text?(r(),o("div",uk,[j[47]||(j[47]=e("div",{class:"font-semibold text-purple-600 dark:text-purple-400 mb-1"}," Reasoning Text: ",-1)),e("div",dk,C(z.text),1),z.signature?(r(),o("div",ck,[j[46]||(j[46]=e("div",{class:"font-semibold text-purple-600 dark:text-purple-400 mb-1"}," Signature: ",-1)),e("div",pk,C(z.signature),1)])):S("",!0)])):S("",!0),["reasoning.summary","reasoning.encrypted","reasoning.text"].includes(z.type)?S("",!0):(r(),o("div",mk,[e("pre",vk,C(JSON.stringify(z,null,2)),1)]))]))),128))],512),[[dt,!h.value]])])])):S("",!0),t.log.response_body?(r(),o("div",fk,[j[48]||(j[48]=e("div",{class:"text-xs font-semibold mb-1"},"Full Response Body",-1)),e("div",gk,[w(Qt,{json:t.log.response_body,"thread-id":t.threadId,"show-copy-button":""},null,8,["json","thread-id"])])])):S("",!0)],512),[[dt,l.value==="response"]])])],512))}}),bk={class:"flex flex-col h-full"},xk={class:"px-4 py-3 border-b border-neutral-300 dark:border-neutral-700"},yk={class:"flex items-center justify-between"},kk={class:"flex items-center gap-2"},wk={key:0,class:"text-neutral-500 dark:text-neutral-400 text-center py-12"},_k={key:1,class:"flex justify-center py-12"},$k={key:2,class:"text-red-600 dark:text-red-400 text-center py-12"},Ck={key:3,class:"text-neutral-500 dark:text-neutral-400 text-center py-12"},Sk={key:4},Ik={key:0,class:"border-b border-neutral-300 dark:border-neutral-700 bg-white dark:bg-black sticky top-0 z-10"},Tk=["disabled"],Mk={key:1},zk={key:2},Vk={key:3},Ek={class:"w-full text-sm"},Lk=["onClick","onMouseenter"],Ak={class:"px-3 py-2 text-xs"},Pk={class:"flex items-center gap-1"},jk={key:0,class:"text-neutral-400 dark:text-neutral-600 mr-1"},Rk={key:3},Ok={class:"px-3 py-2"},Dk={class:"flex items-center gap-2"},Uk={key:0,class:"text-red-600 dark:text-red-400",title:"Error"},Bk={class:"font-mono text-xs"},Nk={class:"px-3 py-2 font-mono text-xs"},qk={key:1},Fk={key:1,class:"text-neutral-400"},Hk={key:2},Wk={key:0,class:"text-emerald-600 dark:text-emerald-400",title:"Programmatically called with state.queueTool()"},Kk={key:1},Jk={key:2},Gk={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"},Yk={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"},Zk={key:0,class:"flex flex-col items-center justify-center h-full gap-3 text-neutral-500 dark:text-neutral-400"},Xk={key:2,class:"absolute inset-0 bg-white/50 dark:bg-black/50 flex items-center justify-center"},Qr=20,Qk=20,e2=Ce({__name:"LogsPane",props:{threadId:{},selectedLogId:{},hoveredLogId:{}},emits:["logClick","logHover","logsLoaded"],setup(t,{expose:n,emit:a}){const s=t,l=a,u=m(0),i=m(Qr),{logs:p,hasMore:x,isFetching:k,error:h,wsConnected:g,wsError:y,connectWebSocket:_,disconnectWebSocket:v,refetch:d}=d1(q(()=>s.threadId),{limit:q(()=>i.value),offset:q(()=>u.value),enableWebSocket:!0,order:"desc"}),b=m([]),c=m(!0),f=m(null),$=m(null),N=m(!1),E=m(!1),L=m(new Map),V=async()=>{await Ne(),$.value&&($.value.scrollTop=$.value.scrollHeight)},A=m(null);Ee(p,async M=>{if(u.value===0)b.value=[...M].reverse(),c.value&&b.value.length>0&&(await V(),c.value=!1);else{const P=[...M].reverse(),re=new Map;b.value.forEach(se=>re.set(se.id,se)),P.forEach(se=>re.set(se.id,se)),b.value=Array.from(re.values()).sort((se,Ie)=>se.created_at-Ie.created_at)}},{deep:!0,immediate:!0}),Ee(k,(M,P)=>{if(P&&!M&&u.value===0&&s.threadId&&A.value!==s.threadId&&b.value.length>0){A.value=s.threadId;const re=b.value[b.value.length-1];l("logsLoaded",re?.id??null)}});const{logDetails:G,isFetching:ee}=c1(q(()=>s.threadId),q(()=>f.value)),ie=q(()=>{if(!f.value)return null;const P=b.value.find(re=>re.id===f.value);return P?G.value?{...G.value,...P}:P:null}),be=q(()=>f.value?z.value.findIndex(M=>M.id===f.value):-1),Q=q(()=>be.value>0),U=q(()=>be.value>=0&&be.value<z.value.length-1),R=()=>{if(Q.value){const M=z.value[be.value-1];ve(M)}},K=()=>{if(U.value){const M=z.value[be.value+1];ve(M)}},H=M=>{if(!$.value)return;const P=L.value.get(M);if(!P)return;const re=$.value,se=P.getBoundingClientRect(),Ie=re.getBoundingClientRect(),he=re.querySelectorAll(".sticky");let ge=0;he.forEach(oe=>{ge+=oe.getBoundingClientRect().height}),ge+=16;const Oe=se.top<Ie.top+ge,Z=se.bottom>Ie.bottom;Oe?re.scrollBy({top:se.top-Ie.top-ge,behavior:"smooth"}):Z&&re.scrollBy({top:se.bottom-Ie.bottom,behavior:"smooth"})},ve=M=>{l("logClick",M.id),f.value=M.id},X=(M,P)=>{P?L.value.set(M,P):L.value.delete(M)};Ee(f,async M=>{M&&(await Ne(),H(M))}),Ee(()=>s.selectedLogId,M=>{M&&(f.value=M)},{immediate:!0});const D=M=>{f.value=M},W=async M=>{await Ne();const P=L.value.get(M);if(P&&$.value){const re=$.value,se=P.getBoundingClientRect(),Ie=re.getBoundingClientRect(),he=re.querySelector("thead"),ge=re.querySelector(":scope > div > div.sticky");let Oe=0;he&&(Oe+=he.getBoundingClientRect().height),ge&&(Oe+=ge.getBoundingClientRect().height),Oe+=40;const Z=se.top<Ie.top+Oe,oe=se.bottom>Ie.bottom;Z?re.scrollBy({top:se.top-Ie.top-Oe,behavior:"smooth"}):oe&&re.scrollBy({top:se.bottom-Ie.bottom,behavior:"smooth"})}},me=M=>{if(M.length===0)return;const P=new Set(M);b.value=b.value.filter(re=>!P.has(re.id))},ue=m(!1),te=M=>b.value.some(P=>P.id===M),Y=M=>b.value.find(P=>P.id===M)??null,ae=(M,P=3e3)=>new Promise(re=>{const se=Date.now(),Ie=Ee(b,()=>{b.value.length!==M&&(Ie(),re(!0))},{deep:!0}),he=setInterval(()=>{b.value.length!==M?(clearInterval(he),Ie(),re(!0)):Date.now()-se>P&&(clearInterval(he),Ie(),re(!1))},50)});n({scrollToLog:W,selectLogById:D,removeLogsByIds:me,loadUntilLogId:async M=>{if(te(M))return!0;if(!x.value)return!1;ue.value=!0;const P=100,re=50;try{let se=0;for(;x.value&&!te(M)&&se<re;){se++;const Ie=b.value.length;if(u.value+=i.value,i.value=P,await d(),!await ae(Ie))break}return te(M)}finally{ue.value=!1}},hasLog:te,getLog:Y,setLoadingForLog:M=>{ue.value=M},waitForLogRow:async(M,P=2e3)=>{const re=Date.now();for(;Date.now()-re<P;){if(L.value.has(M))return!0;if(!z.value.some(Ie=>Ie.id===M)){await Ne(),await new Promise(Ie=>setTimeout(Ie,16));continue}await Ne(),await new Promise(Ie=>setTimeout(Ie,16))}return!1}});const ke=async()=>{if(E.value||!x.value||k.value)return;E.value=!0;const M=$.value?.scrollHeight||0;if(u.value+=i.value,i.value=Qk,await d(),await Ne(),$.value){const P=$.value.scrollHeight;$.value.scrollTop+=P-M}E.value=!1};Ee(()=>s.threadId,async M=>{M?(v(),_()):v(),u.value=0,i.value=Qr,b.value=[],f.value=null,N.value=!1,c.value=!0},{immediate:!0}),Ee(b,async()=>{N.value||await V()},{deep:!0});const _e=()=>{if(!$.value)return;const{scrollTop:M,scrollHeight:P,clientHeight:re}=$.value,se=P-M-re<50;N.value=!se},O=M=>{const P=[];if(M.tools_called)try{const re=JSON.parse(M.tools_called);Array.isArray(re)&&P.push(...re.map(se=>({name:se,isProgrammatic:!1})))}catch{}if(M.provider_tools)try{const re=JSON.parse(M.provider_tools);Array.isArray(re)&&P.push(...re.map(se=>({name:se.type,isProgrammatic:!1})))}catch{}if(M.queued_tools)try{const re=JSON.parse(M.queued_tools);Array.isArray(re)&&P.push(...re.map(se=>({name:se.function?.name||"unknown",isProgrammatic:!0})))}catch{}return P},j=M=>M==null?"—":`$${M.toFixed(6)}`,z=q(()=>{const M=new Map,P=new Map;b.value.forEach(Ie=>{M.set(Ie.id,Ie);const he=Ie.parent_log_id;he&&(P.has(he)||P.set(he,[]),P.get(he).push(Ie))});const re=[],se=(Ie,he)=>{re.push({...Ie,depth:he}),(P.get(Ie.id)||[]).forEach(Oe=>{se(Oe,he+1)})};return b.value.forEach(Ie=>{Ie.parent_log_id||se(Ie,0)}),re});return(M,P)=>(r(),o("div",bk,[e("div",xk,[e("div",yk,[e("div",kk,[w(I(Mn),{size:18,class:"shrink-0"}),P[3]||(P[3]=e("h2",{class:"text-base font-bold"},"Logs",-1)),t.threadId?(r(),J(Er,{key:0,connected:I(g),error:I(y)},null,8,["connected","error"])):S("",!0)])])]),e("div",{ref_key:"logsScrollContainer",ref:$,class:"logs-list-container flex-1 overflow-y-auto overflow-x-auto",onScroll:_e},[t.threadId?I(k)&&u.value===0?(r(),o("div",_k,[w(Be)])):I(h)?(r(),o("div",$k," Error loading logs: "+C(I(h)),1)):b.value.length===0?(r(),o("div",Ck," No logs yet ")):(r(),o("div",Sk,[I(x)?(r(),o("div",Ik,[e("button",{onClick:ke,disabled:E.value||ue.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"},[E.value||ue.value?(r(),J(Be,{key:0,size:"xs"})):S("",!0),ue.value?(r(),o("span",Mk,"Loading to find log...")):E.value?(r(),o("span",zk,"Loading older logs...")):(r(),o("span",Vk,"Load previous logs"))],8,Tk)])):S("",!0),e("table",Ek,[e("thead",{class:ce(["border-b border-neutral-300 dark:border-neutral-700 sticky bg-white z-[10] dark:bg-black",{"top-0":!I(x),"top-[34px]":I(x)}])},[...P[4]||(P[4]=[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,[(r(!0),o(we,null,Ae(z.value,re=>(r(),o("tr",{key:re.id,ref_for:!0,ref:se=>X(re.id,se),class:ce(["border-b border-neutral-200 dark:border-neutral-800 cursor-pointer transition-colors relative",{"last:border-b-0":ie.value,"bg-red-50 dark:bg-red-950/20":re.error,"bg-accent-100 dark:bg-accent-900 dark:text-white":f.value===re.id,"ring-2 ring-inset ring-accent-400 dark:ring-accent-400":re.id===s.selectedLogId||re.id!==s.selectedLogId&&re.id===s.hoveredLogId}]),onClick:se=>ve(re),onMouseenter:se=>l("logHover",re.id),onMouseleave:P[0]||(P[0]=se=>l("logHover",null))},[e("td",Ak,[e("div",Pk,[re.depth>0?(r(),o("span",jk,"└─")):S("",!0),re.retry_of_log_id?(r(),J(I(zn),{key:1,size:14,class:"text-neutral-500 dark:text-neutral-400 flex-shrink-0"})):S("",!0),!re.is_complete&&!re.prompt_name?(r(),J(Be,{key:2,size:"xs"})):(r(),o("span",Rk,C(re.prompt_name||"—"),1))])]),e("td",Ok,[e("div",Dk,[re.error?(r(),o("span",Uk," ✕ ")):S("",!0),e("span",Bk,C(re.model_name||re.model),1)])]),e("td",Nk,[!re.is_complete&&!re.cost_total?(r(),J(Be,{key:0,size:"xs"})):(r(),o("span",qk,C(j(re.cost_total)),1))]),e("td",{class:ce(["px-3 py-2 text-xs",f.value===re.id?"text-neutral-800 dark:text-neutral-100":"text-neutral-600 dark:text-neutral-400"])},[!re.is_complete&&O(re).length===0?(r(),J(Be,{key:0,size:"xs"})):O(re).length===0?(r(),o("span",Fk,"—")):(r(),o("span",Hk,[(r(!0),o(we,null,Ae(O(re),(se,Ie)=>(r(),o(we,{key:Ie},[se.isProgrammatic?(r(),o("span",Wk,[w(I(Vn),{size:11,class:"inline-block -mt-0.5 mr-0.5"}),de(C(se.name),1)])):(r(),o("span",Kk,C(se.name),1)),Ie<O(re).length-1?(r(),o("span",Jk,", ")):S("",!0)],64))),128))]))],2),e("td",{class:ce(["px-3 py-2 text-right text-xs",f.value===re.id?"text-neutral-800 dark:text-neutral-100":"text-neutral-500 dark:text-neutral-500"])},[w(Nt,{timestamp:re.created_at},null,8,["timestamp"])],2)],42,Lk))),128))])])])):(r(),o("div",wk," Select a thread to view logs "))],544),w(bt,{name:"slide-up",onAfterEnter:P[2]||(P[2]=()=>f.value&&H(f.value))},{default:F(()=>[ie.value||ue.value&&f.value?(r(),o("div",Gk,[e("div",Yk,[ue.value&&!ie.value?(r(),o("div",Zk,[w(Be),P[5]||(P[5]=e("span",{class:"text-sm"},"Loading log...",-1))])):ie.value?(r(),J(hk,{key:1,log:ie.value,"thread-id":t.threadId,"has-previous":Q.value,"has-next":U.value,onClose:P[1]||(P[1]=re=>f.value=null),onPrevious:R,onNext:K},null,8,["log","thread-id","has-previous","has-next"])):S("",!0),I(ee)&&ie.value?(r(),o("div",Xk,[w(Be)])):S("",!0)])])):S("",!0)]),_:1})]))}}),t2=ct(e2,[["__scopeId","data-v-f8e4fdfe"]]),r2={class:"space-y-3"},a2=["data-variable-property"],n2={class:"text-xs text-neutral-400 dark:text-neutral-500 px-1"},o2=["data-enabler-property"],l2={class:"text-[11px] text-neutral-500 dark:text-neutral-400"},s2={key:0,class:"text-[11px] text-neutral-500 dark:text-neutral-400"},i2={class:"space-y-2"},u2={class:"text-xs text-neutral-500 dark:text-neutral-400"},d2={class:"grid gap-2 items-start grid-cols-[minmax(180px,1fr)_140px_minmax(220px,1fr)]"},c2={class:"text-xs text-neutral-400 dark:text-neutral-500 px-1"},ea="grid-cols-[minmax(180px,1fr)_140px_minmax(220px,1fr)_44px]",p2=Ce({__name:"ThreadVariableForm",props:{scanned:{default:()=>[]},disabled:{type:Boolean,default:!1},requireRequiredValues:{type:Boolean,default:!0},groupName:{default:"env"}},setup(t){const n=t,a=q(()=>(n.scanned||[]).map(f=>({...f,type:f.type==="secret"?"secret":"text",required:!!f.required,description:f.description||"",optionalOnly:!!f.optionalOnly,optionalBranches:Array.isArray(f.optionalBranches)?f.optionalBranches.filter($=>$?.gate&&$?.tool):void 0}))),s=q(()=>{const f=new Map;for(const $ of a.value)f.set($.property,$);return f}),l=f=>{if(!f.optionalOnly)return null;const $=f.optionalBranches?.[0];return $?.gate?$.gate:null},u=q(()=>{const f=new Map;for(const $ of a.value){const N=l($);N&&(f.has(N)||f.set(N,[]),f.get(N).push($))}for(const $ of f.values())$.sort((N,E)=>N.property.localeCompare(E.property));return f}),i=q(()=>a.value.filter(f=>!l(f))),p=f=>{const $=u.value.get(f)||[],N=[];for(const E of $){const L=E.optionalBranches||[];for(const V of L)V.gate===f&&typeof V.maxInstances=="number"&&V.maxInstances>0&&N.push(V.maxInstances)}if(N.length!==0)return Math.min(...N)},x=f=>{if(f==null)return!1;const $=String(f).trim().toLowerCase();return $==="true"||$==="1"||$==="yes"},k=f=>f&&typeof f=="object"&&!Array.isArray(f)?f:{},h=(f,$)=>{const E=k($)[f];if(E!=null&&String(E).trim()!=="")return String(E);const L=s.value.get(f);return L?.value!==void 0&&L.value!==null?String(L.value):""},g=(f,$)=>x(h(f,$)),y=f=>`__optional__${f}`,_=f=>!u.value.has(f.property)||f.value===void 0||f.value===null?"":String(f.value),v=f=>f.name==="local"?`this ${f.type}`:`the ${f.name} ${f.type}`,d=f=>f.length===0?"":f.length===1?f[0]:f.length===2?`${f[0]} and ${f[1]}`:`${f.slice(0,-1).join(", ")}, and ${f[f.length-1]}`,b=f=>(f.type==="agent"||f.type==="prompt")&&f.name?`the ${f.name} ${f.type}`:f.type==="thread"?"the thread":f.type==="account"?"the account":f.type==="instance"?"the instance":`the ${f.type}`,c=f=>{const $=f.required?"Required by":"Requested by",N=f.declared.length?d(f.declared.map(v)):"this configuration";return f.defined?`${$} ${N}, value provided by ${b(f.defined)}.`:`${$} ${N}.`};return(f,$)=>{const N=tt("FormKit");return r(),J(N,{type:"group",name:t.groupName,"outer-class":"$reset",classes:{outer:"$remove:mb-4 mb-0"}},{default:F(({value:E})=>[e("div",r2,[e("div",{class:ce(["grid gap-2 text-xs font-medium text-neutral-500 dark:text-neutral-400 px-1",ea])},[...$[0]||($[0]=[e("span",null,"Name",-1),e("span",null,"Type",-1),e("span",null,"Value",-1),e("span",{class:"text-center text-[10px] leading-none tracking-tight self-center"},"Required",-1)])]),(r(!0),o(we,null,Ae(i.value,L=>(r(),o("div",{key:L.property,class:"space-y-1","data-variable-property":L.property},[e("div",{class:ce(["grid gap-2 items-start",ea])},[w(N,{type:"text",value:L.property,disabled:!0,"outer-class":"$reset",classes:{outer:"$remove:mb-4 group mb-0",wrapper:"$remove:flex-1 flex-1",inner:"!bg-zinc-100 dark:!bg-zinc-700/40 !cursor-not-allowed"}},null,8,["value"]),w(N,{type:"text",value:L.type,disabled:!0,"outer-class":"$reset",classes:{outer:"$remove:mb-4 group mb-0",wrapper:"$remove:flex-1 flex-1",inner:"!bg-zinc-100 dark:!bg-zinc-700/40 !cursor-not-allowed"}},null,8,["value"]),w(N,{name:L.property,type:L.type==="secret"?"password":"text",value:_(L),placeholder:L.description||"Enter value...",disabled:t.disabled,validation:t.requireRequiredValues&&L.required&&!L.defined?"required":"","validation-label":"Value","validation-visibility":"submit","outer-class":"$reset",classes:{outer:"$remove:mb-4 group mb-0",wrapper:"$remove:flex-1 flex-1",inner:t.disabled?"!bg-zinc-100 dark:!bg-zinc-700/40 !cursor-not-allowed":""}},null,8,["name","type","value","placeholder","disabled","validation","classes"]),w(N,{type:"checkbox",value:L.required,disabled:!0,classes:{outer:"$remove:mb-4 mb-0 pt-[8px] h-[34px] w-full flex items-center justify-center justify-self-center",wrapper:"$remove:items-center flex items-center justify-center",decorator:"$remove:mr-1.5 mr-0",label:"$remove:hidden",help:"$remove:hidden",messages:"$remove:formkit-messages hidden"}},null,8,["value"])]),e("p",n2,C(c(L)),1),(u.value.get(L.property)||[]).length>0&&g(L.property,E)?(r(),o("div",{key:0,class:"ml-5 space-y-2","data-enabler-property":L.property},[e("p",l2,[$[1]||($[1]=de(" Optional branch enabled by ",-1)),e("code",null,C(L.property),1)]),typeof p(L.property)=="number"?(r(),o("p",s2," Max instances: "+C(p(L.property)),1)):S("",!0),w(N,{type:"repeater",name:y(L.property),min:1,max:p(L.property),"add-label":"Add instance","remove-icon":"close","add-attrs":{outerClass:"$reset m-0 inline-flex",wrapperClass:"$reset m-0 inline-flex",inputClass:"inline-flex w-auto min-w-0 py-1 px-2 text-sm font-medium rounded-sm border border-accent-500/50 text-accent-500 hover:bg-accent-500/10 hover:border-accent-400 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent-400 disabled:opacity-50",helpClass:"$remove:hidden",messagesClass:"$remove:hidden"},"insert-control":!1,"up-control":!1,"down-control":!1,"remove-control":!0,"outer-class":"$reset",classes:{outer:"$remove:mb-4 mb-0",wrapper:"$remove",fieldset:"$remove:border-0 p-0 m-0 min-w-0",legend:"$remove:hidden",content:"$remove:p-5 $remove:space-y-2 p-0 space-y-2",item:"$remove:bg-white $remove:border $remove:border-zinc-200 $remove:rounded-sm $remove:dark:border-zinc-700 $remove:dark:bg-transparent $remove:mb-2 mb-0 border border-neutral-200 dark:border-neutral-700 bg-transparent rounded-sm p-2",controls:"$reset m-0 h-full self-stretch flex items-center justify-end list-none p-0 bg-transparent border-0",remove:"$reset list-none m-0 ml-2 p-0 h-full flex items-center justify-center",removeControl:"$reset inline-flex h-5 w-5 items-center justify-center rounded text-neutral-500 dark:text-white/70 hover:text-red-500 dark:hover:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/30 disabled:opacity-50 disabled:hidden",removeIcon:"$reset h-3.5 w-3.5",controlLabel:"$reset hidden",addButton:"$reset mt-1 inline-flex",help:"$remove:hidden",messages:"$remove:formkit-messages hidden"}},{default:F(({index:V})=>[e("div",i2,[e("p",u2," Instance "+C(Number(V)+1),1),(r(!0),o(we,null,Ae(u.value.get(L.property)||[],A=>(r(),o("div",{key:`${L.property}-${A.property}-${V}`,class:"space-y-1"},[e("div",d2,[w(N,{type:"text",value:A.property,disabled:!0,"outer-class":"$reset",classes:{outer:"$remove:mb-4 group mb-0",wrapper:"$remove:flex-1 flex-1",inner:"!bg-zinc-100 dark:!bg-zinc-700/40 !cursor-not-allowed"}},null,8,["value"]),w(N,{type:"text",value:A.type,disabled:!0,"outer-class":"$reset",classes:{outer:"$remove:mb-4 group mb-0",wrapper:"$remove:flex-1 flex-1",inner:"!bg-zinc-100 dark:!bg-zinc-700/40 !cursor-not-allowed"}},null,8,["value"]),w(N,{name:A.property,type:A.type==="secret"?"password":"text",placeholder:A.description||"Enter value...",disabled:t.disabled,validation:t.requireRequiredValues&&A.required?"required":"","validation-label":"Value","validation-visibility":"submit","outer-class":"$reset",classes:{outer:"$remove:mb-4 group mb-0",wrapper:"$remove:flex-1 flex-1",inner:t.disabled?"!bg-zinc-100 dark:!bg-zinc-700/40 !cursor-not-allowed":""}},null,8,["name","type","placeholder","disabled","validation","classes"])]),e("p",c2,C(c(A)),1)]))),128))])]),_:2},1032,["name","max"])],8,o2)):S("",!0)],8,a2))),128))])]),_:1},8,["name"])}}}),m2={class:"hidden"},v2={class:"flex-1 overflow-y-auto p-6"},f2={class:"space-y-4"},g2={class:"flex items-center justify-between mb-1"},h2={key:0,class:"flex items-center gap-1.5 ml-auto"},b2={key:0},x2={key:1},y2={key:2},k2={key:1,class:"space-y-4"},w2={key:2,class:"text-center text-sm text-neutral-500"},_2={key:3,class:"space-y-3"},$2={key:4,class:"text-center text-sm text-neutral-500"},C2={class:"p-6 border-t border-neutral-200 dark:border-neutral-700 flex-shrink-0"},S2={class:"flex justify-between items-center"},I2={class:"flex gap-2"},ta="__optional__",T2=Ce({__name:"CreateThreadModal",props:{modelValue:{type:Boolean},editThread:{}},emits:["update:modelValue","thread-created","thread-updated"],setup(t,{emit:n}){const a=t,s=n,l=q(()=>!!a.editThread),u=m(""),i=m(!1),p=m(!1),x=m(""),k=m([]),h=m(!1),g=m(null),y=D=>D&&typeof D=="object"&&!Array.isArray(D)?D:{},_=D=>D==null?"":String(D),v=D=>_(D).split(",").map(W=>W.trim()).filter(W=>W.length>0),d=D=>{const W=y(D),me={};for(const[ue,te]of Object.entries(W)){if(ue.startsWith(ta))continue;const Y=_(te);Y&&(me[ue]=Y)}for(const[ue,te]of Object.entries(W)){if(!ue.startsWith(ta)||!Array.isArray(te))continue;let Y=0;for(const ae of te){const ye=y(ae);if(Object.values(ye).some(ne=>_(ne).trim().length>0)){for(const[ne,ke]of Object.entries(ye)){const _e=_(ke),O=Y===0?ne:`${ne}__${Y+1}`;if(Y===0){_e&&(me[O]=_e);continue}me[O]=_e}Y+=1}}}return me},b=D=>{const W=new URL(Ve(`/api/variables/agents/${encodeURIComponent(D)}`),window.location.origin);return W.searchParams.set("include_optional_disabled","1"),W.toString()},c=()=>({include_subagents:!1,agent_id:l.value&&a.editThread?.agent_id||"",tags_csv:l.value&&a.editThread?.tags?.join(", ")||"",data:{},env:{}}),f=D=>{g.value=D},$=D=>{const W=y(D),me=_(W.agent_id),ue=!!W.include_subagents;return u.value!==me&&(u.value=me),i.value!==ue&&(i.value=ue),""},{data:N,isFetching:E,execute:L}=ot(Ve("/api/agents"),{immediate:!1}).json(),V=q(()=>{if(!N.value)return[];const D=N.value?.agents||[];return l.value||i.value?D:D.filter(W=>W.type!=="dual_ai")}),A=()=>V.value.map(D=>({value:D.id,label:D.title})),G=q(()=>!u.value||!N.value?null:(N.value?.agents||[]).find(W=>W.id===u.value)||null),{data:ee,isFetching:ie,execute:be}=ot(q(()=>G.value?.side_a_agent_prompt?Ve(`/api/prompts/${encodeURIComponent(G.value.side_a_agent_prompt)}`):""),{immediate:!1}).json(),Q=q(()=>{if(!ee.value)return null;const W=(ee.value?.prompt||ee.value)?.required_schema;if(!W)return null;try{return typeof W=="string"?JSON.parse(W):W}catch{return null}}),U=q(()=>{const D=Q.value;return!D||!D.properties?[]:Object.entries(D.properties).map(([W,me])=>({name:W,type:me.type||"string",description:me.description||"",required:D.required?.includes(W)||!1,enum:me.enum}))}),R=q(()=>k.value.length>0),K=async D=>{if(!D){k.value=[];return}h.value=!0;try{const W=await fetch(b(D));if(!W.ok){k.value=[];return}const me=await W.json();k.value=me.variables||[]}catch(W){console.error("Error scanning agent variables:",W),k.value=[]}finally{h.value=!1}};Ee(u,async D=>{D&&G.value?.side_a_agent_prompt?await be():ee.value=null,D?await K(D):k.value=[]}),Ee([i,V,l],()=>{l.value||!u.value||V.value.some(W=>W.id===u.value)||(u.value="",g.value?.at("agent_id")?.input(""))});const H=()=>{u.value=l.value&&a.editThread?.agent_id||"",i.value=!1,x.value="",k.value=[],ee.value=null,g.value?.reset(c())},ve=async D=>{p.value=!0,x.value="";const W=y(D),me=v(W.tags_csv);try{if(l.value){const ne=await fetch(Ve(`/api/threads/${a.editThread.id}`),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({tags:me})});if(!ne.ok){const ke=await ne.json();throw new Error(ke.error||"Failed to update thread")}s("thread-updated"),H(),s("update:modelValue",!1);return}const ue={agent_id:_(W.agent_id),tags:me.length>0?me:void 0},te=y(W.data);Object.keys(te).length>0&&(ue.data=te);const Y=d(W.env);Object.keys(Y).length>0&&(ue.env=Y);const ae=await fetch(Ve("/api/threads"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(ue)});if(!ae.ok){const ne=await ae.json();throw new Error(ne.error||"Failed to create thread")}const Te=(await ae.json()).threadId;if(!Te)throw new Error("Thread created but ID not found in response");s("thread-created",Te),H(),s("update:modelValue",!1)}catch(ue){console.error(`Error ${l.value?"updating":"creating"} thread:`,ue),x.value=ue.message||`Failed to ${l.value?"update":"create"} thread`}finally{p.value=!1}},X=()=>{H(),s("update:modelValue",!1)};return Ee(()=>a.modelValue,async D=>{D&&(await L(),H())}),(D,W)=>{const me=tt("FormKit");return r(),J(st,{"model-value":t.modelValue,"onUpdate:modelValue":W[0]||(W[0]=ue=>D.$emit("update:modelValue",ue)),title:l.value?"Edit Thread":"Create New Thread",width:"max-w-3xl","content-padding":!1},{default:F(()=>[w(me,{type:"form",id:"create-thread-form",actions:!1,onSubmit:ve,onNode:f,"form-class":"$reset flex-1 min-h-0 flex flex-col"},{default:F(({value:ue})=>[e("span",m2,C($(ue)),1),e("div",v2,[e("div",f2,[x.value?(r(),J(I(at),{key:0,variant:"error"},{default:F(()=>[de(C(x.value),1)]),_:1})):S("",!0),e("div",null,[e("div",g2,[W[2]||(W[2]=e("label",{class:"block text-zinc-700 dark:text-zinc-300 text-xs font-bold"}," Agent ",-1)),l.value?S("",!0):(r(),o("div",h2,[W[1]||(W[1]=e("span",{class:"text-[11px] text-neutral-500 dark:text-neutral-400"}," Include subagents ",-1)),w(me,{type:"toggle",name:"include_subagents",value:!1,"on-value":!0,"off-value":!1,"on-value-label":"","off-value-label":"",disabled:I(E),classes:{outer:"$remove:mb-4 mb-0",wrapper:"$remove:items-center flex items-center",label:"$remove:hidden",inner:"h-4",track:"h-4 w-7 rounded-full",thumb:"h-3 w-3",valueLabel:"$remove:hidden"}},null,8,["disabled"])]))]),w(me,{type:"selectSearch",name:"agent_id",value:u.value,options:A,disabled:I(E)||l.value,placeholder:"Select an agent...",validation:"required","validation-visibility":"submit"},null,8,["value","disabled"]),w(I(Ue),{class:"mt-1"},{default:F(()=>[l.value?(r(),o("span",b2,"Agent cannot be changed after thread creation")):i.value?(r(),o("span",x2,"Choose which agent will handle this conversation (subagents included)")):(r(),o("span",y2,"Choose which agent will handle this conversation"))]),_:1})]),!l.value&&U.value.length>0&&!I(ie)?(r(),o("div",k2,[W[3]||(W[3]=e("h4",{class:"text-sm font-medium text-neutral-700 dark:text-neutral-300"}," Required Information ",-1)),w(me,{type:"group",name:"data","outer-class":"$reset",classes:{outer:"$remove:mb-4 mb-0"}},{default:F(()=>[(r(!0),o(we,null,Ae(U.value,te=>(r(),o("div",{key:te.name,class:"space-y-2"},[te.enum?(r(),J(me,{key:0,type:"selectSearch",name:te.name,label:te.name,options:[{value:"",label:"Select..."},...te.enum.map(Y=>({value:Y,label:Y}))],validation:te.required?"required":"","validation-visibility":"submit"},null,8,["name","label","options","validation"])):te.type==="string"?(r(),J(me,{key:1,type:"text",name:te.name,label:te.name,placeholder:te.description,validation:te.required?"required":"","validation-visibility":"submit"},null,8,["name","label","placeholder","validation"])):te.type==="number"||te.type==="integer"?(r(),J(me,{key:2,type:"number",name:te.name,label:te.name,placeholder:te.description,validation:te.required?"required":"","validation-visibility":"submit"},null,8,["name","label","placeholder","validation"])):te.type==="boolean"?(r(),J(me,{key:3,type:"checkbox",name:te.name,label:te.name,validation:te.required?"required":"","validation-visibility":"submit"},null,8,["name","label","validation"])):(r(),J(me,{key:4,type:"textarea",name:te.name,label:te.name,placeholder:te.description||`Enter ${te.name} (JSON format)`,validation:te.required?"required":"","validation-visibility":"submit",rows:3},null,8,["name","label","placeholder","validation"])),te.description?(r(),J(I(Ue),{key:5,class:"mt-1"},{default:F(()=>[de(C(te.description),1)]),_:2},1024)):S("",!0)]))),128))]),_:1})])):S("",!0),!l.value&&I(ie)?(r(),o("div",w2," Loading agent requirements... ")):S("",!0),!l.value&&R.value?(r(),o("div",_2,[W[4]||(W[4]=e("h4",{class:"text-sm font-medium text-neutral-700 dark:text-neutral-300"}," Variables ",-1)),W[5]||(W[5]=e("p",{class:"text-xs text-neutral-500 dark:text-neutral-400"}," Required variables must be resolved before a new thread can be created. ",-1)),w(p2,{"group-name":"env",scanned:k.value,disabled:p.value,"require-required-values":!0},null,8,["scanned","disabled"])])):S("",!0),!l.value&&h.value?(r(),o("div",$2," Scanning environment variables... ")):S("",!0),e("div",null,[w(me,{type:"text",name:"tags_csv",value:l.value&&a.editThread?.tags?.join(", ")||"",label:"Tags",placeholder:"research, urgent, production"},null,8,["value"]),w(I(Ue),{class:"mt-1"},{default:F(()=>[...W[6]||(W[6]=[de(" Comma-separated tags to help organize and search threads ",-1)])]),_:1})])])]),e("div",C2,[e("div",S2,[w(I(Sr),{node:g.value||void 0},null,8,["node"]),e("div",I2,[w(I(Je),{variant:"ghost",size:"sm",disabled:p.value,onClick:X},{default:F(()=>[...W[7]||(W[7]=[de(" Cancel ",-1)])]),_:1},8,["disabled"]),w(I(Je),{variant:"primary",size:"sm",disabled:p.value||I(E),loading:p.value,type:"submit",form:"create-thread-form"},{default:F(()=>[l.value?(r(),o(we,{key:0},[de(C(p.value?"Updating...":"Update Thread"),1)],64)):(r(),o(we,{key:1},[de(C(p.value?"Creating...":"Create Thread"),1)],64))]),_:1},8,["disabled","loading"])])])])]),_:1})]),_:1},8,["model-value","title"])}}}),M2={class:"flex h-full overflow-hidden"},z2={key:0,class:"flex flex-col items-center p-4"},V2={key:0,class:"flex flex-col items-center p-4"},E2={class:"flex-1 overflow-hidden flex flex-col min-h-0"},ra=Ce({__name:"ThreadsView",setup(t){const n=Tt(),a=Ot(),s=m(typeof n.params.id=="string"?n.params.id:null),l=m({threadList:!1,messages:!1}),u=m(!1),i=m(null),p=m(null),{thread:x}=Vr(q(()=>s.value)),k=m(null),h=m(null),g=m(null),y=m(null),_=m(null),v=R=>{y.value=R,_.value=R},d=R=>{const K=c.value,H=f.value;if(!K||!H)return null;if(K.hasWorkblockForLogId(R))return R;let ve=R;const X=10;for(let D=0;D<X&&ve;D++){const W=H.getLog(ve);if(!W)break;const me=W.parent_log_id;if(!me)break;if(K.hasWorkblockForLogId(me))return me;ve=me}return null},b=R=>{if(y.value=R,!R){_.value=null;return}_.value=d(R)??R},c=m(null),f=m(null);Ee(()=>n.params.id,R=>{s.value=typeof R=="string"?R:null,k.value=null,h.value=null,g.value=null});const $=R=>{a.push(`/threads/${R}`)},N=R=>{window.location.href="/threads"},E=()=>{x.value&&(i.value=x.value,u.value=!0)},L=()=>{i.value=null,u.value=!0},V=R=>{p.value?.refetch(),a.push(`/threads/${R}`)},A=()=>{p.value?.refetch()},G=R=>{l.value[R]=!l.value[R]},ee=async(R,K)=>{if(k.value=R,!K){h.value=null,g.value=null;return}const H=f.value;if(!H){h.value=K,g.value=K;return}const ve=!H.hasLog(K);if(ve&&H.setLoadingForLog(!0),h.value=K,g.value=K,ve&&!await H.loadUntilLogId(K)){console.warn(`Could not find log ${K} after loading all available logs`),H.setLoadingForLog(!1);return}if(!await H.waitForLogRow(K)){console.warn(`Log row ${K} not rendered in time`);return}H.scrollToLog(K),H.selectLogById(K)},ie=R=>{h.value=R,k.value=null;const K=c.value;if(!K){g.value=R;return}if(K.scrollToLogId(R)){g.value=R;return}const H=d(R);H&&H!==R&&K.scrollToLogId(H),g.value=H??R},be=R=>{R&&(h.value=R)},Q=R=>{f.value?.removeLogsByIds(R)},U=R=>{R&&!s.value&&a.push(`/threads/${R}`)};return(R,K)=>(r(),o("div",M2,[e("div",{class:ce([l.value.threadList?"w-[60px]":"w-[320px]","border-r border-neutral-300 dark:border-neutral-700 flex-shrink-0 transition-all duration-200 flex flex-col min-h-0"])},[l.value.threadList?(r(),o("div",z2,[e("button",{onClick:K[0]||(K[0]=H=>G("threadList")),class:"p-2 hover:bg-neutral-100 dark:hover:bg-neutral-900 rounded transition-colors",title:"Expand Threads pane"},[w(I(ha),{size:20})])])):(r(),J(Kf,{key:1,ref_key:"threadListPaneRef",ref:p,"selected-thread-id":s.value,onSelectThread:$,onCollapse:K[1]||(K[1]=H=>G("threadList")),onCreateThread:L,onThreadsLoaded:U},null,8,["selected-thread-id"]))],2),e("div",{class:ce([l.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"])},[l.value.messages?(r(),o("div",V2,[e("button",{onClick:K[2]||(K[2]=H=>G("messages")),class:"p-2 hover:bg-neutral-100 dark:hover:bg-neutral-900 rounded transition-colors",title:"Expand Messages pane"},[w(I(ka),{size:20})])])):s.value?(r(),J(I(bo),{key:1,"thread-id":s.value,preload:!0,live:!0,"include-silent":!0,"use-workblocks":!0,"use-subagent-blocks":!0},{default:F(()=>[w(Xr,{ref_key:"messagesPaneRef",ref:c,"thread-id":s.value,"selected-message-id":k.value,"selected-log-id":g.value,"hovered-log-id":_.value,onCollapse:K[3]||(K[3]=H=>G("messages")),onMessageClick:ee,onMessageHover:v,onThreadDeleted:N,onEditThread:E,onLogsDeleted:Q,onThreadUpdated:A},null,8,["thread-id","selected-message-id","selected-log-id","hovered-log-id"])]),_:1},8,["thread-id"])):l.value.messages?S("",!0):(r(),J(Xr,{key:2,ref_key:"messagesPaneRef",ref:c,"thread-id":null,"selected-message-id":k.value,"selected-log-id":g.value,"hovered-log-id":_.value,onCollapse:K[4]||(K[4]=H=>G("messages")),onMessageClick:ee,onMessageHover:v,onThreadDeleted:N,onEditThread:E,onLogsDeleted:Q,onThreadUpdated:A},null,8,["selected-message-id","selected-log-id","hovered-log-id"]))],2),e("div",E2,[w(t2,{ref_key:"logsPaneRef",ref:f,"thread-id":s.value,"selected-log-id":h.value,"hovered-log-id":y.value,onLogClick:ie,onLogHover:b,onLogsLoaded:be},null,8,["thread-id","selected-log-id","hovered-log-id"])]),w(T2,{modelValue:u.value,"onUpdate:modelValue":K[5]||(K[5]=H=>u.value=H),"edit-thread":i.value,onThreadCreated:V,onThreadUpdated:A},null,8,["modelValue","edit-thread"])]))}}),L2=Ce({__name:"PromptsDataTable",props:{title:{},description:{},primaryAction:{},readonly:{type:Boolean,default:!1}},emits:["add","edit","delete"],setup(t,{expose:n,emit:a}){const s=t,l=a,u=m([]),i=m(!1),p=[{key:"name",label:"Name",width:"w-1/4",sortable:!0},{key:"tool_description",label:"Description",width:"w-2/5"},{key:"model_name",label:"Model",width:"w-1/5",sortable:!0,filterable:!0,formatter:(y,_)=>y||_.model_id||"-",filterIcon:(y,_)=>_.model_provider?`/api/providers/${_.model_provider}/icon?model=${encodeURIComponent(_.model_id||"")}`:void 0},{key:"created_at",label:"Created",width:"w-1/6",sortable:!0,searchable:!1,formatter:y=>y?new Date(y*1e3).toLocaleDateString():"-"}],x=[{icon:"edit",label:"Edit",handler:y=>l("edit",y)},{icon:"delete",label:"Delete",handler:async y=>{await g(y)},confirm:!0,confirmMessage:"Are you sure you want to delete this prompt?",variant:"danger"}],k=q(()=>s.readonly?x.filter(y=>y.variant!=="danger"):x),h=async()=>{i.value=!0;try{const y=await fetch(Ve("/api/prompts"));if(y.ok){const _=await y.json();u.value=_.prompts||[]}}catch(y){console.error("Error fetching prompts:",y)}finally{i.value=!1}},g=async y=>{try{const _=await fetch(Ve(`/api/prompts/${encodeURIComponent(y.id)}`),{method:"DELETE"});if(_.ok)await h();else{const v=await _.json();alert(v.error||"Failed to delete prompt")}}catch(_){console.error("Error deleting prompt:",_),alert("Failed to delete prompt")}};return qe(()=>{h()}),n({refresh:h}),(y,_)=>(r(),o("div",null,[w($t,{title:t.title,description:t.description,"primary-action":t.primaryAction,columns:p,data:u.value,actions:k.value,loading:i.value,sortable:"",searchable:"","search-placeholder":"Search prompts...","empty-message":"No prompts available. Create your first prompt to get started.",onRowClick:_[0]||(_[0]=v=>l("edit",v))},null,8,["title","description","primary-action","data","actions","loading"])]))}}),A2={class:"space-y-4"},P2={key:0,class:"-mt-2 text-sm text-neutral-500 dark:text-neutral-400"},j2={class:"px-1 py-0.5 bg-neutral-100 dark:bg-neutral-800 rounded"},R2=Ce({__name:"PromptBasicInfo",props:{name:{},toolDescription:{}},emits:["update:name","update:toolDescription"],setup(t,{emit:n}){const a=n,s=u=>{let i=u.replace(/[^a-zA-Z0-9\s_]/g,"");return i=i.trim().toLowerCase().replace(/\s+/g,"_").replace(/_+/g,"_").replace(/^_|_$/g,""),i},l=u=>{const i=s(u);a("update:name",i)};return(u,i)=>{const p=tt("FormKit");return r(),o("div",A2,[w(p,{type:"text",name:"name",value:t.name,onInput:l,label:"Prompt Name",placeholder:"Enter a unique name (will be converted to snake_case)",validation:"required|matches:/^[a-z][a-z0-9_]*$/","validation-messages":{matches:"Must start with a letter and contain only lowercase letters, numbers, and underscores"},"validation-visibility":"submit","outer-class":"$reset"},null,8,["value"]),t.name?(r(),o("p",P2,[i[1]||(i[1]=de(" Will be saved as: ",-1)),e("code",j2,C(t.name),1)])):S("",!0),w(p,{type:"textarea",name:"tool_description",value:t.toolDescription,onInput:i[0]||(i[0]=x=>a("update:toolDescription",x)),label:"Tool Description",placeholder:"Describe what this prompt does (shown when used as a tool)",rows:"3",validation:"required","validation-visibility":"submit","outer-class":"$reset"},null,8,["value"])])}}}),O2={class:"space-y-4"},D2=Ce({__name:"PromptModelSelect",props:{modelValue:{}},emits:["update:modelValue"],setup(t,{emit:n}){const a=n,s=m([]),l=m(!1),u=q(()=>s.value.map(p=>({value:p.id,label:p.name,description:p.model||p.provider,icon:p.provider?`/api/providers/${p.provider}/icon?model=${encodeURIComponent(p.model||"")}`:void 0}))),i=async()=>{l.value=!0;try{const p=await fetch(Ve("/api/models"));if(p.ok){const x=await p.json();s.value=x.models||[]}}catch(p){console.error("Error fetching models:",p)}finally{l.value=!1}};return qe(()=>{i()}),(p,x)=>{const k=tt("FormKit");return r(),o("div",O2,[w(k,{type:"selectSearch",name:"model_id",value:t.modelValue,onInput:x[0]||(x[0]=h=>a("update:modelValue",h)),options:u.value,label:"Model",placeholder:"Select a model for this prompt","search-placeholder":"Search models...",loading:l.value,validation:"required","validation-visibility":"submit","outer-class":"$reset"},null,8,["value","options","loading"])])}}});function aa(t,n){if(!n||!n.properties||Object.keys(n.properties).length===0)return!0;if(!t||!t.properties)return Object.keys(n.properties);const a=[],s=t.properties||{},l=n.properties||{};return(n.required||[]).forEach(i=>{i in s||a.push(i)}),Object.keys(l).forEach(i=>{!(i in s)&&!a.includes(i)&&a.push(i)}),a.length>0?a:!0}function na(t){return t.length===0?"":t.length===1?`Missing required field: ${t[0]}`:`Missing required fields: ${t.join(", ")}`}const U2=Ce({__name:"PromptTemplate",props:{promptText:{},beforeTool:{},afterTool:{},requiredSchema:{},currentPromptName:{},availableEnvVariables:{}},emits:["update:promptText","update:beforeTool","update:afterTool"],setup(t,{emit:n}){const a=t,s=n,l=m([]),u=m(!1),i=y=>y.type==="text"?{type:"string",value:y.content||""}:y.type==="include"?{type:"prompt",id:y.prompt||"",label:y.prompt||""}:y.type==="env"?{type:"env",property:y.property||"",label:y.label||y.property||""}:y.type==="string"?{type:"string",value:y.value||""}:y.type==="prompt"?{type:"prompt",id:y.id||"",label:y.label||y.id||""}:y.type==="variable"?{type:"variable",value:y.value||"",label:y.label||y.value||""}:{type:"string",value:""},p=q(()=>{if(!a.promptText)return[{type:"string",value:""}];let y=[];try{const v=JSON.parse(a.promptText);Array.isArray(v)?y=v.map(i):y=[{type:"string",value:a.promptText}]}catch{y=[{type:"string",value:a.promptText}]}const _=a.requiredSchema?JSON.parse(a.requiredSchema):{};return y.map(v=>{if(v.type==="prompt"&&v.schema){const d=aa(_,v.schema),b=d===!0,c=b?[]:d;return{...v,meta:{isValid:b,missingFields:c,validationMessage:b?"":na(c)}}}if(v.type==="env"){const d=v.property;if(!(a.availableEnvVariables||[]).includes(d))return{...v,meta:{isValid:!1,validationMessage:`Variable "${d}" is not defined on this prompt`}}}return v})}),x=q(()=>{try{const y=JSON.parse(a.requiredSchema);if(y.properties&&typeof y.properties=="object")return Object.keys(y.properties)}catch{return[]}return[]}),k=async y=>{u.value=!0;try{const _=new URLSearchParams;y&&_.set("search",y);const v=await fetch(Ve(`/api/prompts${_.toString()?"?"+_.toString():""}`));if(v.ok){const d=await v.json();l.value=d.prompts||[]}}catch(_){console.error("Error fetching prompts:",_)}finally{u.value=!1}},h=async y=>{const _=[];return x.value.forEach(v=>{(!y||v.toLowerCase().includes(y.toLowerCase()))&&_.push({type:"variable",value:v,label:v,description:"Schema property"})}),(a.availableEnvVariables||[]).forEach(v=>{(!y||v.toLowerCase().includes(y.toLowerCase()))&&_.push({type:"env",value:v,label:v,description:"Thread env variable"})}),y!==void 0&&await k(y),l.value.forEach(v=>{if(!(a.currentPromptName&&v.name===a.currentPromptName)&&(!y||v.name.toLowerCase().includes(y.toLowerCase()))){const d=a.requiredSchema?JSON.parse(a.requiredSchema):{},b=aa(d,v.required_schema),c=b===!0,f=c?[]:b;_.push({type:"prompt",id:v.name,label:v.name,description:v.tool_description||"Available prompt",schema:v.required_schema,meta:{isValid:c,missingFields:f,validationMessage:c?"":na(f)}})}}),_},g=y=>{const _=y.map(v=>{const{type:d,value:b,label:c,id:f,property:$,schema:N}=v;return d==="string"?{type:d,value:b||""}:d==="variable"?{type:d,value:b||"",label:c}:d==="env"?{type:d,property:$||b||f||"",label:c}:d==="prompt"?{type:d,id:f||"",label:c,schema:N}:v});s("update:promptText",JSON.stringify(_))};return qe(()=>{k()}),(y,_)=>(r(),o("div",null,[w(Mr,{"model-value":p.value,"onUpdate:modelValue":g,search:h,placeholder:"Enter your prompt template... Type @ to insert variables, env, or prompts"},null,8,["model-value"])]))}}),B2={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function N2(t,n){return r(),o("svg",B2,[...n[0]||(n[0]=[e("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2a2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1m8 0h1a2 2 0 0 0 2-2v-5c0-1.1.9-2 2-2a2 2 0 0 1-2-2V5a2 2 0 0 0-2-2h-1"},null,-1)])])}const oa=De({name:"lucide-braces",render:N2}),q2={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function F2(t,n){return r(),o("svg",q2,[...n[0]||(n[0]=[e("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M10 5H3m9 14H3M14 3v4m2 10v4m5-9h-9m9 7h-5m5-14h-7m-6 5v4m0-2H3"},null,-1)])])}const la=De({name:"lucide-sliders-horizontal",render:F2}),H2={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function W2(t,n){return r(),o("svg",H2,[...n[0]||(n[0]=[e("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z"},null,-1)])])}const sa=De({name:"lucide-zap",render:W2}),K2={key:0,class:"min-h-[500px] flex items-center justify-center"},J2={class:"flex flex-1 min-h-0"},G2={class:"w-44 flex-shrink-0 border-r border-neutral-200 dark:border-neutral-700 py-4"},Y2={class:"space-y-4"},Z2={class:"space-y-5"},X2={key:0,class:"mb-4 py-6 px-4 border border-dashed border-neutral-300 dark:border-neutral-600 rounded-lg text-center"},Q2={key:0,class:"space-y-2 mb-4"},ew={class:"flex-1 min-w-0"},tw={class:"font-medium text-sm"},rw={class:"text-xs text-neutral-500 dark:text-neutral-400"},aw=["onClick","aria-label"],nw={key:2,class:"py-6 px-4 border border-dashed border-neutral-300 dark:border-neutral-600 rounded-lg text-center"},ow={key:3,class:"text-center py-3 text-xs text-neutral-400 dark:text-neutral-500"},lw={key:0,class:"text-xs text-neutral-500 dark:text-neutral-400 mb-3"},sw={class:"mb-6"},iw={class:"grid grid-cols-2 gap-6 items-start"},uw={class:"flex flex-col"},dw={class:"space-y-4 mb-6 mt-6 pt-6 border-t border-neutral-100 dark:border-neutral-800"},cw={class:"pt-6 border-t border-neutral-100 dark:border-neutral-800"},pw={class:"grid grid-cols-2 gap-6 mb-4"},mw={class:"p-6 border-t border-neutral-200 dark:border-neutral-700 flex-shrink-0"},vw={class:"flex justify-between items-center"},fw={key:0,class:"flex items-center gap-3"},Za=Ce({__name:"PromptModal",props:{modelValue:{type:Boolean},editPrompt:{},mode:{},readonly:{type:Boolean,default:!1}},emits:["update:modelValue","save"],setup(t,{expose:n,emit:a}){const s=t,l=a,u=q(()=>s.mode==="edit"),i=m(!1),p=m(null),x=["basics","schema","prompt","tools","hooks","variables","behavior"],{activeTab:k,scrollToSection:h}=Fa(p,x),g=[{id:"basics",label:"Basics",icon:lr},{id:"schema",label:"Schema",icon:oa},{id:"prompt",label:"Prompt",icon:or},{id:"tools",label:"Tools",icon:_r},{id:"hooks",label:"Hooks",icon:sa},{id:"variables",label:"Variables",icon:qt},{id:"behavior",label:"Behavior",icon:la}],y=q(()=>A.value.length===1),_=m(""),v=m(null),d=m(""),b=m(""),c=m(""),f=m({type:"object",properties:{},required:[],additionalProperties:!1}),$=m(""),N=m(!1),E=m(!1),L=m(""),V=m(""),A=m([]),G=m(!1),ee=m(null),ie=m("auto"),be=m(""),Q=m(null),U=m(!1),R=m(!1),K=m([]),H=m([]),ve=m(""),X=m([]),D=m({}),W=m([]),me=m(!1),ue=m({}),te=m([]);let Y=null,ae=0;const ye=q(()=>{const Se=new Set;for(const xe of W.value)Se.add(xe.property);for(const xe of X.value){const Pe=xe.name?.trim();Pe&&Se.add(Pe)}return Array.from(Se).sort((xe,Pe)=>xe.localeCompare(Pe))}),Te=(Se,xe)=>{const Pe=!!xe?.pruneRemoved,Me=Se.map(Ke=>Ke.property),Fe=new Set(Me),Ze=Pe?te.value.filter(Ke=>!Fe.has(Ke)):[];if(Ze.length>0){const Ke=new Set(Ze);let nt=!1;const je={...D.value};for(const T of Ke)T in je&&(delete je[T],nt=!0);nt&&(D.value=je);const le=X.value.filter(T=>{const B=T.name?.trim();return!B||!Ke.has(B)});le.length!==X.value.length&&(X.value=le)}W.value=Se,te.value=Me},ne=q(()=>{const Se=new Set(K.value);return H.value.filter(xe=>!Se.has(xe.id)).map(xe=>({value:xe.id,label:xe.id,attrs:{description:xe.hook}}))}),ke=Se=>{Se&&(K.value.includes(Se)||(K.value=[...K.value,Se],Ne(()=>{ve.value=""})))},_e=m(null),O=Se=>{_e.value=Se},j={sparkles:"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z'/%3E%3Cpath d='M20 3v4'/%3E%3Cpath d='M22 5h-4'/%3E%3C/svg%3E",ban:"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpath d='m4.9 4.9 14.2 14.2'/%3E%3C/svg%3E",checkCircle:"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpath d='m9 12 2 2 4-4'/%3E%3C/svg%3E",target:"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Ccircle cx='12' cy='12' r='6'/%3E%3Ccircle cx='12' cy='12' r='2'/%3E%3C/svg%3E",signalNone:"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none'%3E%3Crect x='5' y='15' width='3' height='5' rx='1' fill='currentColor' opacity='0.2'/%3E%3Crect x='10.5' y='10' width='3' height='10' rx='1' fill='currentColor' opacity='0.2'/%3E%3Crect x='16' y='5' width='3' height='15' rx='1' fill='currentColor' opacity='0.2'/%3E%3C/svg%3E",signalLow:"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none'%3E%3Crect x='5' y='15' width='3' height='5' rx='1' fill='currentColor'/%3E%3Crect x='10.5' y='10' width='3' height='10' rx='1' fill='currentColor' opacity='0.2'/%3E%3Crect x='16' y='5' width='3' height='15' rx='1' fill='currentColor' opacity='0.2'/%3E%3C/svg%3E",signalMedium:"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none'%3E%3Crect x='5' y='15' width='3' height='5' rx='1' fill='currentColor'/%3E%3Crect x='10.5' y='10' width='3' height='10' rx='1' fill='currentColor'/%3E%3Crect x='16' y='5' width='3' height='15' rx='1' fill='currentColor' opacity='0.2'/%3E%3C/svg%3E",signalHigh:"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none'%3E%3Crect x='5' y='15' width='3' height='5' rx='1' fill='currentColor'/%3E%3Crect x='10.5' y='10' width='3' height='10' rx='1' fill='currentColor'/%3E%3Crect x='16' y='5' width='3' height='15' rx='1' fill='currentColor'/%3E%3C/svg%3E"},z=q(()=>{const Se=[{value:"auto",label:"Auto",description:"Model decides",icon:j.sparkles},{value:"none",label:"None",description:"No tools allowed",icon:j.ban},{value:"required",label:"Required",description:"Must call a tool",icon:j.checkCircle}];return y.value&&Se.push({value:"function",label:"Function",description:"Call specific tool",icon:j.target}),Se}),M=[{value:"",label:"None",description:"Disabled",icon:j.signalNone},{value:"low",label:"Low",description:"~20% of max_tokens",icon:j.signalLow},{value:"medium",label:"Medium",description:"~50% of max_tokens",icon:j.signalMedium},{value:"high",label:"High",description:"~80% of max_tokens",icon:j.signalHigh}],P=()=>{d.value="",_.value="",b.value="",c.value="",v.value=null,f.value={type:"object",properties:{},required:[],additionalProperties:!1},$.value="",N.value=!1,E.value=!1,L.value="",V.value="",A.value=[],G.value=!1,ie.value="auto",be.value="",Q.value=null,U.value=!1,R.value=!1,K.value=[],X.value=[],D.value={},W.value=[],te.value=[],me.value=!1},re=async Se=>{if(!Se){v.value=null;return}try{const xe=await lt(`/models/${encodeURIComponent(Se)}`);if(xe.ok){const Pe=await xe.json();v.value=Pe.model||Pe}}catch(xe){console.error("Error fetching model info:",xe),v.value=null}};Ee(c,async Se=>{Se?await re(Se):v.value=null});const se=async()=>{try{const Se=await lt("/hooks");if(Se.ok){const xe=await Se.json();H.value=xe.hooks||[]}}catch(Se){console.error("Error fetching hooks:",Se),H.value=[]}},Ie=async()=>{try{const Se=await lt("/tools");Se.ok?ue.value=await Se.json()||{}:ue.value={}}catch(Se){console.error("Error fetching tool catalog:",Se),ue.value={}}},he=Se=>{if(!Se||Se.startsWith("provider:")||Se.startsWith("mcp:"))return null;const xe=ue.value[Se];return xe?.type==="prompt"?{type:"prompt",name:Se}:xe?.type==="handoff"||xe?.type==="subagent"||xe?.type==="agent"?{type:"agent",name:Se}:{type:"tool",name:Se}},ge=()=>{if(!$.value)return[];const Se=[];try{const xe=JSON.parse($.value);if(!Array.isArray(xe))return[];for(const Pe of xe){if(!Pe||typeof Pe!="object")continue;const Me=Pe.type;Me==="prompt"&&typeof Pe.id=="string"&&Pe.id.trim()&&Se.push({type:"prompt",name:Pe.id.trim()}),Me==="include"&&typeof Pe.prompt=="string"&&Pe.prompt.trim()&&Se.push({type:"prompt",name:Pe.prompt.trim()})}}catch{}return Se},Oe=()=>{const Se=new Map;for(const xe of A.value){const Pe=he(xe.name);Pe&&Se.set(`${Pe.type}:${Pe.name}`,Pe)}for(const xe of ge())Se.set(`${xe.type}:${xe.name}`,xe);return Array.from(Se.values())},Z=Se=>`/variables/${Se.type==="agent"?"agents":`${Se.type}s`}/${encodeURIComponent(Se.name)}`,oe=async()=>{if(!s.modelValue)return;const Se=++ae,xe=Oe();let Pe=null,Me=[];if(xe.length>0&&(Pe=xe[0],Me=xe.slice(1)),!Pe){Se===ae&&(Te([],{pruneRemoved:!0}),me.value=!1);return}Se===ae&&(me.value=!0);try{const Fe=Me.length>0?`?include=${encodeURIComponent(JSON.stringify(Me))}`:"",Ze=[Pe,...["tool","prompt","agent"].filter(je=>je!==Pe.type).map(je=>({type:je,name:Pe.name}))];let Ke=null;for(const je of Ze){const le=await lt(`${Z(je)}${Fe}`);if(Se!==ae)return;if(le.ok){Ke=le;break}if(le.status!==404)break}if(!Ke){Se===ae&&Te([],{pruneRemoved:!0});return}const nt=await Ke.json();Se===ae&&Te(nt.variables||[],{pruneRemoved:!0})}catch(Fe){console.error("Error scanning variables for prompt:",Fe),Se===ae&&Te([],{pruneRemoved:!1})}finally{Se===ae&&(me.value=!1)}},Le=()=>{Y&&clearTimeout(Y),Y=setTimeout(()=>{Y=null,oe()},0)},$e=async()=>{if(s.editPrompt?.id){i.value=!0;try{const Se=await lt(`/prompts/${encodeURIComponent(s.editPrompt.id)}`);if(Se.ok){const xe=await Se.json(),Pe=xe.prompt||xe;d.value=Pe.name||"",_.value=Pe.name||"",b.value=Pe.tool_description||"",c.value=Pe.model_id||"",Pe.model_id&&await re(Pe.model_id);let Me=Pe.required_schema;if(typeof Me=="string")try{Me=JSON.parse(Me)}catch{Me=null}f.value=Me||{type:"object",properties:{},required:[],additionalProperties:!1},$.value=Pe.prompt||"",N.value=Pe.include_chat||!1,E.value=Pe.include_past_tools||!1,L.value=Pe.before_tool||"",V.value=Pe.after_tool||"";const Fe=Pe.tools||[];A.value=Fe.map(Ke=>{if(typeof Ke=="string")return{name:Ke,include_text_response:!0,include_tool_calls:!0,include_errors:!0,init_user_message_property:null,init_attachments_property:null,tenvs:void 0};const nt=Ke.env??Ke.tenvs;return{...Ke,init_attachments_property:Ke.init_attachments_property??null,tenvs:nt&&typeof nt=="object"?nt:void 0}}),G.value=Pe.parallel_tool_calls||!1,ie.value=Pe.tool_choice||"auto";const Ze=Pe.reasoning||{};be.value=Ze.effort||Pe.reasoning_effort||"",Q.value=Ze.maxTokens||Pe.reasoning_max_tokens||null,U.value=Ze.exclude||Pe.reasoning_exclude||!1,R.value=Ze.include||Pe.include_reasoning||!1,K.value=Pe.hooks||[],X.value=Array.isArray(Pe.variables)?Pe.variables.map(Ke=>({name:Ke.name||"",type:Ke.type==="secret"?"secret":"text",required:!!Ke.required,description:Ke.description||""})):[],D.value=(Pe.env&&typeof Pe.env=="object"?Pe.env:null)||(Pe.tenvs&&typeof Pe.tenvs=="object"?Pe.tenvs:null)||{},await oe()}}catch(Se){console.error("Error loading prompt data:",Se)}finally{i.value=!1}}},Ye=async()=>{Uv(_e.value),ee.value?.removeUnavailableTools();const Se={name:d.value,tool_description:b.value,prompt:$.value,required_schema:f.value,model_id:c.value,include_chat:N.value,include_past_tools:E.value,before_tool:L.value||null,after_tool:V.value||null,parallel_tool_calls:G.value,tool_choice:ie.value,tools:A.value,reasoning_effort:be.value||null,reasoning_max_tokens:Q.value,reasoning_exclude:U.value,include_reasoning:R.value,hooks:K.value.length>0?K.value:null,variables:X.value,env:D.value};u.value&&s.editPrompt?.id&&(Se.id=s.editPrompt.id,_.value&&_.value!==d.value&&(Se.originalName=_.value)),l("save",Se)},et=()=>{P(),l("update:modelValue",!1)};return Ee(()=>A.value.length,Se=>{ie.value==="function"&&Se!==1&&(ie.value="auto")}),Ee(()=>s.modelValue,async Se=>{Se?(await Promise.all([se(),Ie()]),u.value?(P(),await Ne(),await $e()):(P(),await oe())):(ae+=1,me.value=!1,Y&&(clearTimeout(Y),Y=null))}),n({formNode:_e}),Ee(()=>s.editPrompt,async Se=>{Se&&u.value&&s.modelValue&&(await Promise.all([se(),Ie()]),await Ne(),await $e())},{immediate:!0}),Ee([A,$],()=>{s.modelValue&&Le()},{deep:!0}),ut(()=>{ae+=1,Y&&(clearTimeout(Y),Y=null)}),(Se,xe)=>{const Pe=tt("FormKit");return r(),J(st,{"model-value":t.modelValue,"onUpdate:modelValue":xe[19]||(xe[19]=Me=>Se.$emit("update:modelValue",Me)),title:u.value?"Edit Prompt":"Add Prompt",width:"max-w-5xl","content-padding":!1},{default:F(()=>[i.value?(r(),o("div",K2,[...xe[20]||(xe[20]=[e("span",{class:"text-neutral-500"},"Loading prompt data...",-1)])])):(r(),J(Pe,{key:1,type:"form",id:"prompt-form",actions:!1,disabled:t.readonly,onSubmit:Ye,onNode:O,"form-class":"$reset flex-1 min-h-0 flex flex-col"},{default:F(()=>[e("div",J2,[e("nav",G2,[w(I(qa),{tabs:g,"active-tab":I(k),onSelect:I(h)},null,8,["active-tab","onSelect"])]),e("div",{ref_key:"contentRef",ref:p,class:"flex-1 overflow-y-auto p-5 bg-neutral-100 dark:bg-neutral-950"},[e("div",Y2,[w(I(ft),{id:"section-basics",title:"Basics",icon:I(lr)},{default:F(()=>[e("div",Z2,[w(R2,{name:d.value,"onUpdate:name":xe[0]||(xe[0]=Me=>d.value=Me),"tool-description":b.value,"onUpdate:toolDescription":xe[1]||(xe[1]=Me=>b.value=Me)},null,8,["name","tool-description"]),w(D2,{modelValue:c.value,"onUpdate:modelValue":xe[2]||(xe[2]=Me=>c.value=Me)},null,8,["modelValue"])])]),_:1},8,["icon"]),w(I(ft),{id:"section-schema",title:"Schema",icon:I(oa)},{default:F(()=>[w(Pe,{type:"schemaEditor",modelValue:f.value,"onUpdate:modelValue":xe[3]||(xe[3]=Me=>f.value=Me),label:"","outer-class":"$reset"},null,8,["modelValue"])]),_:1},8,["icon"]),w(I(ft),{id:"section-prompt",title:"Prompt",icon:I(or)},{footer:F(()=>[...xe[21]||(xe[21]=[e("p",{class:"text-xs text-neutral-500 dark:text-neutral-400"},[de(" Type "),e("kbd",{class:"px-1.5 py-0.5 rounded bg-neutral-200 dark:bg-neutral-700 font-mono text-xs"},"@"),de(" to insert schema properties, env variables, or other prompts ")],-1)])]),default:F(()=>[w(U2,{"prompt-text":$.value,"onUpdate:promptText":xe[4]||(xe[4]=Me=>$.value=Me),"before-tool":L.value,"onUpdate:beforeTool":xe[5]||(xe[5]=Me=>L.value=Me),"after-tool":V.value,"onUpdate:afterTool":xe[6]||(xe[6]=Me=>V.value=Me),"required-schema":JSON.stringify(f.value,null,2),"current-prompt-name":u.value?d.value:void 0,"available-env-variables":ye.value},null,8,["prompt-text","before-tool","after-tool","required-schema","current-prompt-name","available-env-variables"])]),_:1},8,["icon"]),w(I(ft),{id:"section-tools",title:"Tools",icon:I(_r)},{default:F(()=>[A.value.length===0?(r(),o("div",X2,[...xe[22]||(xe[22]=[e("p",{class:"text-sm text-neutral-500 dark:text-neutral-400"}," No tools selected. This prompt will run without tool access. ",-1)])])):S("",!0),w(Pa,{ref_key:"toolSelectorRef",ref:ee,modelValue:A.value,"onUpdate:modelValue":xe[7]||(xe[7]=Me=>A.value=Me),"provider-id":v.value?.provider_id||v.value?.provider,"model-id":v.value?.model,"available-env-variables":ye.value},null,8,["modelValue","provider-id","model-id","available-env-variables"])]),_:1},8,["icon"]),w(I(ft),{id:"section-hooks",title:"Hooks",icon:I(sa)},{default:F(()=>[xe[25]||(xe[25]=e("p",{class:"text-sm text-neutral-500 dark:text-neutral-400 mb-4"}," Select hooks to run when this prompt is active. Hooks execute in the order listed. ",-1)),K.value.length>0?(r(),o("div",Q2,[(r(!0),o(we,null,Ae(K.value,Me=>(r(),o("div",{key:Me,class:"flex items-center justify-between p-3 border border-neutral-300 dark:border-neutral-600 rounded-lg"},[e("div",ew,[e("div",tw,C(Me),1),e("div",rw,C(H.value.find(Fe=>Fe.id===Me)?.hook||"unknown"),1)]),e("button",{onClick:Fe=>K.value=K.value.filter(Ze=>Ze!==Me),type:"button",class:"p-1 hover:bg-neutral-200 dark:hover:bg-neutral-800 rounded transition-colors text-neutral-500 hover:text-red-500","aria-label":`Remove ${Me}`},[...xe[23]||(xe[23]=[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,aw)]))),128))])):S("",!0),ne.value.length>0?(r(),J(Pe,{key:1,type:"selectSearch",modelValue:ve.value,"onUpdate:modelValue":xe[8]||(xe[8]=Me=>ve.value=Me),onInput:ke,placeholder:K.value.length>0?"Add another hook...":"Select a hook","search-placeholder":"Search hooks...",options:ne.value,"outer-class":"$reset"},null,8,["modelValue","placeholder","options"])):S("",!0),H.value.length===0?(r(),o("div",nw,[...xe[24]||(xe[24]=[e("p",{class:"text-sm text-neutral-500 dark:text-neutral-400"},[de(" No hooks available. Create hooks in "),e("code",{class:"px-1.5 py-0.5 rounded bg-neutral-200 dark:bg-neutral-700 font-mono text-xs"},"agents/hooks/"),de(" to enable them here. ")],-1)])])):ne.value.length===0&&K.value.length>0?(r(),o("div",ow," All available hooks are selected. ")):S("",!0)]),_:1},8,["icon"]),w(I(ft),{id:"section-variables",title:"Variables",icon:I(qt)},{default:F(()=>[xe[26]||(xe[26]=e("p",{class:"text-sm text-neutral-500 dark:text-neutral-400 mb-4"}," Environment variables required by tools used in this prompt. Values set here are the lowest priority and can be overridden by agents, instances, users, or threads. ",-1)),me.value?(r(),o("div",lw," Scanning variables... ")):S("",!0),w(Ha,{modelValue:D.value,"onUpdate:modelValue":xe[9]||(xe[9]=Me=>D.value=Me),declarations:X.value,"onUpdate:declarations":xe[10]||(xe[10]=Me=>X.value=Me),scanned:W.value,"allow-declaration-edit":!0,"allow-secret-values":!1,"allow-secret-declarations":!0,"require-required-values":!1,disabled:t.readonly},null,8,["modelValue","declarations","scanned","disabled"])]),_:1},8,["icon"]),w(I(ft),{id:"section-behavior",title:"Behavior",icon:I(la)},{default:F(()=>[e("div",sw,[w(I(Ut),{title:"Tool Behavior",class:"mb-4"}),e("div",iw,[e("div",null,[w(Pe,{type:"selectSearch",name:"tool_choice",modelValue:ie.value,"onUpdate:modelValue":xe[11]||(xe[11]=Me=>ie.value=Me),label:"Tool Choice",options:z.value,placeholder:"Select tool choice","outer-class":"$reset"},null,8,["modelValue","options"]),w(I(Ue),{class:"mt-1"},{default:F(()=>[...xe[27]||(xe[27]=[de(" Controls whether and how the model can call tools ",-1)])]),_:1})]),e("div",uw,[xe[29]||(xe[29]=e("div",{class:"h-7"},null,-1)),w(Pe,{type:"checkbox",name:"parallel_tool_calls",modelValue:G.value,"onUpdate:modelValue":xe[12]||(xe[12]=Me=>G.value=Me),label:"Allow parallel tool calls","outer-class":"$reset"},null,8,["modelValue"]),w(I(Ue),{class:"mt-1"},{default:F(()=>[...xe[28]||(xe[28]=[de(" Allow the model to call multiple tools simultaneously ",-1)])]),_:1})])])]),e("div",dw,[w(I(Ut),{title:"Context"}),w(Pe,{type:"checkbox",name:"include_chat",modelValue:N.value,"onUpdate:modelValue":xe[13]||(xe[13]=Me=>N.value=Me),label:"Include chat history",help:"Expose chat history to the LLM when this prompt is used as a full prompt","outer-class":"$reset"},null,8,["modelValue"]),w(Pe,{type:"checkbox",name:"include_past_tools",modelValue:E.value,"onUpdate:modelValue":xe[14]||(xe[14]=Me=>E.value=Me),label:"Include past tool calls",help:"Include prior tool call history in this prompt","outer-class":"$reset"},null,8,["modelValue"]),w(Pe,{type:"checkbox",name:"include_reasoning",modelValue:R.value,"onUpdate:modelValue":xe[15]||(xe[15]=Me=>R.value=Me),label:"Include reasoning in history",help:"Include reasoning_details from previous responses","outer-class":"$reset"},null,8,["modelValue"])]),e("div",cw,[w(I(Ut),{title:"Reasoning",class:"mb-2"}),xe[31]||(xe[31]=e("p",{class:"text-xs text-neutral-500 dark:text-neutral-400 mb-4"}," Configure extended reasoning for models like o1, o3, Gemini Thinking, and others. Reasoning is enabled automatically when either field is set. ",-1)),e("div",pw,[e("div",null,[w(Pe,{type:"selectSearch",name:"reasoning_effort",modelValue:be.value,"onUpdate:modelValue":xe[16]||(xe[16]=Me=>be.value=Me),label:"Reasoning Effort",options:M,placeholder:"Select reasoning effort","outer-class":"$reset"},null,8,["modelValue"]),w(I(Ue),{class:"mt-1"},{default:F(()=>[...xe[30]||(xe[30]=[de(" Controls reasoning capacity. Supported by OpenAI o-series and Grok. ",-1)])]),_:1})]),w(Pe,{type:"unit",name:"reasoning_max_tokens",modelValue:Q.value,"onUpdate:modelValue":xe[17]||(xe[17]=Me=>Q.value=Me),label:"Max Reasoning Tokens",min:0,step:1,decimals:0,validation:"min:1024|max:32000","validation-messages":{min:"Recommended minimum is 1,024 tokens",max:"Recommended maximum is 32,000 tokens"},"validation-visibility":"live",placeholder:"Leave empty to disable",help:"Specify reasoning token limit (1024-32000)","outer-class":"$reset"},null,8,["modelValue"])]),w(Pe,{type:"checkbox",name:"reasoning_exclude",modelValue:U.value,"onUpdate:modelValue":xe[18]||(xe[18]=Me=>U.value=Me),label:"Exclude reasoning from response",help:"Use reasoning internally but don't return it in the response (saves tokens and cost)","outer-class":"$reset"},null,8,["modelValue"])])]),_:1},8,["icon"])])],512)]),e("div",mw,[e("div",vw,[w(I(Je),{variant:"ghost",size:"sm",onClick:et},{default:F(()=>[de(C(t.readonly?"Close":"Cancel"),1)]),_:1}),t.readonly?S("",!0):(r(),o("div",fw,[w(I(Sr),{node:_e.value||void 0},null,8,["node"]),w(I(Je),{variant:"primary",size:"sm",disabled:i.value,loading:i.value,type:"submit",form:"prompt-form"},{default:F(()=>[de(C(u.value?"Update Prompt":"Create Prompt"),1)]),_:1},8,["disabled","loading"])]))])])]),_:1},8,["disabled"]))]),_:1},8,["model-value","title"])}}}),gw={key:0,class:"mb-5 rounded-lg border border-amber-200 dark:border-amber-800 bg-amber-50 dark:bg-amber-950/30 px-4 py-3 text-sm text-amber-800 dark:text-amber-200"},hw=Ce({__name:"PromptsView",setup(t){const n=Ot(),a=Tt(),s=m(!1),l=m(null),u=m(null),i=dr();Ee(()=>a.query.refresh,()=>{a.query.refresh&&(l.value?.refresh(),n.replace({path:"/prompts",query:{}}))});const p=()=>{s.value=!0},x=h=>{n.push(`/prompts/${h.id}`)},k=async h=>{try{const g=await fetch(Ve("/api/prompts"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(h)});if(g.ok)s.value=!1,await new Promise(y=>setTimeout(y,100)),await l.value?.refresh();else{const y=await g.json();Ft(y,u.value?.formNode)||alert(y.error||"Failed to create prompt")}}catch(g){console.error("Error creating prompt:",g),alert("Failed to create prompt")}};return(h,g)=>(r(),J(Et,null,{default:F(()=>[I(i)?S("",!0):(r(),o("div",gw," Configuration is read-only in production. To make changes, edit your configuration files locally and deploy. ")),w(L2,{ref_key:"dataTableRef",ref:l,title:"Prompts",description:"Define and manage prompt templates for your agents.","primary-action":I(i)?{label:"Create Prompt",icon:I(cr),handler:p}:void 0,readonly:!I(i),onAdd:p,onEdit:x},null,8,["primary-action","readonly"]),w(Za,{ref_key:"promptModalRef",ref:u,modelValue:s.value,"onUpdate:modelValue":g[0]||(g[0]=y=>s.value=y),mode:"add",onSave:k},null,8,["modelValue"])]),_:1}))}}),bw={class:"p-8"},xw={key:0,class:"flex items-center justify-center min-h-[400px]"},yw={key:2,class:"flex items-center justify-center min-h-[400px]"},kw=Ce({__name:"PromptEditView",setup(t){const n=dr(),a=Ot(),s=Tt(),l=m(!0),u=m(null),i=m(!0),p=m(null),x=async()=>{const g=s.params.id;if(!g){a.push("/prompts");return}i.value=!0;try{const y=await fetch(Ve(`/api/prompts/${encodeURIComponent(g)}`));if(y.ok){const _=await y.json();u.value=_.prompt||_}else alert("Prompt not found"),a.push("/prompts")}catch(y){console.error("Error loading prompt:",y),alert("Failed to load prompt"),a.push("/prompts")}finally{i.value=!1}},k=async g=>{try{const{originalName:y,..._}=g,v=y||_.id,d=await fetch(Ve(`/api/prompts/${encodeURIComponent(v)}`),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(_)});if(d.ok)a.push({path:"/prompts",query:{refresh:Date.now().toString()}});else{const b=await d.json();Ft(b,p.value?.formNode)||alert(b.error||"Failed to update prompt")}}catch(y){console.error("Error updating prompt:",y),alert("Failed to update prompt")}},h=g=>{g||a.push("/prompts")};return qe(()=>{x()}),Ee(l,g=>{g||a.push("/prompts")}),(g,y)=>(r(),o("div",bw,[i.value?(r(),o("div",xw,[...y[1]||(y[1]=[e("span",{class:"text-neutral-500"},"Loading prompt...",-1)])])):u.value?(r(),J(Za,{key:1,ref_key:"promptModalRef",ref:p,modelValue:l.value,"onUpdate:modelValue":[y[0]||(y[0]=_=>l.value=_),h],mode:"edit","edit-prompt":u.value,readonly:!I(n),onSave:k},null,8,["modelValue","edit-prompt","readonly"])):(r(),o("div",yw,[...y[2]||(y[2]=[e("span",{class:"text-neutral-500"},"Prompt not found",-1)])]))]))}}),ww={class:"space-y-4"},_w={key:0},$w={key:1},Cw={class:"px-1 py-0.5 bg-neutral-100 dark:bg-neutral-800 rounded"},Sw={key:2,class:"space-y-3"},Iw={class:"flex items-center justify-between"},Tw={key:0,class:"text-sm text-neutral-500 dark:text-neutral-400"},Mw={key:1,class:"space-y-3"},zw={class:"grid grid-cols-2 gap-x-4 gap-y-2"},Vw={class:"grid grid-cols-2 gap-4"},Ew={key:3,class:"space-y-3"},Lw={key:0,class:"text-sm text-neutral-500 dark:text-neutral-400"},Aw={key:1,class:"grid grid-cols-1 gap-2"},Pw=["value"],jw={class:"flex-1 min-w-0"},Rw={class:"font-medium text-sm"},Ow={class:"text-xs text-neutral-500 dark:text-neutral-400 mt-0.5"},Dw={key:0,class:"mt-1"},Uw={class:"text-xs text-amber-600 dark:text-amber-400"},Bw={key:4,class:"space-y-3"},Nw={class:"flex items-center justify-between"},qw={key:0,class:"flex gap-2"},Fw={key:0,class:"flex items-center gap-2 py-4"},Hw={key:1,class:"py-4 text-sm text-neutral-500 dark:text-neutral-400"},Ww={key:2,class:"space-y-2"},Kw=["checked","onChange"],Jw={class:"flex-1 min-w-0"},Gw={class:"flex items-center gap-2"},Yw={class:"font-medium text-sm"},Zw={key:0,class:"px-1.5 py-0.5 text-xs font-medium rounded bg-neutral-100 dark:bg-neutral-800 text-neutral-600 dark:text-neutral-400"},Xw={class:"flex flex-wrap gap-x-4 gap-y-1 mt-1 text-xs text-neutral-500 dark:text-neutral-400"},Qw={key:0},e_={key:1},t_={key:5,class:"space-y-3"},r_={class:"flex items-center justify-between gap-4"},a_={key:1},n_={class:"flex gap-2"},o_=Ce({__name:"ModelModal",props:{modelValue:{type:Boolean},editModel:{},mode:{default:"add"},readonly:{type:Boolean,default:!1}},emits:["update:modelValue","save"],setup(t,{expose:n,emit:a}){const s=t,l=a,u=m([]),i=m(""),p=m(""),x=m([]),k=m(!1),h=m(!1),g=m([]),y=m([]),_=m(!1),v=m({supportsImages:!1,supportsToolCalls:!0,supportsStreaming:!0,supportsJsonMode:!0}),d=m(null),b=m(!1),c=m([]),f=m([]),$=m(!1),N=m([]),E=m(!1),L=q(()=>N.value.map(he=>({value:he.id,label:he.name,description:he.provider_id||he.provider,icon:he.iconId}))),V=async()=>{E.value=!0;try{const he=await fetch(Ve("/api/models"));if(he.ok){const ge=await he.json();N.value=ge.models||[]}}catch(he){console.error("Error fetching configured models:",he)}finally{E.value=!1}},A=m([]),G=q(()=>s.mode==="edit"),ee=m(null),ie=m(!0),be=m(!1),Q=he=>{ee.value=he,he.on("commit",()=>{ie.value=he.context?.state.valid??!0,be.value=he.context?.state.submitted??!1})},U=m(""),R=m(""),K=he=>{let ge=he.replace(/[^a-zA-Z0-9\s_-]/g,"");return ge=ge.trim().toLowerCase().replace(/[\s-]+/g,"_").replace(/_+/g,"_").replace(/^_|_$/g,""),ge},H=he=>{R.value=K(he)},ve=m(!1),X=m(null),D=q(()=>u.value.filter(he=>he.hasApiKey).map(he=>({value:he.name,label:he.name,description:he.sdk==="cerebras"?"Cerebras":he.sdk==="openai-sdk"?"OpenAI SDK":he.sdk==="openrouter"?"OpenRouter":he.sdk,icon:he.iconId}))),W=q(()=>x.value.map(he=>({...he,icon:he.iconId}))),me=q(()=>!G.value||!X.value||ve.value?!1:R.value!==X.value.name||i.value!==X.value.provider||p.value!==X.value.model||JSON.stringify(y.value.sort())!==JSON.stringify(X.value.endpoints.sort())||JSON.stringify(A.value)!==JSON.stringify(X.value.fallbacks)||JSON.stringify(v.value)!==JSON.stringify(X.value.capabilities)||JSON.stringify(f.value.sort())!==JSON.stringify(X.value.providerTools.sort())),ue=q(()=>u.value.find(ge=>ge.name===i.value)?.sdk==="openrouter"),te=async()=>{k.value=!0;try{const he=await fetch(Ve("/api/providers"));if(he.ok){const ge=await he.json();u.value=ge.providers||[]}}catch(he){console.error("Error fetching providers:",he)}finally{k.value=!1}},Y=async()=>{if(!i.value){x.value=[];return}h.value=!0;try{const he=await fetch(Ve("/api/models/available"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:i.value})});if(he.ok){const ge=await he.json();x.value=ge.models||[]}else{const ge=await he.json();console.error("Error fetching models:",ge),x.value=[],alert(ge.error||"Failed to fetch available models")}}catch(he){console.error("Error fetching models:",he),x.value=[]}finally{h.value=!1}},ae=async()=>{if(!(!i.value||!p.value)){b.value=!0;try{const he=await fetch(Ve("/api/models/capabilities"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:i.value,modelId:p.value})});if(he.ok){const ge=await he.json();ge.capabilities&&(d.value=ge.capabilities,v.value={supportsImages:ge.capabilities.supportsImages??!1,supportsToolCalls:ge.capabilities.supportsToolCalls??!0,supportsStreaming:ge.capabilities.supportsStreaming??!0,supportsJsonMode:ge.capabilities.supportsJsonMode??!0,maxContextTokens:ge.capabilities.maxContextTokens,maxOutputTokens:ge.capabilities.maxOutputTokens})}}catch(he){console.error("Error fetching capabilities:",he)}finally{b.value=!1}}},ye=async()=>{if(!i.value||!p.value){c.value=[];return}$.value=!0;try{const he=await fetch(Ve(`/api/providers/${i.value}/tools?model=${encodeURIComponent(p.value)}`));if(he.ok){const ge=await he.json();c.value=ge.tools||[],G.value||(f.value=c.value.map(Oe=>Oe.name))}else c.value=[]}catch(he){console.error("Error fetching provider tools:",he),c.value=[]}finally{$.value=!1}},Te=()=>{v.value={supportsImages:!1,supportsToolCalls:!0,supportsStreaming:!0,supportsJsonMode:!0},d.value=null},ne=he=>{const ge=y.value.indexOf(he);ge===-1?y.value.push(he):y.value.splice(ge,1)},ke=()=>{y.value=g.value.map(he=>he.id)},_e=()=>{y.value=[]},O=he=>{const ge=he*1e6;return ge>=1?`$${ge.toFixed(2)}/M`:`$${ge.toFixed(4)}/M`},j=()=>{d.value&&(v.value={supportsImages:d.value.supportsImages??!1,supportsToolCalls:d.value.supportsToolCalls??!0,supportsStreaming:d.value.supportsStreaming??!0,supportsJsonMode:d.value.supportsJsonMode??!0,maxContextTokens:d.value.maxContextTokens,maxOutputTokens:d.value.maxOutputTokens})},z=()=>{R.value="",U.value="",i.value="",p.value="",x.value=[],A.value=[],g.value=[],y.value=[],c.value=[],f.value=[],Te(),X.value=null,ve.value=!1,ie.value=!0,be.value=!1,ee.value?.reset()},M=async()=>{if(s.editModel){ve.value=!0;try{await te(),R.value=s.editModel.name||"",U.value=s.editModel.name||"",i.value=s.editModel.provider_id||s.editModel.provider,await Y(),p.value=s.editModel.model,await re(),s.editModel.included_providers&&s.editModel.included_providers.length>0&&(y.value=s.editModel.included_providers),await P(),s.editModel.capabilities?v.value={supportsImages:s.editModel.capabilities.supportsImages??!1,supportsToolCalls:s.editModel.capabilities.supportsToolCalls??!0,supportsStreaming:s.editModel.capabilities.supportsStreaming??!0,supportsJsonMode:s.editModel.capabilities.supportsJsonMode??!0,maxContextTokens:s.editModel.capabilities.maxContextTokens,maxOutputTokens:s.editModel.capabilities.maxOutputTokens}:await ae(),await ye(),s.editModel.providerTools&&Array.isArray(s.editModel.providerTools)&&(f.value=s.editModel.providerTools),X.value={name:R.value,provider:i.value,model:p.value,endpoints:[...y.value],fallbacks:[...A.value],capabilities:{...v.value},providerTools:[...f.value]}}finally{ve.value=!1}}};Ee(()=>s.modelValue,async he=>{he?(V(),G.value&&s.editModel?await M():(await te(),z())):z()});const P=async()=>{if(s.editModel?.id){if(s.editModel.fallbacks&&Array.isArray(s.editModel.fallbacks)){A.value=s.editModel.fallbacks.map(he=>typeof he=="string"?he:he.id);return}try{const he=await fetch(Ve(`/api/models/${encodeURIComponent(s.editModel.id)}/fallbacks`));if(he.ok){const ge=await he.json();A.value=ge.fallbacks.map(Oe=>Oe.fallback_model_id)}}catch(he){console.error("Error loading fallbacks:",he)}}};Ee(i,async(he,ge)=>{ve.value||G.value&&!ge&&he===(s.editModel?.provider_id||s.editModel?.provider)||(p.value="",g.value=[],y.value=[],i.value&&await Y())});const re=async()=>{if(!p.value||!i.value){g.value=[];return}const he=u.value.find(Oe=>Oe.name===i.value);if(!he||he.sdk!=="openrouter"){g.value=[];return}const ge=W.value.find(Oe=>Oe.value===p.value);if(!ge?.slug){console.error("Model slug not found"),g.value=[];return}_.value=!0;try{const Oe=await fetch(Ve("/api/models/endpoints"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:i.value,modelSlug:ge.slug})});if(Oe.ok){const Z=await Oe.json();g.value=Z.endpoints||[],G.value||(y.value=g.value.map(oe=>oe.id))}else{const Z=await Oe.json();console.error("Error fetching endpoints:",Z),g.value=[]}}catch(Oe){console.error("Error fetching endpoints:",Oe),g.value=[]}finally{_.value=!1}};Ee(p,async(he,ge)=>{ve.value||G.value&&!ge&&he===s.editModel?.model||(p.value?(await re(),await ae(),await ye(),ge&&he!==ge&&(y.value=g.value.map(Oe=>Oe.id))):(g.value=[],y.value=[],c.value=[],f.value=[],Te()))});const se=()=>{const he=ue.value?y.value:[],ge={name:R.value,model:p.value,provider:i.value,included_providers:he,fallbacks:A.value,capabilities:v.value,providerTools:f.value};G.value&&s.editModel?.id&&(ge.id=s.editModel.id,U.value&&U.value!==R.value&&(ge.originalName=U.value)),l("save",ge)};n({formNode:ee});const Ie=()=>{z(),l("update:modelValue",!1)};return(he,ge)=>{const Oe=tt("FormKit");return r(),J(st,{"model-value":t.modelValue,"onUpdate:modelValue":ge[10]||(ge[10]=Z=>he.$emit("update:modelValue",Z)),title:G.value?"Edit Model":"Add Model",width:"max-w-2xl","min-height":"min-h-[36rem]","has-changes":me.value},{footer:F(()=>[e("div",r_,[!t.readonly&&be.value&&!ie.value?(r(),J(I(kt),{key:0},{default:F(()=>[...ge[22]||(ge[22]=[de(" Please fix the errors above before submitting. ",-1)])]),_:1})):(r(),o("div",a_)),e("div",n_,[w(I(Je),{variant:"ghost",size:"sm",onClick:Ie},{default:F(()=>[de(C(t.readonly?"Close":"Cancel"),1)]),_:1}),t.readonly?S("",!0):(r(),J(I(Je),{key:0,variant:"primary",size:"sm",type:"submit",form:"model-form"},{default:F(()=>[de(C(G.value?"Update Model":"Add Model"),1)]),_:1}))])])]),default:F(()=>[w(Oe,{type:"form",id:"model-form",actions:!1,disabled:t.readonly,onSubmit:se,onNode:Q},{default:F(()=>[e("div",ww,[w(Oe,{type:"selectSearch",name:"provider",modelValue:i.value,"onUpdate:modelValue":ge[0]||(ge[0]=Z=>i.value=Z),options:D.value,label:"Provider",placeholder:"Select a provider",disabled:k.value||G.value&&!!s.editModel,validation:"required","validation-visibility":"submit"},null,8,["modelValue","options","disabled"]),i.value?(r(),o("div",_w,[w(Oe,{type:"selectSearch",name:"model",modelValue:p.value,"onUpdate:modelValue":ge[1]||(ge[1]=Z=>p.value=Z),options:W.value,label:"Model",placeholder:"Select a model","search-placeholder":"Search models...",loading:h.value,validation:"required","validation-visibility":"submit"},null,8,["modelValue","options","loading"])])):S("",!0),p.value?(r(),o("div",$w,[w(Oe,{type:"text",name:"name","model-value":R.value,onInput:H,label:"Name",placeholder:"e.g., coding_model, planning_model, fast_response",validation:"required|snakeCase","validation-visibility":"blur",help:R.value?void 0:"A descriptive name for this model. This becomes the filename and reference ID."},null,8,["model-value","help"]),R.value?(r(),J(I(Ue),{key:0,class:"mt-1"},{default:F(()=>[ge[11]||(ge[11]=de(" Will be saved as: ",-1)),e("code",Cw,C(R.value),1)]),_:1})):S("",!0)])):S("",!0),p.value?(r(),o("div",Sw,[e("div",Iw,[ge[12]||(ge[12]=e("label",{class:"block text-sm font-medium"},"Model Capabilities",-1)),d.value?(r(),o("button",{key:0,onClick:j,type:"button",class:"text-xs text-accent-600 dark:text-accent-400 hover:underline"}," Reset to detected ")):S("",!0)]),ge[13]||(ge[13]=e("p",{class:"text-xs text-neutral-500 dark:text-neutral-400 -mt-1"}," Auto-detected from the provider. Override if needed. ",-1)),b.value?(r(),o("div",Tw," Detecting capabilities... ")):(r(),o("div",Mw,[e("div",zw,[w(Oe,{type:"checkbox",modelValue:v.value.supportsImages,"onUpdate:modelValue":ge[2]||(ge[2]=Z=>v.value.supportsImages=Z),label:"Vision/Images"},null,8,["modelValue"]),w(Oe,{type:"checkbox",modelValue:v.value.supportsToolCalls,"onUpdate:modelValue":ge[3]||(ge[3]=Z=>v.value.supportsToolCalls=Z),label:"Tool Calls"},null,8,["modelValue"]),w(Oe,{type:"checkbox",modelValue:v.value.supportsStreaming,"onUpdate:modelValue":ge[4]||(ge[4]=Z=>v.value.supportsStreaming=Z),label:"Streaming"},null,8,["modelValue"]),w(Oe,{type:"checkbox",modelValue:v.value.supportsJsonMode,"onUpdate:modelValue":ge[5]||(ge[5]=Z=>v.value.supportsJsonMode=Z),label:"JSON Mode"},null,8,["modelValue"])]),e("div",Vw,[w(Oe,{type:"unit",modelValue:v.value.maxContextTokens,"onUpdate:modelValue":ge[6]||(ge[6]=Z=>v.value.maxContextTokens=Z),label:"Max Context Tokens",placeholder:"e.g., 128,000",unit:"",decimals:"0",step:"1000",min:"0"},null,8,["modelValue"]),w(Oe,{type:"unit",modelValue:v.value.maxOutputTokens,"onUpdate:modelValue":ge[7]||(ge[7]=Z=>v.value.maxOutputTokens=Z),label:"Max Output Tokens",placeholder:"e.g., 16,384",unit:"",decimals:"0",step:"1000",min:"0"},null,8,["modelValue"])])]))])):S("",!0),p.value&&c.value.length>0?(r(),o("div",Ew,[ge[14]||(ge[14]=e("label",{class:"block text-sm font-medium"},"Provider Tools",-1)),ge[15]||(ge[15]=e("p",{class:"text-xs text-neutral-500 dark:text-neutral-400 -mt-1"}," Built-in tools available for this model. ",-1)),$.value?(r(),o("div",Lw," Loading provider tools... ")):(r(),o("div",Aw,[(r(!0),o(we,null,Ae(c.value,Z=>(r(),o("label",{key:Z.name,class:ce(["flex items-start gap-3 p-3 border rounded cursor-pointer hover:bg-neutral-50 dark:hover:bg-neutral-800/50 transition-colors",f.value.includes(Z.name)?"border-black dark:border-white":"border-neutral-200 dark:border-neutral-700"])},[He(e("input",{type:"checkbox",value:Z.name,"onUpdate:modelValue":ge[8]||(ge[8]=oe=>f.value=oe),class:"mt-0.5 h-4 w-4 rounded border-neutral-300 dark:border-neutral-600 text-black dark:text-white focus:ring-black dark:focus:ring-white accent-black dark:accent-white"},null,8,Pw),[[Ir,f.value]]),e("div",jw,[e("div",Rw,C(Z.name),1),e("div",Ow,C(Z.description),1),Z.tenvs&&Z.tenvs.length>0?(r(),o("div",Dw,[e("span",Uw," Requires: "+C(Z.tenvs.filter(oe=>oe.required).map(oe=>oe.name).join(", ")||"none (optional config available)"),1)])):S("",!0)])],2))),128))]))])):S("",!0),p.value&&ue.value?(r(),o("div",Bw,[e("div",Nw,[ge[17]||(ge[17]=e("label",{class:"block text-sm font-medium"},"Available Providers",-1)),g.value.length>0?(r(),o("div",qw,[e("button",{type:"button",onClick:ke,class:"text-xs text-accent-600 dark:text-accent-400 hover:underline"}," Select all "),ge[16]||(ge[16]=e("span",{class:"text-xs text-neutral-300 dark:text-neutral-600"},"|",-1)),e("button",{type:"button",onClick:_e,class:"text-xs text-accent-600 dark:text-accent-400 hover:underline"}," Clear ")])):S("",!0)]),ge[19]||(ge[19]=e("p",{class:"text-xs text-neutral-500 dark:text-neutral-400 -mt-1"}," OpenRouter routes to the cheapest available provider. ",-1)),_.value?(r(),o("div",Fw,[w(Be,{class:"w-4 h-4"}),ge[18]||(ge[18]=e("span",{class:"text-sm text-neutral-500 dark:text-neutral-400"},"Loading providers...",-1))])):g.value.length===0?(r(),o("div",Hw," No providers available for this model ")):(r(),o("div",Ww,[(r(!0),o(we,null,Ae(g.value,Z=>(r(),o("label",{key:Z.id,class:ce(["flex items-start gap-3 p-3 border rounded-md cursor-pointer transition-colors",[y.value.includes(Z.id)?"border-accent-500 dark:border-accent-400 bg-accent-50/50 dark:bg-accent-900/20":"border-neutral-200 dark:border-neutral-700 hover:border-neutral-300 dark:hover:border-neutral-600"]])},[e("input",{type:"checkbox",checked:y.value.includes(Z.id),onChange:oe=>ne(Z.id),class:"mt-0.5 h-4 w-4 rounded border-neutral-300 dark:border-neutral-600 text-accent-600 dark:text-accent-500 focus:ring-accent-500 dark:focus:ring-accent-400 accent-accent-600 dark:accent-accent-500"},null,40,Kw),e("div",Jw,[e("div",Gw,[e("span",Yw,C(Z.name),1),Z.quantization&&Z.quantization!=="unknown"?(r(),o("span",Zw,C(Z.quantization),1)):S("",!0)]),e("div",Xw,[e("span",null," Input: "+C(O(Z.pricing.prompt)),1),e("span",null," Output: "+C(O(Z.pricing.completion)),1),Z.maxPromptTokens?(r(),o("span",Qw," Max prompt: "+C(Z.maxPromptTokens.toLocaleString()),1)):S("",!0),Z.maxCompletionTokens?(r(),o("span",e_," Max output: "+C(Z.maxCompletionTokens.toLocaleString()),1)):S("",!0)])])],2))),128))]))])):S("",!0),p.value?(r(),o("div",t_,[ge[20]||(ge[20]=e("label",{class:"block text-sm font-medium"},"Fallback Models",-1)),ge[21]||(ge[21]=e("p",{class:"text-xs text-neutral-500 dark:text-neutral-400 -mt-1"}," Used in order if the primary model fails. ",-1)),w(Oe,{type:"sortableMultiSelect",modelValue:A.value,"onUpdate:modelValue":ge[9]||(ge[9]=Z=>A.value=Z),options:L.value,loading:E.value,placeholder:"Add fallback model...","search-placeholder":"Search models...","add-label":"Add another model"},null,8,["modelValue","options","loading"])])):S("",!0)])]),_:1},8,["disabled"])]),_:1},8,["model-value","title","has-changes"])}}}),l_={key:0,class:"mb-5 rounded-lg border border-amber-200 dark:border-amber-800 bg-amber-50 dark:bg-amber-950/30 px-4 py-3 text-sm text-amber-800 dark:text-amber-200"},s_={class:"flex items-center gap-2"},i_=["src","alt"],u_={class:"text-sm text-neutral-600 dark:text-neutral-400 font-mono"},d_={key:0,class:"space-y-0.5"},c_=["title"],p_={class:"shrink-0 font-mono pr-2"},m_=["src","alt"],v_={class:"truncate"},f_={key:1,class:"text-neutral-400 dark:text-neutral-600 text-sm"},g_=Ce({__name:"ModelsView",setup(t){const n=m(!1),a=m([]),s=m(!1),l=m(null),u=m("add"),i=m(null),p=dr(),x=[{key:"name",label:"Name",width:"w-1/4",sortable:!0},{key:"model",label:"Model",width:"w-1/4",sortable:!0,filterable:!0,filterIcon:(b,c)=>`/api/providers/${c.provider}/icon?model=${encodeURIComponent(c.model||"")}`},{key:"provider",label:"Provider",width:"w-1/4",sortable:!0,filterable:!0,filterIcon:(b,c)=>`/api/providers/${c.provider}/icon`},{key:"fallbacks",label:"Fallbacks",width:"w-1/4"}],k=b=>{l.value=b,u.value="edit",n.value=!0},h=[{icon:"edit",label:"Edit",handler:b=>k(b)},{icon:"delete",label:"Delete",confirm:!0,confirmMessage:"Are you sure you want to delete this model? This action cannot be undone.",variant:"danger",handler:async b=>{await v(b.id)}}],g=q(()=>p?h:h.filter(b=>b.variant!=="danger")),y=async()=>{s.value=!0;try{const b=await fetch(Ve("/api/models"));if(!b.ok)throw new Error("Failed to fetch models");const c=await b.json();a.value=c.models||[]}catch(b){console.error("Error fetching models:",b),a.value=[]}finally{s.value=!1}},_=async b=>{try{if(l.value){const{originalName:c,...f}=b,$=c||l.value.id,N=await fetch(Ve(`/api/models/${encodeURIComponent($)}`),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(f)});if(!N.ok){const E=await N.json();Ft(E,i.value?.formNode)||alert(E.error||"Failed to update model");return}}else{const c=await fetch(Ve("/api/models"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)});if(!c.ok){const f=await c.json();Ft(f,i.value?.formNode)||alert(f.error||"Failed to add model");return}}await y(),n.value=!1,l.value=null,u.value="add"}catch(c){console.error("Error saving model:",c),alert("Failed to save model")}},v=async b=>{try{const c=await fetch(Ve(`/api/models/${encodeURIComponent(b)}`),{method:"DELETE"});if(!c.ok){const f=await c.json();alert(f.error||"Failed to delete model");return}await y()}catch(c){console.error("Error deleting model:",c),alert("Failed to delete model")}},d=()=>{u.value="add",l.value=null,n.value=!0};return qe(()=>{y()}),(b,c)=>(r(),J(Et,null,{default:F(()=>[I(p)?S("",!0):(r(),o("div",l_," Configuration is read-only in production. To make changes, edit your configuration files locally and deploy. ")),w($t,{title:"Models",description:"Configure AI models from your connected providers. Models define which AI capabilities are available to your agents.","primary-action":I(p)?{label:"Add Model",icon:I(cr),handler:d}:void 0,columns:x,data:a.value,actions:g.value,loading:s.value,sortable:"",searchable:"","search-placeholder":"Search models...","empty-message":"No models configured yet. Add your first model to get started.",onRowClick:k},{"cell-name":F(({value:f,row:$})=>[e("div",s_,[$.provider?(r(),o("img",{key:0,src:`/api/providers/${$.provider}/icon?model=${encodeURIComponent($.model||"")}`,class:"w-5 h-5 shrink-0",alt:$.provider},null,8,i_)):S("",!0),e("span",null,C(f),1)])]),"cell-model":F(({value:f})=>[e("span",u_,C(f||"—"),1)]),"cell-fallbacks":F(({value:f})=>[f&&f.length>0?(r(),o("div",d_,[(r(!0),o(we,null,Ae(f,($,N)=>(r(),o("div",{key:$.id,class:"text-sm text-neutral-600 dark:text-neutral-400 flex items-center",title:$.name},[e("span",p_,C(N===f.length-1?"└─":"├─"),1),$.provider?(r(),o("img",{key:0,src:`/api/providers/${$.provider}/icon?model=${encodeURIComponent($.model||"")}`,class:"w-4 h-4 shrink-0 mr-1.5",alt:$.provider},null,8,m_)):S("",!0),e("span",v_,C($.name),1)],8,c_))),128))])):(r(),o("span",f_," None "))]),_:1},8,["primary-action","data","actions","loading"]),w(o_,{ref_key:"modelModalRef",ref:i,modelValue:n.value,"onUpdate:modelValue":[c[0]||(c[0]=f=>n.value=f),c[1]||(c[1]=f=>{n.value=f,f||(l.value=null,u.value="add")})],"edit-model":l.value,mode:u.value,readonly:!I(p),onSave:_},null,8,["modelValue","edit-model","mode","readonly"])]),_:1}))}}),h_={class:"space-y-4"},b_={class:"space-y-1"},x_={class:"relative"},y_={key:0,class:"flex items-center gap-2"},k_=["src","alt"],w_={key:1,class:"text-neutral-500"},__={key:0,class:"absolute z-10 w-full mt-1 bg-white dark:bg-black border-2 border-neutral-300 dark:border-neutral-600 rounded shadow-lg max-h-60 overflow-auto"},$_=["onClick"],C_=["src","alt"],S_={key:0,class:"text-xs text-red-500 dark:text-red-400"},I_={class:"flex gap-2 justify-end"},T_=Ce({__name:"AddProviderModal",props:{modelValue:{type:Boolean}},emits:["update:modelValue","save"],setup(t,{emit:n}){const a=n,s=m([]),l=m(!1),u=m(!1),i=m(""),p=m(""),x=async()=>{l.value=!0;try{const b=await fetch(Ve("/api/providers"));if(b.ok){const c=await b.json();s.value=(c.providers||[]).map(f=>({value:f.name,label:f.label||f.name,icon:f.iconId,sdk:f.sdk}))}}catch(b){console.error("Error fetching providers:",b)}finally{l.value=!1}};qe(()=>{x()});const k=q(()=>s.value.find(b=>b.value===i.value)),h=()=>{setTimeout(()=>{u.value=!1},200)},g=b=>{i.value=b,u.value=!1,p.value=""},y=q(()=>i.value==="custom"||i.value==="openai"),_=m("");Ee(i,b=>{if(b&&!_.value){const c=s.value.find(f=>f.value===b);c&&(_.value=c.label)}});const v=b=>{if(!i.value){p.value="Provider type is required";return}a("save",{name:b.name,type:i.value,apiKey:b.apiKey,baseUrl:b.baseUrl}),d()},d=()=>{nr("add-provider-form"),i.value="",_.value="",p.value="",a("update:modelValue",!1)};return(b,c)=>{const f=tt("FormKit");return r(),J(st,{"model-value":t.modelValue,"onUpdate:modelValue":c[2]||(c[2]=$=>b.$emit("update:modelValue",$)),title:"Add Provider",width:"max-w-md"},{footer:F(()=>[e("div",I_,[w(I(Je),{variant:"ghost",size:"sm",onClick:d},{default:F(()=>[...c[5]||(c[5]=[de(" Cancel ",-1)])]),_:1}),w(I(Je),{variant:"primary",size:"sm",type:"submit",form:"add-provider-form"},{default:F(()=>[...c[6]||(c[6]=[de(" Add Provider ",-1)])]),_:1})])]),default:F(()=>[w(f,{id:"add-provider-form",type:"form",actions:!1,onSubmit:v},{default:F(()=>[e("div",h_,[e("div",b_,[c[4]||(c[4]=e("label",{class:"block text-sm font-medium"},[de(" Provider Type "),e("span",{class:"text-red-500"},"*")],-1)),e("div",x_,[e("button",{type:"button",onClick:c[0]||(c[0]=$=>u.value=!u.value),onBlur:h,class:ce(["w-full px-3 py-2 bg-white dark:bg-black border rounded font-mono text-sm text-left focus:outline-none focus:ring-2 focus:ring-accent-500 dark:focus:ring-accent-400 transition-colors",[p.value?"border-red-500 dark:border-red-400":"border-neutral-300 dark:border-neutral-600"]])},[k.value?(r(),o("div",y_,[e("img",{src:k.value.icon,alt:k.value.label,class:"w-5 h-5"},null,8,k_),e("span",null,C(k.value.label),1)])):(r(),o("span",w_,"Select a provider")),c[3]||(c[3]=e("div",{class:"absolute inset-y-0 right-0 flex items-center px-2 pointer-events-none"},[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:"M19 9l-7 7-7-7"})])],-1))],34),u.value?(r(),o("div",__,[(r(!0),o(we,null,Ae(s.value,$=>(r(),o("button",{key:$.value,type:"button",onClick:N=>g($.value),class:"w-full px-3 py-2 text-left hover:bg-accent-50 dark:hover:bg-accent-900/20 transition-colors flex items-center gap-2"},[e("img",{src:$.icon,alt:$.label,class:"w-5 h-5"},null,8,C_),e("span",null,C($.label),1)],8,$_))),128))])):S("",!0)]),p.value?(r(),o("p",S_,C(p.value),1)):S("",!0)]),w(f,{type:"text",name:"name",label:"Provider Name",placeholder:"e.g., My OpenAI Provider",validation:"required",modelValue:_.value,"onUpdate:modelValue":c[1]||(c[1]=$=>_.value=$),"validation-messages":{required:"Provider name is required"}},null,8,["modelValue"]),w(f,{type:"password",name:"apiKey",label:"API Key",placeholder:"sk-...",validation:"required","validation-messages":{required:"API key is required"}}),y.value?(r(),J(f,{key:0,type:"text",name:"baseUrl",label:"Base URL",placeholder:"https://api.example.com",validation:i.value==="custom"?"required":"","validation-messages":{required:"Base URL is required for custom providers"}},null,8,["validation"])):S("",!0)])]),_:1})]),_:1},8,["model-value"])}}}),M_={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function z_(t,n){return r(),o("svg",M_,[...n[0]||(n[0]=[e("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M20 6L9 17l-5-5"},null,-1)])])}const V_=De({name:"lucide-check",render:z_}),E_={class:"flex items-center gap-2"},L_=["src","alt"],A_={key:0,class:"inline-flex items-center gap-1.5 px-2.5 py-1 text-xs font-medium rounded-full bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400"},P_={key:1,class:"inline-flex items-center gap-1.5 px-2.5 py-1 text-xs font-medium rounded-full bg-neutral-100 text-neutral-500 dark:bg-neutral-800 dark:text-neutral-400"},j_=Ce({__name:"ProvidersView",setup(t){const n=m(!1),a=m([]),s=m(!1),l={cerebras:"Cerebras","openai-sdk":"OpenAI SDK",openrouter:"OpenRouter",openai:"OpenAI"},u=g=>l[g]||g,i=[{key:"name",label:"Name",width:"w-1/3",sortable:!0},{key:"sdk",label:"SDK Type",width:"w-1/3",sortable:!0,formatter:g=>u(g)},{key:"hasApiKey",label:"API Key",width:"w-1/3"}],p=[{icon:"delete",label:"Delete",confirm:!0,confirmMessage:"Are you sure you want to delete this provider? This action cannot be undone.",variant:"danger",handler:async g=>{await h(g.name)}}],x=async()=>{s.value=!0;try{const g=await fetch(Ve("/api/providers"));if(!g.ok)throw new Error("Failed to fetch providers");const y=await g.json();a.value=y.providers||[]}catch(g){console.error("Error fetching providers:",g),a.value=[]}finally{s.value=!1}},k=async g=>{try{const y=await fetch(Ve("/api/providers"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(g)});if(!y.ok){const _=await y.json();alert(_.error||"Failed to add provider");return}await x(),n.value=!1}catch(y){console.error("Error adding provider:",y),alert("Failed to add provider")}},h=async g=>{try{const y=await fetch(Ve(`/api/providers/${encodeURIComponent(g)}`),{method:"DELETE"});if(!y.ok){const _=await y.json();_.modelCount?alert(`${_.error}
46
+ `).trim():""),A=F(()=>{if(!a.log.response_body)return[];try{const D=JSON.parse(a.log.response_body)?.choices?.[0]?.message?.images;return Array.isArray(D)?D:[]}catch{return[]}}),oe=F(()=>{if(!a.log.provider_tools)return[];try{const B=JSON.parse(a.log.provider_tools);return Array.isArray(B)?B:[]}catch{return[]}}),ne=F(()=>{if(!a.log.queued_tools)return[];try{const B=JSON.parse(a.log.queued_tools);return Array.isArray(B)?B:[]}catch{return[]}}),fe=F(()=>{const B=[];for(const D of P.value)B.push({id:D.id||`tool-${B.length}`,name:D.function?.name||"Unknown",isProvider:!1,isQueued:!1,function:D.function});for(const D of ne.value)B.push({id:D.id||`queued-${B.length}`,name:D.function?.name||"Unknown",isProvider:!1,isQueued:!0,function:D.function,queuedAt:D.queued_at});for(const D of oe.value)B.push({id:D.id,name:D.type,isProvider:!0,isQueued:!1,providerType:D.type,status:D.status,result:D.result});return B}),ye=B=>{u.value.has(B)?u.value.delete(B):u.value.add(B)},te=B=>{i.value.has(B)?i.value.delete(B):i.value.add(B)},q=()=>{h.value=!h.value},j=()=>{x.value=!x.value},J=B=>{w.value.has(B)?w.value.delete(B):w.value.add(B)},H=B=>!w.value.has(B),ce=F(()=>{if(!a.log.errors)return[];try{const B=JSON.parse(a.log.errors);return Array.isArray(B)?B:[]}catch{return[]}}),Z=p("standard"),U=p(null),K=p(!1),me=p(null),ue=["cloudflare","cerebras","google","groq","openai","openrouter","xai"],Q=()=>(a.log.actual_provider||a.log.provider)?.toLowerCase(),G=()=>{const B=Q();B&&ue.includes(B)?Z.value=B:Z.value="standard"},ae=B=>({cloudflare:"Cloudflare",cerebras:"Cerebras",google:"Google",groq:"Groq",openai:"OpenAI",openrouter:"OpenRouter",xai:"xAI"})[B]||B.charAt(0).toUpperCase()+B.slice(1);Ve(Z,async B=>{if(B==="standard"){U.value=null,me.value=null;return}if(!a.threadId||!a.log.id){me.value="Missing thread or log ID";return}K.value=!0,me.value=null;try{const D=await fetch(ze(`/api/threads/${a.threadId}/logs/${a.log.id}/inspect/${B}`));if(!D.ok){const M=await D.json();throw new Error(M.error||"Failed to inspect")}U.value=await D.json()}catch(D){me.value=D.message||"Failed to fetch inspected request",U.value=null}finally{K.value=!1}}),Ve(()=>a.log.id,async()=>{if(U.value=null,me.value=null,G(),Z.value!=="standard"&&a.threadId&&a.log.id){K.value=!0;try{const B=await fetch(ze(`/api/threads/${a.threadId}/logs/${a.log.id}/inspect/${Z.value}`));if(!B.ok){const D=await B.json();throw new Error(D.error||"Failed to fetch inspected request")}U.value=await B.json()}catch(B){me.value=B.message||"Failed to fetch inspected request"}finally{K.value=!1}}},{immediate:!0});const ie=F(()=>{if(Z.value==="standard"||!U.value)return a.log.message_history;const B=U.value.messagesPath,D=B?U.value.body?.[B]:U.value.body;return JSON.stringify(D,null,2)}),xe=F(()=>Z.value==="standard"||!U.value?a.log.request_body:JSON.stringify(U.value.body,null,2)),X=F(()=>Z.value==="standard"||!U.value?null:`${Z.value} format`),he=F(()=>{if(!a.log.request_body)return null;try{const D=JSON.parse(a.log.request_body)?._metadata?.visionFiltering;if(!D||D.enabled!==!0)return null;const M=Number(D.removedUserImageParts||0),T=Number(D.removedToolImageAttachments||0),L=M+T;return L<=0?null:{removedUserImageParts:M,removedToolImageAttachments:T,totalRemoved:L}}catch{return null}});Ve(()=>a.log,()=>{Fe(()=>{y.value?.checkHeight(),$.value?.checkHeight(),g.value?.checkHeight(),d.value?.checkHeight()})});const be=async()=>{c.value=!0;try{if(!a.log.request_body||!a.log.model)throw new Error("Missing request data");const B=await fetch(ze(`/api/models/${encodeURIComponent(a.log.model)}/curl-data`));if(!B.ok)throw new Error("Failed to fetch model data");const D=await B.json(),M=v(a.log.request_body);let T=`curl -X POST '${D.endpoint}' \\
47
+ `;T+=` -H 'Content-Type: application/json' \\
48
+ `,D.sdk?.toLowerCase()==="openrouter"?(T+=` -H 'Authorization: Bearer ${D.api_key}' \\
49
+ `,T+=` -H 'HTTP-Referer: https://agentkit.local' \\
50
+ `,T+=` -H 'X-Title: AgentKit' \\
51
+ `):(D.sdk?.toLowerCase()==="cloudflare"||D.sdk?.toLowerCase()==="openai"||D.sdk?.toLowerCase()==="cerebras")&&(T+=` -H 'Authorization: Bearer ${D.api_key}' \\
52
+ `),T+=` -d '${M.replace(/'/g,"'\\''")}'`,await navigator.clipboard.writeText(T),f.value=!0,setTimeout(()=>{f.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{c.value=!1}};return(B,D)=>(r(),o("div",{ref_key:"scrollContainer",ref:b,class:"p-4 h-full overflow-y-auto"},[t("div",H1,[t("div",W1,[t("div",K1,[t("button",{onClick:D[0]||(D[0]=M=>s("previous")),disabled:!e.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"},[...D[10]||(D[10]=[t("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"},[t("polyline",{points:"15 18 9 12 15 6"})],-1)])],8,J1),t("button",{onClick:D[1]||(D[1]=M=>s("next")),disabled:!e.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"},[...D[11]||(D[11]=[t("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"},[t("polyline",{points:"9 18 15 12 9 6"})],-1)])],8,G1)]),t("h3",Y1,C(e.log.prompt_name||e.log.model_name||e.log.model),1)]),t("div",Z1,[t("button",{onClick:be,disabled:c.value||!e.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:e.log.request_body?"Copy cURL command":"No request data available"},[c.value?(r(),Y(Be,{key:0,size:"xs"})):(r(),o("span",Q1,C(f.value?"Copied!":"Copy cURL"),1))],8,X1),t("button",{onClick:D[2]||(D[2]=M=>s("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"},[...D[12]||(D[12]=[t("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"},[t("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),t("line",{x1:"6",y1:"6",x2:"18",y2:"18"})],-1)])])])]),t("div",ex,[t("div",tx,[t("table",rx,[D[13]||(D[13]=t("thead",null,[t("tr",{class:"border-b border-neutral-200 dark:border-neutral-800"},[t("th",{class:"text-left py-1 pr-4 text-neutral-600 dark:text-neutral-400 font-medium"}," Status "),t("th",{class:"text-left py-1 pr-4 text-neutral-600 dark:text-neutral-400 font-medium"}," Provider "),t("th",{class:"text-left py-1 pr-4 text-neutral-600 dark:text-neutral-400 font-medium"}," Prompt "),t("th",{class:"text-left py-1 pr-4 text-neutral-600 dark:text-neutral-400 font-medium"}," Latency "),t("th",{class:"text-left py-1 pr-4 text-neutral-600 dark:text-neutral-400 font-medium"}," Tokens "),t("th",{class:"text-left py-1 pr-4 text-neutral-600 dark:text-neutral-400 font-medium"}," Cost "),t("th",{class:"text-left py-1 pr-4 text-neutral-600 dark:text-neutral-400 font-medium"}," Created ")])],-1)),t("tbody",null,[t("tr",null,[t("td",{class:pe(["py-1 font-mono",e.log.error?"text-red-600 dark:text-red-400":e.log.is_complete?"text-green-600 dark:text-green-400":"text-yellow-600 dark:text-yellow-400"])},C(e.log.error?"ERROR":e.log.is_complete?"SUCCESS":"LOADING"),3),t("td",ax,C(e.log.actual_provider||e.log.provider),1),t("td",nx,[!e.log.is_complete&&!e.log.prompt_name?(r(),Y(Be,{key:0,size:"xs"})):(r(),o("span",ox,C(e.log.prompt_name||"—"),1))]),t("td",lx,[!e.log.is_complete&&!e.log.latency_ms?(r(),Y(Be,{key:0,size:"xs"})):(r(),o("span",sx,C(e.log.latency_ms?`${e.log.latency_ms}ms`:"—"),1))]),t("td",ix,[!e.log.is_complete&&!e.log.total_tokens?(r(),Y(Be,{key:0,size:"xs"})):(r(),o("span",ux,C(e.log.total_tokens?`${e.log.input_tokens}/${e.log.output_tokens} (${e.log.total_tokens})`:"—"),1))]),t("td",dx,[!e.log.is_complete&&(e.log.cost_total===null||e.log.cost_total===void 0)?(r(),Y(Be,{key:0,size:"xs"})):(r(),o("span",cx,C(e.log.cost_total!==null&&e.log.cost_total!==void 0?`$${e.log.cost_total.toFixed(6)}`:"—"),1))]),t("td",px,[k(Kt,{timestamp:e.log.created_at},null,8,["timestamp"])])])])])]),t("div",mx,[t("table",vx,[D[14]||(D[14]=t("thead",null,[t("tr",{class:"border-b border-neutral-200 dark:border-neutral-800"},[t("th",{class:"text-left py-1 pr-4 text-neutral-600 dark:text-neutral-400 font-medium"}," Status "),t("th",{class:"text-left py-1 pr-4 text-neutral-600 dark:text-neutral-400 font-medium"}," Provider "),t("th",{class:"text-left py-1 pr-4 text-neutral-600 dark:text-neutral-400 font-medium"}," Prompt ")])],-1)),t("tbody",null,[t("tr",null,[t("td",{class:pe(["py-1 font-mono",e.log.error?"text-red-600 dark:text-red-400":e.log.is_complete?"text-green-600 dark:text-green-400":"text-yellow-600 dark:text-yellow-400"])},C(e.log.error?"ERROR":e.log.is_complete?"SUCCESS":"LOADING"),3),t("td",fx,C(e.log.actual_provider||e.log.provider),1),t("td",gx,[!e.log.is_complete&&!e.log.prompt_name?(r(),Y(Be,{key:0,size:"xs"})):(r(),o("span",hx,C(e.log.prompt_name||"—"),1))])])])]),t("table",bx,[D[15]||(D[15]=t("thead",null,[t("tr",{class:"border-b border-neutral-200 dark:border-neutral-800"},[t("th",{class:"text-left py-1 pr-4 text-neutral-600 dark:text-neutral-400 font-medium"}," Latency "),t("th",{class:"text-left py-1 pr-4 text-neutral-600 dark:text-neutral-400 font-medium"}," Tokens "),t("th",{class:"text-left py-1 pr-4 text-neutral-600 dark:text-neutral-400 font-medium"}," Cost "),t("th",{class:"text-left py-1 pr-4 text-neutral-600 dark:text-neutral-400 font-medium"}," Created ")])],-1)),t("tbody",null,[t("tr",null,[t("td",xx,[!e.log.is_complete&&!e.log.latency_ms?(r(),Y(Be,{key:0,size:"xs"})):(r(),o("span",yx,C(e.log.latency_ms?`${e.log.latency_ms}ms`:"—"),1))]),t("td",kx,[!e.log.is_complete&&!e.log.total_tokens?(r(),Y(Be,{key:0,size:"xs"})):(r(),o("span",wx,C(e.log.total_tokens?`${e.log.input_tokens}/${e.log.output_tokens} (${e.log.total_tokens})`:"—"),1))]),t("td",_x,[!e.log.is_complete&&(e.log.cost_total===null||e.log.cost_total===void 0)?(r(),Y(Be,{key:0,size:"xs"})):(r(),o("span",$x,C(e.log.cost_total!==null&&e.log.cost_total!==void 0?`$${e.log.cost_total.toFixed(6)}`:"—"),1))]),t("td",Cx,[k(Kt,{timestamp:e.log.created_at},null,8,["timestamp"])])])])])])]),t("div",Sx,[t("div",Ix,[t("button",{onClick:D[3]||(D[3]=M=>l.value="request"),class:pe(["pb-2 px-1 text-sm font-medium border-b-2 transition-colors",l.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),t("button",{onClick:D[4]||(D[4]=M=>l.value="response"),class:pe(["pb-2 px-1 text-sm font-medium border-b-2 transition-colors flex items-center gap-1",l.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"])},[D[16]||(D[16]=ve(" Response ",-1)),e.log.error||ce.value.length>0?(r(),o("span",Tx,"⚠")):S("",!0)],2)])]),t("div",Mx,[Je(t("div",zx,[t("div",Vx,[D[17]||(D[17]=t("span",{class:"text-xs text-neutral-500 dark:text-neutral-400 mr-2"},"View as:",-1)),t("button",{onClick:D[5]||(D[5]=M=>Z.value="standard"),class:pe(["px-2 py-1 text-xs rounded transition-colors",Z.value==="standard"?"bg-black text-white dark:bg-white dark:text-black":"bg-neutral-100 dark:bg-neutral-800 text-neutral-600 dark:text-neutral-400 hover:bg-neutral-200 dark:hover:bg-neutral-700"])}," Standard Agents ",2),(r(),o($e,null,Le(ue,M=>t("button",{key:M,onClick:T=>Z.value=M,class:pe(["px-2 py-1 text-xs rounded transition-colors",Z.value===M?"bg-black text-white dark:bg-white dark:text-black":"bg-neutral-100 dark:bg-neutral-800 text-neutral-600 dark:text-neutral-400 hover:bg-neutral-200 dark:hover:bg-neutral-700"])},C(ae(M)),11,Ex)),64)),K.value?(r(),Y(Be,{key:0,size:"xs",class:"ml-2"})):S("",!0),me.value?(r(),o("span",Lx,C(me.value),1)):S("",!0)]),he.value?(r(),o("div",Ax,[D[18]||(D[18]=t("div",{class:"text-xs font-semibold text-amber-800 dark:text-amber-200"}," Vision Input Filtered For This Request ",-1)),t("div",Px," This model does not support image input. Removed "+C(he.value.removedUserImageParts)+" user image part(s) and "+C(he.value.removedToolImageAttachments)+" tool image attachment(s) before sending the request. Stored thread messages remain unchanged. ",1)])):S("",!0),_.value.length>0?(r(),Y(tr,{key:1,ref_key:"toolsSectionRef",ref:y,title:`Available Tools (${_.value.length})`,"section-id":"tools",expanded:H("tools"),"scroll-container":b.value,onToggle:D[6]||(D[6]=M=>J("tools"))},{default:W(()=>[(r(!0),o($e,null,Le(_.value,(M,T)=>(r(),o("div",{key:T,class:"border-b border-neutral-200 dark:border-neutral-800 last:border-b-0"},[t("button",{onClick:L=>ye(T),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"},[t("span",Rx,C(M.function?.name||M.name||"Unknown"),1),t("span",jx,C(u.value.has(T)?"▼":"▶"),1)],8,Ox),Je(t("div",Dx,[M.function?.description||M.description?(r(),o("div",Ux,C(M.function?.description||M.description),1)):S("",!0),k(Cr,{code:JSON.stringify(M,null,2),language:"json"},null,8,["code"])],512),[[pt,u.value.has(T)]])]))),128))]),_:1},8,["title","expanded","scroll-container"])):S("",!0),e.log.message_history?(r(),Y(tr,{key:2,ref_key:"messagesSectionRef",ref:$,title:`Messages (${e.log.message_history_length||0} messages)`,subtitle:X.value,"section-id":"messages",expanded:H("messages"),"scroll-container":b.value,onToggle:D[7]||(D[7]=M=>J("messages"))},{default:W(()=>[k(nr,{json:ie.value,"thread-id":e.threadId,"show-copy-button":""},null,8,["json","thread-id"])]),_:1},8,["title","subtitle","expanded","scroll-container"])):S("",!0),e.log.system_prompt?(r(),Y(tr,{key:3,ref_key:"systemPromptSectionRef",ref:g,title:"System Prompt","section-id":"system_prompt",expanded:H("system_prompt"),"scroll-container":b.value,onToggle:D[8]||(D[8]=M=>J("system_prompt"))},{default:W(()=>[t("div",Bx,[k(Cr,{code:e.log.system_prompt,language:"markdown"},null,8,["code"]),t("div",Nx,[k(on,{content:e.log.system_prompt,variant:"ghost",size:"xs"},null,8,["content"])])])]),_:1},8,["expanded","scroll-container"])):S("",!0),e.log.request_body?(r(),Y(tr,{key:4,ref_key:"requestBodySectionRef",ref:d,title:"Full Request Body",subtitle:X.value,"section-id":"request_body",expanded:H("request_body"),"scroll-container":b.value,onToggle:D[9]||(D[9]=M=>J("request_body"))},{default:W(()=>[k(nr,{json:xe.value,"thread-id":e.threadId,"show-copy-button":""},null,8,["json","thread-id"])]),_:1},8,["subtitle","expanded","scroll-container"])):S("",!0)],512),[[pt,l.value==="request"]]),Je(t("div",null,[ce.value.length>0?(r(),o("div",qx,[t("div",Fx,C(ce.value.length>1?`Errors (${ce.value.length})`:"Error"),1),t("div",Hx,[(r(!0),o($e,null,Le(ce.value,(M,T)=>(r(),o("div",{key:T,class:"border border-red-300 dark:border-red-700 rounded overflow-hidden"},[t("div",Wx,C(M.type||"error"),1),t("pre",Kx,C(M.message),1)]))),128))])])):e.log.error?(r(),o("div",Jx,[t("div",Gx," Error "+C(e.log.error_type?`(${e.log.error_type})`:""),1),t("pre",Yx,C(e.log.error),1)])):S("",!0),e.log.is_complete||!e.log.error?(r(),o("div",Zx,[D[26]||(D[26]=t("div",{class:"text-xs font-semibold mb-1"},"Response Stats",-1)),t("table",Xx,[t("tbody",null,[t("tr",Qx,[D[19]||(D[19]=t("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)),t("td",ey,[!e.log.is_complete&&!e.log.finish_reason?(r(),Y(Be,{key:0,size:"xs"})):(r(),o("span",ty,C(e.log.finish_reason||"—"),1))])]),t("tr",ry,[D[20]||(D[20]=t("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)),t("td",ay,[!e.log.is_complete&&!e.log.input_tokens?(r(),Y(Be,{key:0,size:"xs"})):(r(),o("span",ny,C(e.log.input_tokens||"—"),1))])]),e.log.cached_tokens||!e.log.is_complete?(r(),o("tr",oy,[D[21]||(D[21]=t("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)),t("td",ly,[!e.log.is_complete&&!e.log.cached_tokens?(r(),Y(Be,{key:0,size:"xs"})):(r(),o("span",sy,C(e.log.cached_tokens||0),1))])])):S("",!0),t("tr",iy,[D[22]||(D[22]=t("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)),t("td",uy,[!e.log.is_complete&&!e.log.output_tokens?(r(),Y(Be,{key:0,size:"xs"})):(r(),o("span",dy,C(e.log.output_tokens||"—"),1))])]),e.log.reasoning_tokens&&e.log.reasoning_tokens>0?(r(),o("tr",cy,[D[23]||(D[23]=t("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)),t("td",py,C(e.log.reasoning_tokens),1)])):S("",!0),t("tr",my,[D[24]||(D[24]=t("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)),t("td",vy,[!e.log.is_complete&&!e.log.total_tokens?(r(),Y(Be,{key:0,size:"xs"})):(r(),o("span",fy,C(e.log.total_tokens||"—"),1))])]),t("tr",null,[D[25]||(D[25]=t("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)),t("td",gy,[!e.log.is_complete&&(e.log.cost_total===null||e.log.cost_total===void 0)?(r(),Y(Be,{key:0,size:"xs"})):(r(),o("span",hy,C(e.log.cost_total!==null&&e.log.cost_total!==void 0?`$${e.log.cost_total.toFixed(6)}`:"—"),1))])])])])])):S("",!0),fe.value.length>0?(r(),o("div",by,[t("div",xy," Tools Called ("+C(fe.value.length)+") ",1),t("div",yy,[(r(!0),o($e,null,Le(fe.value,M=>(r(),o("div",{key:M.id,class:"border-b border-neutral-200 dark:border-neutral-800 last:border-b-0"},[t("button",{onClick:T=>te(M.id),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"},[t("div",wy,[t("span",_y,C(M.name),1),M.isQueued?(r(),o("span",$y," programmatically invoked ")):S("",!0),M.isProvider?(r(),o("span",Cy," provider ")):S("",!0),M.isProvider&&M.status?(r(),o("span",{key:2,class:pe([M.status==="completed"?"text-green-600 dark:text-green-400":M.status==="failed"?"text-red-600 dark:text-red-400":"text-yellow-600 dark:text-yellow-400","text-[10px]"])},C(M.status),3)):S("",!0)]),t("span",Sy,C(i.value.has(M.id)?"▼":"▶"),1)],8,ky),Je(t("div",{class:pe(["px-2 py-2 border-t border-neutral-200 dark:border-neutral-800",M.isProvider?"bg-purple-50 dark:bg-purple-900/10":M.isQueued?"bg-emerald-50 dark:bg-emerald-900/10":"bg-white dark:bg-neutral-950"])},[M.isProvider?(r(),o($e,{key:1},[t("div",jy,[D[33]||(D[33]=t("div",{class:"font-semibold text-purple-600 dark:text-purple-400 mb-1"}," Provider Tool ID ",-1)),t("div",Dy,C(M.id),1)]),M.providerType==="web_search"&&M.result?.actions?(r(),o("div",Uy,[(r(!0),o($e,null,Le(M.result.actions,(T,L)=>(r(),o("div",{key:L,class:"mb-2"},[T.type==="search"?(r(),o("div",By,[D[34]||(D[34]=t("span",{class:"font-medium"},"Searched:",-1)),ve(' "'+C(T.query)+'" ',1)])):S("",!0),T.type==="open"?(r(),o("div",Ny,[D[35]||(D[35]=t("span",{class:"font-medium"},"Opened:",-1)),t("a",{href:T.url,target:"_blank",class:"text-blue-600 hover:underline ml-1"},C(T.url),9,qy)])):S("",!0),T.sources?.length?(r(),o("div",Fy,[(r(!0),o($e,null,Le(T.sources.slice(0,5),(ee,le)=>(r(),o("a",{key:le,href:ee.url,target:"_blank",class:"block text-blue-600 hover:underline text-xs truncate"},C(ee.title||ee.url),9,Hy))),128)),T.sources.length>5?(r(),o("span",Wy," ... and "+C(T.sources.length-5)+" more ",1)):S("",!0)])):S("",!0)]))),128))])):S("",!0),M.providerType==="image_generation"?(r(),o("div",Ky,[M.result?.imagePath?(r(),o("span",Jy,[D[36]||(D[36]=ve(" Stored at: ",-1)),t("span",Gy,C(M.result.imagePath),1)])):(r(),o("span",Yy," See Generated Images section below "))])):S("",!0),M.providerType==="code_interpreter"&&M.result?.output?(r(),o("div",Zy,[D[37]||(D[37]=t("div",{class:"font-medium text-neutral-600 dark:text-neutral-400 mb-1"},"Output:",-1)),t("pre",Xy,C(M.result.output),1)])):S("",!0),M.providerType==="file_search"&&M.result?.results?.length?(r(),o("div",Qy,[t("div",ek," Found "+C(M.result.results.length)+" result(s) ",1)])):S("",!0)],64)):(r(),o($e,{key:0},[M.isQueued&&M.queuedAt?(r(),o("div",Iy,[D[27]||(D[27]=t("div",{class:"font-semibold text-emerald-600 dark:text-emerald-400 mb-1"}," Invoked At ",-1)),t("div",Ty,[k(Kt,{timestamp:M.queuedAt},null,8,["timestamp"])])])):S("",!0),t("div",My,[D[28]||(D[28]=t("div",{class:"font-semibold text-neutral-600 dark:text-neutral-400 mb-1"}," Tool Call ID ",-1)),t("div",zy,C(M.id),1)]),t("div",Vy,[D[29]||(D[29]=t("div",{class:"font-semibold text-neutral-600 dark:text-neutral-400 mb-1"}," Function Name ",-1)),t("div",Ey,C(M.function?.name),1)]),t("div",Ly,[D[30]||(D[30]=t("div",{class:"font-semibold text-neutral-600 dark:text-neutral-400 mb-1"}," Arguments ",-1)),t("div",Ay,[k(Cr,{code:v(M.function?.arguments||"{}"),language:"json"},null,8,["code"])])]),V.value.has(M.id)?(r(),o("div",Py,[D[31]||(D[31]=t("div",{class:"font-semibold text-green-600 dark:text-green-400 mb-1"}," Result ",-1)),t("pre",Oy,C(V.value.get(M.id)?.content||"No content"),1)])):(r(),o("div",Ry,[...D[32]||(D[32]=[t("div",{class:"font-semibold text-neutral-500 dark:text-neutral-500 mb-1"}," Result ",-1),t("div",{class:"text-xs text-neutral-500 dark:text-neutral-500 italic"}," No result available ",-1)])]))],64))],2),[[pt,i.value.has(M.id)]])]))),128))])])):S("",!0),A.value.length>0?(r(),o("div",tk,[t("div",rk," Generated Images ("+C(A.value.length)+") ",1),t("div",ak,[D[38]||(D[38]=t("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)),t("div",nk,[(r(!0),o($e,null,Le(A.value,(M,T)=>(r(),o("div",{key:T,class:"relative"},[M.image_url?.url?(r(),o("img",{key:0,src:m(M.image_url.url)||M.image_url.url,alt:`Generated image ${T+1}`,class:"max-w-[300px] max-h-[300px] rounded border border-emerald-200 dark:border-emerald-800 object-contain"},null,8,ok)):(r(),o("div",lk," No URL "))]))),128))])])])):S("",!0),e.log.reasoning_content?(r(),o("div",sk,[t("div",ik,[t("button",{onClick:q,class:"w-full px-2 py-1.5 bg-accent-100 dark:bg-accent-900/30 text-xs text-accent-800 dark:text-accent-200 flex items-center justify-between hover:bg-accent-200 dark:hover:bg-accent-900/50 transition-colors"},[D[39]||(D[39]=t("div",{class:"flex items-center gap-2"},[t("span",{class:"font-semibold"},"Reasoning Content"),t("span",{class:"text-accent-600 dark:text-accent-400 font-normal"}," Internal reasoning output (not displayed to users) ")],-1)),t("span",uk,C(h.value?"▶":"▼"),1)]),Je(t("pre",{class:"text-xs p-2 overflow-x-auto whitespace-pre-wrap max-h-96 text-accent-900 dark:text-accent-100 border-t border-accent-300 dark:border-accent-700"},C(z.value),513),[[pt,!h.value]])])])):S("",!0),E.value.length>0?(r(),o("div",dk,[t("div",ck,[t("button",{onClick:j,class:"w-full px-2 py-1.5 bg-purple-100 dark:bg-purple-900/30 text-xs text-purple-800 dark:text-purple-200 flex items-center justify-between hover:bg-purple-200 dark:hover:bg-purple-900/50 transition-colors"},[t("div",pk,[D[40]||(D[40]=t("span",{class:"font-semibold"},"Reasoning Details",-1)),t("span",mk,C(E.value.length)+" blocks ",1),D[41]||(D[41]=t("span",{class:"text-purple-600 dark:text-purple-400 font-normal"}," Structured reasoning from OpenRouter ",-1))]),t("span",vk,C(x.value?"▶":"▼"),1)]),Je(t("div",fk,[(r(!0),o($e,null,Le(E.value,(M,T)=>(r(),o("div",{key:T,class:"p-2"},[t("div",gk,[t("span",hk,C(M.type||"unknown"),1),M.id?(r(),o("span",bk," ID: "+C(M.id),1)):S("",!0),M.format?(r(),o("span",xk," Format: "+C(M.format),1)):S("",!0),M.index!==void 0?(r(),o("span",yk," Index: "+C(M.index),1)):S("",!0)]),M.type==="reasoning.summary"&&M.summary?(r(),o("div",kk,[D[42]||(D[42]=t("div",{class:"font-semibold text-purple-600 dark:text-purple-400 mb-1"}," Summary: ",-1)),t("div",wk,C(M.summary),1)])):S("",!0),M.type==="reasoning.encrypted"&&M.data?(r(),o("div",_k,[D[43]||(D[43]=t("div",{class:"font-semibold text-purple-600 dark:text-purple-400 mb-1"}," Encrypted Data: ",-1)),t("div",$k,C(M.data),1)])):S("",!0),M.type==="reasoning.text"&&M.text?(r(),o("div",Ck,[D[45]||(D[45]=t("div",{class:"font-semibold text-purple-600 dark:text-purple-400 mb-1"}," Reasoning Text: ",-1)),t("div",Sk,C(M.text),1),M.signature?(r(),o("div",Ik,[D[44]||(D[44]=t("div",{class:"font-semibold text-purple-600 dark:text-purple-400 mb-1"}," Signature: ",-1)),t("div",Tk,C(M.signature),1)])):S("",!0)])):S("",!0),["reasoning.summary","reasoning.encrypted","reasoning.text"].includes(M.type)?S("",!0):(r(),o("div",Mk,[t("pre",zk,C(JSON.stringify(M,null,2)),1)]))]))),128))],512),[[pt,!x.value]])])])):S("",!0),e.log.response_body?(r(),o("div",Vk,[D[46]||(D[46]=t("div",{class:"text-xs font-semibold mb-1"},"Full Response Body",-1)),t("div",Ek,[k(nr,{json:e.log.response_body,"thread-id":e.threadId,"show-copy-button":""},null,8,["json","thread-id"])])])):S("",!0)],512),[[pt,l.value==="response"]])])],512))}}),Ak={class:"flex flex-col h-full"},Pk={class:"px-4 py-3 border-b border-neutral-300 dark:border-neutral-700"},Ok={class:"flex items-center justify-between"},Rk={class:"flex items-center gap-2"},jk={key:0,class:"text-neutral-500 dark:text-neutral-400 text-center py-12"},Dk={key:1,class:"flex justify-center py-12"},Uk={key:2,class:"text-red-600 dark:text-red-400 text-center py-12"},Bk={key:3,class:"text-neutral-500 dark:text-neutral-400 text-center py-12"},Nk={key:4},qk={key:0,class:"border-b border-neutral-300 dark:border-neutral-700 bg-white dark:bg-black sticky top-0 z-10"},Fk=["disabled"],Hk={key:1},Wk={key:2},Kk={key:3},Jk={class:"w-full text-sm"},Gk=["onClick","onMouseenter"],Yk={class:"px-3 py-2 text-xs"},Zk={class:"flex items-center gap-1"},Xk={key:0,class:"text-neutral-400 dark:text-neutral-600 mr-1"},Qk={key:3},e2={class:"px-3 py-2"},t2={class:"flex items-center gap-2"},r2={key:0,class:"text-red-600 dark:text-red-400",title:"Error"},a2={class:"font-mono text-xs"},n2={class:"px-3 py-2 font-mono text-xs"},o2={key:1},l2={key:1,class:"text-neutral-400"},s2={key:2},i2={key:0,class:"text-emerald-600 dark:text-emerald-400",title:"Programmatically called with state.queueTool()"},u2={key:1},d2={key:2},c2={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"},p2={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"},m2={key:0,class:"flex flex-col items-center justify-center h-full gap-3 text-neutral-500 dark:text-neutral-400"},v2={key:2,class:"absolute inset-0 bg-white/50 dark:bg-black/50 flex items-center justify-center"},ia=20,f2=20,g2=Se({__name:"LogsPane",props:{threadId:{},selectedLogId:{},hoveredLogId:{}},emits:["logClick","logHover","logsLoaded"],setup(e,{expose:n,emit:a}){const s=e,l=a,u=p(0),i=p(ia),{logs:c,hasMore:f,isFetching:h,error:x,wsConnected:b,wsError:y,connectWebSocket:$,disconnectWebSocket:g,refetch:d}=S1(F(()=>s.threadId),{limit:F(()=>i.value),offset:F(()=>u.value),enableWebSocket:!0,order:"desc"}),w=p([]),m=p(!0),v=p(null),_=p(null),P=p(!1),V=p(!1),E=p(new Map),z=async()=>{await Fe(),_.value&&(_.value.scrollTop=_.value.scrollHeight)},A=p(null);Ve(c,async T=>{if(u.value===0)w.value=[...T].reverse(),m.value&&w.value.length>0&&(await z(),m.value=!1);else{const L=[...T].reverse(),ee=new Map;w.value.forEach(le=>ee.set(le.id,le)),L.forEach(le=>ee.set(le.id,le)),w.value=Array.from(ee.values()).sort((le,Ie)=>le.created_at-Ie.created_at)}},{deep:!0,immediate:!0}),Ve(h,(T,L)=>{if(L&&!T&&u.value===0&&s.threadId&&A.value!==s.threadId&&w.value.length>0){A.value=s.threadId;const ee=w.value[w.value.length-1];l("logsLoaded",ee?.id??null)}});const{logDetails:oe,isFetching:ne}=I1(F(()=>s.threadId),F(()=>v.value)),fe=F(()=>{if(!v.value)return null;const L=w.value.find(ee=>ee.id===v.value);return L?oe.value?{...oe.value,...L}:L:null}),ye=F(()=>v.value?M.value.findIndex(T=>T.id===v.value):-1),te=F(()=>ye.value>0),q=F(()=>ye.value>=0&&ye.value<M.value.length-1),j=()=>{if(te.value){const T=M.value[ye.value-1];ce(T)}},J=()=>{if(q.value){const T=M.value[ye.value+1];ce(T)}},H=T=>{if(!_.value)return;const L=E.value.get(T);if(!L)return;const ee=_.value,le=L.getBoundingClientRect(),Ie=ee.getBoundingClientRect(),Re=ee.querySelectorAll(".sticky");let qe=0;Re.forEach(O=>{qe+=O.getBoundingClientRect().height}),qe+=16;const We=le.top<Ie.top+qe,R=le.bottom>Ie.bottom;We?ee.scrollBy({top:le.top-Ie.top-qe,behavior:"smooth"}):R&&ee.scrollBy({top:le.bottom-Ie.bottom,behavior:"smooth"})},ce=T=>{l("logClick",T.id),v.value=T.id},Z=(T,L)=>{L?E.value.set(T,L):E.value.delete(T)};Ve(v,async T=>{T&&(await Fe(),H(T))}),Ve(()=>s.selectedLogId,T=>{T&&(v.value=T)},{immediate:!0});const U=T=>{v.value=T},K=async T=>{await Fe();const L=E.value.get(T);if(L&&_.value){const ee=_.value,le=L.getBoundingClientRect(),Ie=ee.getBoundingClientRect(),Re=ee.querySelector("thead"),qe=ee.querySelector(":scope > div > div.sticky");let We=0;Re&&(We+=Re.getBoundingClientRect().height),qe&&(We+=qe.getBoundingClientRect().height),We+=40;const R=le.top<Ie.top+We,O=le.bottom>Ie.bottom;R?ee.scrollBy({top:le.top-Ie.top-We,behavior:"smooth"}):O&&ee.scrollBy({top:le.bottom-Ie.bottom,behavior:"smooth"})}},me=T=>{if(T.length===0)return;const L=new Set(T);w.value=w.value.filter(ee=>!L.has(ee.id))},ue=p(!1),Q=T=>w.value.some(L=>L.id===T),G=T=>w.value.find(L=>L.id===T)??null,ae=(T,L=3e3)=>new Promise(ee=>{const le=Date.now(),Ie=Ve(w,()=>{w.value.length!==T&&(Ie(),ee(!0))},{deep:!0}),Re=setInterval(()=>{w.value.length!==T?(clearInterval(Re),Ie(),ee(!0)):Date.now()-le>L&&(clearInterval(Re),Ie(),ee(!1))},50)});n({scrollToLog:K,selectLogById:U,removeLogsByIds:me,loadUntilLogId:async T=>{if(Q(T))return!0;if(!f.value)return!1;ue.value=!0;const L=100,ee=50;try{let le=0;for(;f.value&&!Q(T)&&le<ee;){le++;const Ie=w.value.length;if(u.value+=i.value,i.value=L,await d(),!await ae(Ie))break}return Q(T)}finally{ue.value=!1}},hasLog:Q,getLog:G,setLoadingForLog:T=>{ue.value=T},waitForLogRow:async(T,L=2e3)=>{const ee=Date.now();for(;Date.now()-ee<L;){if(E.value.has(T))return!0;if(!M.value.some(Ie=>Ie.id===T)){await Fe(),await new Promise(Ie=>setTimeout(Ie,16));continue}await Fe(),await new Promise(Ie=>setTimeout(Ie,16))}return!1}});const he=async()=>{if(V.value||!f.value||h.value)return;V.value=!0;const T=_.value?.scrollHeight||0;if(u.value+=i.value,i.value=f2,await d(),await Fe(),_.value){const L=_.value.scrollHeight;_.value.scrollTop+=L-T}V.value=!1};Ve(()=>s.threadId,async T=>{T?(g(),$()):g(),u.value=0,i.value=ia,w.value=[],v.value=null,P.value=!1,m.value=!0},{immediate:!0}),Ve(w,async()=>{P.value||await z()},{deep:!0});const be=()=>{if(!_.value)return;const{scrollTop:T,scrollHeight:L,clientHeight:ee}=_.value,le=L-T-ee<50;P.value=!le},B=T=>{const L=[];if(T.tools_called)try{const ee=JSON.parse(T.tools_called);Array.isArray(ee)&&L.push(...ee.map(le=>({name:le,isProgrammatic:!1})))}catch{}if(T.provider_tools)try{const ee=JSON.parse(T.provider_tools);Array.isArray(ee)&&L.push(...ee.map(le=>({name:le.type,isProgrammatic:!1})))}catch{}if(T.queued_tools)try{const ee=JSON.parse(T.queued_tools);Array.isArray(ee)&&L.push(...ee.map(le=>({name:le.function?.name||"unknown",isProgrammatic:!0})))}catch{}return L},D=T=>T==null?"—":`$${T.toFixed(6)}`,M=F(()=>{const T=new Map,L=new Map;w.value.forEach(Ie=>{T.set(Ie.id,Ie);const Re=Ie.parent_log_id;Re&&(L.has(Re)||L.set(Re,[]),L.get(Re).push(Ie))});const ee=[],le=(Ie,Re)=>{ee.push({...Ie,depth:Re}),(L.get(Ie.id)||[]).forEach(We=>{le(We,Re+1)})};return w.value.forEach(Ie=>{Ie.parent_log_id||le(Ie,0)}),ee});return(T,L)=>(r(),o("div",Ak,[t("div",Pk,[t("div",Ok,[t("div",Rk,[k(I(jn),{size:18,class:"shrink-0"}),L[3]||(L[3]=t("h2",{class:"text-base font-bold"},"Logs",-1)),e.threadId?(r(),Y(Dr,{key:0,connected:I(b),error:I(y)},null,8,["connected","error"])):S("",!0)])])]),t("div",{ref_key:"logsScrollContainer",ref:_,class:"logs-list-container flex-1 overflow-y-auto overflow-x-auto",onScroll:be},[e.threadId?I(h)&&u.value===0?(r(),o("div",Dk,[k(Be)])):I(x)?(r(),o("div",Uk," Error loading logs: "+C(I(x)),1)):w.value.length===0?(r(),o("div",Bk," No logs yet ")):(r(),o("div",Nk,[I(f)?(r(),o("div",qk,[t("button",{onClick:he,disabled:V.value||ue.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"},[V.value||ue.value?(r(),Y(Be,{key:0,size:"xs"})):S("",!0),ue.value?(r(),o("span",Hk,"Loading to find log...")):V.value?(r(),o("span",Wk,"Loading older logs...")):(r(),o("span",Kk,"Load previous logs"))],8,Fk)])):S("",!0),t("table",Jk,[t("thead",{class:pe(["border-b border-neutral-300 dark:border-neutral-700 sticky bg-white z-[10] dark:bg-black",{"top-0":!I(f),"top-[34px]":I(f)}])},[...L[4]||(L[4]=[t("tr",null,[t("th",{class:"text-left px-3 py-1.5 text-xs font-semibold"},"Prompt"),t("th",{class:"text-left px-3 py-1.5 text-xs font-semibold"},"Model"),t("th",{class:"text-left px-3 py-1.5 text-xs font-semibold"},"Cost"),t("th",{class:"text-left px-3 py-1.5 text-xs font-semibold"},"Tools Called"),t("th",{class:"text-right px-3 py-1.5 text-xs font-semibold"},"Called At")],-1)])],2),t("tbody",null,[(r(!0),o($e,null,Le(M.value,ee=>(r(),o("tr",{key:ee.id,ref_for:!0,ref:le=>Z(ee.id,le),class:pe(["border-b border-neutral-200 dark:border-neutral-800 cursor-pointer transition-colors relative",{"last:border-b-0":fe.value,"bg-red-50 dark:bg-red-950/20":ee.error,"bg-accent-100 dark:bg-accent-900 dark:text-white":v.value===ee.id,"ring-2 ring-inset ring-accent-400 dark:ring-accent-400":ee.id===s.selectedLogId||ee.id!==s.selectedLogId&&ee.id===s.hoveredLogId}]),onClick:le=>ce(ee),onMouseenter:le=>l("logHover",ee.id),onMouseleave:L[0]||(L[0]=le=>l("logHover",null))},[t("td",Yk,[t("div",Zk,[ee.depth>0?(r(),o("span",Xk,"└─")):S("",!0),ee.retry_of_log_id?(r(),Y(I(Dn),{key:1,size:14,class:"text-neutral-500 dark:text-neutral-400 flex-shrink-0"})):S("",!0),!ee.is_complete&&!ee.prompt_name?(r(),Y(Be,{key:2,size:"xs"})):(r(),o("span",Qk,C(ee.prompt_name||"—"),1))])]),t("td",e2,[t("div",t2,[ee.error?(r(),o("span",r2," ✕ ")):S("",!0),t("span",a2,C(ee.model_name||ee.model),1)])]),t("td",n2,[!ee.is_complete&&(ee.cost_total===null||ee.cost_total===void 0)?(r(),Y(Be,{key:0,size:"xs"})):(r(),o("span",o2,C(D(ee.cost_total)),1))]),t("td",{class:pe(["px-3 py-2 text-xs",v.value===ee.id?"text-neutral-800 dark:text-neutral-100":"text-neutral-600 dark:text-neutral-400"])},[!ee.is_complete&&B(ee).length===0?(r(),Y(Be,{key:0,size:"xs"})):B(ee).length===0?(r(),o("span",l2,"—")):(r(),o("span",s2,[(r(!0),o($e,null,Le(B(ee),(le,Ie)=>(r(),o($e,{key:Ie},[le.isProgrammatic?(r(),o("span",i2,[k(I(Un),{size:11,class:"inline-block -mt-0.5 mr-0.5"}),ve(C(le.name),1)])):(r(),o("span",u2,C(le.name),1)),Ie<B(ee).length-1?(r(),o("span",d2,", ")):S("",!0)],64))),128))]))],2),t("td",{class:pe(["px-3 py-2 text-right text-xs",v.value===ee.id?"text-neutral-800 dark:text-neutral-100":"text-neutral-500 dark:text-neutral-500"])},[k(Kt,{timestamp:ee.created_at},null,8,["timestamp"])],2)],42,Gk))),128))])])])):(r(),o("div",jk," Select a thread to view logs "))],544),k(kt,{name:"slide-up",onAfterEnter:L[2]||(L[2]=()=>v.value&&H(v.value))},{default:W(()=>[fe.value||ue.value&&v.value?(r(),o("div",c2,[t("div",p2,[ue.value&&!fe.value?(r(),o("div",m2,[k(Be),L[5]||(L[5]=t("span",{class:"text-sm"},"Loading log...",-1))])):fe.value?(r(),Y(Lk,{key:1,log:fe.value,"thread-id":e.threadId,"has-previous":te.value,"has-next":q.value,onClose:L[1]||(L[1]=ee=>v.value=null),onPrevious:j,onNext:J},null,8,["log","thread-id","has-previous","has-next"])):S("",!0),I(ne)&&fe.value?(r(),o("div",v2,[k(Be)])):S("",!0)])])):S("",!0)]),_:1})]))}}),h2=mt(g2,[["__scopeId","data-v-e90eff55"]]),b2={class:"space-y-3"},x2=["data-variable-property"],y2={class:"text-xs text-neutral-400 dark:text-neutral-500 px-1"},k2=["data-enabler-property"],w2={class:"text-[11px] text-neutral-500 dark:text-neutral-400"},_2={key:0,class:"text-[11px] text-neutral-500 dark:text-neutral-400"},$2={class:"space-y-2"},C2={class:"text-xs text-neutral-500 dark:text-neutral-400"},S2={class:"grid gap-2 items-start grid-cols-[minmax(180px,1fr)_140px_minmax(220px,1fr)]"},I2={class:"text-xs text-neutral-400 dark:text-neutral-500 px-1"},ua="grid-cols-[minmax(180px,1fr)_140px_minmax(220px,1fr)_44px]",T2=Se({__name:"ThreadVariableForm",props:{scanned:{default:()=>[]},disabled:{type:Boolean,default:!1},requireRequiredValues:{type:Boolean,default:!0},groupName:{default:"env"}},setup(e){const n=e,a=F(()=>(n.scanned||[]).map(v=>({...v,type:v.type==="secret"?"secret":"text",required:!!v.required,description:v.description||"",optionalOnly:!!v.optionalOnly,optionalBranches:Array.isArray(v.optionalBranches)?v.optionalBranches.filter(_=>_?.gate&&_?.tool):void 0}))),s=F(()=>{const v=new Map;for(const _ of a.value)v.set(_.property,_);return v}),l=v=>{if(!v.optionalOnly)return null;const _=v.optionalBranches?.[0];return _?.gate?_.gate:null},u=F(()=>{const v=new Map;for(const _ of a.value){const P=l(_);P&&(v.has(P)||v.set(P,[]),v.get(P).push(_))}for(const _ of v.values())_.sort((P,V)=>P.property.localeCompare(V.property));return v}),i=F(()=>a.value.filter(v=>!l(v))),c=v=>{const _=u.value.get(v)||[],P=[];for(const V of _){const E=V.optionalBranches||[];for(const z of E)z.gate===v&&typeof z.maxInstances=="number"&&z.maxInstances>0&&P.push(z.maxInstances)}if(P.length!==0)return Math.min(...P)},f=v=>{if(v==null)return!1;const _=String(v).trim().toLowerCase();return _==="true"||_==="1"||_==="yes"},h=v=>v&&typeof v=="object"&&!Array.isArray(v)?v:{},x=(v,_)=>{const V=h(_)[v];if(V!=null&&String(V).trim()!=="")return String(V);const E=s.value.get(v);return E?.value!==void 0&&E.value!==null?String(E.value):""},b=(v,_)=>f(x(v,_)),y=v=>`__optional__${v}`,$=v=>!u.value.has(v.property)||v.value===void 0||v.value===null?"":String(v.value),g=v=>v.name==="local"?`this ${v.type}`:`the ${v.name} ${v.type}`,d=v=>v.length===0?"":v.length===1?v[0]:v.length===2?`${v[0]} and ${v[1]}`:`${v.slice(0,-1).join(", ")}, and ${v[v.length-1]}`,w=v=>(v.type==="agent"||v.type==="prompt")&&v.name?`the ${v.name} ${v.type}`:v.type==="thread"?"the thread":v.type==="account"?"the account":v.type==="instance"?"the instance":`the ${v.type}`,m=v=>{const _=v.required?"Required by":"Requested by",P=v.declared.length?d(v.declared.map(g)):"this configuration";return v.defined?`${_} ${P}, value provided by ${w(v.defined)}.`:`${_} ${P}.`};return(v,_)=>{const P=at("FormKit");return r(),Y(P,{type:"group",name:e.groupName,"outer-class":"$reset",classes:{outer:"$remove:mb-4 mb-0"}},{default:W(({value:V})=>[t("div",b2,[t("div",{class:pe(["grid gap-2 text-xs font-medium text-neutral-500 dark:text-neutral-400 px-1",ua])},[..._[0]||(_[0]=[t("span",null,"Name",-1),t("span",null,"Type",-1),t("span",null,"Value",-1),t("span",{class:"text-center text-[10px] leading-none tracking-tight self-center"},"Required",-1)])]),(r(!0),o($e,null,Le(i.value,E=>(r(),o("div",{key:E.property,class:"space-y-1","data-variable-property":E.property},[t("div",{class:pe(["grid gap-2 items-start",ua])},[k(P,{type:"text",value:E.property,disabled:!0,"outer-class":"$reset",classes:{outer:"$remove:mb-4 group mb-0",wrapper:"$remove:flex-1 flex-1",inner:"!bg-zinc-100 dark:!bg-zinc-700/40 !cursor-not-allowed"}},null,8,["value"]),k(P,{type:"text",value:E.type,disabled:!0,"outer-class":"$reset",classes:{outer:"$remove:mb-4 group mb-0",wrapper:"$remove:flex-1 flex-1",inner:"!bg-zinc-100 dark:!bg-zinc-700/40 !cursor-not-allowed"}},null,8,["value"]),k(P,{name:E.property,type:E.type==="secret"?"password":"text",value:$(E),placeholder:E.description||"Enter value...",disabled:e.disabled,validation:e.requireRequiredValues&&E.required&&!E.defined?"required":"","validation-label":"Value","validation-visibility":"submit","outer-class":"$reset",classes:{outer:"$remove:mb-4 group mb-0",wrapper:"$remove:flex-1 flex-1",inner:e.disabled?"!bg-zinc-100 dark:!bg-zinc-700/40 !cursor-not-allowed":""}},null,8,["name","type","value","placeholder","disabled","validation","classes"]),k(P,{type:"checkbox",value:E.required,disabled:!0,classes:{outer:"$remove:mb-4 mb-0 pt-[8px] h-[34px] w-full flex items-center justify-center justify-self-center",wrapper:"$remove:items-center flex items-center justify-center",decorator:"$remove:mr-1.5 mr-0",label:"$remove:hidden",help:"$remove:hidden",messages:"$remove:formkit-messages hidden"}},null,8,["value"])]),t("p",y2,C(m(E)),1),(u.value.get(E.property)||[]).length>0&&b(E.property,V)?(r(),o("div",{key:0,class:"ml-5 space-y-2","data-enabler-property":E.property},[t("p",w2,[_[1]||(_[1]=ve(" Optional branch enabled by ",-1)),t("code",null,C(E.property),1)]),typeof c(E.property)=="number"?(r(),o("p",_2," Max instances: "+C(c(E.property)),1)):S("",!0),k(P,{type:"repeater",name:y(E.property),min:1,max:c(E.property),"add-label":"Add instance","remove-icon":"close","add-attrs":{outerClass:"$reset m-0 inline-flex",wrapperClass:"$reset m-0 inline-flex",inputClass:"inline-flex w-auto min-w-0 py-1 px-2 text-sm font-medium rounded-sm border border-accent-500/50 text-accent-500 hover:bg-accent-500/10 hover:border-accent-400 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent-400 disabled:opacity-50",helpClass:"$remove:hidden",messagesClass:"$remove:hidden"},"insert-control":!1,"up-control":!1,"down-control":!1,"remove-control":!0,"outer-class":"$reset",classes:{outer:"$remove:mb-4 mb-0",wrapper:"$remove",fieldset:"$remove:border-0 p-0 m-0 min-w-0",legend:"$remove:hidden",content:"$remove:p-5 $remove:space-y-2 p-0 space-y-2",item:"$remove:bg-white $remove:border $remove:border-zinc-200 $remove:rounded-sm $remove:dark:border-zinc-700 $remove:dark:bg-transparent $remove:mb-2 mb-0 border border-neutral-200 dark:border-neutral-700 bg-transparent rounded-sm p-2",controls:"$reset m-0 h-full self-stretch flex items-center justify-end list-none p-0 bg-transparent border-0",remove:"$reset list-none m-0 ml-2 p-0 h-full flex items-center justify-center",removeControl:"$reset inline-flex h-5 w-5 items-center justify-center rounded text-neutral-500 dark:text-white/70 hover:text-red-500 dark:hover:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/30 disabled:opacity-50 disabled:hidden",removeIcon:"$reset h-3.5 w-3.5",controlLabel:"$reset hidden",addButton:"$reset mt-1 inline-flex",help:"$remove:hidden",messages:"$remove:formkit-messages hidden"}},{default:W(({index:z})=>[t("div",$2,[t("p",C2," Instance "+C(Number(z)+1),1),(r(!0),o($e,null,Le(u.value.get(E.property)||[],A=>(r(),o("div",{key:`${E.property}-${A.property}-${z}`,class:"space-y-1"},[t("div",S2,[k(P,{type:"text",value:A.property,disabled:!0,"outer-class":"$reset",classes:{outer:"$remove:mb-4 group mb-0",wrapper:"$remove:flex-1 flex-1",inner:"!bg-zinc-100 dark:!bg-zinc-700/40 !cursor-not-allowed"}},null,8,["value"]),k(P,{type:"text",value:A.type,disabled:!0,"outer-class":"$reset",classes:{outer:"$remove:mb-4 group mb-0",wrapper:"$remove:flex-1 flex-1",inner:"!bg-zinc-100 dark:!bg-zinc-700/40 !cursor-not-allowed"}},null,8,["value"]),k(P,{name:A.property,type:A.type==="secret"?"password":"text",placeholder:A.description||"Enter value...",disabled:e.disabled,validation:e.requireRequiredValues&&A.required?"required":"","validation-label":"Value","validation-visibility":"submit","outer-class":"$reset",classes:{outer:"$remove:mb-4 group mb-0",wrapper:"$remove:flex-1 flex-1",inner:e.disabled?"!bg-zinc-100 dark:!bg-zinc-700/40 !cursor-not-allowed":""}},null,8,["name","type","placeholder","disabled","validation","classes"])]),t("p",I2,C(m(A)),1)]))),128))])]),_:2},1032,["name","max"])],8,k2)):S("",!0)],8,x2))),128))])]),_:1},8,["name"])}}}),M2={class:"hidden"},z2={class:"flex-1 overflow-y-auto p-6"},V2={class:"space-y-4"},E2={class:"flex items-center justify-between mb-1"},L2={key:0,class:"flex items-center gap-1.5 ml-auto"},A2={key:0},P2={key:1},O2={key:2},R2={key:1,class:"space-y-4"},j2={key:2,class:"text-center text-sm text-neutral-500"},D2={key:3,class:"space-y-3"},U2={key:4,class:"text-center text-sm text-neutral-500"},B2={class:"p-6 border-t border-neutral-200 dark:border-neutral-700 flex-shrink-0"},N2={class:"flex justify-between items-center"},q2={class:"flex gap-2"},da="__optional__",F2=Se({__name:"CreateThreadModal",props:{modelValue:{type:Boolean},editThread:{}},emits:["update:modelValue","thread-created","thread-updated"],setup(e,{emit:n}){const a=e,s=n,l=F(()=>!!a.editThread),u=p(""),i=p(!1),c=p(!1),f=p(""),h=p([]),x=p(!1),b=p(null),y=U=>U&&typeof U=="object"&&!Array.isArray(U)?U:{},$=U=>U==null?"":String(U),g=U=>$(U).split(",").map(K=>K.trim()).filter(K=>K.length>0),d=U=>{const K=y(U),me={};for(const[ue,Q]of Object.entries(K)){if(ue.startsWith(da))continue;const G=$(Q);G&&(me[ue]=G)}for(const[ue,Q]of Object.entries(K)){if(!ue.startsWith(da)||!Array.isArray(Q))continue;let G=0;for(const ae of Q){const ie=y(ae);if(Object.values(ie).some(X=>$(X).trim().length>0)){for(const[X,he]of Object.entries(ie)){const be=$(he),B=G===0?X:`${X}__${G+1}`;if(G===0){be&&(me[B]=be);continue}me[B]=be}G+=1}}}return me},w=U=>{const K=new URL(ze(`/api/variables/agents/${encodeURIComponent(U)}`),window.location.origin);return K.searchParams.set("include_optional_disabled","1"),K.toString()},m=()=>({include_subagents:!1,agent_id:l.value&&a.editThread?.agent_id||"",tags_csv:l.value&&a.editThread?.tags?.join(", ")||"",data:{},env:{}}),v=U=>{b.value=U},_=U=>{const K=y(U),me=$(K.agent_id),ue=!!K.include_subagents;return u.value!==me&&(u.value=me),i.value!==ue&&(i.value=ue),""},{data:P,isFetching:V,execute:E}=it(ze("/api/agents"),{immediate:!1}).json(),z=F(()=>{if(!P.value)return[];const U=P.value?.agents||[];return l.value||i.value?U:U.filter(K=>K.type!=="dual_ai")}),A=()=>z.value.map(U=>({value:U.id,label:U.title})),oe=F(()=>!u.value||!P.value?null:(P.value?.agents||[]).find(K=>K.id===u.value)||null),{data:ne,isFetching:fe,execute:ye}=it(F(()=>oe.value?.side_a_agent_prompt?ze(`/api/prompts/${encodeURIComponent(oe.value.side_a_agent_prompt)}`):""),{immediate:!1}).json(),te=F(()=>{if(!ne.value)return null;const K=(ne.value?.prompt||ne.value)?.required_schema;if(!K)return null;try{return typeof K=="string"?JSON.parse(K):K}catch{return null}}),q=F(()=>{const U=te.value;return!U||!U.properties?[]:Object.entries(U.properties).map(([K,me])=>({name:K,type:me.type||"string",description:me.description||"",required:U.required?.includes(K)||!1,enum:me.enum}))}),j=F(()=>h.value.length>0),J=async U=>{if(!U){h.value=[];return}x.value=!0;try{const K=await fetch(w(U));if(!K.ok){h.value=[];return}const me=await K.json();h.value=me.variables||[]}catch(K){console.error("Error scanning agent variables:",K),h.value=[]}finally{x.value=!1}};Ve(u,async U=>{U&&oe.value?.side_a_agent_prompt?await ye():ne.value=null,U?await J(U):h.value=[]}),Ve([i,z,l],()=>{l.value||!u.value||z.value.some(K=>K.id===u.value)||(u.value="",b.value?.at("agent_id")?.input(""))});const H=()=>{u.value=l.value&&a.editThread?.agent_id||"",i.value=!1,f.value="",h.value=[],ne.value=null,b.value?.reset(m())},ce=async U=>{c.value=!0,f.value="";const K=y(U),me=g(K.tags_csv);try{if(l.value){const X=await fetch(ze(`/api/threads/${a.editThread.id}`),{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({tags:me})});if(!X.ok){const he=await X.json();throw new Error(he.error||"Failed to update thread")}s("thread-updated"),H(),s("update:modelValue",!1);return}const ue={agent_id:$(K.agent_id),tags:me.length>0?me:void 0},Q=y(K.data);Object.keys(Q).length>0&&(ue.data=Q);const G=d(K.env);Object.keys(G).length>0&&(ue.env=G);const ae=await fetch(ze("/api/threads"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(ue)});if(!ae.ok){const X=await ae.json();throw new Error(X.error||"Failed to create thread")}const xe=(await ae.json()).threadId;if(!xe)throw new Error("Thread created but ID not found in response");s("thread-created",xe),H(),s("update:modelValue",!1)}catch(ue){console.error(`Error ${l.value?"updating":"creating"} thread:`,ue),f.value=ue.message||`Failed to ${l.value?"update":"create"} thread`}finally{c.value=!1}},Z=()=>{H(),s("update:modelValue",!1)};return Ve(()=>a.modelValue,async U=>{U&&(await E(),H())}),(U,K)=>{const me=at("FormKit");return r(),Y(dt,{"model-value":e.modelValue,"onUpdate:modelValue":K[0]||(K[0]=ue=>U.$emit("update:modelValue",ue)),title:l.value?"Edit Thread":"Create New Thread",width:"max-w-3xl","content-padding":!1},{default:W(()=>[k(me,{type:"form",id:"create-thread-form",actions:!1,onSubmit:ce,onNode:v,"form-class":"$reset flex-1 min-h-0 flex flex-col"},{default:W(({value:ue})=>[t("span",M2,C(_(ue)),1),t("div",z2,[t("div",V2,[f.value?(r(),Y(I(ot),{key:0,variant:"error"},{default:W(()=>[ve(C(f.value),1)]),_:1})):S("",!0),t("div",null,[t("div",E2,[K[2]||(K[2]=t("label",{class:"block text-zinc-700 dark:text-zinc-300 text-xs font-bold"}," Agent ",-1)),l.value?S("",!0):(r(),o("div",L2,[K[1]||(K[1]=t("span",{class:"text-[11px] text-neutral-500 dark:text-neutral-400"}," Include subagents ",-1)),k(me,{type:"toggle",name:"include_subagents",value:!1,"on-value":!0,"off-value":!1,"on-value-label":"","off-value-label":"",disabled:I(V),classes:{outer:"$remove:mb-4 mb-0",wrapper:"$remove:items-center flex items-center",label:"$remove:hidden",inner:"h-4",track:"h-4 w-7 rounded-full",thumb:"h-3 w-3",valueLabel:"$remove:hidden"}},null,8,["disabled"])]))]),k(me,{type:"selectSearch",name:"agent_id",value:u.value,options:A,disabled:I(V)||l.value,placeholder:"Select an agent...",validation:"required","validation-visibility":"submit"},null,8,["value","disabled"]),k(I(Ne),{class:"mt-1"},{default:W(()=>[l.value?(r(),o("span",A2,"Agent cannot be changed after thread creation")):i.value?(r(),o("span",P2,"Choose which agent will handle this conversation (subagents included)")):(r(),o("span",O2,"Choose which agent will handle this conversation"))]),_:1})]),!l.value&&q.value.length>0&&!I(fe)?(r(),o("div",R2,[K[3]||(K[3]=t("h4",{class:"text-sm font-medium text-neutral-700 dark:text-neutral-300"}," Required Information ",-1)),k(me,{type:"group",name:"data","outer-class":"$reset",classes:{outer:"$remove:mb-4 mb-0"}},{default:W(()=>[(r(!0),o($e,null,Le(q.value,Q=>(r(),o("div",{key:Q.name,class:"space-y-2"},[Q.enum?(r(),Y(me,{key:0,type:"selectSearch",name:Q.name,label:Q.name,options:[{value:"",label:"Select..."},...Q.enum.map(G=>({value:G,label:G}))],validation:Q.required?"required":"","validation-visibility":"submit"},null,8,["name","label","options","validation"])):Q.type==="string"?(r(),Y(me,{key:1,type:"text",name:Q.name,label:Q.name,placeholder:Q.description,validation:Q.required?"required":"","validation-visibility":"submit"},null,8,["name","label","placeholder","validation"])):Q.type==="number"||Q.type==="integer"?(r(),Y(me,{key:2,type:"number",name:Q.name,label:Q.name,placeholder:Q.description,validation:Q.required?"required":"","validation-visibility":"submit"},null,8,["name","label","placeholder","validation"])):Q.type==="boolean"?(r(),Y(me,{key:3,type:"checkbox",name:Q.name,label:Q.name,validation:Q.required?"required":"","validation-visibility":"submit"},null,8,["name","label","validation"])):(r(),Y(me,{key:4,type:"textarea",name:Q.name,label:Q.name,placeholder:Q.description||`Enter ${Q.name} (JSON format)`,validation:Q.required?"required":"","validation-visibility":"submit",rows:3},null,8,["name","label","placeholder","validation"])),Q.description?(r(),Y(I(Ne),{key:5,class:"mt-1"},{default:W(()=>[ve(C(Q.description),1)]),_:2},1024)):S("",!0)]))),128))]),_:1})])):S("",!0),!l.value&&I(fe)?(r(),o("div",j2," Loading agent requirements... ")):S("",!0),!l.value&&j.value?(r(),o("div",D2,[K[4]||(K[4]=t("h4",{class:"text-sm font-medium text-neutral-700 dark:text-neutral-300"}," Variables ",-1)),K[5]||(K[5]=t("p",{class:"text-xs text-neutral-500 dark:text-neutral-400"}," Required variables must be resolved before a new thread can be created. ",-1)),k(T2,{"group-name":"env",scanned:h.value,disabled:c.value,"require-required-values":!0},null,8,["scanned","disabled"])])):S("",!0),!l.value&&x.value?(r(),o("div",U2," Scanning environment variables... ")):S("",!0),t("div",null,[k(me,{type:"text",name:"tags_csv",value:l.value&&a.editThread?.tags?.join(", ")||"",label:"Tags",placeholder:"research, urgent, production"},null,8,["value"]),k(I(Ne),{class:"mt-1"},{default:W(()=>[...K[6]||(K[6]=[ve(" Comma-separated tags to help organize and search threads ",-1)])]),_:1})])])]),t("div",B2,[t("div",N2,[k(I(Er),{node:b.value||void 0},null,8,["node"]),t("div",q2,[k(I(Qe),{variant:"ghost",size:"sm",disabled:c.value,onClick:Z},{default:W(()=>[...K[7]||(K[7]=[ve(" Cancel ",-1)])]),_:1},8,["disabled"]),k(I(Qe),{variant:"primary",size:"sm",disabled:c.value||I(V),loading:c.value,type:"submit",form:"create-thread-form"},{default:W(()=>[l.value?(r(),o($e,{key:0},[ve(C(c.value?"Updating...":"Update Thread"),1)],64)):(r(),o($e,{key:1},[ve(C(c.value?"Creating...":"Create Thread"),1)],64))]),_:1},8,["disabled","loading"])])])])]),_:1})]),_:1},8,["model-value","title"])}}}),H2={class:"flex h-full overflow-hidden"},W2={key:0,class:"flex flex-col items-center p-4"},K2={key:0,class:"flex flex-col items-center p-4"},J2={class:"flex-1 overflow-hidden flex flex-col min-h-0"},ca=Se({__name:"ThreadsView",setup(e){const n=Vt(),a=qt(),s=p(typeof n.params.id=="string"?n.params.id:null),l=p({threadList:!1,messages:!1}),u=p(!1),i=p(null),c=p(null),{thread:f}=jr(F(()=>s.value)),h=p(null),x=p(null),b=p(null),y=p(null),$=p(null),g=j=>{y.value=j,$.value=j},d=j=>{const J=m.value,H=v.value;if(!J||!H)return null;if(J.hasWorkblockForLogId(j))return j;let ce=j;const Z=10;for(let U=0;U<Z&&ce;U++){const K=H.getLog(ce);if(!K)break;const me=K.parent_log_id;if(!me)break;if(J.hasWorkblockForLogId(me))return me;ce=me}return null},w=j=>{if(y.value=j,!j){$.value=null;return}$.value=d(j)??j},m=p(null),v=p(null);Ve(()=>n.params.id,j=>{s.value=typeof j=="string"?j:null,h.value=null,x.value=null,b.value=null});const _=j=>{a.push(`/threads/${j}`)},P=j=>{window.location.href="/threads"},V=()=>{f.value&&(i.value=f.value,u.value=!0)},E=()=>{i.value=null,u.value=!0},z=j=>{c.value?.refetch(),a.push(`/threads/${j}`)},A=()=>{c.value?.refetch()},oe=j=>{l.value[j]=!l.value[j]},ne=async(j,J)=>{if(h.value=j,!J){x.value=null,b.value=null;return}const H=v.value;if(!H){x.value=J,b.value=J;return}const ce=!H.hasLog(J);if(ce&&H.setLoadingForLog(!0),x.value=J,b.value=J,ce&&!await H.loadUntilLogId(J)){console.warn(`Could not find log ${J} after loading all available logs`),H.setLoadingForLog(!1);return}if(!await H.waitForLogRow(J)){console.warn(`Log row ${J} not rendered in time`);return}H.scrollToLog(J),H.selectLogById(J)},fe=j=>{x.value=j,h.value=null;const J=m.value;if(!J){b.value=j;return}if(J.scrollToLogId(j)){b.value=j;return}const H=d(j);H&&H!==j&&J.scrollToLogId(H),b.value=H??j},ye=j=>{j&&(x.value=j)},te=j=>{v.value?.removeLogsByIds(j)},q=j=>{j&&!s.value&&a.push(`/threads/${j}`)};return(j,J)=>(r(),o("div",H2,[t("div",{class:pe([l.value.threadList?"w-[60px]":"w-[320px]","border-r border-neutral-300 dark:border-neutral-700 flex-shrink-0 transition-all duration-200 flex flex-col min-h-0"])},[l.value.threadList?(r(),o("div",W2,[t("button",{onClick:J[0]||(J[0]=H=>oe("threadList")),class:"p-2 hover:bg-neutral-100 dark:hover:bg-neutral-900 rounded transition-colors",title:"Expand Threads pane"},[k(I(Sa),{size:20})])])):(r(),Y(ug,{key:1,ref_key:"threadListPaneRef",ref:c,"selected-thread-id":s.value,onSelectThread:_,onCollapse:J[1]||(J[1]=H=>oe("threadList")),onCreateThread:E,onThreadsLoaded:q},null,8,["selected-thread-id"]))],2),t("div",{class:pe([l.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"])},[l.value.messages?(r(),o("div",K2,[t("button",{onClick:J[2]||(J[2]=H=>oe("messages")),class:"p-2 hover:bg-neutral-100 dark:hover:bg-neutral-900 rounded transition-colors",title:"Expand Messages pane"},[k(I(za),{size:20})])])):s.value?(r(),Y(I(Io),{key:1,"thread-id":s.value,preload:!0,live:!0,"include-silent":!0,"use-workblocks":!0,"use-subagent-blocks":!0},{default:W(()=>[k(sa,{ref_key:"messagesPaneRef",ref:m,"thread-id":s.value,"selected-message-id":h.value,"selected-log-id":b.value,"hovered-log-id":$.value,onCollapse:J[3]||(J[3]=H=>oe("messages")),onMessageClick:ne,onMessageHover:g,onThreadDeleted:P,onEditThread:V,onLogsDeleted:te,onThreadUpdated:A},null,8,["thread-id","selected-message-id","selected-log-id","hovered-log-id"])]),_:1},8,["thread-id"])):l.value.messages?S("",!0):(r(),Y(sa,{key:2,ref_key:"messagesPaneRef",ref:m,"thread-id":null,"selected-message-id":h.value,"selected-log-id":b.value,"hovered-log-id":$.value,onCollapse:J[4]||(J[4]=H=>oe("messages")),onMessageClick:ne,onMessageHover:g,onThreadDeleted:P,onEditThread:V,onLogsDeleted:te,onThreadUpdated:A},null,8,["selected-message-id","selected-log-id","hovered-log-id"]))],2),t("div",J2,[k(h2,{ref_key:"logsPaneRef",ref:v,"thread-id":s.value,"selected-log-id":x.value,"hovered-log-id":y.value,onLogClick:fe,onLogHover:w,onLogsLoaded:ye},null,8,["thread-id","selected-log-id","hovered-log-id"])]),k(F2,{modelValue:u.value,"onUpdate:modelValue":J[5]||(J[5]=H=>u.value=H),"edit-thread":i.value,onThreadCreated:z,onThreadUpdated:A},null,8,["modelValue","edit-thread"])]))}}),G2=Se({__name:"PromptsDataTable",props:{title:{},description:{},primaryAction:{},readonly:{type:Boolean,default:!1}},emits:["add","edit","delete"],setup(e,{expose:n,emit:a}){const s=e,l=a,u=p([]),i=p(!1),c=[{key:"name",label:"Name",width:"w-1/4",sortable:!0},{key:"tool_description",label:"Description",width:"w-2/5"},{key:"model_name",label:"Model",width:"w-1/5",sortable:!0,filterable:!0,formatter:(y,$)=>y||$.model_id||"-",filterIcon:(y,$)=>$.model_provider?`/api/providers/${$.model_provider}/icon?model=${encodeURIComponent($.model_id||"")}`:void 0},{key:"created_at",label:"Created",width:"w-1/6",sortable:!0,searchable:!1,formatter:y=>y?new Date(y*1e3).toLocaleDateString():"-"}],f=[{icon:"edit",label:"Edit",handler:y=>l("edit",y)},{icon:"delete",label:"Delete",handler:async y=>{await b(y)},confirm:!0,confirmMessage:"Are you sure you want to delete this prompt?",variant:"danger"}],h=F(()=>s.readonly?f.filter(y=>y.variant!=="danger"):f),x=async()=>{i.value=!0;try{const y=await fetch(ze("/api/prompts"));if(y.ok){const $=await y.json();u.value=$.prompts||[]}}catch(y){console.error("Error fetching prompts:",y)}finally{i.value=!1}},b=async y=>{try{const $=await fetch(ze(`/api/prompts/${encodeURIComponent(y.id)}`),{method:"DELETE"});if($.ok)await x();else{const g=await $.json();alert(g.error||"Failed to delete prompt")}}catch($){console.error("Error deleting prompt:",$),alert("Failed to delete prompt")}};return He(()=>{x()}),n({refresh:x}),(y,$)=>(r(),o("div",null,[k(It,{title:e.title,description:e.description,"primary-action":e.primaryAction,columns:c,data:u.value,actions:h.value,loading:i.value,sortable:"",searchable:"","search-placeholder":"Search prompts...","empty-message":"No prompts available. Create your first prompt to get started.",onRowClick:$[0]||($[0]=g=>l("edit",g))},null,8,["title","description","primary-action","data","actions","loading"])]))}}),Y2={class:"space-y-4"},Z2={key:0,class:"-mt-2 text-sm text-neutral-500 dark:text-neutral-400"},X2={class:"px-1 py-0.5 bg-neutral-100 dark:bg-neutral-800 rounded"},Q2=Se({__name:"PromptBasicInfo",props:{name:{},toolDescription:{}},emits:["update:name","update:toolDescription"],setup(e,{emit:n}){const a=n,s=u=>{let i=u.replace(/[^a-zA-Z0-9\s_]/g,"");return i=i.trim().toLowerCase().replace(/\s+/g,"_").replace(/_+/g,"_").replace(/^_|_$/g,""),i},l=u=>{const i=s(u);a("update:name",i)};return(u,i)=>{const c=at("FormKit");return r(),o("div",Y2,[k(c,{type:"text",name:"name",value:e.name,onInput:l,label:"Prompt Name",placeholder:"Enter a unique name (will be converted to snake_case)",validation:"required|matches:/^[a-z][a-z0-9_]*$/","validation-messages":{matches:"Must start with a letter and contain only lowercase letters, numbers, and underscores"},"validation-visibility":"submit","outer-class":"$reset"},null,8,["value"]),e.name?(r(),o("p",Z2,[i[1]||(i[1]=ve(" Will be saved as: ",-1)),t("code",X2,C(e.name),1)])):S("",!0),k(c,{type:"textarea",name:"tool_description",value:e.toolDescription,onInput:i[0]||(i[0]=f=>a("update:toolDescription",f)),label:"Tool Description",placeholder:"Describe what this prompt does (shown when used as a tool)",rows:"3",validation:"required","validation-visibility":"submit","outer-class":"$reset"},null,8,["value"])])}}}),ew={class:"space-y-4"},tw=Se({__name:"PromptModelSelect",props:{modelValue:{}},emits:["update:modelValue"],setup(e,{emit:n}){const a=n,s=p([]),l=p(!1),u=F(()=>s.value.map(c=>({value:c.id,label:c.name,description:c.model||c.provider,icon:c.provider?`/api/providers/${c.provider}/icon?model=${encodeURIComponent(c.model||"")}`:void 0}))),i=async()=>{l.value=!0;try{const c=await fetch(ze("/api/models"));if(c.ok){const f=await c.json();s.value=f.models||[]}}catch(c){console.error("Error fetching models:",c)}finally{l.value=!1}};return He(()=>{i()}),(c,f)=>{const h=at("FormKit");return r(),o("div",ew,[k(h,{type:"autocomplete",name:"model_id",value:e.modelValue,onInput:f[0]||(f[0]=x=>a("update:modelValue",x)),options:u.value,label:"Model",placeholder:"Search models...",loading:l.value,validation:"required","validation-visibility":"submit","outer-class":"$reset","selection-removable":""},null,8,["value","options","loading"])])}}});function pa(e,n){if(!n||!n.properties||Object.keys(n.properties).length===0)return!0;if(!e||!e.properties)return Object.keys(n.properties);const a=[],s=e.properties||{},l=n.properties||{};return(n.required||[]).forEach(i=>{i in s||a.push(i)}),Object.keys(l).forEach(i=>{!(i in s)&&!a.includes(i)&&a.push(i)}),a.length>0?a:!0}function ma(e){return e.length===0?"":e.length===1?`Missing required field: ${e[0]}`:`Missing required fields: ${e.join(", ")}`}const rw=Se({__name:"PromptTemplate",props:{promptText:{},beforeTool:{},afterTool:{},requiredSchema:{},currentPromptName:{},availableEnvVariables:{}},emits:["update:promptText","update:beforeTool","update:afterTool"],setup(e,{emit:n}){const a=e,s=n,l=p([]),u=p(!1),i=y=>y.type==="text"?{type:"string",value:y.content||""}:y.type==="include"?{type:"prompt",id:y.prompt||"",label:y.prompt||""}:y.type==="env"?{type:"env",property:y.property||"",label:y.label||y.property||""}:y.type==="string"?{type:"string",value:y.value||""}:y.type==="prompt"?{type:"prompt",id:y.id||"",label:y.label||y.id||""}:y.type==="variable"?{type:"variable",value:y.value||"",label:y.label||y.value||""}:{type:"string",value:""},c=F(()=>{if(!a.promptText)return[{type:"string",value:""}];let y=[];try{const g=JSON.parse(a.promptText);Array.isArray(g)?y=g.map(i):y=[{type:"string",value:a.promptText}]}catch{y=[{type:"string",value:a.promptText}]}const $=a.requiredSchema?JSON.parse(a.requiredSchema):{};return y.map(g=>{if(g.type==="prompt"&&g.schema){const d=pa($,g.schema),w=d===!0,m=w?[]:d;return{...g,meta:{isValid:w,missingFields:m,validationMessage:w?"":ma(m)}}}if(g.type==="env"){const d=g.property;if(!(a.availableEnvVariables||[]).includes(d))return{...g,meta:{isValid:!1,validationMessage:`Variable "${d}" is not defined on this prompt`}}}return g})}),f=F(()=>{try{const y=JSON.parse(a.requiredSchema);if(y.properties&&typeof y.properties=="object")return Object.keys(y.properties)}catch{return[]}return[]}),h=async y=>{u.value=!0;try{const $=new URLSearchParams;y&&$.set("search",y);const g=await fetch(ze(`/api/prompts${$.toString()?"?"+$.toString():""}`));if(g.ok){const d=await g.json();l.value=d.prompts||[]}}catch($){console.error("Error fetching prompts:",$)}finally{u.value=!1}},x=async y=>{const $=[];return f.value.forEach(g=>{(!y||g.toLowerCase().includes(y.toLowerCase()))&&$.push({type:"variable",value:g,label:g,description:"Schema property"})}),(a.availableEnvVariables||[]).forEach(g=>{(!y||g.toLowerCase().includes(y.toLowerCase()))&&$.push({type:"env",value:g,label:g,description:"Thread env variable"})}),y!==void 0&&await h(y),l.value.forEach(g=>{if(!(a.currentPromptName&&g.name===a.currentPromptName)&&(!y||g.name.toLowerCase().includes(y.toLowerCase()))){const d=a.requiredSchema?JSON.parse(a.requiredSchema):{},w=pa(d,g.required_schema),m=w===!0,v=m?[]:w;$.push({type:"prompt",id:g.name,label:g.name,description:g.tool_description||"Available prompt",schema:g.required_schema,meta:{isValid:m,missingFields:v,validationMessage:m?"":ma(v)}})}}),$},b=y=>{const $=y.map(g=>{const{type:d,value:w,label:m,id:v,property:_,schema:P}=g;return d==="string"?{type:d,value:w||""}:d==="variable"?{type:d,value:w||"",label:m}:d==="env"?{type:d,property:_||w||v||"",label:m}:d==="prompt"?{type:d,id:v||"",label:m,schema:P}:g});s("update:promptText",JSON.stringify($))};return He(()=>{h()}),(y,$)=>(r(),o("div",null,[k(Pr,{"model-value":c.value,"onUpdate:modelValue":b,search:x,placeholder:"Enter your prompt template... Type @ to insert variables, env, or prompts"},null,8,["model-value"])]))}}),aw={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function nw(e,n){return r(),o("svg",aw,[...n[0]||(n[0]=[t("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2a2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1m8 0h1a2 2 0 0 0 2-2v-5c0-1.1.9-2 2-2a2 2 0 0 1-2-2V5a2 2 0 0 0-2-2h-1"},null,-1)])])}const va=je({name:"lucide-braces",render:nw}),ow={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function lw(e,n){return r(),o("svg",ow,[...n[0]||(n[0]=[t("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M10 5H3m9 14H3M14 3v4m2 10v4m5-9h-9m9 7h-5m5-14h-7m-6 5v4m0-2H3"},null,-1)])])}const fa=je({name:"lucide-sliders-horizontal",render:lw}),sw={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function iw(e,n){return r(),o("svg",sw,[...n[0]||(n[0]=[t("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z"},null,-1)])])}const ga=je({name:"lucide-zap",render:iw}),uw={key:0,class:"min-h-[500px] flex items-center justify-center"},dw={class:"flex flex-1 min-h-0"},cw={class:"w-44 flex-shrink-0 border-r border-neutral-200 dark:border-neutral-700 py-4"},pw={class:"space-y-4"},mw={class:"space-y-5"},vw={key:0,class:"mb-4 py-6 px-4 border border-dashed border-neutral-300 dark:border-neutral-600 rounded-lg text-center"},fw={key:0,class:"space-y-2 mb-4"},gw={class:"flex-1 min-w-0"},hw={class:"font-medium text-sm"},bw={class:"text-xs text-neutral-500 dark:text-neutral-400"},xw=["onClick","aria-label"],yw={key:2,class:"py-6 px-4 border border-dashed border-neutral-300 dark:border-neutral-600 rounded-lg text-center"},kw={key:3,class:"text-center py-3 text-xs text-neutral-400 dark:text-neutral-500"},ww={key:0,class:"text-xs text-neutral-500 dark:text-neutral-400 mb-3"},_w={class:"mb-6"},$w={class:"grid grid-cols-2 gap-6 items-start"},Cw={class:"flex flex-col"},Sw={class:"space-y-4 mb-6 mt-6 pt-6 border-t border-neutral-100 dark:border-neutral-800"},Iw={class:"pt-6 border-t border-neutral-100 dark:border-neutral-800"},Tw={class:"grid grid-cols-2 gap-6 mb-4"},Mw={class:"p-6 border-t border-neutral-200 dark:border-neutral-700 flex-shrink-0"},zw={class:"flex justify-between items-center"},Vw={key:0,class:"flex items-center gap-3"},ln=Se({__name:"PromptModal",props:{modelValue:{type:Boolean},editPrompt:{},mode:{},readonly:{type:Boolean,default:!1},saving:{type:Boolean,default:!1}},emits:["update:modelValue","save"],setup(e,{expose:n,emit:a}){const s=e,l=a,u=F(()=>s.mode==="edit"),i=p(!1),c=p(null),f=["basics","schema","prompt","tools","hooks","variables","behavior"],{activeTab:h,scrollToSection:x}=Qa(c,f),b=[{id:"basics",label:"Basics",icon:cr},{id:"schema",label:"Schema",icon:va},{id:"prompt",label:"Prompt",icon:dr},{id:"tools",label:"Tools",icon:Mr},{id:"hooks",label:"Hooks",icon:ga},{id:"variables",label:"Variables",icon:Jt},{id:"behavior",label:"Behavior",icon:fa}],y=F(()=>A.value.length===1),$=p(""),g=p(null),d=p(""),w=p(""),m=p(""),v=p({type:"object",properties:{},required:[],additionalProperties:!1}),_=p(""),P=p(!1),V=p(!1),E=p(""),z=p(""),A=p([]),oe=p(!1),ne=p(null),fe=p("auto"),ye=p(""),te=p(null),q=p(!1),j=p(!1),J=p([]),H=p([]),ce=p(""),Z=p([]),U=p({}),K=p([]),me=p(!1),ue=p({}),Q=p([]);let G=null,ae=0;const ie=F(()=>{const Ce=new Set;for(const we of K.value)Ce.add(we.property);for(const we of Z.value){const Ae=we.name?.trim();Ae&&Ce.add(Ae)}return Array.from(Ce).sort((we,Ae)=>we.localeCompare(Ae))}),xe=(Ce,we)=>{const Ae=!!we?.pruneRemoved,Te=Ce.map(Ze=>Ze.property),Ke=new Set(Te),et=Ae?Q.value.filter(Ze=>!Ke.has(Ze)):[];if(et.length>0){const Ze=new Set(et);let st=!1;const Pe={...U.value};for(const Ee of Ze)Ee in Pe&&(delete Pe[Ee],st=!0);st&&(U.value=Pe);const se=Z.value.filter(Ee=>{const Oe=Ee.name?.trim();return!Oe||!Ze.has(Oe)});se.length!==Z.value.length&&(Z.value=se)}K.value=Ce,Q.value=Te},X=F(()=>{const Ce=new Set(J.value);return H.value.filter(we=>!Ce.has(we.id)).map(we=>({value:we.id,label:we.id,attrs:{description:we.hook}}))}),he=Ce=>{Ce&&(J.value.includes(Ce)||(J.value=[...J.value,Ce],Fe(()=>{ce.value=""})))},be=p(null),B=Ce=>{be.value=Ce},D={sparkles:"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z'/%3E%3Cpath d='M20 3v4'/%3E%3Cpath d='M22 5h-4'/%3E%3C/svg%3E",ban:"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpath d='m4.9 4.9 14.2 14.2'/%3E%3C/svg%3E",checkCircle:"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpath d='m9 12 2 2 4-4'/%3E%3C/svg%3E",target:"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Ccircle cx='12' cy='12' r='6'/%3E%3Ccircle cx='12' cy='12' r='2'/%3E%3C/svg%3E",signalNone:"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none'%3E%3Crect x='5' y='15' width='3' height='5' rx='1' fill='currentColor' opacity='0.2'/%3E%3Crect x='10.5' y='10' width='3' height='10' rx='1' fill='currentColor' opacity='0.2'/%3E%3Crect x='16' y='5' width='3' height='15' rx='1' fill='currentColor' opacity='0.2'/%3E%3C/svg%3E",signalLow:"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none'%3E%3Crect x='5' y='15' width='3' height='5' rx='1' fill='currentColor'/%3E%3Crect x='10.5' y='10' width='3' height='10' rx='1' fill='currentColor' opacity='0.2'/%3E%3Crect x='16' y='5' width='3' height='15' rx='1' fill='currentColor' opacity='0.2'/%3E%3C/svg%3E",signalMedium:"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none'%3E%3Crect x='5' y='15' width='3' height='5' rx='1' fill='currentColor'/%3E%3Crect x='10.5' y='10' width='3' height='10' rx='1' fill='currentColor'/%3E%3Crect x='16' y='5' width='3' height='15' rx='1' fill='currentColor' opacity='0.2'/%3E%3C/svg%3E",signalHigh:"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none'%3E%3Crect x='5' y='15' width='3' height='5' rx='1' fill='currentColor'/%3E%3Crect x='10.5' y='10' width='3' height='10' rx='1' fill='currentColor'/%3E%3Crect x='16' y='5' width='3' height='15' rx='1' fill='currentColor'/%3E%3C/svg%3E"},M=F(()=>{const Ce=[{value:"auto",label:"Auto",description:"Model decides",icon:D.sparkles},{value:"none",label:"None",description:"No tools allowed",icon:D.ban},{value:"required",label:"Required",description:"Must call a tool",icon:D.checkCircle}];return y.value&&Ce.push({value:"function",label:"Function",description:"Call specific tool",icon:D.target}),Ce}),T=[{value:"",label:"None",description:"Disabled",icon:D.signalNone},{value:"low",label:"Low",description:"~20% of max_tokens",icon:D.signalLow},{value:"medium",label:"Medium",description:"~50% of max_tokens",icon:D.signalMedium},{value:"high",label:"High",description:"~80% of max_tokens",icon:D.signalHigh}],L=()=>{d.value="",$.value="",w.value="",m.value="",g.value=null,v.value={type:"object",properties:{},required:[],additionalProperties:!1},_.value="",P.value=!1,V.value=!1,E.value="",z.value="",A.value=[],oe.value=!1,fe.value="auto",ye.value="",te.value=null,q.value=!1,j.value=!1,J.value=[],Z.value=[],U.value={},K.value=[],Q.value=[],me.value=!1},ee=async Ce=>{if(!Ce){g.value=null;return}try{const we=await ut(`/models/${encodeURIComponent(Ce)}`);if(we.ok){const Ae=await we.json();g.value=Ae.model||Ae}}catch(we){console.error("Error fetching model info:",we),g.value=null}};Ve(m,async Ce=>{Ce?await ee(Ce):g.value=null});const le=async()=>{try{const Ce=await ut("/hooks");if(Ce.ok){const we=await Ce.json();H.value=we.hooks||[]}}catch(Ce){console.error("Error fetching hooks:",Ce),H.value=[]}},Ie=async()=>{try{const Ce=await ut("/tools");Ce.ok?ue.value=await Ce.json()||{}:ue.value={}}catch(Ce){console.error("Error fetching tool catalog:",Ce),ue.value={}}},Re=Ce=>{if(!Ce||Ce.startsWith("provider:")||Ce.startsWith("mcp:"))return null;const we=ue.value[Ce];return we?.type==="prompt"?{type:"prompt",name:Ce}:we?.type==="handoff"||we?.type==="subagent"||we?.type==="agent"?{type:"agent",name:Ce}:{type:"tool",name:Ce}},qe=()=>{if(!_.value)return[];const Ce=[];try{const we=JSON.parse(_.value);if(!Array.isArray(we))return[];for(const Ae of we){if(!Ae||typeof Ae!="object")continue;const Te=Ae.type;Te==="prompt"&&typeof Ae.id=="string"&&Ae.id.trim()&&Ce.push({type:"prompt",name:Ae.id.trim()}),Te==="include"&&typeof Ae.prompt=="string"&&Ae.prompt.trim()&&Ce.push({type:"prompt",name:Ae.prompt.trim()})}}catch{}return Ce},We=()=>{const Ce=new Map;for(const we of A.value){const Ae=Re(we.name);Ae&&Ce.set(`${Ae.type}:${Ae.name}`,Ae)}for(const we of qe())Ce.set(`${we.type}:${we.name}`,we);return Array.from(Ce.values())},R=Ce=>`/variables/${Ce.type==="agent"?"agents":`${Ce.type}s`}/${encodeURIComponent(Ce.name)}`,O=async()=>{if(!s.modelValue)return;const Ce=++ae,we=We();let Ae=null,Te=[];if(we.length>0&&(Ae=we[0],Te=we.slice(1)),!Ae){Ce===ae&&(xe([],{pruneRemoved:!0}),me.value=!1);return}Ce===ae&&(me.value=!0);try{const Ke=Te.length>0?`?include=${encodeURIComponent(JSON.stringify(Te))}`:"",et=[Ae,...["tool","prompt","agent"].filter(Pe=>Pe!==Ae.type).map(Pe=>({type:Pe,name:Ae.name}))];let Ze=null;for(const Pe of et){const se=await ut(`${R(Pe)}${Ke}`);if(Ce!==ae)return;if(se.ok){Ze=se;break}if(se.status!==404)break}if(!Ze){Ce===ae&&xe([],{pruneRemoved:!0});return}const st=await Ze.json();Ce===ae&&xe(st.variables||[],{pruneRemoved:!0})}catch(Ke){console.error("Error scanning variables for prompt:",Ke),Ce===ae&&xe([],{pruneRemoved:!1})}finally{Ce===ae&&(me.value=!1)}},ke=()=>{G&&clearTimeout(G),G=setTimeout(()=>{G=null,O()},0)},de=async()=>{if(s.editPrompt?.id){i.value=!0;try{const Ce=await ut(`/prompts/${encodeURIComponent(s.editPrompt.id)}`);if(Ce.ok){const we=await Ce.json(),Ae=we.prompt||we;d.value=Ae.name||"",$.value=Ae.name||"",w.value=Ae.tool_description||"",m.value=Ae.model_id||"",Ae.model_id&&await ee(Ae.model_id);let Te=Ae.required_schema;if(typeof Te=="string")try{Te=JSON.parse(Te)}catch{Te=null}v.value=Te||{type:"object",properties:{},required:[],additionalProperties:!1},_.value=Ae.prompt||"",P.value=Ae.include_chat||!1,V.value=Ae.include_past_tools||!1,E.value=Ae.before_tool||"",z.value=Ae.after_tool||"";const Ke=Ae.tools||[];A.value=Ke.map(Ze=>{if(typeof Ze=="string")return{name:Ze,include_text_response:!0,include_tool_calls:!0,include_errors:!0,init_user_message_property:null,init_attachments_property:null,tenvs:void 0};const st=Ze.env??Ze.tenvs;return{...Ze,init_attachments_property:Ze.init_attachments_property??null,tenvs:st&&typeof st=="object"?st:void 0}}),oe.value=Ae.parallel_tool_calls||!1,fe.value=Ae.tool_choice||"auto";const et=Ae.reasoning||{};ye.value=et.effort||Ae.reasoning_effort||"",te.value=et.maxTokens||Ae.reasoning_max_tokens||null,q.value=et.exclude||Ae.reasoning_exclude||!1,j.value=et.include||Ae.include_reasoning||!1,J.value=Ae.hooks||[],Z.value=Array.isArray(Ae.variables)?Ae.variables.map(Ze=>({name:Ze.name||"",type:Ze.type==="secret"?"secret":"text",required:!!Ze.required,description:Ze.description||""})):[],U.value=(Ae.env&&typeof Ae.env=="object"?Ae.env:null)||(Ae.tenvs&&typeof Ae.tenvs=="object"?Ae.tenvs:null)||{},await O()}}catch(Ce){console.error("Error loading prompt data:",Ce)}finally{i.value=!1}}},Ue=async()=>{rf(be.value),ne.value?.removeUnavailableTools(),await Fe();const Ce={name:d.value,tool_description:w.value,prompt:_.value,required_schema:v.value,model_id:m.value,include_chat:P.value,include_past_tools:V.value,before_tool:E.value||null,after_tool:z.value||null,parallel_tool_calls:oe.value,tool_choice:fe.value,tools:A.value,reasoning_effort:ye.value||null,reasoning_max_tokens:te.value,reasoning_exclude:q.value,include_reasoning:j.value,hooks:J.value.length>0?J.value:null,variables:Z.value,env:U.value};u.value&&s.editPrompt?.id&&(Ce.id=s.editPrompt.id,$.value&&$.value!==d.value&&(Ce.originalName=$.value)),l("save",Ce)},Ge=()=>{L(),l("update:modelValue",!1)};return Ve(()=>A.value.length,Ce=>{fe.value==="function"&&Ce!==1&&(fe.value="auto")}),Ve(()=>s.modelValue,async Ce=>{Ce?(await Promise.all([le(),Ie()]),u.value?(L(),await Fe(),await de()):(L(),await O())):(ae+=1,me.value=!1,G&&(clearTimeout(G),G=null))}),n({formNode:be}),Ve(()=>s.editPrompt,async Ce=>{Ce&&u.value&&s.modelValue&&(await Promise.all([le(),Ie()]),await Fe(),await de())},{immediate:!0}),Ve([A,_],()=>{s.modelValue&&ke()},{deep:!0}),ct(()=>{ae+=1,G&&(clearTimeout(G),G=null)}),(Ce,we)=>{const Ae=at("FormKit");return r(),Y(dt,{"model-value":e.modelValue,"onUpdate:modelValue":we[19]||(we[19]=Te=>Ce.$emit("update:modelValue",Te)),title:u.value?"Edit Prompt":"Add Prompt",width:"max-w-5xl","content-padding":!1},{default:W(()=>[i.value?(r(),o("div",uw,[...we[20]||(we[20]=[t("span",{class:"text-neutral-500"},"Loading prompt data...",-1)])])):(r(),Y(Ae,{key:1,type:"form",id:"prompt-form",actions:!1,disabled:e.readonly||e.saving,onSubmit:Ue,onNode:B,"form-class":"$reset flex-1 min-h-0 flex flex-col"},{default:W(()=>[t("div",dw,[t("nav",cw,[k(I(Xa),{tabs:b,"active-tab":I(h),onSelect:I(x)},null,8,["active-tab","onSelect"])]),t("div",{ref_key:"contentRef",ref:c,class:"flex-1 overflow-y-auto p-5 bg-neutral-100 dark:bg-neutral-950"},[t("div",pw,[k(I(bt),{id:"section-basics",title:"Basics",icon:I(cr)},{default:W(()=>[t("div",mw,[k(Q2,{name:d.value,"onUpdate:name":we[0]||(we[0]=Te=>d.value=Te),"tool-description":w.value,"onUpdate:toolDescription":we[1]||(we[1]=Te=>w.value=Te)},null,8,["name","tool-description"]),k(tw,{modelValue:m.value,"onUpdate:modelValue":we[2]||(we[2]=Te=>m.value=Te)},null,8,["modelValue"])])]),_:1},8,["icon"]),k(I(bt),{id:"section-schema",title:"Schema",icon:I(va)},{default:W(()=>[k(Ae,{type:"schemaEditor",modelValue:v.value,"onUpdate:modelValue":we[3]||(we[3]=Te=>v.value=Te),label:"","outer-class":"$reset"},null,8,["modelValue"])]),_:1},8,["icon"]),k(I(bt),{id:"section-prompt",title:"Prompt",icon:I(dr)},{footer:W(()=>[...we[21]||(we[21]=[t("p",{class:"text-xs text-neutral-500 dark:text-neutral-400"},[ve(" Type "),t("kbd",{class:"px-1.5 py-0.5 rounded bg-neutral-200 dark:bg-neutral-700 font-mono text-xs"},"@"),ve(" to insert schema properties, env variables, or other prompts ")],-1)])]),default:W(()=>[k(rw,{"prompt-text":_.value,"onUpdate:promptText":we[4]||(we[4]=Te=>_.value=Te),"before-tool":E.value,"onUpdate:beforeTool":we[5]||(we[5]=Te=>E.value=Te),"after-tool":z.value,"onUpdate:afterTool":we[6]||(we[6]=Te=>z.value=Te),"required-schema":JSON.stringify(v.value,null,2),"current-prompt-name":u.value?d.value:void 0,"available-env-variables":ie.value},null,8,["prompt-text","before-tool","after-tool","required-schema","current-prompt-name","available-env-variables"])]),_:1},8,["icon"]),k(I(bt),{id:"section-tools",title:"Tools",icon:I(Mr)},{default:W(()=>[A.value.length===0?(r(),o("div",vw,[...we[22]||(we[22]=[t("p",{class:"text-sm text-neutral-500 dark:text-neutral-400"}," No tools selected. This prompt will run without tool access. ",-1)])])):S("",!0),k(Fa,{ref_key:"toolSelectorRef",ref:ne,modelValue:A.value,"onUpdate:modelValue":we[7]||(we[7]=Te=>A.value=Te),"provider-id":g.value?.provider_id||g.value?.provider,"model-id":g.value?.model,"available-env-variables":ie.value},null,8,["modelValue","provider-id","model-id","available-env-variables"])]),_:1},8,["icon"]),k(I(bt),{id:"section-hooks",title:"Hooks",icon:I(ga)},{default:W(()=>[we[25]||(we[25]=t("p",{class:"text-sm text-neutral-500 dark:text-neutral-400 mb-4"}," Select hooks to run when this prompt is active. Hooks execute in the order listed. ",-1)),J.value.length>0?(r(),o("div",fw,[(r(!0),o($e,null,Le(J.value,Te=>(r(),o("div",{key:Te,class:"flex items-center justify-between p-3 border border-neutral-300 dark:border-neutral-600 rounded-lg"},[t("div",gw,[t("div",hw,C(Te),1),t("div",bw,C(H.value.find(Ke=>Ke.id===Te)?.hook||"unknown"),1)]),t("button",{onClick:Ke=>J.value=J.value.filter(et=>et!==Te),type:"button",class:"p-1 hover:bg-neutral-200 dark:hover:bg-neutral-800 rounded transition-colors text-neutral-500 hover:text-red-500","aria-label":`Remove ${Te}`},[...we[23]||(we[23]=[t("svg",{class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},[t("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M6 18L18 6M6 6l12 12"})],-1)])],8,xw)]))),128))])):S("",!0),X.value.length>0?(r(),Y(Ae,{key:1,type:"selectSearch",modelValue:ce.value,"onUpdate:modelValue":we[8]||(we[8]=Te=>ce.value=Te),onInput:he,placeholder:J.value.length>0?"Add another hook...":"Select a hook","search-placeholder":"Search hooks...",options:X.value,"outer-class":"$reset"},null,8,["modelValue","placeholder","options"])):S("",!0),H.value.length===0?(r(),o("div",yw,[...we[24]||(we[24]=[t("p",{class:"text-sm text-neutral-500 dark:text-neutral-400"},[ve(" No hooks available. Create hooks in "),t("code",{class:"px-1.5 py-0.5 rounded bg-neutral-200 dark:bg-neutral-700 font-mono text-xs"},"agents/hooks/"),ve(" to enable them here. ")],-1)])])):X.value.length===0&&J.value.length>0?(r(),o("div",kw," All available hooks are selected. ")):S("",!0)]),_:1},8,["icon"]),k(I(bt),{id:"section-variables",title:"Variables",icon:I(Jt)},{default:W(()=>[we[26]||(we[26]=t("p",{class:"text-sm text-neutral-500 dark:text-neutral-400 mb-4"}," Environment variables required by tools used in this prompt. Values set here are the lowest priority and can be overridden by agents, instances, users, or threads. ",-1)),me.value?(r(),o("div",ww," Scanning variables... ")):S("",!0),k(en,{modelValue:U.value,"onUpdate:modelValue":we[9]||(we[9]=Te=>U.value=Te),declarations:Z.value,"onUpdate:declarations":we[10]||(we[10]=Te=>Z.value=Te),scanned:K.value,"allow-declaration-edit":!0,"allow-secret-values":!1,"allow-secret-declarations":!0,"require-required-values":!1,disabled:e.readonly},null,8,["modelValue","declarations","scanned","disabled"])]),_:1},8,["icon"]),k(I(bt),{id:"section-behavior",title:"Behavior",icon:I(fa)},{default:W(()=>[t("div",_w,[k(I(Ht),{title:"Tool Behavior",class:"mb-4"}),t("div",$w,[t("div",null,[k(Ae,{type:"selectSearch",name:"tool_choice",modelValue:fe.value,"onUpdate:modelValue":we[11]||(we[11]=Te=>fe.value=Te),label:"Tool Choice",options:M.value,placeholder:"Select tool choice","outer-class":"$reset"},null,8,["modelValue","options"]),k(I(Ne),{class:"mt-1"},{default:W(()=>[...we[27]||(we[27]=[ve(" Controls whether and how the model can call tools ",-1)])]),_:1})]),t("div",Cw,[we[29]||(we[29]=t("div",{class:"h-7"},null,-1)),k(Ae,{type:"checkbox",name:"parallel_tool_calls",modelValue:oe.value,"onUpdate:modelValue":we[12]||(we[12]=Te=>oe.value=Te),label:"Allow parallel tool calls","outer-class":"$reset"},null,8,["modelValue"]),k(I(Ne),{class:"mt-1"},{default:W(()=>[...we[28]||(we[28]=[ve(" Allow the model to call multiple tools simultaneously ",-1)])]),_:1})])])]),t("div",Sw,[k(I(Ht),{title:"Context"}),k(Ae,{type:"checkbox",name:"include_chat",modelValue:P.value,"onUpdate:modelValue":we[13]||(we[13]=Te=>P.value=Te),label:"Include chat history",help:"Expose chat history to the LLM when this prompt is used as a full prompt","outer-class":"$reset"},null,8,["modelValue"]),k(Ae,{type:"checkbox",name:"include_past_tools",modelValue:V.value,"onUpdate:modelValue":we[14]||(we[14]=Te=>V.value=Te),label:"Include past tool calls",help:"Include prior tool call history in this prompt","outer-class":"$reset"},null,8,["modelValue"]),k(Ae,{type:"checkbox",name:"include_reasoning",modelValue:j.value,"onUpdate:modelValue":we[15]||(we[15]=Te=>j.value=Te),label:"Include reasoning in history",help:"Include reasoning_details from previous responses","outer-class":"$reset"},null,8,["modelValue"])]),t("div",Iw,[k(I(Ht),{title:"Reasoning",class:"mb-2"}),we[31]||(we[31]=t("p",{class:"text-xs text-neutral-500 dark:text-neutral-400 mb-4"}," Configure extended reasoning for models like o1, o3, Gemini Thinking, and others. Reasoning is enabled automatically when either field is set. ",-1)),t("div",Tw,[t("div",null,[k(Ae,{type:"selectSearch",name:"reasoning_effort",modelValue:ye.value,"onUpdate:modelValue":we[16]||(we[16]=Te=>ye.value=Te),label:"Reasoning Effort",options:T,placeholder:"Select reasoning effort","outer-class":"$reset"},null,8,["modelValue"]),k(I(Ne),{class:"mt-1"},{default:W(()=>[...we[30]||(we[30]=[ve(" Controls reasoning capacity. Supported by OpenAI o-series and Grok. ",-1)])]),_:1})]),k(Ae,{type:"unit",name:"reasoning_max_tokens",modelValue:te.value,"onUpdate:modelValue":we[17]||(we[17]=Te=>te.value=Te),label:"Max Reasoning Tokens",min:0,step:1,decimals:0,validation:"min:1024|max:32000","validation-messages":{min:"Recommended minimum is 1,024 tokens",max:"Recommended maximum is 32,000 tokens"},"validation-visibility":"live",placeholder:"Leave empty to disable",help:"Specify reasoning token limit (1024-32000)","outer-class":"$reset"},null,8,["modelValue"])]),k(Ae,{type:"checkbox",name:"reasoning_exclude",modelValue:q.value,"onUpdate:modelValue":we[18]||(we[18]=Te=>q.value=Te),label:"Exclude reasoning from response",help:"Use reasoning internally but don't return it in the response (saves tokens and cost)","outer-class":"$reset"},null,8,["modelValue"])])]),_:1},8,["icon"])])],512)]),t("div",Mw,[t("div",zw,[k(I(Qe),{variant:"ghost",size:"sm",disabled:e.saving,onClick:Ge},{default:W(()=>[ve(C(e.readonly?"Close":"Cancel"),1)]),_:1},8,["disabled"]),e.readonly?S("",!0):(r(),o("div",Vw,[k(I(Er),{node:be.value||void 0},null,8,["node"]),k(I(Qe),{variant:"primary",size:"sm",disabled:e.saving,loading:e.saving,type:"submit",form:"prompt-form"},{default:W(()=>[ve(C(u.value?"Update Prompt":"Create Prompt"),1)]),_:1},8,["disabled","loading"])]))])])]),_:1},8,["disabled"]))]),_:1},8,["model-value","title"])}}}),Ew={key:0,class:"mb-5 rounded-lg border border-amber-200 dark:border-amber-800 bg-amber-50 dark:bg-amber-950/30 px-4 py-3 text-sm text-amber-800 dark:text-amber-200"},Lw=Se({__name:"PromptsView",setup(e){const n=qt(),a=Vt(),s=p(!1),l=p(null),u=p(null),i=p(!1),c=fr();Ve(()=>a.query.refresh,()=>{a.query.refresh&&(l.value?.refresh(),n.replace({path:"/prompts",query:{}}))});const f=()=>{s.value=!0},h=b=>{n.push(`/prompts/${b.id}`)},x=async b=>{i.value=!0;try{const y=await fetch(ze("/api/prompts"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b)});if(y.ok)s.value=!1,await new Promise($=>setTimeout($,100)),await l.value?.refresh();else{const $=await y.json();Gt($,u.value?.formNode)||alert($.error||"Failed to create prompt")}}catch(y){console.error("Error creating prompt:",y),alert("Failed to create prompt")}finally{i.value=!1}};return(b,y)=>(r(),Y(Pt,null,{default:W(()=>[I(c)?S("",!0):(r(),o("div",Ew," Configuration is read-only in production. To make changes, edit your configuration files locally and deploy. ")),k(G2,{ref_key:"dataTableRef",ref:l,title:"Prompts",description:"Define and manage prompt templates for your agents.","primary-action":I(c)?{label:"Create Prompt",icon:I(Rr),handler:f}:void 0,readonly:!I(c),onAdd:f,onEdit:h},null,8,["primary-action","readonly"]),k(ln,{ref_key:"promptModalRef",ref:u,modelValue:s.value,"onUpdate:modelValue":y[0]||(y[0]=$=>s.value=$),mode:"add",saving:i.value,onSave:x},null,8,["modelValue","saving"])]),_:1}))}}),Aw={class:"p-8"},Pw={key:0,class:"flex items-center justify-center min-h-[400px]"},Ow={key:2,class:"flex items-center justify-center min-h-[400px]"},Rw=Se({__name:"PromptEditView",setup(e){const n=fr(),a=qt(),s=Vt(),l=p(!0),u=p(null),i=p(!0),c=p(null),f=p(!1),h=async()=>{const y=s.params.id;if(!y){a.push("/prompts");return}i.value=!0;try{const $=await fetch(ze(`/api/prompts/${encodeURIComponent(y)}`));if($.ok){const g=await $.json();u.value=g.prompt||g}else alert("Prompt not found"),a.push("/prompts")}catch($){console.error("Error loading prompt:",$),alert("Failed to load prompt"),a.push("/prompts")}finally{i.value=!1}},x=async y=>{f.value=!0;try{const{originalName:$,...g}=y,d=$||g.id,w=await fetch(ze(`/api/prompts/${encodeURIComponent(d)}`),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(g)});if(w.ok)a.push({path:"/prompts",query:{refresh:Date.now().toString()}});else{const m=await w.json();Gt(m,c.value?.formNode)||alert(m.error||"Failed to update prompt")}}catch($){console.error("Error updating prompt:",$),alert("Failed to update prompt")}finally{f.value=!1}},b=y=>{y||a.push("/prompts")};return He(()=>{h()}),Ve(l,y=>{y||a.push("/prompts")}),(y,$)=>(r(),o("div",Aw,[i.value?(r(),o("div",Pw,[...$[1]||($[1]=[t("span",{class:"text-neutral-500"},"Loading prompt...",-1)])])):u.value?(r(),Y(ln,{key:1,ref_key:"promptModalRef",ref:c,modelValue:l.value,"onUpdate:modelValue":[$[0]||($[0]=g=>l.value=g),b],mode:"edit","edit-prompt":u.value,readonly:!I(n),saving:f.value,onSave:x},null,8,["modelValue","edit-prompt","readonly","saving"])):(r(),o("div",Ow,[...$[2]||($[2]=[t("span",{class:"text-neutral-500"},"Prompt not found",-1)])]))]))}}),jw={class:"space-y-4"},Dw={key:0},Uw={key:1},Bw={class:"px-1 py-0.5 bg-neutral-100 dark:bg-neutral-800 rounded"},Nw={key:2,class:"space-y-3"},qw={class:"flex items-center justify-between"},Fw={key:0,class:"text-sm text-neutral-500 dark:text-neutral-400"},Hw={key:1,class:"space-y-3"},Ww={class:"grid grid-cols-2 gap-x-4 gap-y-2"},Kw={class:"grid grid-cols-2 gap-4"},Jw={key:3,class:"space-y-3"},Gw={key:0,class:"text-sm text-neutral-500 dark:text-neutral-400"},Yw={key:1,class:"grid grid-cols-1 gap-2"},Zw=["value"],Xw={class:"flex-1 min-w-0"},Qw={class:"font-medium text-sm"},e_={class:"text-xs text-neutral-500 dark:text-neutral-400 mt-0.5"},t_={key:0,class:"mt-1"},r_={class:"text-xs text-amber-600 dark:text-amber-400"},a_={key:4,class:"space-y-3"},n_={class:"flex items-center justify-between"},o_={key:0,class:"flex gap-2"},l_={key:0,class:"flex items-center gap-2 py-4"},s_={key:1,class:"py-4 text-sm text-neutral-500 dark:text-neutral-400"},i_={key:2,class:"space-y-2"},u_=["checked","onChange"],d_={class:"flex-1 min-w-0"},c_={class:"flex items-center gap-2"},p_={class:"font-medium text-sm"},m_={key:0,class:"px-1.5 py-0.5 text-xs font-medium rounded bg-neutral-100 dark:bg-neutral-800 text-neutral-600 dark:text-neutral-400"},v_={class:"flex flex-wrap gap-x-4 gap-y-1 mt-1 text-xs text-neutral-500 dark:text-neutral-400"},f_={key:0},g_={key:1},h_={key:5,class:"space-y-3"},b_={class:"flex items-center justify-between gap-4"},x_={key:1},y_={class:"flex gap-2"},k_=Se({__name:"ModelModal",props:{modelValue:{type:Boolean},editModel:{},mode:{default:"add"},readonly:{type:Boolean,default:!1},saving:{type:Boolean,default:!1}},emits:["update:modelValue","save"],setup(e,{expose:n,emit:a}){const s=e,l=a,u=p([]),i=p(""),c=p(""),f=p({}),h=p(!1),x=p(!1),b=p([]),y=p([]),$=p(!1),g=p({supportsImages:!1,supportsToolCalls:!0,supportsStreaming:!0,supportsJsonMode:!0}),d=p(null),w=p(!1),m=p([]),v=p([]),_=p(!1),P=p([]),V=p(!1),E=F(()=>P.value.map(R=>({value:R.id,label:R.name,description:R.provider_id||R.provider,icon:R.iconId}))),z=async()=>{V.value=!0;try{const R=await fetch(ze("/api/models"));if(R.ok){const O=await R.json();P.value=O.models||[]}}catch(R){console.error("Error fetching configured models:",R)}finally{V.value=!1}},A=p([]),oe=F(()=>s.mode==="edit"),ne=p(null),fe=p(!0),ye=p(!1),te=R=>{ne.value=R,R.on("commit",()=>{fe.value=R.context?.state.valid??!0,ye.value=R.context?.state.submitted??!1})},q=p(""),j=p(""),J=R=>{let O=R.replace(/[^a-zA-Z0-9\s_-]/g,"");return O=O.trim().toLowerCase().replace(/[\s-]+/g,"_").replace(/_+/g,"_").replace(/^_|_$/g,""),O},H=R=>{j.value=J(R)},ce=p(!1),Z=p(null),U=F(()=>u.value.filter(R=>R.hasApiKey).map(R=>({value:R.name,label:R.name,description:R.sdk==="cerebras"?"Cerebras":R.sdk==="openai-sdk"?"OpenAI SDK":R.sdk==="openrouter"?"OpenRouter":R.sdk,icon:R.iconId}))),K=R=>{if(!R.length)return;const O={...f.value};for(const ke of R)O[ke.value]=ke;f.value=O},me=R=>f.value[R],ue=F(()=>Object.values(f.value).map(R=>({value:R.value,label:R.label,description:R.description,icon:R.iconId,slug:R.slug}))),Q=F(()=>!oe.value||!Z.value||ce.value?!1:j.value!==Z.value.name||i.value!==Z.value.provider||c.value!==Z.value.model||JSON.stringify(y.value.sort())!==JSON.stringify(Z.value.endpoints.sort())||JSON.stringify(A.value)!==JSON.stringify(Z.value.fallbacks)||JSON.stringify(g.value)!==JSON.stringify(Z.value.capabilities)||JSON.stringify(v.value.sort())!==JSON.stringify(Z.value.providerTools.sort())),G=F(()=>u.value.find(O=>O.name===i.value)?.sdk==="openrouter"),ae=async()=>{h.value=!0;try{const R=await fetch(ze("/api/providers"));if(R.ok){const O=await R.json();u.value=O.providers||[]}}catch(R){console.error("Error fetching providers:",R)}finally{h.value=!1}},ie=async R=>{if(!i.value)return[];x.value=!0;try{const O=await fetch(ze("/api/models/available"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:i.value,search:R?.search||void 0,page:R?.page||1,perPage:25})});if(!O.ok){const Ue=await O.json().catch(()=>({}));return console.error("Error fetching models:",Ue),[]}const ke=await O.json(),de=ke.models||[];return K(de),ke.hasNextPage&&typeof R?.hasNextPage=="function"&&R.hasNextPage(),de.map(Ue=>({value:Ue.value,label:Ue.label,description:Ue.description,icon:Ue.iconId,slug:Ue.slug}))}catch(O){return console.error("Error fetching models:",O),[]}finally{x.value=!1}},xe=async R=>{const O=me(R);if(O)return{value:O.value,label:O.label,description:O.description,icon:O.iconId,slug:O.slug};if(!i.value||!R)return null;x.value=!0;try{const ke=await fetch(ze("/api/models/available"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:i.value,search:R,page:1,perPage:25})});if(!ke.ok)return null;const Ue=(await ke.json()).models||[];K(Ue);const Ge=Ue.find(Ce=>Ce.value===R)||Ue.find(Ce=>Ce.slug===R)||Ue.find(Ce=>Ce.label===R);return Ge?{value:Ge.value,label:Ge.label,description:Ge.description,icon:Ge.iconId,slug:Ge.slug}:null}catch(ke){return console.error("Error fetching model option:",ke),null}finally{x.value=!1}},X=async()=>{if(!(!i.value||!c.value)){w.value=!0;try{const R=await fetch(ze("/api/models/capabilities"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:i.value,modelId:c.value})});if(R.ok){const O=await R.json();O.capabilities&&(d.value=O.capabilities,g.value={supportsImages:O.capabilities.supportsImages??!1,supportsToolCalls:O.capabilities.supportsToolCalls??!0,supportsStreaming:O.capabilities.supportsStreaming??!0,supportsJsonMode:O.capabilities.supportsJsonMode??!0,maxContextTokens:O.capabilities.maxContextTokens,maxOutputTokens:O.capabilities.maxOutputTokens})}}catch(R){console.error("Error fetching capabilities:",R)}finally{w.value=!1}}},he=async()=>{if(!i.value||!c.value){m.value=[],v.value=[];return}_.value=!0;try{const R=await fetch(ze(`/api/providers/${i.value}/tools?model=${encodeURIComponent(c.value)}`));if(R.ok){const O=await R.json();if(m.value=O.tools||[],!oe.value)v.value=m.value.map(ke=>ke.name);else{const ke=new Set(m.value.map(de=>de.name));v.value=v.value.filter(de=>ke.has(de))}}else m.value=[],v.value=[]}catch(R){console.error("Error fetching provider tools:",R),m.value=[],v.value=[]}finally{_.value=!1}},be=()=>{g.value={supportsImages:!1,supportsToolCalls:!0,supportsStreaming:!0,supportsJsonMode:!0},d.value=null},B=R=>{const O=y.value.indexOf(R);O===-1?y.value.push(R):y.value.splice(O,1)},D=()=>{y.value=b.value.map(R=>R.id)},M=()=>{y.value=[]},T=R=>{const O=R*1e6;return O>=1?`$${O.toFixed(2)}/M`:`$${O.toFixed(4)}/M`},L=()=>{d.value&&(g.value={supportsImages:d.value.supportsImages??!1,supportsToolCalls:d.value.supportsToolCalls??!0,supportsStreaming:d.value.supportsStreaming??!0,supportsJsonMode:d.value.supportsJsonMode??!0,maxContextTokens:d.value.maxContextTokens,maxOutputTokens:d.value.maxOutputTokens})},ee=()=>{j.value="",q.value="",i.value="",c.value="",f.value={},A.value=[],b.value=[],y.value=[],m.value=[],v.value=[],be(),Z.value=null,ce.value=!1,fe.value=!0,ye.value=!1,ne.value?.reset()},le=async()=>{if(s.editModel){ce.value=!0;try{await ae(),j.value=s.editModel.name||"",q.value=s.editModel.name||"",i.value=s.editModel.provider_id||s.editModel.provider,c.value=s.editModel.model,await Re(),s.editModel.included_providers&&s.editModel.included_providers.length>0&&(y.value=s.editModel.included_providers),await Ie(),s.editModel.capabilities?g.value={supportsImages:s.editModel.capabilities.supportsImages??!1,supportsToolCalls:s.editModel.capabilities.supportsToolCalls??!0,supportsStreaming:s.editModel.capabilities.supportsStreaming??!0,supportsJsonMode:s.editModel.capabilities.supportsJsonMode??!0,maxContextTokens:s.editModel.capabilities.maxContextTokens,maxOutputTokens:s.editModel.capabilities.maxOutputTokens}:await X(),await he(),s.editModel.providerTools&&Array.isArray(s.editModel.providerTools)&&(v.value=s.editModel.providerTools),Z.value={name:j.value,provider:i.value,model:c.value,endpoints:[...y.value],fallbacks:[...A.value],capabilities:{...g.value},providerTools:[...v.value]}}finally{ce.value=!1}}};Ve(()=>s.modelValue,async R=>{R?(z(),oe.value&&s.editModel?await le():(await ae(),ee())):ee()});const Ie=async()=>{if(s.editModel?.id){if(s.editModel.fallbacks&&Array.isArray(s.editModel.fallbacks)){A.value=s.editModel.fallbacks.map(R=>typeof R=="string"?R:R.id);return}try{const R=await fetch(ze(`/api/models/${encodeURIComponent(s.editModel.id)}/fallbacks`));if(R.ok){const O=await R.json();A.value=O.fallbacks.map(ke=>ke.fallback_model_id)}}catch(R){console.error("Error loading fallbacks:",R)}}};Ve(i,async(R,O)=>{ce.value||oe.value&&!O&&R===(s.editModel?.provider_id||s.editModel?.provider)||(c.value="",f.value={},b.value=[],y.value=[],i.value&&(x.value=!1))});const Re=async()=>{if(!c.value||!i.value){b.value=[];return}const R=u.value.find(ke=>ke.name===i.value);if(!R||R.sdk!=="openrouter"){b.value=[];return}const O=me(c.value);if(!O?.slug){console.error("Model slug not found"),b.value=[];return}$.value=!0;try{const ke=await fetch(ze("/api/models/endpoints"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:i.value,modelSlug:O.slug})});if(ke.ok){const de=await ke.json();b.value=de.endpoints||[],oe.value||(y.value=b.value.map(Ue=>Ue.id))}else{const de=await ke.json();console.error("Error fetching endpoints:",de),b.value=[]}}catch(ke){console.error("Error fetching endpoints:",ke),b.value=[]}finally{$.value=!1}};Ve(c,async(R,O)=>{ce.value||oe.value&&!O&&R===s.editModel?.model||(c.value?(await Re(),await X(),await he(),O&&R!==O&&(y.value=b.value.map(ke=>ke.id))):(b.value=[],y.value=[],m.value=[],v.value=[],be()))});const qe=()=>{const R=G.value?y.value:[],O={name:j.value,model:c.value,provider:i.value,included_providers:R,fallbacks:A.value,capabilities:g.value,providerTools:v.value};oe.value&&s.editModel?.id&&(O.id=s.editModel.id,q.value&&q.value!==j.value&&(O.originalName=q.value)),l("save",O)};n({formNode:ne});const We=()=>{ee(),l("update:modelValue",!1)};return(R,O)=>{const ke=at("FormKit");return r(),Y(dt,{"model-value":e.modelValue,"onUpdate:modelValue":O[10]||(O[10]=de=>R.$emit("update:modelValue",de)),title:oe.value?"Edit Model":"Add Model",width:"max-w-2xl","min-height":"min-h-[36rem]","has-changes":Q.value},{footer:W(()=>[t("div",b_,[!e.readonly&&ye.value&&!fe.value?(r(),Y(I($t),{key:0},{default:W(()=>[...O[22]||(O[22]=[ve(" Please fix the errors above before submitting. ",-1)])]),_:1})):(r(),o("div",x_)),t("div",y_,[k(I(Qe),{variant:"ghost",size:"sm",disabled:e.saving,onClick:We},{default:W(()=>[ve(C(e.readonly?"Close":"Cancel"),1)]),_:1},8,["disabled"]),e.readonly?S("",!0):(r(),Y(I(Qe),{key:0,variant:"primary",size:"sm",disabled:e.saving,loading:e.saving,type:"submit",form:"model-form"},{default:W(()=>[ve(C(oe.value?"Update Model":"Add Model"),1)]),_:1},8,["disabled","loading"]))])])]),default:W(()=>[k(ke,{type:"form",id:"model-form",actions:!1,disabled:e.readonly||e.saving||ce.value,onSubmit:qe,onNode:te},{default:W(()=>[t("div",jw,[k(ke,{type:"autocomplete",name:"provider",modelValue:i.value,"onUpdate:modelValue":O[0]||(O[0]=de=>i.value=de),options:U.value,label:"Provider",placeholder:"Search providers...",disabled:h.value,validation:"required","validation-visibility":"submit","selection-removable":""},null,8,["modelValue","options","disabled"]),i.value?(r(),o("div",Dw,[k(ke,{type:"autocomplete",name:"model",modelValue:c.value,"onUpdate:modelValue":O[1]||(O[1]=de=>c.value=de),options:ue.value,"options-loader":ie,"option-loader":xe,"load-on-scroll":"","load-on-created":"",debounce:150,label:"Model",placeholder:"Search models...",loading:x.value,validation:"required","validation-visibility":"submit","selection-removable":""},null,8,["modelValue","options","loading"])])):S("",!0),c.value?(r(),o("div",Uw,[k(ke,{type:"text",name:"name","model-value":j.value,onInput:H,label:"Name",placeholder:"e.g., coding_model, planning_model, fast_response",validation:"required|snakeCase","validation-visibility":"blur",help:j.value?void 0:"A descriptive name for this model. This becomes the filename and reference ID."},null,8,["model-value","help"]),j.value?(r(),Y(I(Ne),{key:0,class:"mt-1"},{default:W(()=>[O[11]||(O[11]=ve(" Will be saved as: ",-1)),t("code",Bw,C(j.value),1)]),_:1})):S("",!0)])):S("",!0),c.value?(r(),o("div",Nw,[t("div",qw,[O[12]||(O[12]=t("label",{class:"block text-sm font-medium"},"Model Capabilities",-1)),d.value?(r(),o("button",{key:0,onClick:L,type:"button",class:"text-xs text-accent-600 dark:text-accent-400 hover:underline"}," Reset to detected ")):S("",!0)]),O[13]||(O[13]=t("p",{class:"text-xs text-neutral-500 dark:text-neutral-400 -mt-1"}," Auto-detected from the provider. Override if needed. ",-1)),w.value?(r(),o("div",Fw," Detecting capabilities... ")):(r(),o("div",Hw,[t("div",Ww,[k(ke,{type:"checkbox",modelValue:g.value.supportsImages,"onUpdate:modelValue":O[2]||(O[2]=de=>g.value.supportsImages=de),label:"Vision/Images"},null,8,["modelValue"]),k(ke,{type:"checkbox",modelValue:g.value.supportsToolCalls,"onUpdate:modelValue":O[3]||(O[3]=de=>g.value.supportsToolCalls=de),label:"Tool Calls"},null,8,["modelValue"]),k(ke,{type:"checkbox",modelValue:g.value.supportsStreaming,"onUpdate:modelValue":O[4]||(O[4]=de=>g.value.supportsStreaming=de),label:"Streaming"},null,8,["modelValue"]),k(ke,{type:"checkbox",modelValue:g.value.supportsJsonMode,"onUpdate:modelValue":O[5]||(O[5]=de=>g.value.supportsJsonMode=de),label:"JSON Mode"},null,8,["modelValue"])]),t("div",Kw,[k(ke,{type:"unit",modelValue:g.value.maxContextTokens,"onUpdate:modelValue":O[6]||(O[6]=de=>g.value.maxContextTokens=de),label:"Max Context Tokens",placeholder:"e.g., 128,000",unit:"",decimals:"0",step:"1000",min:"0"},null,8,["modelValue"]),k(ke,{type:"unit",modelValue:g.value.maxOutputTokens,"onUpdate:modelValue":O[7]||(O[7]=de=>g.value.maxOutputTokens=de),label:"Max Output Tokens",placeholder:"e.g., 16,384",unit:"",decimals:"0",step:"1000",min:"0"},null,8,["modelValue"])])]))])):S("",!0),c.value&&m.value.length>0?(r(),o("div",Jw,[O[14]||(O[14]=t("label",{class:"block text-sm font-medium"},"Provider Tools",-1)),O[15]||(O[15]=t("p",{class:"text-xs text-neutral-500 dark:text-neutral-400 -mt-1"}," Built-in tools available for this model. ",-1)),_.value?(r(),o("div",Gw," Loading provider tools... ")):(r(),o("div",Yw,[(r(!0),o($e,null,Le(m.value,de=>(r(),o("label",{key:de.name,class:pe(["flex items-start gap-3 p-3 border rounded cursor-pointer hover:bg-neutral-50 dark:hover:bg-neutral-800/50 transition-colors",v.value.includes(de.name)?"border-black dark:border-white":"border-neutral-200 dark:border-neutral-700"])},[Je(t("input",{type:"checkbox",value:de.name,"onUpdate:modelValue":O[8]||(O[8]=Ue=>v.value=Ue),class:"mt-0.5 h-4 w-4 rounded border-neutral-300 dark:border-neutral-600 text-black dark:text-white focus:ring-black dark:focus:ring-white accent-black dark:accent-white"},null,8,Zw),[[Lr,v.value]]),t("div",Xw,[t("div",Qw,C(de.name),1),t("div",e_,C(de.description),1),de.tenvs&&de.tenvs.length>0?(r(),o("div",t_,[t("span",r_," Requires: "+C(de.tenvs.filter(Ue=>Ue.required).map(Ue=>Ue.name).join(", ")||"none (optional config available)"),1)])):S("",!0)])],2))),128))]))])):S("",!0),c.value&&G.value?(r(),o("div",a_,[t("div",n_,[O[17]||(O[17]=t("label",{class:"block text-sm font-medium"},"Available Providers",-1)),b.value.length>0?(r(),o("div",o_,[t("button",{type:"button",onClick:D,class:"text-xs text-accent-600 dark:text-accent-400 hover:underline"}," Select all "),O[16]||(O[16]=t("span",{class:"text-xs text-neutral-300 dark:text-neutral-600"},"|",-1)),t("button",{type:"button",onClick:M,class:"text-xs text-accent-600 dark:text-accent-400 hover:underline"}," Clear ")])):S("",!0)]),O[19]||(O[19]=t("p",{class:"text-xs text-neutral-500 dark:text-neutral-400 -mt-1"}," OpenRouter routes to the cheapest available provider. ",-1)),$.value?(r(),o("div",l_,[k(Be,{class:"w-4 h-4"}),O[18]||(O[18]=t("span",{class:"text-sm text-neutral-500 dark:text-neutral-400"},"Loading providers...",-1))])):b.value.length===0?(r(),o("div",s_," No providers available for this model ")):(r(),o("div",i_,[(r(!0),o($e,null,Le(b.value,de=>(r(),o("label",{key:de.id,class:pe(["flex items-start gap-3 p-3 border rounded-md cursor-pointer transition-colors",[y.value.includes(de.id)?"border-accent-500 dark:border-accent-400 bg-accent-50/50 dark:bg-accent-900/20":"border-neutral-200 dark:border-neutral-700 hover:border-neutral-300 dark:hover:border-neutral-600"]])},[t("input",{type:"checkbox",checked:y.value.includes(de.id),onChange:Ue=>B(de.id),class:"mt-0.5 h-4 w-4 rounded border-neutral-300 dark:border-neutral-600 text-accent-600 dark:text-accent-500 focus:ring-accent-500 dark:focus:ring-accent-400 accent-accent-600 dark:accent-accent-500"},null,40,u_),t("div",d_,[t("div",c_,[t("span",p_,C(de.name),1),de.quantization&&de.quantization!=="unknown"?(r(),o("span",m_,C(de.quantization),1)):S("",!0)]),t("div",v_,[t("span",null," Input: "+C(T(de.pricing.prompt)),1),t("span",null," Output: "+C(T(de.pricing.completion)),1),de.maxPromptTokens?(r(),o("span",f_," Max prompt: "+C(de.maxPromptTokens.toLocaleString()),1)):S("",!0),de.maxCompletionTokens?(r(),o("span",g_," Max output: "+C(de.maxCompletionTokens.toLocaleString()),1)):S("",!0)])])],2))),128))]))])):S("",!0),c.value?(r(),o("div",h_,[O[20]||(O[20]=t("label",{class:"block text-sm font-medium"},"Fallback Models",-1)),O[21]||(O[21]=t("p",{class:"text-xs text-neutral-500 dark:text-neutral-400 -mt-1"}," Used in order if the primary model fails. ",-1)),k(ke,{type:"sortableMultiSelect",modelValue:A.value,"onUpdate:modelValue":O[9]||(O[9]=de=>A.value=de),options:E.value,loading:V.value,placeholder:"Add fallback model...","search-placeholder":"Search models...","add-label":"Add another model"},null,8,["modelValue","options","loading"])])):S("",!0)])]),_:1},8,["disabled"])]),_:1},8,["model-value","title","has-changes"])}}}),w_={key:0,class:"mb-5 rounded-lg border border-amber-200 dark:border-amber-800 bg-amber-50 dark:bg-amber-950/30 px-4 py-3 text-sm text-amber-800 dark:text-amber-200"},__={class:"flex items-center gap-2"},$_=["src","alt"],C_={class:"text-sm text-neutral-600 dark:text-neutral-400 font-mono"},S_={class:"flex items-center gap-2"},I_=["src","alt"],T_={key:0,class:"space-y-0.5"},M_=["title"],z_={class:"shrink-0 font-mono pr-2"},V_=["src","alt"],E_={class:"truncate"},L_={key:1,class:"text-neutral-400 dark:text-neutral-600 text-sm"},A_=Se({__name:"ModelsView",setup(e){const n=p(!1),a=p([]),s=p(!1),l=p(null),u=p("add"),i=p(null),c=p(!1),f=fr(),h=[{key:"name",label:"Name",width:"w-1/4",sortable:!0},{key:"model",label:"Model",width:"w-1/4",sortable:!0,filterable:!0,filterIcon:(m,v)=>`/api/providers/${v.provider}/icon?model=${encodeURIComponent(v.model||"")}`},{key:"provider",label:"Provider",width:"w-1/4",sortable:!0,filterable:!0,filterIcon:(m,v)=>`/api/providers/${v.provider}/icon`},{key:"fallbacks",label:"Fallbacks",width:"w-1/4"}],x=m=>{l.value=m,u.value="edit",n.value=!0},b=[{icon:"edit",label:"Edit",handler:m=>x(m)},{icon:"delete",label:"Delete",confirm:!0,confirmMessage:"Are you sure you want to delete this model? This action cannot be undone.",variant:"danger",handler:async m=>{await d(m.id)}}],y=F(()=>f?b:b.filter(m=>m.variant!=="danger")),$=async()=>{s.value=!0;try{const m=await fetch(ze("/api/models"));if(!m.ok)throw new Error("Failed to fetch models");const v=await m.json();a.value=v.models||[]}catch(m){console.error("Error fetching models:",m),a.value=[]}finally{s.value=!1}},g=async m=>{c.value=!0;try{if(l.value){const{originalName:v,..._}=m,P=v||l.value.id,V=await fetch(ze(`/api/models/${encodeURIComponent(P)}`),{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(_)});if(!V.ok){const E=await V.json();Gt(E,i.value?.formNode)||alert(E.error||"Failed to update model");return}}else{const v=await fetch(ze("/api/models"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(m)});if(!v.ok){const _=await v.json();Gt(_,i.value?.formNode)||alert(_.error||"Failed to add model");return}}await $(),n.value=!1,l.value=null,u.value="add"}catch(v){console.error("Error saving model:",v),alert("Failed to save model")}finally{c.value=!1}},d=async m=>{try{const v=await fetch(ze(`/api/models/${encodeURIComponent(m)}`),{method:"DELETE"});if(!v.ok){const _=await v.json();alert(_.error||"Failed to delete model");return}await $()}catch(v){console.error("Error deleting model:",v),alert("Failed to delete model")}},w=()=>{u.value="add",l.value=null,n.value=!0};return He(()=>{$()}),(m,v)=>(r(),Y(Pt,null,{default:W(()=>[I(f)?S("",!0):(r(),o("div",w_," Configuration is read-only in production. To make changes, edit your configuration files locally and deploy. ")),k(It,{title:"Models",description:"Configure AI models from your connected providers. Models define which AI capabilities are available to your agents.","primary-action":I(f)?{label:"Add Model",icon:I(Rr),handler:w}:void 0,columns:h,data:a.value,actions:y.value,loading:s.value,sortable:"",searchable:"","search-placeholder":"Search models...","empty-message":"No models configured yet. Add your first model to get started.",onRowClick:x},{"cell-name":W(({value:_,row:P})=>[t("div",__,[P.provider?(r(),o("img",{key:0,src:`/api/providers/${P.provider}/icon?model=${encodeURIComponent(P.model||"")}`,class:"w-5 h-5 shrink-0",alt:P.provider},null,8,$_)):S("",!0),t("span",null,C(_),1)])]),"cell-model":W(({value:_})=>[t("span",C_,C(_||"—"),1)]),"cell-provider":W(({value:_,row:P})=>[t("div",S_,[P.provider?(r(),o("img",{key:0,src:`/api/providers/${P.provider}/icon`,class:"w-5 h-5 shrink-0",alt:P.provider},null,8,I_)):S("",!0),t("span",null,C(_||"—"),1)])]),"cell-fallbacks":W(({value:_})=>[_&&_.length>0?(r(),o("div",T_,[(r(!0),o($e,null,Le(_,(P,V)=>(r(),o("div",{key:P.id,class:"text-sm text-neutral-600 dark:text-neutral-400 flex items-center",title:P.name},[t("span",z_,C(V===_.length-1?"└─":"├─"),1),P.provider?(r(),o("img",{key:0,src:`/api/providers/${P.provider}/icon?model=${encodeURIComponent(P.model||"")}`,class:"w-4 h-4 shrink-0 mr-1.5",alt:P.provider},null,8,V_)):S("",!0),t("span",E_,C(P.name),1)],8,M_))),128))])):(r(),o("span",L_," None "))]),_:1},8,["primary-action","data","actions","loading"]),k(k_,{ref_key:"modelModalRef",ref:i,modelValue:n.value,"onUpdate:modelValue":[v[0]||(v[0]=_=>n.value=_),v[1]||(v[1]=_=>{n.value=_,_||(l.value=null,u.value="add")})],"edit-model":l.value,mode:u.value,readonly:!I(f),saving:c.value,onSave:g},null,8,["modelValue","edit-model","mode","readonly","saving"])]),_:1}))}}),P_={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function O_(e,n){return r(),o("svg",P_,[...n[0]||(n[0]=[t("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M20 6L9 17l-5-5"},null,-1)])])}const R_=je({name:"lucide-check",render:O_}),j_={class:"flex items-center gap-2"},D_=["src","alt"],U_={key:0,class:"inline-flex items-center gap-1.5 px-2.5 py-1 text-xs font-medium rounded-full bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400"},B_=["title"],N_=Se({__name:"ProvidersView",setup(e){const n=p([]),a=p(!1),s={cloudflare:"Cloudflare Workers AI",cerebras:"Cerebras","openai-sdk":"OpenAI SDK",openrouter:"OpenRouter",openai:"OpenAI"},l=h=>s[h]||h,u=[{key:"name",label:"Name",width:"w-1/3",sortable:!0},{key:"sdk",label:"SDK Type",width:"w-1/3",sortable:!0,formatter:h=>l(h)},{key:"hasApiKey",label:"API Key",width:"w-1/3"}],i=[{icon:"delete",label:"Delete",confirm:!0,confirmMessage:"Are you sure you want to delete this provider? This action cannot be undone.",variant:"danger",handler:async h=>{await f(h.name)}}],c=async()=>{a.value=!0;try{const h=await fetch(ze("/api/providers"));if(!h.ok)throw new Error("Failed to fetch providers");const x=await h.json();n.value=x.providers||[]}catch(h){console.error("Error fetching providers:",h),n.value=[]}finally{a.value=!1}},f=async h=>{try{const x=await fetch(ze(`/api/providers/${encodeURIComponent(h)}`),{method:"DELETE"});if(!x.ok){const b=await x.json();b.modelCount?alert(`${b.error}
53
53
 
54
- This provider has ${_.modelCount} associated model(s).`):alert(_.error||"Failed to delete provider");return}await x()}catch(y){console.error("Error deleting provider:",y),alert("Failed to delete provider")}};return qe(()=>{x()}),(g,y)=>(r(),J(Et,null,{default:F(()=>[w($t,{title:"Providers",description:"Manage API providers and authentication keys. All API keys are encrypted at rest.","primary-action":{label:"Add Provider",icon:I(cr),handler:()=>n.value=!0},columns:i,data:a.value,actions:p,loading:s.value,sortable:"",searchable:"","search-placeholder":"Search providers...","empty-message":"No providers configured yet. Add your first provider to get started."},{"cell-sdk":F(({value:_,row:v})=>[e("div",E_,[e("img",{src:`/api/providers/${v.name}/icon`,alt:u(_),class:"w-5 h-5"},null,8,L_),e("span",null,C(u(_)),1)])]),"cell-hasApiKey":F(({value:_})=>[_?(r(),o("span",A_,[w(I(V_),{class:"w-3.5 h-3.5"}),y[1]||(y[1]=de(" Configured ",-1))])):(r(),o("span",P_,[w(I(ir),{class:"w-3.5 h-3.5"}),y[2]||(y[2]=de(" Not configured ",-1))]))]),_:1},8,["primary-action","data","loading"]),w(T_,{modelValue:n.value,"onUpdate:modelValue":y[0]||(y[0]=_=>n.value=_),onSave:k},null,8,["modelValue"])]),_:1}))}}),R_={class:"font-medium mb-1"},O_={id:"functions"},D_=["onClick"],U_={key:1,class:"text-left font-medium text-red-600 dark:text-red-400"},B_={key:0,class:"mt-2 flex flex-wrap gap-1"},N_=["title"],q_={class:"flex justify-end"},F_=["onClick"],H_={key:1,class:"text-neutral-400 text-sm"},W_={id:"prompts",class:"mt-12"},K_=["onClick"],J_={class:"text-neutral-600 dark:text-neutral-400"},G_={key:0,class:"mt-2 flex flex-wrap gap-1"},Y_=["title"],Z_={class:"text-sm text-neutral-500 dark:text-neutral-400"},X_={id:"agents",class:"mt-12"},Q_=["onClick"],e4={class:"text-neutral-600 dark:text-neutral-400"},t4={key:0,class:"mt-2 flex flex-wrap gap-1"},r4=["title"],a4={class:"text-sm text-neutral-500 dark:text-neutral-400"},n4={class:"flex items-center gap-2"},o4={key:0,class:"space-y-4"},l4={class:"text-lg font-medium mb-2"},s4={class:"text-sm text-neutral-600 dark:text-neutral-400 mb-4"},i4={key:0,class:"h-96 flex items-center justify-center border border-black/20 dark:border-white/20 rounded bg-black/5 dark:bg-white/5"},u4=Ce({__name:"ToolsView",setup(t){const n=m(null),a=m(!1),{data:s}=ot(Ve("/api/config")).json(),{data:l,error:u,isFetching:i,execute:p}=ot(Ve("/api/tools?type=tools"),{immediate:!1}).json(),{data:x,error:k,isFetching:h,execute:g}=ot(Ve("/api/tools?type=prompts&schema=true"),{immediate:!1}).json(),{data:y,error:_,isFetching:v,execute:d}=ot(Ve("/api/tools?type=agents&schema=true"),{immediate:!1}).json(),{data:b,error:c,isFetching:f,execute:$}=ot(()=>n.value?Ve(`/api/tools/${encodeURIComponent(n.value.name)}`):null,{immediate:!1}).json(),N=m([]),E=m([]),L=m([]),V=Tt(),A=async()=>{const te=V.hash;if(te){await Ne();const Y=document.getElementById(te.slice(1));Y&&Y.scrollIntoView({behavior:"smooth"})}};Ee(()=>V.hash,A);const G=async te=>{n.value=te,await $(),b.value?n.value={...te,schema:b.value.schema||null}:c.value&&console.error("Error fetching tool schema:",c.value),a.value=!0},ee=async te=>{if(n.value=te,a.value=!0,!te.schema&&te.type==="prompt"){const Y=await fetch(Ve("/api/tools?type=prompts&schema=true"));if(Y.ok){const ae=await Y.json();ae[te.name]&&(n.value={...te,schema:ae[te.name].schema||null})}}},ie=[{key:"name",label:"Prompt Name",width:"w-1/3",sortable:!0},{key:"description",label:"Description",width:"w-1/2"},{key:"model",label:"Model",width:"w-1/6",sortable:!0,filterable:!0}],be=[{key:"name",label:"Agent Name",width:"w-1/3",sortable:!0},{key:"description",label:"Description",width:"w-1/2"},{key:"prompt",label:"Prompt",width:"w-1/6",sortable:!0,filterable:!0}],Q=[{key:"name",label:"Tool Name",width:"w-1/3",sortable:!0},{key:"description",label:"Description",width:"w-1/2"},{key:"actions",label:"Actions",width:"w-1/6"}],U=te=>/^[a-z][a-z0-9_]*[a-z0-9]$/.test(te)||/^[a-z]$/.test(te),R=te=>te.hasError&&te.error?te.error:te.description||"No description available",K=te=>te.required?`${te.name}*`:te.name,H=()=>{l.value&&(N.value=Object.entries(l.value).map(([te,Y])=>({name:te,description:Y.description||"No description available",schema:null,hasError:Y.hasError||!1,error:Y.error,type:Y.type||"tool",variables:Y.variables||Y.tenvs||[]})))},ve=()=>{x.value&&(E.value=Object.entries(x.value).map(([te,Y])=>({name:te,description:Y.description||"No description available",schema:Y.schema||null,hasError:!1,type:"prompt",model:Y.model,variables:Y.variables||Y.tenvs||[]})))},X=()=>{y.value&&(L.value=Object.entries(y.value).map(([te,Y])=>({name:te,description:Y.description||"No description available",schema:Y.schema||null,hasError:!1,type:"agent",prompt:Y.prompt||Y.model,variables:Y.variables||Y.tenvs||[]})))},D=async()=>{await p(),H()},W=async()=>{await g(),ve()},me=async()=>{await d(),X()},ue=()=>{a.value=!1,n.value=null};return qe(()=>{D(),W(),me(),A()}),(te,Y)=>(r(),J(Et,null,{default:F(()=>[Y[6]||(Y[6]=e("div",{class:"flex justify-between items-center mb-6"},[e("h1",{class:"text-3xl font-bold"},"Tools")],-1)),Y[7]||(Y[7]=e("p",{class:"text-neutral-600 dark:text-neutral-400 mb-6"}," Tools are the fundamental building blocks of how your business logic is exposed to your agents. Your prompts can expose tools for the agents to call. There are 3 types of tools: functions, prompts, and agents. Functions are actual code in your AgentKit codebase. Prompts are any prompts created in the prompts table (which can themselves expose tools). Agents are multi-turn conversations that can be invoked as tools. ",-1)),w(I(at),{variant:"info",class:"mb-6"},{default:F(()=>[e("p",R_,[Y[1]||(Y[1]=de(" To create or modify tools, edit the ",-1)),w(I(Ea),null,{default:F(()=>[de(C(I(s)?.toolsDir||"agentbuilder/tools")+"/",1)]),_:1}),Y[2]||(Y[2]=de(" directory of your codebase. ",-1))]),Y[3]||(Y[3]=e("p",{class:"opacity-70"}," Changes will be automatically detected. ",-1))]),_:1}),e("div",O_,[w($t,{title:"Functions",description:"Function tools defined in your codebase.",columns:Q,data:N.value,loading:I(i),sortable:"",searchable:"","search-placeholder":"Search functions...","empty-message":`No tools found. Add tool files to the ${I(s)?.toolsDir||"agentbuilder/tools"}/ directory.`},{"cell-name":F(({row:ae})=>[e("div",{class:ce(["flex items-center gap-2",{"text-red-600 dark:text-red-400":ae.hasError}])},[ae.hasError?(r(),o("span",U_,C(ae.name),1)):(r(),o("button",{key:0,onClick:ye=>G(ae),class:"text-left font-medium hover:text-black/70 dark:hover:text-white/70 transition-colors underline decoration-transparent hover:decoration-current"},C(ae.name),9,D_)),ae.hasError?(r(),J(I(Kr),{key:2,content:"This tool has validation errors"},{default:F(()=>[w(I(Hr),{class:"w-4 h-4 text-red-500"})]),_:1})):U(ae.name)?S("",!0):(r(),J(I(Kr),{key:3,content:"Tool name should be in snake_case format (e.g., 'log_name', 'send_email')"},{default:F(()=>[w(I(Hr),{class:"w-4 h-4 text-amber-500"})]),_:1}))],2)]),"cell-description":F(({row:ae})=>[e("div",null,[e("span",{class:ce({"text-red-600 dark:text-red-400":ae.hasError,"text-neutral-600 dark:text-neutral-400":!ae.hasError})},C(R(ae)),3),ae.variables&&ae.variables.length>0?(r(),o("div",B_,[(r(!0),o(we,null,Ae(ae.variables,ye=>(r(),o("span",{key:`${ae.name}-${ye.name}`,class:ce(["text-[10px] px-1.5 py-0.5 rounded uppercase tracking-wide",ye.type==="secret"?"bg-amber-100 dark:bg-amber-900 text-amber-700 dark:text-amber-300":"bg-blue-100 dark:bg-blue-900 text-blue-700 dark:text-blue-300"]),title:ye.description||ye.name},C(K(ye)),11,N_))),128))])):S("",!0)])]),"cell-actions":F(({row:ae})=>[e("div",q_,[ae.hasError?(r(),o("span",H_,"—")):(r(),o("button",{key:0,onClick:ye=>G(ae),class:"p-1.5 rounded hover:bg-black/10 dark:hover:bg-white/10 transition-colors",title:"View Schema"},[w(I(Cr),{class:"w-4 h-4"})],8,F_))])]),_:1},8,["data","loading","empty-message"])]),e("div",W_,[w($t,{title:"Prompts",description:"Prompts that are exposed as tools can be called by other prompts and agents. These allow you to create reusable, composable prompt chains.",columns:ie,data:E.value,loading:I(h),sortable:"",searchable:"","search-placeholder":"Search prompts...","empty-message":"No prompts are currently exposed as tools. Mark a prompt as 'Expose as tool' to see it here."},{"cell-name":F(({row:ae})=>[e("button",{onClick:ye=>ee(ae),class:"text-left font-medium hover:text-black/70 dark:hover:text-white/70 transition-colors underline decoration-transparent hover:decoration-current"},C(ae.name),9,K_)]),"cell-description":F(({row:ae})=>[e("div",null,[e("span",J_,C(ae.description),1),ae.variables&&ae.variables.length>0?(r(),o("div",G_,[(r(!0),o(we,null,Ae(ae.variables,ye=>(r(),o("span",{key:`${ae.name}-${ye.name}`,class:ce(["text-[10px] px-1.5 py-0.5 rounded uppercase tracking-wide",ye.type==="secret"?"bg-amber-100 dark:bg-amber-900 text-amber-700 dark:text-amber-300":"bg-blue-100 dark:bg-blue-900 text-blue-700 dark:text-blue-300"]),title:ye.description||ye.name},C(K(ye)),11,Y_))),128))])):S("",!0)])]),"cell-model":F(({row:ae})=>[e("span",Z_,C(ae.model||"-"),1)]),_:1},8,["data","loading"])]),e("div",X_,[w($t,{title:"Agents",description:"Agents that are exposed as tools can be called by other prompts and agents. When an agent is called as a tool, it uses the Side A system prompt's requirements as the tool's input schema.",columns:be,data:L.value,loading:I(v),sortable:"",searchable:"","search-placeholder":"Search agents...","empty-message":"No agents are currently exposed as tools. Mark an agent as 'Expose as tool' to see it here."},{"cell-name":F(({row:ae})=>[e("button",{onClick:ye=>ee(ae),class:"text-left font-medium hover:text-black/70 dark:hover:text-white/70 transition-colors underline decoration-transparent hover:decoration-current"},C(ae.name),9,Q_)]),"cell-description":F(({row:ae})=>[e("div",null,[e("span",e4,C(ae.description),1),ae.variables&&ae.variables.length>0?(r(),o("div",t4,[(r(!0),o(we,null,Ae(ae.variables,ye=>(r(),o("span",{key:`${ae.name}-${ye.name}`,class:ce(["text-[10px] px-1.5 py-0.5 rounded uppercase tracking-wide",ye.type==="secret"?"bg-amber-100 dark:bg-amber-900 text-amber-700 dark:text-amber-300":"bg-blue-100 dark:bg-blue-900 text-blue-700 dark:text-blue-300"]),title:ye.description||ye.name},C(K(ye)),11,r4))),128))])):S("",!0)])]),"cell-prompt":F(({row:ae})=>[e("span",a4,C(ae.prompt||"-"),1)]),_:1},8,["data","loading"])]),w(st,{modelValue:a.value,"onUpdate:modelValue":Y[0]||(Y[0]=ae=>a.value=ae),onClose:ue,width:"max-w-4xl"},{header:F(()=>[e("div",n4,[w(I(Cr),{class:"w-5 h-5"}),e("span",null,C(n.value?.name)+" Schema",1)])]),footer:F(()=>[w(I(Je),{onClick:ue},{default:F(()=>[...Y[5]||(Y[5]=[de(" Close ",-1)])]),_:1})]),default:F(()=>[n.value?(r(),o("div",o4,[e("div",null,[e("h3",l4,C(n.value.type==="prompt"?"Required Schema":"JSON Schema"),1),e("p",s4,C(n.value.type==="prompt"?"This is the JSON schema that defines the input parameters for this prompt.":"This is the automatically generated JSON schema for the tool's arguments."),1)]),n.value.schema===null?(r(),o("div",i4,[...Y[4]||(Y[4]=[e("p",{class:"text-neutral-500 dark:text-neutral-400"}," No parameters required ",-1)])])):(r(),J(Qt,{key:1,value:n.value.schema,class:"h-96 border border-black/20 dark:border-white/20 rounded"},null,8,["value"]))])):S("",!0)]),_:1},8,["modelValue"])]),_:1}))}}),d4={class:"space-y-4"},c4={class:"flex justify-end gap-2"},p4={class:"space-y-4"},m4={class:"flex justify-end gap-2"},v4=Ce({__name:"UsersView",setup(t){const n=m(!1),a=m(!1),s=m([]),l=m(!1),u=m(null),i=m({username:"",role:"admin"}),p=[{value:"admin",label:"Admin"}],x=[{key:"username",label:"Username",width:"w-1/3"},{key:"role",label:"Role",width:"w-1/4"},{key:"created_at",label:"Created",width:"w-1/3",formatter:b=>new Date(b*1e3).toLocaleString()}],k=[{icon:"edit",label:"Edit",handler:async b=>{u.value=b,i.value={username:b.username,role:b.role},a.value=!0}},{icon:"delete",label:"Delete",confirm:!0,confirmMessage:"Are you sure you want to delete this user? This action cannot be undone.",handler:async b=>{await _(b.id)}}],h=async()=>{l.value=!0;try{const b=await lt("/users");if(!b.ok)throw new Error("Failed to fetch users");const c=await b.json();s.value=c.users||[]}catch(b){console.error("Error fetching users:",b),s.value=[]}finally{l.value=!1}},g=async b=>{try{const c=await lt("/users",{method:"POST",body:JSON.stringify(b)});if(!c.ok){const f=await c.json();alert(f.error||"Failed to add user");return}await h(),v()}catch(c){console.error("Error adding user:",c),alert("Failed to add user")}},y=async b=>{try{const c={username:b.username,role:b.role};b.password&&(c.password=b.password);const f=await lt(`/users/${u.value.id}`,{method:"PUT",body:JSON.stringify(c)});if(!f.ok){const $=await f.json();alert($.error||"Failed to update user");return}await h(),d()}catch(c){console.error("Error updating user:",c),alert("Failed to update user")}},_=async b=>{try{const c=await lt(`/users/${b}`,{method:"DELETE"});if(!c.ok){const f=await c.json();alert(f.error||"Failed to delete user");return}await h()}catch(c){console.error("Error deleting user:",c),alert("Failed to delete user")}},v=()=>{nr("add-user-form"),n.value=!1},d=()=>{nr("edit-user-form"),a.value=!1,u.value=null};return qe(()=>{h()}),(b,c)=>{const f=tt("FormKit");return r(),J(Et,null,{default:F(()=>[w($t,{title:"Users",description:"Manage user accounts and permissions","primary-action":{label:"Add User",handler:()=>n.value=!0},columns:x,data:s.value,actions:k,loading:l.value,"empty-message":"No users found"},null,8,["primary-action","data","loading"]),w(st,{modelValue:n.value,"onUpdate:modelValue":c[0]||(c[0]=$=>n.value=$),title:"Add User",onClose:v},{footer:F(()=>[e("div",c4,[w(I(Je),{variant:"secondary",onClick:v},{default:F(()=>[...c[4]||(c[4]=[de(" Cancel ",-1)])]),_:1}),w(I(Je),{type:"submit",form:"add-user-form"},{default:F(()=>[...c[5]||(c[5]=[de(" Add User ",-1)])]),_:1})])]),default:F(()=>[w(f,{id:"add-user-form",type:"form",actions:!1,onSubmit:g},{default:F(()=>[e("div",d4,[w(f,{type:"text",name:"username",label:"Username",validation:"required","validation-messages":{required:"Username is required"}}),w(f,{type:"password",name:"password",label:"Password",validation:"required","validation-messages":{required:"Password is required"}}),w(f,{type:"selectSearch",name:"role",label:"Role",options:p,value:"admin",placeholder:"Select role"})])]),_:1})]),_:1},8,["modelValue"]),w(st,{modelValue:a.value,"onUpdate:modelValue":c[3]||(c[3]=$=>a.value=$),title:"Edit User",onClose:d},{footer:F(()=>[e("div",m4,[w(I(Je),{variant:"secondary",onClick:d},{default:F(()=>[...c[6]||(c[6]=[de(" Cancel ",-1)])]),_:1}),w(I(Je),{type:"submit",form:"edit-user-form"},{default:F(()=>[...c[7]||(c[7]=[de(" Update User ",-1)])]),_:1})])]),default:F(()=>[w(f,{id:"edit-user-form",type:"form",actions:!1,onSubmit:y},{default:F(()=>[e("div",p4,[w(f,{type:"text",name:"username",label:"Username",validation:"required",modelValue:i.value.username,"onUpdate:modelValue":c[1]||(c[1]=$=>i.value.username=$),"validation-messages":{required:"Username is required"}},null,8,["modelValue"]),w(f,{type:"password",name:"password",label:"Password",help:"Leave blank to keep current password"}),w(f,{type:"selectSearch",name:"role",label:"Role",options:p,modelValue:i.value.role,"onUpdate:modelValue":c[2]||(c[2]=$=>i.value.role=$),placeholder:"Select role"},null,8,["modelValue"])])]),_:1})]),_:1},8,["modelValue"])]),_:1})}}}),f4={class:"flex justify-end gap-2"},g4={class:"space-y-4"},h4={class:"flex gap-2"},b4=["value"],x4={class:"flex justify-end mt-4"},y4=Ce({__name:"ApiKeysView",setup(t){const n=m(!1),a=m(!1),s=m([]),l=m(!1),u=m(""),i=[{key:"name",label:"Name",width:"w-1/3"},{key:"keyPreview",label:"API Key",width:"w-1/3",html:!0,formatter:_=>`<code class="bg-neutral-100 dark:bg-neutral-800 px-2 py-1 rounded text-sm">${_}</code>`},{key:"createdAt",label:"Created",width:"w-1/6",formatter:_=>new Date(_*1e3).toLocaleDateString()},{key:"lastUsedAt",label:"Last Used",width:"w-1/6",formatter:_=>_?new Date(_*1e3).toLocaleDateString():"Never"}],p=[{icon:"delete",label:"Delete",confirm:!0,confirmMessage:"Are you sure you want to delete this API key? This action cannot be undone.",handler:async _=>{await g(_.id)}}],x=async()=>{l.value=!0;try{const _=await lt("/api-keys");if(!_.ok)throw new Error("Failed to fetch API keys");const v=await _.json();s.value=(v.keys||[]).map(d=>({...d,keyPreview:`${d.key_prefix}...${d.last_five}`,createdAt:d.created_at,lastUsedAt:d.last_used_at}))}catch(_){console.error("Error fetching API keys:",_),s.value=[]}finally{l.value=!1}},k=async _=>{try{const v=await lt("/api-keys",{method:"POST",body:JSON.stringify(_)}),d=await v.json();if(!v.ok){alert(d.error||"Failed to create API key");return}u.value=d.key,h(),a.value=!0,await x()}catch(v){console.error("Error creating API key:",v),alert("Failed to create API key")}},h=()=>{nr("add-api-key-form"),n.value=!1},g=async _=>{try{const v=await lt(`/api-keys/${_}`,{method:"DELETE"});if(!v.ok){const d=await v.json();alert(d.error||"Failed to delete API key");return}await x()}catch(v){console.error("Error deleting API key:",v),alert("Failed to delete API key")}},y=async _=>{try{await navigator.clipboard.writeText(_),alert("API key copied to clipboard!")}catch(v){console.error("Failed to copy:",v)}};return qe(()=>{x()}),(_,v)=>{const d=tt("FormKit");return r(),J(Et,null,{default:F(()=>[w($t,{title:"API Keys",description:"Manage API keys for programmatic access","primary-action":{label:"Create API Key",handler:()=>n.value=!0},columns:i,data:s.value,actions:p,loading:l.value,"empty-message":"No API keys found"},null,8,["primary-action","data","loading"]),w(st,{modelValue:n.value,"onUpdate:modelValue":v[0]||(v[0]=b=>n.value=b),title:"Create API Key",onClose:h},{footer:F(()=>[e("div",f4,[w(I(Je),{variant:"secondary",onClick:h},{default:F(()=>[...v[5]||(v[5]=[de(" Cancel ",-1)])]),_:1}),w(I(Je),{type:"submit",form:"add-api-key-form"},{default:F(()=>[...v[6]||(v[6]=[de(" Create Key ",-1)])]),_:1})])]),default:F(()=>[w(d,{id:"add-api-key-form",type:"form",actions:!1,onSubmit:k},{default:F(()=>[w(d,{type:"text",name:"name",label:"Name",placeholder:"e.g., Production API Key",help:"A descriptive name to help you identify this key",validation:"required","validation-messages":{required:"Name is required"}})]),_:1})]),_:1},8,["modelValue"]),w(st,{modelValue:a.value,"onUpdate:modelValue":v[3]||(v[3]=b=>a.value=b),title:"API Key Created",onClose:v[4]||(v[4]=b=>a.value=!1)},{default:F(()=>[e("div",g4,[w(I(at),{variant:"warning"},{default:F(()=>[...v[7]||(v[7]=[e("p",{class:"font-semibold"},"Important: Save this key now!",-1),e("p",{class:"text-sm mt-1"}," You won't be able to see it again. If you lose this key, you'll need to create a new one. ",-1)])]),_:1}),e("div",null,[v[9]||(v[9]=e("label",{class:"block text-sm font-medium mb-2"},"Your new API key:",-1)),e("div",h4,[e("input",{value:u.value,type:"text",readonly:"",class:"flex-1 px-3 py-2 border border-neutral-300 dark:border-neutral-600 rounded-md dark:bg-neutral-700 font-mono text-sm"},null,8,b4),w(I(Je),{variant:"secondary",onClick:v[1]||(v[1]=b=>y(u.value))},{default:F(()=>[...v[8]||(v[8]=[de(" Copy ",-1)])]),_:1})])]),w(I(at),{variant:"info"},{default:F(()=>[v[10]||(v[10]=e("p",{class:"text-sm"}," Use this key in the Authorization header of your API requests: ",-1)),w(I(Ea),{inline:!1,class:"mt-2"},{default:F(()=>[de(" Authorization: Bearer "+C(u.value),1)]),_:1})]),_:1}),e("div",x4,[w(I(Je),{onClick:v[2]||(v[2]=b=>a.value=!1)},{default:F(()=>[...v[11]||(v[11]=[de(" Done ",-1)])]),_:1})])])]),_:1},8,["modelValue"])]),_:1})}}}),k4={class:"login-container flex-1 flex items-center justify-center px-4"},w4={class:"max-w-md w-full space-y-8"},_4={class:"flex justify-center"},$4=["src"],C4={class:"bg-white dark:bg-neutral-900 border border-neutral-300 dark:border-neutral-700 py-8 px-6 rounded-lg"},S4={key:0,class:"bg-red-50 dark:bg-red-950 border border-red-500 text-red-700 dark:text-red-400 px-4 py-3 mb-6 rounded"},I4={class:"mt-6"},T4=["disabled"],M4={key:0,class:"mt-6"},z4=Ce({__name:"LoginView",setup(t){function n(d){if(d.startsWith("/src/")||d.startsWith("data:"))return d;const b=Kt();return b==="/"?d.replace("/agents/","/"):d.replace("/agents/",`${b}/`)}const a=n(Ba),s=n(Na),l=Ot(),u=Tt(),i=m(""),p=m(!1),x=m(!1),k=m(!1),h=m(!1),g=q(()=>h.value?s:a);qe(async()=>{const d=localStorage.getItem("theme");h.value=d==="dark"||!d&&window.matchMedia("(prefers-color-scheme: dark)").matches;const b=u.query.token,c=u.query.error;if(b){localStorage.setItem("auth_token",b),l.push("/");return}c&&(c==="oauth_failed"?i.value="OAuth authentication failed. Please try again.":c==="oauth_not_configured"&&(i.value="OAuth provider is not configured."));try{const f=await fetch(Ve("/api/auth/config"));if(f.ok){const $=await f.json();x.value=$.github||!1,k.value=$.google||!1}}catch(f){console.error("Failed to fetch auth config:",f)}});async function y(d){i.value="",p.value=!0;try{const b=await fetch(Ve("/api/auth/login"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:d.username,password:d.password})}),c=await b.json();b.ok?(localStorage.setItem("auth_token",c.token),l.push("/")):i.value=c.error||"Login failed"}catch{i.value="Network error. Please try again."}finally{p.value=!1}}function _(){window.location.href=Ve("/api/auth/oauth/github")}function v(){window.location.href=Ve("/api/auth/oauth/google")}return(d,b)=>{const c=tt("FormKit");return r(),o("div",k4,[e("div",w4,[e("div",_4,[e("img",{src:g.value,alt:"AgentBuilder",class:"h-16 pointer-events-none select-none"},null,8,$4)]),w(Wt,{offsetX:8,offsetY:8,intensity:.2,pattern:"crosshatch"},{default:F(()=>[e("div",C4,[w(c,{type:"form",actions:!1,onSubmit:y,disabled:p.value},{default:F(()=>[i.value?(r(),o("div",S4,C(i.value),1)):S("",!0),w(c,{type:"text",name:"username",label:"Username",placeholder:"Enter your username",validation:"required","validation-messages":{required:"Username is required"}}),w(c,{type:"password",name:"password",label:"Password",placeholder:"Enter your password",validation:"required","validation-messages":{required:"Password is required"}}),e("div",I4,[e("button",{type:"submit",disabled:p.value,class:"w-full px-4 py-2.5 bg-neutral-900 text-white dark:bg-neutral-100 dark:text-neutral-900 rounded-md font-medium hover:bg-neutral-800 dark:hover:bg-neutral-200 transition-colors disabled:opacity-50 disabled:cursor-not-allowed"},C(p.value?"Signing in...":"Sign in"),9,T4)])]),_:1},8,["disabled"]),x.value||k.value?(r(),o("div",M4,[b[2]||(b[2]=e("div",{class:"relative"},[e("div",{class:"absolute inset-0 flex items-center"},[e("div",{class:"w-full border-t border-neutral-300 dark:border-neutral-600"})]),e("div",{class:"relative flex justify-center text-sm"},[e("span",{class:"px-2 bg-white dark:bg-neutral-900 text-neutral-500 dark:text-neutral-400"},"Or continue with")])],-1)),e("div",{class:ce(["mt-6 grid gap-3",x.value&&k.value?"grid-cols-2":"grid-cols-1"])},[x.value?(r(),o("button",{key:0,onClick:_,type:"button",class:"w-full inline-flex justify-center items-center px-4 py-2.5 border border-neutral-300 dark:border-neutral-600 bg-white dark:bg-neutral-800 text-neutral-700 dark:text-neutral-200 rounded-md font-medium hover:bg-neutral-50 dark:hover:bg-neutral-700 transition-colors"},[...b[0]||(b[0]=[e("svg",{class:"h-5 w-5",fill:"currentColor",viewBox:"0 0 20 20"},[e("path",{"fill-rule":"evenodd",d:"M10 0C4.477 0 0 4.484 0 10.017c0 4.425 2.865 8.18 6.839 9.504.5.092.682-.217.682-.483 0-.237-.008-.868-.013-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.029-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0110 4.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.028 1.595 1.028 2.688 0 3.848-2.339 4.695-4.566 4.942.359.31.678.921.678 1.856 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.019 10.019 0 0020 10.017C20 4.484 15.522 0 10 0z","clip-rule":"evenodd"})],-1),e("span",{class:"ml-2"},"GitHub",-1)])])):S("",!0),k.value?(r(),o("button",{key:1,onClick:v,type:"button",class:"w-full inline-flex justify-center items-center px-4 py-2.5 border border-neutral-300 dark:border-neutral-600 bg-white dark:bg-neutral-800 text-neutral-700 dark:text-neutral-200 rounded-md font-medium hover:bg-neutral-50 dark:hover:bg-neutral-700 transition-colors"},[...b[1]||(b[1]=[e("svg",{class:"h-5 w-5",viewBox:"0 0 24 24"},[e("path",{fill:"currentColor",d:"M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z"}),e("path",{fill:"currentColor",d:"M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z"}),e("path",{fill:"currentColor",d:"M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z"}),e("path",{fill:"currentColor",d:"M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z"})],-1),e("span",{class:"ml-2"},"Google",-1)])])):S("",!0)],2)])):S("",!0)])]),_:1})])])}}}),V4={class:"space-y-1"},E4=["value","placeholder","disabled"],kr=Ce({__name:"MultilineInput",props:{modelValue:{},label:{},placeholder:{},error:{},required:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1}},emits:["update:modelValue","focus","blur"],setup(t,{expose:n,emit:a}){const s=t,l=a,u=m(null),i=q(()=>["w-full px-3 py-2.5 bg-neutral-50 dark:bg-neutral-950 border rounded-md font-mono text-sm","focus:outline-none focus:ring-2 focus:ring-neutral-400 dark:focus:ring-neutral-500 focus:border-transparent","transition-colors resize-none overflow-hidden placeholder:text-neutral-400 dark:placeholder:text-neutral-500",s.error?"border-red-500 dark:border-red-400":"border-neutral-300 dark:border-neutral-600",s.disabled?"opacity-50 cursor-not-allowed":""]),p=()=>{const g=u.value;g&&(g.style.height="auto",g.style.height=`${g.scrollHeight+2}px`)},x=g=>{const y=g.target;l("update:modelValue",y.value),p()},k=g=>{l("focus",g)},h=g=>{l("blur",g)};return qe(()=>{p()}),Ee(()=>s.modelValue,async()=>{await Ne(),p()}),n({textareaRef:u,adjustHeight:p}),(g,y)=>(r(),o("div",V4,[t.label?(r(),J(I(Va),{key:0,required:t.required},{default:F(()=>[de(C(t.label),1)]),_:1},8,["required"])):S("",!0),e("textarea",{ref_key:"textareaRef",ref:u,value:t.modelValue,placeholder:t.placeholder,disabled:t.disabled,class:ce(i.value),rows:"1",onInput:x,onFocus:k,onBlur:h},null,42,E4),t.error?(r(),J(I(kt),{key:1},{default:F(()=>[de(C(t.error),1)]),_:1})):S("",!0)]))}}),L4={class:"flex items-start"},A4=["for"],P4=["id","checked","disabled"],j4={class:"flex items-center h-5"},R4={class:"flex-1"},O4={key:0,class:"text-red-500"},Zt=Ce({__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:n}){const a=t,s=n,l=En(),u=q(()=>["w-5 h-5 border-2 rounded relative flex-shrink-0","transition-all duration-150",a.error?"border-red-500 dark:border-red-400":"border-black dark:border-neutral-300",a.disabled?"opacity-50":"hover:scale-110",a.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]",a.modelValue?"before:block":"before:hidden"]),i=p=>{if(!a.disabled){const x=p.target;s("update:modelValue",x.checked)}};return(p,x)=>(r(),o("div",L4,[e("label",{for:I(l),class:ce(["flex items-start space-x-3 cursor-pointer select-none",{"cursor-not-allowed":t.disabled}])},[e("input",{id:I(l),type:"checkbox",checked:t.modelValue,disabled:t.disabled,onChange:i,class:"absolute left-[-9999px]"},null,40,P4),e("div",j4,[e("span",{class:ce(u.value)},null,2)]),e("div",R4,[t.label?(r(),o("span",{key:0,class:ce(["block text-sm font-medium",{"opacity-50":t.disabled}])},[de(C(t.label)+" ",1),t.required?(r(),o("span",O4,"*")):S("",!0)],2)):S("",!0),t.helpText?(r(),J(I(Ue),{key:1,class:"mt-1"},{default:F(()=>[de(C(t.helpText),1)]),_:1})):S("",!0),t.error?(r(),J(I(kt),{key:2,class:"mt-1"},{default:F(()=>[de(C(t.error),1)]),_:1})):S("",!0)])],10,A4)]))}}),D4={class:"p-8 space-y-6"},U4={class:"mt-12"},B4={class:"mb-6"},N4={class:"mb-6"},q4={class:"mb-6"},F4={class:"mt-8"},H4={class:"border-2 border-red-500 p-4 h-32 overflow-hidden relative"},W4={class:"mt-12"},K4={class:"mb-6"},J4={class:"border-2 border-accent-500 p-4 h-32 overflow-hidden relative"},G4={class:"mt-12"},Y4={class:"mb-6"},Z4={class:"mb-6"},X4={class:"mt-12"},Q4={class:"mb-6"},e5={class:"mt-2 text-sm"},t5={class:"mb-6"},r5={class:"mt-2 text-sm"},a5={class:"mb-6"},n5={class:"mb-6"},o5={class:"mt-12"},l5={class:"mb-6"},s5={class:"mt-4 p-4 bg-neutral-100 dark:bg-neutral-900 rounded"},i5={class:"text-xs overflow-x-auto"},u5=Ce({__name:"TestView",setup(t){const n=m(""),a=m(""),s=m(""),l=m(`Line 1
54
+ This provider has ${b.modelCount} associated model(s).`):alert(b.error||"Failed to delete provider");return}await c()}catch(x){console.error("Error deleting provider:",x),alert("Failed to delete provider")}};return He(()=>{c()}),(h,x)=>(r(),Y(Pt,null,{default:W(()=>[k(It,{title:"Providers",description:"Installed providers and API key status. Provider availability is defined in code and environment configuration.",columns:u,data:n.value,actions:i,loading:a.value,sortable:"",searchable:"","search-placeholder":"Search providers...","empty-message":"No providers are installed in this AgentBuilder instance."},{"cell-sdk":W(({value:b,row:y})=>[t("div",j_,[t("img",{src:`/api/providers/${y.name}/icon`,alt:l(b),class:"w-5 h-5"},null,8,D_),t("span",null,C(l(b)),1)])]),"cell-hasApiKey":W(({value:b,row:y})=>[b?(r(),o("span",U_,[k(I(R_),{class:"w-3.5 h-3.5"}),x[0]||(x[0]=ve(" Configured ",-1))])):(r(),o("span",{key:1,class:"inline-flex items-center gap-1.5 px-2.5 py-1 text-xs font-medium rounded-full bg-neutral-100 text-neutral-500 dark:bg-neutral-800 dark:text-neutral-400",title:y.envKeys?.length?`Required: ${y.envKeys.join(", ")}`:void 0},[k(I(mr),{class:"w-3.5 h-3.5"}),x[1]||(x[1]=ve(" Not configured ",-1))],8,B_))]),_:1},8,["data","loading"])]),_:1}))}}),q_={class:"font-medium mb-1"},F_={id:"functions"},H_=["onClick"],W_={key:1,class:"text-left font-medium text-red-600 dark:text-red-400"},K_={key:0,class:"mt-2 flex flex-wrap gap-1"},J_=["title"],G_={class:"flex justify-end"},Y_=["onClick"],Z_={key:1,class:"text-neutral-400 text-sm"},X_={id:"prompts",class:"mt-12"},Q_=["onClick"],e4={class:"text-neutral-600 dark:text-neutral-400"},t4={key:0,class:"mt-2 flex flex-wrap gap-1"},r4=["title"],a4={class:"text-sm text-neutral-500 dark:text-neutral-400"},n4={id:"agents",class:"mt-12"},o4=["onClick"],l4={class:"text-neutral-600 dark:text-neutral-400"},s4={key:0,class:"mt-2 flex flex-wrap gap-1"},i4=["title"],u4={class:"text-sm text-neutral-500 dark:text-neutral-400"},d4={class:"flex items-center gap-2"},c4={key:0,class:"space-y-4"},p4={class:"text-lg font-medium mb-2"},m4={class:"text-sm text-neutral-600 dark:text-neutral-400 mb-4"},v4={key:0,class:"h-96 flex items-center justify-center border border-black/20 dark:border-white/20 rounded bg-black/5 dark:bg-white/5"},f4=Se({__name:"ToolsView",setup(e){const n=p(null),a=p(!1),{data:s}=it(ze("/api/config")).json(),{data:l,error:u,isFetching:i,execute:c}=it(ze("/api/tools?type=tools"),{immediate:!1}).json(),{data:f,error:h,isFetching:x,execute:b}=it(ze("/api/tools?type=prompts&schema=true"),{immediate:!1}).json(),{data:y,error:$,isFetching:g,execute:d}=it(ze("/api/tools?type=agents&schema=true"),{immediate:!1}).json(),{data:w,error:m,isFetching:v,execute:_}=it(()=>n.value?ze(`/api/tools/${encodeURIComponent(n.value.name)}`):null,{immediate:!1}).json(),P=p([]),V=p([]),E=p([]),z=Vt(),A=async()=>{const Q=z.hash;if(Q){await Fe();const G=document.getElementById(Q.slice(1));G&&G.scrollIntoView({behavior:"smooth"})}};Ve(()=>z.hash,A);const oe=async Q=>{n.value=Q,await _(),w.value?n.value={...Q,schema:w.value.schema||null}:m.value&&console.error("Error fetching tool schema:",m.value),a.value=!0},ne=async Q=>{if(n.value=Q,a.value=!0,!Q.schema&&Q.type==="prompt"){const G=await fetch(ze("/api/tools?type=prompts&schema=true"));if(G.ok){const ae=await G.json();ae[Q.name]&&(n.value={...Q,schema:ae[Q.name].schema||null})}}},fe=[{key:"name",label:"Prompt Name",width:"w-1/3",sortable:!0},{key:"description",label:"Description",width:"w-1/2"},{key:"model",label:"Model",width:"w-1/6",sortable:!0,filterable:!0}],ye=[{key:"name",label:"Agent Name",width:"w-1/3",sortable:!0},{key:"description",label:"Description",width:"w-1/2"},{key:"prompt",label:"Prompt",width:"w-1/6",sortable:!0,filterable:!0}],te=[{key:"name",label:"Tool Name",width:"w-1/3",sortable:!0},{key:"description",label:"Description",width:"w-1/2"},{key:"actions",label:"Actions",width:"w-1/6"}],q=Q=>/^[a-z][a-z0-9_]*[a-z0-9]$/.test(Q)||/^[a-z]$/.test(Q),j=Q=>Q.hasError&&Q.error?Q.error:Q.description||"No description available",J=Q=>Q.required?`${Q.name}*`:Q.name,H=()=>{l.value&&(P.value=Object.entries(l.value).map(([Q,G])=>({name:Q,description:G.description||"No description available",schema:null,hasError:G.hasError||!1,error:G.error,type:G.type||"tool",variables:G.variables||G.tenvs||[]})))},ce=()=>{f.value&&(V.value=Object.entries(f.value).map(([Q,G])=>({name:Q,description:G.description||"No description available",schema:G.schema||null,hasError:!1,type:"prompt",model:G.model,variables:G.variables||G.tenvs||[]})))},Z=()=>{y.value&&(E.value=Object.entries(y.value).map(([Q,G])=>({name:Q,description:G.description||"No description available",schema:G.schema||null,hasError:!1,type:"agent",prompt:G.prompt||G.model,variables:G.variables||G.tenvs||[]})))},U=async()=>{await c(),H()},K=async()=>{await b(),ce()},me=async()=>{await d(),Z()},ue=()=>{a.value=!1,n.value=null};return He(()=>{U(),K(),me(),A()}),(Q,G)=>(r(),Y(Pt,null,{default:W(()=>[G[6]||(G[6]=t("div",{class:"flex justify-between items-center mb-6"},[t("h1",{class:"text-3xl font-bold"},"Tools")],-1)),G[7]||(G[7]=t("p",{class:"text-neutral-600 dark:text-neutral-400 mb-6"}," Tools are the fundamental building blocks of how your business logic is exposed to your agents. Your prompts can expose tools for the agents to call. There are 3 types of tools: functions, prompts, and agents. Functions are actual code in your AgentKit codebase. Prompts are any prompts created in the prompts table (which can themselves expose tools). Agents are multi-turn conversations that can be invoked as tools. ",-1)),k(I(ot),{variant:"info",class:"mb-6"},{default:W(()=>[t("p",q_,[G[1]||(G[1]=ve(" To create or modify tools, edit the ",-1)),k(I(Ba),null,{default:W(()=>[ve(C(I(s)?.toolsDir||"agentbuilder/tools")+"/",1)]),_:1}),G[2]||(G[2]=ve(" directory of your codebase. ",-1))]),G[3]||(G[3]=t("p",{class:"opacity-70"}," Changes will be automatically detected. ",-1))]),_:1}),t("div",F_,[k(It,{title:"Functions",description:"Function tools defined in your codebase.",columns:te,data:P.value,loading:I(i),sortable:"",searchable:"","search-placeholder":"Search functions...","empty-message":`No tools found. Add tool files to the ${I(s)?.toolsDir||"agentbuilder/tools"}/ directory.`},{"cell-name":W(({row:ae})=>[t("div",{class:pe(["flex items-center gap-2",{"text-red-600 dark:text-red-400":ae.hasError}])},[ae.hasError?(r(),o("span",W_,C(ae.name),1)):(r(),o("button",{key:0,onClick:ie=>oe(ae),class:"text-left font-medium hover:text-black/70 dark:hover:text-white/70 transition-colors underline decoration-transparent hover:decoration-current"},C(ae.name),9,H_)),ae.hasError?(r(),Y(I(ea),{key:2,content:"This tool has validation errors"},{default:W(()=>[k(I(Xr),{class:"w-4 h-4 text-red-500"})]),_:1})):q(ae.name)?S("",!0):(r(),Y(I(ea),{key:3,content:"Tool name should be in snake_case format (e.g., 'log_name', 'send_email')"},{default:W(()=>[k(I(Xr),{class:"w-4 h-4 text-amber-500"})]),_:1}))],2)]),"cell-description":W(({row:ae})=>[t("div",null,[t("span",{class:pe({"text-red-600 dark:text-red-400":ae.hasError,"text-neutral-600 dark:text-neutral-400":!ae.hasError})},C(j(ae)),3),ae.variables&&ae.variables.length>0?(r(),o("div",K_,[(r(!0),o($e,null,Le(ae.variables,ie=>(r(),o("span",{key:`${ae.name}-${ie.name}`,class:pe(["text-[10px] px-1.5 py-0.5 rounded uppercase tracking-wide",ie.type==="secret"?"bg-amber-100 dark:bg-amber-900 text-amber-700 dark:text-amber-300":"bg-blue-100 dark:bg-blue-900 text-blue-700 dark:text-blue-300"]),title:ie.description||ie.name},C(J(ie)),11,J_))),128))])):S("",!0)])]),"cell-actions":W(({row:ae})=>[t("div",G_,[ae.hasError?(r(),o("span",Z_,"—")):(r(),o("button",{key:0,onClick:ie=>oe(ae),class:"p-1.5 rounded hover:bg-black/10 dark:hover:bg-white/10 transition-colors",title:"View Schema"},[k(I(Vr),{class:"w-4 h-4"})],8,Y_))])]),_:1},8,["data","loading","empty-message"])]),t("div",X_,[k(It,{title:"Prompts",description:"Prompts that are exposed as tools can be called by other prompts and agents. These allow you to create reusable, composable prompt chains.",columns:fe,data:V.value,loading:I(x),sortable:"",searchable:"","search-placeholder":"Search prompts...","empty-message":"No prompts are currently exposed as tools. Mark a prompt as 'Expose as tool' to see it here."},{"cell-name":W(({row:ae})=>[t("button",{onClick:ie=>ne(ae),class:"text-left font-medium hover:text-black/70 dark:hover:text-white/70 transition-colors underline decoration-transparent hover:decoration-current"},C(ae.name),9,Q_)]),"cell-description":W(({row:ae})=>[t("div",null,[t("span",e4,C(ae.description),1),ae.variables&&ae.variables.length>0?(r(),o("div",t4,[(r(!0),o($e,null,Le(ae.variables,ie=>(r(),o("span",{key:`${ae.name}-${ie.name}`,class:pe(["text-[10px] px-1.5 py-0.5 rounded uppercase tracking-wide",ie.type==="secret"?"bg-amber-100 dark:bg-amber-900 text-amber-700 dark:text-amber-300":"bg-blue-100 dark:bg-blue-900 text-blue-700 dark:text-blue-300"]),title:ie.description||ie.name},C(J(ie)),11,r4))),128))])):S("",!0)])]),"cell-model":W(({row:ae})=>[t("span",a4,C(ae.model||"-"),1)]),_:1},8,["data","loading"])]),t("div",n4,[k(It,{title:"Agents",description:"Agents that are exposed as tools can be called by other prompts and agents. When an agent is called as a tool, it uses the Side A system prompt's requirements as the tool's input schema.",columns:ye,data:E.value,loading:I(g),sortable:"",searchable:"","search-placeholder":"Search agents...","empty-message":"No agents are currently exposed as tools. Mark an agent as 'Expose as tool' to see it here."},{"cell-name":W(({row:ae})=>[t("button",{onClick:ie=>ne(ae),class:"text-left font-medium hover:text-black/70 dark:hover:text-white/70 transition-colors underline decoration-transparent hover:decoration-current"},C(ae.name),9,o4)]),"cell-description":W(({row:ae})=>[t("div",null,[t("span",l4,C(ae.description),1),ae.variables&&ae.variables.length>0?(r(),o("div",s4,[(r(!0),o($e,null,Le(ae.variables,ie=>(r(),o("span",{key:`${ae.name}-${ie.name}`,class:pe(["text-[10px] px-1.5 py-0.5 rounded uppercase tracking-wide",ie.type==="secret"?"bg-amber-100 dark:bg-amber-900 text-amber-700 dark:text-amber-300":"bg-blue-100 dark:bg-blue-900 text-blue-700 dark:text-blue-300"]),title:ie.description||ie.name},C(J(ie)),11,i4))),128))])):S("",!0)])]),"cell-prompt":W(({row:ae})=>[t("span",u4,C(ae.prompt||"-"),1)]),_:1},8,["data","loading"])]),k(dt,{modelValue:a.value,"onUpdate:modelValue":G[0]||(G[0]=ae=>a.value=ae),onClose:ue,width:"max-w-4xl"},{header:W(()=>[t("div",d4,[k(I(Vr),{class:"w-5 h-5"}),t("span",null,C(n.value?.name)+" Schema",1)])]),footer:W(()=>[k(I(Qe),{onClick:ue},{default:W(()=>[...G[5]||(G[5]=[ve(" Close ",-1)])]),_:1})]),default:W(()=>[n.value?(r(),o("div",c4,[t("div",null,[t("h3",p4,C(n.value.type==="prompt"?"Required Schema":"JSON Schema"),1),t("p",m4,C(n.value.type==="prompt"?"This is the JSON schema that defines the input parameters for this prompt.":"This is the automatically generated JSON schema for the tool's arguments."),1)]),n.value.schema===null?(r(),o("div",v4,[...G[4]||(G[4]=[t("p",{class:"text-neutral-500 dark:text-neutral-400"}," No parameters required ",-1)])])):(r(),Y(nr,{key:1,value:n.value.schema,class:"h-96 border border-black/20 dark:border-white/20 rounded"},null,8,["value"]))])):S("",!0)]),_:1},8,["modelValue"])]),_:1}))}}),g4={class:"space-y-4"},h4={class:"flex justify-end gap-2"},b4={class:"space-y-4"},x4={class:"flex justify-end gap-2"},y4=Se({__name:"UsersView",setup(e){const n=p(!1),a=p(!1),s=p([]),l=p(!1),u=p(null),i=p(!1),c=p(!1),f=p({username:"",role:"admin"}),h=[{value:"admin",label:"Admin"}],x=[{key:"username",label:"Username",width:"w-1/3"},{key:"role",label:"Role",width:"w-1/4"},{key:"created_at",label:"Created",width:"w-1/3",formatter:v=>new Date(v*1e3).toLocaleString()}],b=[{icon:"edit",label:"Edit",handler:async v=>{u.value=v,f.value={username:v.username,role:v.role},a.value=!0}},{icon:"delete",label:"Delete",confirm:!0,confirmMessage:"Are you sure you want to delete this user? This action cannot be undone.",handler:async v=>{await d(v.id)}}],y=async()=>{l.value=!0;try{const v=await ut("/users");if(!v.ok)throw new Error("Failed to fetch users");const _=await v.json();s.value=_.users||[]}catch(v){console.error("Error fetching users:",v),s.value=[]}finally{l.value=!1}},$=async v=>{i.value=!0;try{const _=await ut("/users",{method:"POST",body:JSON.stringify(v)});if(!_.ok){const P=await _.json();alert(P.error||"Failed to add user");return}await y(),w()}catch(_){console.error("Error adding user:",_),alert("Failed to add user")}finally{i.value=!1}},g=async v=>{c.value=!0;try{const _={username:v.username,role:v.role};v.password&&(_.password=v.password);const P=await ut(`/users/${u.value.id}`,{method:"PUT",body:JSON.stringify(_)});if(!P.ok){const V=await P.json();alert(V.error||"Failed to update user");return}await y(),m()}catch(_){console.error("Error updating user:",_),alert("Failed to update user")}finally{c.value=!1}},d=async v=>{try{const _=await ut(`/users/${v}`,{method:"DELETE"});if(!_.ok){const P=await _.json();alert(P.error||"Failed to delete user");return}await y()}catch(_){console.error("Error deleting user:",_),alert("Failed to delete user")}},w=()=>{Ir("add-user-form"),n.value=!1},m=()=>{Ir("edit-user-form"),a.value=!1,u.value=null};return He(()=>{y()}),(v,_)=>{const P=at("FormKit");return r(),Y(Pt,null,{default:W(()=>[k(It,{title:"Users",description:"Manage user accounts and permissions","primary-action":{label:"Add User",handler:()=>n.value=!0},columns:x,data:s.value,actions:b,loading:l.value,"empty-message":"No users found"},null,8,["primary-action","data","loading"]),k(dt,{modelValue:n.value,"onUpdate:modelValue":_[0]||(_[0]=V=>n.value=V),title:"Add User",onClose:w},{footer:W(()=>[t("div",h4,[k(I(Qe),{variant:"secondary",disabled:i.value,onClick:w},{default:W(()=>[..._[4]||(_[4]=[ve(" Cancel ",-1)])]),_:1},8,["disabled"]),k(I(Qe),{type:"submit",form:"add-user-form",loading:i.value},{default:W(()=>[..._[5]||(_[5]=[ve(" Add User ",-1)])]),_:1},8,["loading"])])]),default:W(()=>[k(P,{id:"add-user-form",type:"form",actions:!1,disabled:i.value,onSubmit:$},{default:W(()=>[t("div",g4,[k(P,{type:"text",name:"username",label:"Username",validation:"required","validation-messages":{required:"Username is required"}}),k(P,{type:"password",name:"password",label:"Password",validation:"required","validation-messages":{required:"Password is required"}}),k(P,{type:"selectSearch",name:"role",label:"Role",options:h,value:"admin",placeholder:"Select role"})])]),_:1},8,["disabled"])]),_:1},8,["modelValue"]),k(dt,{modelValue:a.value,"onUpdate:modelValue":_[3]||(_[3]=V=>a.value=V),title:"Edit User",onClose:m},{footer:W(()=>[t("div",x4,[k(I(Qe),{variant:"secondary",disabled:c.value,onClick:m},{default:W(()=>[..._[6]||(_[6]=[ve(" Cancel ",-1)])]),_:1},8,["disabled"]),k(I(Qe),{type:"submit",form:"edit-user-form",loading:c.value},{default:W(()=>[..._[7]||(_[7]=[ve(" Update User ",-1)])]),_:1},8,["loading"])])]),default:W(()=>[k(P,{id:"edit-user-form",type:"form",actions:!1,disabled:c.value,onSubmit:g},{default:W(()=>[t("div",b4,[k(P,{type:"text",name:"username",label:"Username",validation:"required",modelValue:f.value.username,"onUpdate:modelValue":_[1]||(_[1]=V=>f.value.username=V),"validation-messages":{required:"Username is required"}},null,8,["modelValue"]),k(P,{type:"password",name:"password",label:"Password",help:"Leave blank to keep current password"}),k(P,{type:"selectSearch",name:"role",label:"Role",options:h,modelValue:f.value.role,"onUpdate:modelValue":_[2]||(_[2]=V=>f.value.role=V),placeholder:"Select role"},null,8,["modelValue"])])]),_:1},8,["disabled"])]),_:1},8,["modelValue"])]),_:1})}}}),k4={class:"flex justify-end gap-2"},w4={class:"space-y-4"},_4={class:"flex gap-2"},$4=["value"],C4={class:"flex justify-end mt-4"},S4=Se({__name:"ApiKeysView",setup(e){const n=p(!1),a=p(!1),s=p([]),l=p(!1),u=p(""),i=p(!1),c=[{key:"name",label:"Name",width:"w-1/3"},{key:"keyPreview",label:"API Key",width:"w-1/3",html:!0,formatter:g=>`<code class="bg-neutral-100 dark:bg-neutral-800 px-2 py-1 rounded text-sm">${g}</code>`},{key:"createdAt",label:"Created",width:"w-1/6",formatter:g=>new Date(g*1e3).toLocaleDateString()},{key:"lastUsedAt",label:"Last Used",width:"w-1/6",formatter:g=>g?new Date(g*1e3).toLocaleDateString():"Never"}],f=[{icon:"delete",label:"Delete",confirm:!0,confirmMessage:"Are you sure you want to delete this API key? This action cannot be undone.",handler:async g=>{await y(g.id)}}],h=async()=>{l.value=!0;try{const g=await ut("/api-keys");if(!g.ok)throw new Error("Failed to fetch API keys");const d=await g.json();s.value=(d.keys||[]).map(w=>({...w,keyPreview:`${w.key_prefix}...${w.last_five}`,createdAt:w.created_at,lastUsedAt:w.last_used_at}))}catch(g){console.error("Error fetching API keys:",g),s.value=[]}finally{l.value=!1}},x=async g=>{i.value=!0;try{const d=await ut("/api-keys",{method:"POST",body:JSON.stringify(g)}),w=await d.json();if(!d.ok){alert(w.error||"Failed to create API key");return}u.value=w.key,b(),a.value=!0,await h()}catch(d){console.error("Error creating API key:",d),alert("Failed to create API key")}finally{i.value=!1}},b=()=>{Ir("add-api-key-form"),n.value=!1},y=async g=>{try{const d=await ut(`/api-keys/${g}`,{method:"DELETE"});if(!d.ok){const w=await d.json();alert(w.error||"Failed to delete API key");return}await h()}catch(d){console.error("Error deleting API key:",d),alert("Failed to delete API key")}},$=async g=>{try{await navigator.clipboard.writeText(g),alert("API key copied to clipboard!")}catch(d){console.error("Failed to copy:",d)}};return He(()=>{h()}),(g,d)=>{const w=at("FormKit");return r(),Y(Pt,null,{default:W(()=>[k(It,{title:"API Keys",description:"Manage API keys for programmatic access","primary-action":{label:"Create API Key",handler:()=>n.value=!0},columns:c,data:s.value,actions:f,loading:l.value,"empty-message":"No API keys found"},null,8,["primary-action","data","loading"]),k(dt,{modelValue:n.value,"onUpdate:modelValue":d[0]||(d[0]=m=>n.value=m),title:"Create API Key",onClose:b},{footer:W(()=>[t("div",k4,[k(I(Qe),{variant:"secondary",disabled:i.value,onClick:b},{default:W(()=>[...d[5]||(d[5]=[ve(" Cancel ",-1)])]),_:1},8,["disabled"]),k(I(Qe),{type:"submit",form:"add-api-key-form",loading:i.value},{default:W(()=>[...d[6]||(d[6]=[ve(" Create Key ",-1)])]),_:1},8,["loading"])])]),default:W(()=>[k(w,{id:"add-api-key-form",type:"form",actions:!1,disabled:i.value,onSubmit:x},{default:W(()=>[k(w,{type:"text",name:"name",label:"Name",placeholder:"e.g., Production API Key",help:"A descriptive name to help you identify this key",validation:"required","validation-messages":{required:"Name is required"}})]),_:1},8,["disabled"])]),_:1},8,["modelValue"]),k(dt,{modelValue:a.value,"onUpdate:modelValue":d[3]||(d[3]=m=>a.value=m),title:"API Key Created",onClose:d[4]||(d[4]=m=>a.value=!1)},{default:W(()=>[t("div",w4,[k(I(ot),{variant:"warning"},{default:W(()=>[...d[7]||(d[7]=[t("p",{class:"font-semibold"},"Important: Save this key now!",-1),t("p",{class:"text-sm mt-1"}," You won't be able to see it again. If you lose this key, you'll need to create a new one. ",-1)])]),_:1}),t("div",null,[d[9]||(d[9]=t("label",{class:"block text-sm font-medium mb-2"},"Your new API key:",-1)),t("div",_4,[t("input",{value:u.value,type:"text",readonly:"",class:"flex-1 px-3 py-2 border border-neutral-300 dark:border-neutral-600 rounded-md dark:bg-neutral-700 font-mono text-sm"},null,8,$4),k(I(Qe),{variant:"secondary",onClick:d[1]||(d[1]=m=>$(u.value))},{default:W(()=>[...d[8]||(d[8]=[ve(" Copy ",-1)])]),_:1})])]),k(I(ot),{variant:"info"},{default:W(()=>[d[10]||(d[10]=t("p",{class:"text-sm"}," Use this key in the Authorization header of your API requests: ",-1)),k(I(Ba),{inline:!1,class:"mt-2"},{default:W(()=>[ve(" Authorization: Bearer "+C(u.value),1)]),_:1})]),_:1}),t("div",C4,[k(I(Qe),{onClick:d[2]||(d[2]=m=>a.value=!1)},{default:W(()=>[...d[11]||(d[11]=[ve(" Done ",-1)])]),_:1})])])]),_:1},8,["modelValue"])]),_:1})}}}),I4={class:"login-container flex-1 flex items-center justify-center px-4"},T4={class:"max-w-md w-full space-y-8"},M4={class:"flex justify-center"},z4=["src"],V4={class:"bg-white dark:bg-neutral-900 border border-neutral-300 dark:border-neutral-700 py-8 px-6 rounded-lg"},E4={key:0,class:"bg-red-50 dark:bg-red-950 border border-red-500 text-red-700 dark:text-red-400 px-4 py-3 mb-6 rounded"},L4={class:"mt-6"},A4={key:0,class:"mt-6"},P4=Se({__name:"LoginView",setup(e){function n(d){if(d.startsWith("/src/")||d.startsWith("data:"))return d;const w=Xt();return w==="/"?d.replace("/agents/","/"):d.replace("/agents/",`${w}/`)}const a=n(Ya),s=n(Za),l=qt(),u=Vt(),i=p(""),c=p(!1),f=p(!1),h=p(!1),x=p(!1),b=F(()=>x.value?s:a);He(async()=>{const d=localStorage.getItem("theme");x.value=d==="dark"||!d&&window.matchMedia("(prefers-color-scheme: dark)").matches;const w=u.query.token,m=u.query.error;if(w){localStorage.setItem("auth_token",w),l.push("/");return}m&&(m==="oauth_failed"?i.value="OAuth authentication failed. Please try again.":m==="oauth_not_configured"&&(i.value="OAuth provider is not configured."));try{const v=await fetch(ze("/api/auth/config"));if(v.ok){const _=await v.json();f.value=_.github||!1,h.value=_.google||!1}}catch(v){console.error("Failed to fetch auth config:",v)}});async function y(d){i.value="",c.value=!0;try{const w=await fetch(ze("/api/auth/login"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:d.username,password:d.password})}),m=await w.json();w.ok?(localStorage.setItem("auth_token",m.token),l.push("/")):i.value=m.error||"Login failed"}catch{i.value="Network error. Please try again."}finally{c.value=!1}}function $(){window.location.href=ze("/api/auth/oauth/github")}function g(){window.location.href=ze("/api/auth/oauth/google")}return(d,w)=>{const m=at("FormKit");return r(),o("div",I4,[t("div",T4,[t("div",M4,[t("img",{src:b.value,alt:"AgentBuilder",class:"h-16 pointer-events-none select-none"},null,8,z4)]),k(Zt,{offsetX:8,offsetY:8,intensity:.2,pattern:"crosshatch"},{default:W(()=>[t("div",V4,[k(m,{type:"form",actions:!1,onSubmit:y,disabled:c.value},{default:W(()=>[i.value?(r(),o("div",E4,C(i.value),1)):S("",!0),k(m,{type:"text",name:"username",label:"Username",placeholder:"Enter your username",validation:"required","validation-messages":{required:"Username is required"}}),k(m,{type:"password",name:"password",label:"Password",placeholder:"Enter your password",validation:"required","validation-messages":{required:"Password is required"}}),t("div",L4,[k(I(Qe),{type:"submit",variant:"primary","full-width":"",loading:c.value},{default:W(()=>[...w[0]||(w[0]=[ve(" Sign in ",-1)])]),_:1},8,["loading"])])]),_:1},8,["disabled"]),f.value||h.value?(r(),o("div",A4,[w[3]||(w[3]=t("div",{class:"relative"},[t("div",{class:"absolute inset-0 flex items-center"},[t("div",{class:"w-full border-t border-neutral-300 dark:border-neutral-600"})]),t("div",{class:"relative flex justify-center text-sm"},[t("span",{class:"px-2 bg-white dark:bg-neutral-900 text-neutral-500 dark:text-neutral-400"},"Or continue with")])],-1)),t("div",{class:pe(["mt-6 grid gap-3",f.value&&h.value?"grid-cols-2":"grid-cols-1"])},[f.value?(r(),o("button",{key:0,onClick:$,type:"button",class:"w-full inline-flex justify-center items-center px-4 py-2.5 border border-neutral-300 dark:border-neutral-600 bg-white dark:bg-neutral-800 text-neutral-700 dark:text-neutral-200 rounded-md font-medium hover:bg-neutral-50 dark:hover:bg-neutral-700 transition-colors"},[...w[1]||(w[1]=[t("svg",{class:"h-5 w-5",fill:"currentColor",viewBox:"0 0 20 20"},[t("path",{"fill-rule":"evenodd",d:"M10 0C4.477 0 0 4.484 0 10.017c0 4.425 2.865 8.18 6.839 9.504.5.092.682-.217.682-.483 0-.237-.008-.868-.013-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.029-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0110 4.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.028 1.595 1.028 2.688 0 3.848-2.339 4.695-4.566 4.942.359.31.678.921.678 1.856 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.019 10.019 0 0020 10.017C20 4.484 15.522 0 10 0z","clip-rule":"evenodd"})],-1),t("span",{class:"ml-2"},"GitHub",-1)])])):S("",!0),h.value?(r(),o("button",{key:1,onClick:g,type:"button",class:"w-full inline-flex justify-center items-center px-4 py-2.5 border border-neutral-300 dark:border-neutral-600 bg-white dark:bg-neutral-800 text-neutral-700 dark:text-neutral-200 rounded-md font-medium hover:bg-neutral-50 dark:hover:bg-neutral-700 transition-colors"},[...w[2]||(w[2]=[t("svg",{class:"h-5 w-5",viewBox:"0 0 24 24"},[t("path",{fill:"currentColor",d:"M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z"}),t("path",{fill:"currentColor",d:"M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z"}),t("path",{fill:"currentColor",d:"M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z"}),t("path",{fill:"currentColor",d:"M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z"})],-1),t("span",{class:"ml-2"},"Google",-1)])])):S("",!0)],2)])):S("",!0)])]),_:1})])])}}}),O4={class:"space-y-1"},R4=["value","placeholder","disabled"],Sr=Se({__name:"MultilineInput",props:{modelValue:{},label:{},placeholder:{},error:{},required:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1}},emits:["update:modelValue","focus","blur"],setup(e,{expose:n,emit:a}){const s=e,l=a,u=p(null),i=F(()=>["w-full px-3 py-2.5 bg-neutral-50 dark:bg-neutral-950 border rounded-md font-mono text-sm","focus:outline-none focus:ring-2 focus:ring-neutral-400 dark:focus:ring-neutral-500 focus:border-transparent","transition-colors resize-none overflow-hidden placeholder:text-neutral-400 dark:placeholder:text-neutral-500",s.error?"border-red-500 dark:border-red-400":"border-neutral-300 dark:border-neutral-600",s.disabled?"opacity-50 cursor-not-allowed":""]),c=()=>{const b=u.value;b&&(b.style.height="auto",b.style.height=`${b.scrollHeight+2}px`)},f=b=>{const y=b.target;l("update:modelValue",y.value),c()},h=b=>{l("focus",b)},x=b=>{l("blur",b)};return He(()=>{c()}),Ve(()=>s.modelValue,async()=>{await Fe(),c()}),n({textareaRef:u,adjustHeight:c}),(b,y)=>(r(),o("div",O4,[e.label?(r(),Y(I(Ua),{key:0,required:e.required},{default:W(()=>[ve(C(e.label),1)]),_:1},8,["required"])):S("",!0),t("textarea",{ref_key:"textareaRef",ref:u,value:e.modelValue,placeholder:e.placeholder,disabled:e.disabled,class:pe(i.value),rows:"1",onInput:f,onFocus:h,onBlur:x},null,42,R4),e.error?(r(),Y(I($t),{key:1},{default:W(()=>[ve(C(e.error),1)]),_:1})):S("",!0)]))}}),j4={class:"flex items-start"},D4=["for"],U4=["id","checked","disabled"],B4={class:"flex items-center h-5"},N4={class:"flex-1"},q4={key:0,class:"text-red-500"},rr=Se({__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(e,{emit:n}){const a=e,s=n,l=Bn(),u=F(()=>["w-5 h-5 border-2 rounded relative flex-shrink-0","transition-all duration-150",a.error?"border-red-500 dark:border-red-400":"border-black dark:border-neutral-300",a.disabled?"opacity-50":"hover:scale-110",a.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]",a.modelValue?"before:block":"before:hidden"]),i=c=>{if(!a.disabled){const f=c.target;s("update:modelValue",f.checked)}};return(c,f)=>(r(),o("div",j4,[t("label",{for:I(l),class:pe(["flex items-start space-x-3 cursor-pointer select-none",{"cursor-not-allowed":e.disabled}])},[t("input",{id:I(l),type:"checkbox",checked:e.modelValue,disabled:e.disabled,onChange:i,class:"absolute left-[-9999px]"},null,40,U4),t("div",B4,[t("span",{class:pe(u.value)},null,2)]),t("div",N4,[e.label?(r(),o("span",{key:0,class:pe(["block text-sm font-medium",{"opacity-50":e.disabled}])},[ve(C(e.label)+" ",1),e.required?(r(),o("span",q4,"*")):S("",!0)],2)):S("",!0),e.helpText?(r(),Y(I(Ne),{key:1,class:"mt-1"},{default:W(()=>[ve(C(e.helpText),1)]),_:1})):S("",!0),e.error?(r(),Y(I($t),{key:2,class:"mt-1"},{default:W(()=>[ve(C(e.error),1)]),_:1})):S("",!0)])],10,D4)]))}}),F4={class:"p-8 space-y-6"},H4={class:"mt-12"},W4={class:"mb-6"},K4={class:"mb-6"},J4={class:"mb-6"},G4={class:"mt-8"},Y4={class:"border-2 border-red-500 p-4 h-32 overflow-hidden relative"},Z4={class:"mt-12"},X4={class:"mb-6"},Q4={class:"border-2 border-accent-500 p-4 h-32 overflow-hidden relative"},e5={class:"mt-12"},t5={class:"mb-6"},r5={class:"mb-6"},a5={class:"mt-12"},n5={class:"mb-6"},o5={class:"mt-2 text-sm"},l5={class:"mb-6"},s5={class:"mt-2 text-sm"},i5={class:"mb-6"},u5={class:"mb-6"},d5={class:"mt-12"},c5={class:"mb-6"},p5={class:"mt-4 p-4 bg-neutral-100 dark:bg-neutral-900 rounded"},m5={class:"text-xs overflow-x-auto"},v5=Se({__name:"TestView",setup(e){const n=p(""),a=p(""),s=p(""),l=p(`Line 1
55
55
  Line 2
56
- Line 3`),u=m(""),i=m(""),p=m("option2"),x=m(""),k=m(""),h=m(""),g=m([]),y=m(["test1","test2"]),_=m(!1),v=m(!0),d=m(!1),b=m(!1),c=m({type:"object",properties:{},required:[]}),f=m(0);qe(()=>{window.resetJSONSchema=()=>{c.value={type:"object",properties:{},required:[]},f.value++}});const $=[{value:"option1",label:"Option One"},{value:"option2",label:"Option Two"},{value:"option3",label:"Option Three"},{value:"option4",label:"Option Four"}],N=[{value:"item1",label:"Item One",description:"First item description"},{value:"item2",label:"Item Two",description:"Second item description"},{value:"item3",label:"Item Three",description:"Third item description"},{value:"item4",label:"Item Four",description:"Fourth item description"}],E=[{value:"test1",label:"Test Item 1",description:"First test item"},{value:"test2",label:"Test Item 2",description:"Second test item"},{value:"test3",label:"Test Item 3",description:"Third test item"},{value:"test4",label:"Test Item 4",description:"Fourth test item"},{value:"test5",label:"Test Item 5",description:"Fifth test item"}];return(L,V)=>(r(),o("div",D4,[V[30]||(V[30]=e("h1",{class:"text-2xl font-bold"},"Component Test Page",-1)),e("div",null,[w(St,{modelValue:n.value,"onUpdate:modelValue":V[0]||(V[0]=A=>n.value=A),label:"Test Label",placeholder:"Enter text..."},null,8,["modelValue"]),e("p",null,C(n.value),1)]),e("div",null,[w(St,{modelValue:a.value,"onUpdate:modelValue":V[1]||(V[1]=A=>a.value=A),label:"Email",error:"Invalid email address",required:""},null,8,["modelValue"])]),e("div",U4,[V[18]||(V[18]=e("h2",{class:"text-xl font-bold mb-4"},"MultilineInput Tests",-1)),e("div",B4,[w(kr,{modelValue:s.value,"onUpdate:modelValue":V[2]||(V[2]=A=>s.value=A),label:"Multiline Text",placeholder:"Type multiple lines..."},null,8,["modelValue"]),e("p",null,C(s.value),1)]),e("div",N4,[w(kr,{modelValue:l.value,"onUpdate:modelValue":V[3]||(V[3]=A=>l.value=A),label:"Pre-filled Multiline",placeholder:"Already has content..."},null,8,["modelValue"]),e("pre",null,C(l.value),1)]),e("div",q4,[w(kr,{modelValue:u.value,"onUpdate:modelValue":V[4]||(V[4]=A=>u.value=A),label:"Required Field",error:"This field is required",required:""},null,8,["modelValue"])])]),e("div",null,[w(pt,{modelValue:i.value,"onUpdate:modelValue":V[5]||(V[5]=A=>i.value=A),options:$,label:"Select Option",placeholder:"Choose an option..."},null,8,["modelValue"]),e("p",null,C(i.value),1)]),e("div",null,[w(pt,{modelValue:i.value,"onUpdate:modelValue":V[6]||(V[6]=A=>i.value=A),options:$,label:"Required Select",placeholder:"Please select an option"},null,8,["modelValue"])]),e("div",null,[w(pt,{modelValue:p.value,"onUpdate:modelValue":V[7]||(V[7]=A=>p.value=A),options:$,label:"Disabled Select",disabled:""},null,8,["modelValue"])]),e("div",F4,[V[20]||(V[20]=e("h2",{class:"text-lg font-semibold mb-2"},"Overflow Test",-1)),e("div",H4,[V[19]||(V[19]=e("p",{class:"text-sm text-neutral-600 mb-2"}," This container has overflow:hidden and limited height ",-1)),w(pt,{modelValue:x.value,"onUpdate:modelValue":V[8]||(V[8]=A=>x.value=A),options:$,label:"Select in Overflow Container",placeholder:"Should break out of container..."},null,8,["modelValue"])]),V[21]||(V[21]=e("p",{class:"mt-2 text-sm text-neutral-500"}," The dropdown should appear above the red border (in top layer) ",-1))]),e("div",W4,[V[25]||(V[25]=e("h2",{class:"text-xl font-bold mb-4"},"DropdownList Tests",-1)),e("div",K4,[w(pt,{modelValue:k.value,"onUpdate:modelValue":V[9]||(V[9]=A=>k.value=A),options:N,label:"Select Item",placeholder:"Choose an item..."},null,8,["modelValue"]),e("p",null,C(k.value),1)]),e("div",null,[V[23]||(V[23]=e("h3",{class:"text-lg font-semibold mb-2"},"DropdownList Overflow Test",-1)),e("div",J4,[V[22]||(V[22]=e("p",{class:"text-sm text-neutral-600 mb-2"}," This container has overflow:hidden and limited height ",-1)),w(pt,{modelValue:h.value,"onUpdate:modelValue":V[10]||(V[10]=A=>h.value=A),options:N,label:"Dropdown in Overflow Container",placeholder:"Should use popover API..."},null,8,["modelValue"])]),V[24]||(V[24]=e("p",{class:"mt-2 text-sm text-neutral-500"}," The dropdown should appear above the blue border (using Popover API) ",-1))])]),e("div",G4,[V[26]||(V[26]=e("h2",{class:"text-xl font-bold mb-4"},"MultipleSelectionsInput Tests",-1)),e("div",Y4,[w(jt,{modelValue:g.value,"onUpdate:modelValue":V[11]||(V[11]=A=>g.value=A),options:E,label:"Select Multiple Items",placeholder:"Choose items...","add-label":"Add another"},null,8,["modelValue"]),e("p",null,C(g.value),1)]),e("div",Z4,[w(jt,{modelValue:y.value,"onUpdate:modelValue":V[12]||(V[12]=A=>y.value=A),options:E,label:"Disabled Multiple Select",placeholder:"Cannot select...",disabled:""},null,8,["modelValue"])])]),e("div",X4,[V[27]||(V[27]=e("h2",{class:"text-xl font-bold mb-4"},"CheckboxInput Tests",-1)),e("div",Q4,[w(Zt,{modelValue:_.value,"onUpdate:modelValue":V[13]||(V[13]=A=>_.value=A),label:"Basic Checkbox"},null,8,["modelValue"]),e("p",e5," Value: "+C(_.value),1)]),e("div",t5,[w(Zt,{modelValue:v.value,"onUpdate:modelValue":V[14]||(V[14]=A=>v.value=A),label:"Checkbox with Help Text",helpText:"This is helpful information about what this checkbox does. Notice how the checkbox stays aligned with the label.",required:""},null,8,["modelValue"]),e("p",r5," Value: "+C(v.value),1)]),e("div",a5,[w(Zt,{modelValue:d.value,"onUpdate:modelValue":V[15]||(V[15]=A=>d.value=A),label:"Disabled Checkbox",helpText:"This checkbox is disabled and cannot be changed.",disabled:""},null,8,["modelValue"])]),e("div",n5,[w(Zt,{modelValue:b.value,"onUpdate:modelValue":V[16]||(V[16]=A=>b.value=A),label:"Checkbox with Error",error:"You must accept the terms and conditions",required:""},null,8,["modelValue"])])]),e("div",o5,[V[29]||(V[29]=e("h2",{class:"text-xl font-bold mb-4"},"JSONSchemaInput Tests",-1)),e("div",l5,[(r(),J(La,{key:f.value,modelValue:c.value,"onUpdate:modelValue":V[17]||(V[17]=A=>c.value=A),label:"JSON Schema Builder"},null,8,["modelValue"])),e("div",s5,[V[28]||(V[28]=e("p",{class:"text-sm font-mono mb-2"},"Generated Schema:",-1)),e("pre",i5,C(JSON.stringify(c.value,null,2)),1)])])])]))}}),d5={class:"relative"},c5=["value","placeholder","rows"],p5={class:"bg-white dark:bg-black rounded-lg"},m5={class:"px-3 py-2 border-b border-black dark:border-neutral-300"},v5={class:"text-xs font-medium text-neutral-600 dark:text-neutral-400"},f5={key:0,class:"max-h-[200px] overflow-y-auto"},g5=["onClick"],h5={class:"text-xs text-neutral-500 dark:text-neutral-400 mt-0.5"},b5={class:"flex-1"},x5={key:0,class:"text-xs text-neutral-600 dark:text-neutral-400 mt-0.5"},y5={key:1,class:"px-3 py-4 text-sm text-neutral-500 dark:text-neutral-400 text-center"},k5=Ce({__name:"ReferenceInput",props:{modelValue:{},search:{type:Function},placeholder:{},rows:{}},emits:["update:modelValue"],setup(t,{emit:n}){const a=t,s=n,l=m(null),u=m(null),i=m(!1),p=m(""),x=m([]),k=m(0),h=m(-1),g=m(-1),y=m(0),_=m({top:0,left:0}),v=async A=>{const G=A.target,ee=G.value,ie=G.selectionStart;s("update:modelValue",ee),ee[ie-1]==="@"&&!i.value?d(ie):i.value&&await c(ee,ie)},d=async A=>{h.value=A-1,g.value=A,p.value="",y.value=0,i.value=!0,k.value=0,await b(),await f("")},b=async()=>{if(!l.value)return;await Ne();const A=l.value.getBoundingClientRect(),G=window.getComputedStyle(l.value),ee=parseInt(G.lineHeight||"20"),ie=parseInt(G.paddingTop||"8"),Q=a.modelValue.substring(0,g.value).split(`
57
- `),U=Q.length,R=Q[Q.length-1],H=Math.min(R.length*8,200);_.value={top:A.top+ie+U*ee+4,left:A.left+ie+H}},c=async(A,G)=>{if(G<=h.value){N();return}const ee=h.value+1,ie=A.substring(ee,G);if(x.value.length===0?y.value++:y.value=0,x.value.length===0&&y.value>=5){N();return}p.value=ie,await f(ie)},f=async A=>{if(!a.search){x.value=[];return}const G=await a.search(A);x.value=Array.isArray(G)?G:[],k.value>=x.value.length&&(k.value=0)},$=A=>{if(!l.value)return;const G=a.modelValue,ee=G.substring(0,h.value),ie=G.substring(g.value+p.value.length),be=`@${A.value}`,Q=ee+be+ie;s("update:modelValue",Q),Ne(()=>{if(!l.value)return;const U=ee.length+be.length;l.value.focus(),l.value.setSelectionRange(U,U)}),N()},N=()=>{i.value=!1,p.value="",x.value=[],k.value=0,h.value=-1,g.value=-1,y.value=0},E=A=>{if(i.value)switch(A.key){case"Escape":A.preventDefault(),N();break;case"ArrowDown":A.preventDefault(),k.value=Math.min(k.value+1,x.value.length-1);break;case"ArrowUp":A.preventDefault(),k.value=Math.max(k.value-1,0);break;case"Enter":x.value.length>0&&(A.preventDefault(),$(x.value[k.value]));break;case"Tab":x.value.length>0&&(A.preventDefault(),$(x.value[k.value]));break}},L=()=>{if(!i.value||!l.value)return;l.value.selectionStart<=h.value&&N()},V=A=>{if(!u.value||!i.value)return;const G=A.target;!u.value.contains(G)&&G!==l.value&&N()};return Ee(i,A=>{A?document.addEventListener("click",V):document.removeEventListener("click",V)}),(A,G)=>(r(),o("div",d5,[e("textarea",{ref_key:"textarea",ref:l,value:t.modelValue,onInput:v,onKeydown:E,onSelect:L,placeholder:t.placeholder||"Type @ to insert references...",rows:t.rows||10,class:"w-full px-3 py-2 border border-black dark:border-neutral-300 rounded bg-transparent font-mono text-sm resize-none focus:outline-none focus:ring-1 focus:ring-black dark:focus:ring-white"},null,40,c5),(r(),J(Ht,{to:"body"},[i.value?(r(),o("div",{key:0,ref_key:"searchDialog",ref:u,class:"fixed z-50 min-w-[200px] max-w-[400px] bg-white dark:bg-black border-2 border-black dark:border-neutral-300 rounded-lg",style:yt({top:`${_.value.top}px`,left:`${_.value.left}px`,boxShadow:"4px 4px 0 0 rgba(0, 0, 0, 0.25)",backgroundImage:`
56
+ Line 3`),u=p(""),i=p(""),c=p("option2"),f=p(""),h=p(""),x=p(""),b=p([]),y=p(["test1","test2"]),$=p(!1),g=p(!0),d=p(!1),w=p(!1),m=p({type:"object",properties:{},required:[]}),v=p(0);He(()=>{window.resetJSONSchema=()=>{m.value={type:"object",properties:{},required:[]},v.value++}});const _=[{value:"option1",label:"Option One"},{value:"option2",label:"Option Two"},{value:"option3",label:"Option Three"},{value:"option4",label:"Option Four"}],P=[{value:"item1",label:"Item One",description:"First item description"},{value:"item2",label:"Item Two",description:"Second item description"},{value:"item3",label:"Item Three",description:"Third item description"},{value:"item4",label:"Item Four",description:"Fourth item description"}],V=[{value:"test1",label:"Test Item 1",description:"First test item"},{value:"test2",label:"Test Item 2",description:"Second test item"},{value:"test3",label:"Test Item 3",description:"Third test item"},{value:"test4",label:"Test Item 4",description:"Fourth test item"},{value:"test5",label:"Test Item 5",description:"Fifth test item"}];return(E,z)=>(r(),o("div",F4,[z[30]||(z[30]=t("h1",{class:"text-2xl font-bold"},"Component Test Page",-1)),t("div",null,[k(Mt,{modelValue:n.value,"onUpdate:modelValue":z[0]||(z[0]=A=>n.value=A),label:"Test Label",placeholder:"Enter text..."},null,8,["modelValue"]),t("p",null,C(n.value),1)]),t("div",null,[k(Mt,{modelValue:a.value,"onUpdate:modelValue":z[1]||(z[1]=A=>a.value=A),label:"Email",error:"Invalid email address",required:""},null,8,["modelValue"])]),t("div",H4,[z[18]||(z[18]=t("h2",{class:"text-xl font-bold mb-4"},"MultilineInput Tests",-1)),t("div",W4,[k(Sr,{modelValue:s.value,"onUpdate:modelValue":z[2]||(z[2]=A=>s.value=A),label:"Multiline Text",placeholder:"Type multiple lines..."},null,8,["modelValue"]),t("p",null,C(s.value),1)]),t("div",K4,[k(Sr,{modelValue:l.value,"onUpdate:modelValue":z[3]||(z[3]=A=>l.value=A),label:"Pre-filled Multiline",placeholder:"Already has content..."},null,8,["modelValue"]),t("pre",null,C(l.value),1)]),t("div",J4,[k(Sr,{modelValue:u.value,"onUpdate:modelValue":z[4]||(z[4]=A=>u.value=A),label:"Required Field",error:"This field is required",required:""},null,8,["modelValue"])])]),t("div",null,[k(ft,{modelValue:i.value,"onUpdate:modelValue":z[5]||(z[5]=A=>i.value=A),options:_,label:"Select Option",placeholder:"Choose an option..."},null,8,["modelValue"]),t("p",null,C(i.value),1)]),t("div",null,[k(ft,{modelValue:i.value,"onUpdate:modelValue":z[6]||(z[6]=A=>i.value=A),options:_,label:"Required Select",placeholder:"Please select an option"},null,8,["modelValue"])]),t("div",null,[k(ft,{modelValue:c.value,"onUpdate:modelValue":z[7]||(z[7]=A=>c.value=A),options:_,label:"Disabled Select",disabled:""},null,8,["modelValue"])]),t("div",G4,[z[20]||(z[20]=t("h2",{class:"text-lg font-semibold mb-2"},"Overflow Test",-1)),t("div",Y4,[z[19]||(z[19]=t("p",{class:"text-sm text-neutral-600 mb-2"}," This container has overflow:hidden and limited height ",-1)),k(ft,{modelValue:f.value,"onUpdate:modelValue":z[8]||(z[8]=A=>f.value=A),options:_,label:"Select in Overflow Container",placeholder:"Should break out of container..."},null,8,["modelValue"])]),z[21]||(z[21]=t("p",{class:"mt-2 text-sm text-neutral-500"}," The dropdown should appear above the red border (in top layer) ",-1))]),t("div",Z4,[z[25]||(z[25]=t("h2",{class:"text-xl font-bold mb-4"},"DropdownList Tests",-1)),t("div",X4,[k(ft,{modelValue:h.value,"onUpdate:modelValue":z[9]||(z[9]=A=>h.value=A),options:P,label:"Select Item",placeholder:"Choose an item..."},null,8,["modelValue"]),t("p",null,C(h.value),1)]),t("div",null,[z[23]||(z[23]=t("h3",{class:"text-lg font-semibold mb-2"},"DropdownList Overflow Test",-1)),t("div",Q4,[z[22]||(z[22]=t("p",{class:"text-sm text-neutral-600 mb-2"}," This container has overflow:hidden and limited height ",-1)),k(ft,{modelValue:x.value,"onUpdate:modelValue":z[10]||(z[10]=A=>x.value=A),options:P,label:"Dropdown in Overflow Container",placeholder:"Should use popover API..."},null,8,["modelValue"])]),z[24]||(z[24]=t("p",{class:"mt-2 text-sm text-neutral-500"}," The dropdown should appear above the blue border (using Popover API) ",-1))])]),t("div",e5,[z[26]||(z[26]=t("h2",{class:"text-xl font-bold mb-4"},"MultipleSelectionsInput Tests",-1)),t("div",t5,[k(Bt,{modelValue:b.value,"onUpdate:modelValue":z[11]||(z[11]=A=>b.value=A),options:V,label:"Select Multiple Items",placeholder:"Choose items...","add-label":"Add another"},null,8,["modelValue"]),t("p",null,C(b.value),1)]),t("div",r5,[k(Bt,{modelValue:y.value,"onUpdate:modelValue":z[12]||(z[12]=A=>y.value=A),options:V,label:"Disabled Multiple Select",placeholder:"Cannot select...",disabled:""},null,8,["modelValue"])])]),t("div",a5,[z[27]||(z[27]=t("h2",{class:"text-xl font-bold mb-4"},"CheckboxInput Tests",-1)),t("div",n5,[k(rr,{modelValue:$.value,"onUpdate:modelValue":z[13]||(z[13]=A=>$.value=A),label:"Basic Checkbox"},null,8,["modelValue"]),t("p",o5," Value: "+C($.value),1)]),t("div",l5,[k(rr,{modelValue:g.value,"onUpdate:modelValue":z[14]||(z[14]=A=>g.value=A),label:"Checkbox with Help Text",helpText:"This is helpful information about what this checkbox does. Notice how the checkbox stays aligned with the label.",required:""},null,8,["modelValue"]),t("p",s5," Value: "+C(g.value),1)]),t("div",i5,[k(rr,{modelValue:d.value,"onUpdate:modelValue":z[15]||(z[15]=A=>d.value=A),label:"Disabled Checkbox",helpText:"This checkbox is disabled and cannot be changed.",disabled:""},null,8,["modelValue"])]),t("div",u5,[k(rr,{modelValue:w.value,"onUpdate:modelValue":z[16]||(z[16]=A=>w.value=A),label:"Checkbox with Error",error:"You must accept the terms and conditions",required:""},null,8,["modelValue"])])]),t("div",d5,[z[29]||(z[29]=t("h2",{class:"text-xl font-bold mb-4"},"JSONSchemaInput Tests",-1)),t("div",c5,[(r(),Y(Na,{key:v.value,modelValue:m.value,"onUpdate:modelValue":z[17]||(z[17]=A=>m.value=A),label:"JSON Schema Builder"},null,8,["modelValue"])),t("div",p5,[z[28]||(z[28]=t("p",{class:"text-sm font-mono mb-2"},"Generated Schema:",-1)),t("pre",m5,C(JSON.stringify(m.value,null,2)),1)])])])]))}}),f5={class:"relative"},g5=["value","placeholder","rows"],h5={class:"bg-white dark:bg-black rounded-lg"},b5={class:"px-3 py-2 border-b border-black dark:border-neutral-300"},x5={class:"text-xs font-medium text-neutral-600 dark:text-neutral-400"},y5={key:0,class:"max-h-[200px] overflow-y-auto"},k5=["onClick"],w5={class:"text-xs text-neutral-500 dark:text-neutral-400 mt-0.5"},_5={class:"flex-1"},$5={key:0,class:"text-xs text-neutral-600 dark:text-neutral-400 mt-0.5"},C5={key:1,class:"px-3 py-4 text-sm text-neutral-500 dark:text-neutral-400 text-center"},S5=Se({__name:"ReferenceInput",props:{modelValue:{},search:{type:Function},placeholder:{},rows:{}},emits:["update:modelValue"],setup(e,{emit:n}){const a=e,s=n,l=p(null),u=p(null),i=p(!1),c=p(""),f=p([]),h=p(0),x=p(-1),b=p(-1),y=p(0),$=p({top:0,left:0}),g=async A=>{const oe=A.target,ne=oe.value,fe=oe.selectionStart;s("update:modelValue",ne),ne[fe-1]==="@"&&!i.value?d(fe):i.value&&await m(ne,fe)},d=async A=>{x.value=A-1,b.value=A,c.value="",y.value=0,i.value=!0,h.value=0,await w(),await v("")},w=async()=>{if(!l.value)return;await Fe();const A=l.value.getBoundingClientRect(),oe=window.getComputedStyle(l.value),ne=parseInt(oe.lineHeight||"20"),fe=parseInt(oe.paddingTop||"8"),te=a.modelValue.substring(0,b.value).split(`
57
+ `),q=te.length,j=te[te.length-1],H=Math.min(j.length*8,200);$.value={top:A.top+fe+q*ne+4,left:A.left+fe+H}},m=async(A,oe)=>{if(oe<=x.value){P();return}const ne=x.value+1,fe=A.substring(ne,oe);if(f.value.length===0?y.value++:y.value=0,f.value.length===0&&y.value>=5){P();return}c.value=fe,await v(fe)},v=async A=>{if(!a.search){f.value=[];return}const oe=await a.search(A);f.value=Array.isArray(oe)?oe:[],h.value>=f.value.length&&(h.value=0)},_=A=>{if(!l.value)return;const oe=a.modelValue,ne=oe.substring(0,x.value),fe=oe.substring(b.value+c.value.length),ye=`@${A.value}`,te=ne+ye+fe;s("update:modelValue",te),Fe(()=>{if(!l.value)return;const q=ne.length+ye.length;l.value.focus(),l.value.setSelectionRange(q,q)}),P()},P=()=>{i.value=!1,c.value="",f.value=[],h.value=0,x.value=-1,b.value=-1,y.value=0},V=A=>{if(i.value)switch(A.key){case"Escape":A.preventDefault(),P();break;case"ArrowDown":A.preventDefault(),h.value=Math.min(h.value+1,f.value.length-1);break;case"ArrowUp":A.preventDefault(),h.value=Math.max(h.value-1,0);break;case"Enter":f.value.length>0&&(A.preventDefault(),_(f.value[h.value]));break;case"Tab":f.value.length>0&&(A.preventDefault(),_(f.value[h.value]));break}},E=()=>{if(!i.value||!l.value)return;l.value.selectionStart<=x.value&&P()},z=A=>{if(!u.value||!i.value)return;const oe=A.target;!u.value.contains(oe)&&oe!==l.value&&P()};return Ve(i,A=>{A?document.addEventListener("click",z):document.removeEventListener("click",z)}),(A,oe)=>(r(),o("div",f5,[t("textarea",{ref_key:"textarea",ref:l,value:e.modelValue,onInput:g,onKeydown:V,onSelect:E,placeholder:e.placeholder||"Type @ to insert references...",rows:e.rows||10,class:"w-full px-3 py-2 border border-black dark:border-neutral-300 rounded bg-transparent font-mono text-sm resize-none focus:outline-none focus:ring-1 focus:ring-black dark:focus:ring-white"},null,40,g5),(r(),Y(Yt,{to:"body"},[i.value?(r(),o("div",{key:0,ref_key:"searchDialog",ref:u,class:"fixed z-50 min-w-[200px] max-w-[400px] bg-white dark:bg-black border-2 border-black dark:border-neutral-300 rounded-lg",style:_t({top:`${$.value.top}px`,left:`${$.value.left}px`,boxShadow:"4px 4px 0 0 rgba(0, 0, 0, 0.25)",backgroundImage:`
58
58
  repeating-linear-gradient(
59
59
  45deg,
60
60
  transparent,
@@ -62,18 +62,18 @@ Line 3`),u=m(""),i=m(""),p=m("option2"),x=m(""),k=m(""),h=m(""),g=m([]),y=m(["te
62
62
  rgba(0, 0, 0, 0.03) 2px,
63
63
  rgba(0, 0, 0, 0.03) 4px
64
64
  )
65
- `})},[e("div",p5,[e("div",m5,[e("div",v5," Search: "+C(p.value||"..."),1)]),x.value.length>0?(r(),o("div",f5,[(r(!0),o(we,null,Ae(x.value,(ee,ie)=>(r(),o("button",{key:`${ee.type}-${ee.value}`,onClick:be=>$(ee),class:ce(["w-full px-3 py-2 text-left hover:bg-black/5 dark:hover:bg-white/10 transition-colors flex items-start gap-2 text-sm",{"bg-black/10 dark:bg-white/10":ie===k.value}])},[e("span",h5,C(ee.type),1),e("div",b5,[e("div",null,C(ee.label),1),ee.description?(r(),o("div",x5,C(ee.description),1)):S("",!0)])],10,g5))),128))])):(r(),o("div",y5," No results found ")),G[0]||(G[0]=e("div",{class:"px-3 py-2 border-t border-neutral-200 dark:border-neutral-700 text-xs text-neutral-500 dark:text-neutral-400"},[e("div",null,"↑↓ Navigate • Enter/Tab Select • Esc Cancel")],-1))])],4)):S("",!0)]))]))}}),w5={class:"min-h-screen bg-white dark:bg-black p-8"},_5={class:"max-w-4xl mx-auto space-y-8"},$5={class:"space-y-4"},C5={class:"block"},S5={class:"p-4 border border-neutral-300 dark:border-neutral-700 rounded"},I5={class:"text-sm font-mono whitespace-pre-wrap"},T5=Ce({__name:"TestReferenceInput",setup(t){const n=m("Hello, type @ to see search suggestions"),a=async s=>{await new Promise(u=>setTimeout(u,100));const l=[{type:"variable",value:"userName",label:"userName",description:"Current user name"},{type:"variable",value:"userEmail",label:"userEmail",description:"Current user email"},{type:"function",value:"getCurrentDate()",label:"getCurrentDate",description:"Get current date"},{type:"prompt",value:"{{prompt:welcome}}",label:"welcome",description:"Welcome message prompt"},{type:"prompt",value:"{{prompt:goodbye}}",label:"goodbye",description:"Goodbye message prompt"}];return s?l.filter(u=>u.label.toLowerCase().includes(s.toLowerCase())):l};return(s,l)=>(r(),o("div",w5,[e("div",_5,[l[4]||(l[4]=e("div",null,[e("h1",{class:"text-2xl font-bold mb-2"},"ReferenceInput Component Test"),e("p",{class:"text-neutral-600 dark:text-neutral-400"}," Type @ to trigger search mode and test the reference input functionality ")],-1)),e("div",$5,[e("label",C5,[l[1]||(l[1]=e("span",{class:"text-sm font-medium mb-2 block"},"Test Reference Input",-1)),w(k5,{modelValue:n.value,"onUpdate:modelValue":l[0]||(l[0]=u=>n.value=u),search:a,placeholder:"Type @ to insert references...",rows:10},null,8,["modelValue"])]),e("div",S5,[l[2]||(l[2]=e("h3",{class:"text-sm font-medium mb-2"},"Current Value:",-1)),e("pre",I5,C(n.value),1)]),l[3]||(l[3]=e("div",{class:"p-4 bg-neutral-100 dark:bg-neutral-900 rounded"},[e("h3",{class:"text-sm font-medium mb-2"},"Test Instructions:"),e("ul",{class:"text-sm space-y-1 list-disc list-inside"},[e("li",null,"Type @ anywhere in the textarea to trigger search mode"),e("li",null,"Type characters after @ to filter results"),e("li",null,"Use arrow keys to navigate results"),e("li",null,"Press Enter or Tab to select a result"),e("li",null,"Press Escape to cancel search mode"),e("li",null,"Search exits if no results and you type 5+ more characters"),e("li",null,"Moving cursor before @ also exits search mode")])],-1))])])]))}}),M5={class:"p-8 space-y-8"},z5={class:"space-y-2 mb-4"},V5={class:"mt-4 p-2 bg-neutral-100 rounded"},E5=Ce({__name:"DebugView",setup(t){const n=m([{id:"1",name:"Item 1"}]),a=()=>{console.log("Adding item...");const u={id:crypto.randomUUID(),name:`Item ${n.value.length+1}`};n.value.push(u),console.log("Item added, total:",n.value.length)};Ee(n,()=>{console.log("Items changed:",n.value.length)},{deep:!0});const s={props:["modelValue"],emits:["update:modelValue"],template:`
65
+ `})},[t("div",h5,[t("div",b5,[t("div",x5," Search: "+C(c.value||"..."),1)]),f.value.length>0?(r(),o("div",y5,[(r(!0),o($e,null,Le(f.value,(ne,fe)=>(r(),o("button",{key:`${ne.type}-${ne.value}`,onClick:ye=>_(ne),class:pe(["w-full px-3 py-2 text-left hover:bg-black/5 dark:hover:bg-white/10 transition-colors flex items-start gap-2 text-sm",{"bg-black/10 dark:bg-white/10":fe===h.value}])},[t("span",w5,C(ne.type),1),t("div",_5,[t("div",null,C(ne.label),1),ne.description?(r(),o("div",$5,C(ne.description),1)):S("",!0)])],10,k5))),128))])):(r(),o("div",C5," No results found ")),oe[0]||(oe[0]=t("div",{class:"px-3 py-2 border-t border-neutral-200 dark:border-neutral-700 text-xs text-neutral-500 dark:text-neutral-400"},[t("div",null,"↑↓ Navigate • Enter/Tab Select • Esc Cancel")],-1))])],4)):S("",!0)]))]))}}),I5={class:"min-h-screen bg-white dark:bg-black p-8"},T5={class:"max-w-4xl mx-auto space-y-8"},M5={class:"space-y-4"},z5={class:"block"},V5={class:"p-4 border border-neutral-300 dark:border-neutral-700 rounded"},E5={class:"text-sm font-mono whitespace-pre-wrap"},L5=Se({__name:"TestReferenceInput",setup(e){const n=p("Hello, type @ to see search suggestions"),a=async s=>{await new Promise(u=>setTimeout(u,100));const l=[{type:"variable",value:"userName",label:"userName",description:"Current user name"},{type:"variable",value:"userEmail",label:"userEmail",description:"Current user email"},{type:"function",value:"getCurrentDate()",label:"getCurrentDate",description:"Get current date"},{type:"prompt",value:"{{prompt:welcome}}",label:"welcome",description:"Welcome message prompt"},{type:"prompt",value:"{{prompt:goodbye}}",label:"goodbye",description:"Goodbye message prompt"}];return s?l.filter(u=>u.label.toLowerCase().includes(s.toLowerCase())):l};return(s,l)=>(r(),o("div",I5,[t("div",T5,[l[4]||(l[4]=t("div",null,[t("h1",{class:"text-2xl font-bold mb-2"},"ReferenceInput Component Test"),t("p",{class:"text-neutral-600 dark:text-neutral-400"}," Type @ to trigger search mode and test the reference input functionality ")],-1)),t("div",M5,[t("label",z5,[l[1]||(l[1]=t("span",{class:"text-sm font-medium mb-2 block"},"Test Reference Input",-1)),k(S5,{modelValue:n.value,"onUpdate:modelValue":l[0]||(l[0]=u=>n.value=u),search:a,placeholder:"Type @ to insert references...",rows:10},null,8,["modelValue"])]),t("div",V5,[l[2]||(l[2]=t("h3",{class:"text-sm font-medium mb-2"},"Current Value:",-1)),t("pre",E5,C(n.value),1)]),l[3]||(l[3]=t("div",{class:"p-4 bg-neutral-100 dark:bg-neutral-900 rounded"},[t("h3",{class:"text-sm font-medium mb-2"},"Test Instructions:"),t("ul",{class:"text-sm space-y-1 list-disc list-inside"},[t("li",null,"Type @ anywhere in the textarea to trigger search mode"),t("li",null,"Type characters after @ to filter results"),t("li",null,"Use arrow keys to navigate results"),t("li",null,"Press Enter or Tab to select a result"),t("li",null,"Press Escape to cancel search mode"),t("li",null,"Search exits if no results and you type 5+ more characters"),t("li",null,"Moving cursor before @ also exits search mode")])],-1))])])]))}}),A5={class:"p-8 space-y-8"},P5={class:"space-y-2 mb-4"},O5={class:"mt-4 p-2 bg-neutral-100 rounded"},R5=Se({__name:"DebugView",setup(e){const n=p([{id:"1",name:"Item 1"}]),a=()=>{console.log("Adding item...");const u={id:crypto.randomUUID(),name:`Item ${n.value.length+1}`};n.value.push(u),console.log("Item added, total:",n.value.length)};Ve(n,()=>{console.log("Items changed:",n.value.length)},{deep:!0});const s={props:["modelValue"],emits:["update:modelValue"],template:`
66
66
  <div>
67
67
  <div v-for="item in modelValue" :key="item.id">
68
68
  {{ item.name }}
69
69
  </div>
70
70
  <button @click="addChild">Add in Child</button>
71
71
  </div>
72
- `,setup(u,{emit:i}){return{addChild:()=>{console.log("Child adding item...");const x={id:crypto.randomUUID(),name:`Child Item ${u.modelValue.length+1}`};i("update:modelValue",[...u.modelValue,x])}}}},l=m([{id:"1",name:"Parent Item 1"}]);return(u,i)=>(r(),o("div",M5,[e("div",null,[i[1]||(i[1]=e("h2",{class:"text-xl font-bold mb-4"},"Direct Array Test",-1)),e("div",z5,[(r(!0),o(we,null,Ae(n.value,p=>(r(),o("div",{key:p.id,class:"p-2 border"},C(p.name),1))),128))]),e("button",{onClick:a,class:"px-4 py-2 bg-black text-white rounded"}," Add Item ")]),e("div",null,[i[2]||(i[2]=e("h2",{class:"text-xl font-bold mb-4"},"Parent-Child Test",-1)),w(s,{modelValue:l.value,"onUpdate:modelValue":i[0]||(i[0]=p=>l.value=p)},null,8,["modelValue"]),e("pre",V5,C(JSON.stringify(l.value,null,2)),1)])]))}}),L5={class:"min-h-screen bg-white dark:bg-black p-8"},A5={class:"max-w-4xl mx-auto"},P5={class:"space-y-8"},j5={class:"space-y-4"},R5={class:"space-y-4"},O5={class:"p-4 bg-neutral-100 dark:bg-neutral-900 rounded-lg"},D5={class:"text-sm text-black dark:text-white"},U5=Ce({__name:"TestPromptInput",setup(t){const n=m([{type:"string",value:""}]),a=i=>{n.value=i};qe(()=>{window.setPromptSegments=a}),fa(()=>{delete window.setPromptSegments});const s=async i=>{await new Promise(k=>setTimeout(k,300));const p=(i||"").toLowerCase();return[{type:"variable",value:"first_name",label:"First Name",description:"The user's first name"},{type:"variable",value:"current_date",label:"current_date",description:"Today's date in ISO format"},{type:"variable",value:"system_time",label:"system_time",description:"Current system time"},{type:"variable",value:"api_key",label:"api_key",description:"API key for external services"},{type:"variable",value:"workspace_id",label:"workspace_id",description:"Current workspace identifier"},{type:"prompt",id:"7102973",label:"Onboarding Prompt",schema:{type:"object",properties:{first_name:{type:"string",description:"the first name of the user"}},required:["first_name"],additionalProperties:!1}},{type:"prompt",id:"error_handler",label:"Error Handler",description:"Error handling prompt",schema:{type:"object",properties:{error_message:{type:"string"}},required:["error_message"]}},{type:"prompt",id:"code_review",label:"Code Review",description:"Code review assistant prompt"},{type:"prompt",id:"data_analysis",label:"Data Analysis",description:"Data analysis insights generator"},{type:"prompt",id:"summary_generator",label:"Summary Generator",description:"Creates concise summaries of long text"}].filter(k=>(k.label||k.id||k.value||"").toLowerCase().includes(p)).slice(0,8)},l=i=>{n.value=i,console.log("Updated:",i)},u=(i,p)=>{console.log("Segment clicked:",i),i.type==="prompt"?alert(`Prompt clicked: ${i.label||i.id}
72
+ `,setup(u,{emit:i}){return{addChild:()=>{console.log("Child adding item...");const f={id:crypto.randomUUID(),name:`Child Item ${u.modelValue.length+1}`};i("update:modelValue",[...u.modelValue,f])}}}},l=p([{id:"1",name:"Parent Item 1"}]);return(u,i)=>(r(),o("div",A5,[t("div",null,[i[1]||(i[1]=t("h2",{class:"text-xl font-bold mb-4"},"Direct Array Test",-1)),t("div",P5,[(r(!0),o($e,null,Le(n.value,c=>(r(),o("div",{key:c.id,class:"p-2 border"},C(c.name),1))),128))]),t("button",{onClick:a,class:"px-4 py-2 bg-black text-white rounded"}," Add Item ")]),t("div",null,[i[2]||(i[2]=t("h2",{class:"text-xl font-bold mb-4"},"Parent-Child Test",-1)),k(s,{modelValue:l.value,"onUpdate:modelValue":i[0]||(i[0]=c=>l.value=c)},null,8,["modelValue"]),t("pre",O5,C(JSON.stringify(l.value,null,2)),1)])]))}}),j5={class:"min-h-screen bg-white dark:bg-black p-8"},D5={class:"max-w-4xl mx-auto"},U5={class:"space-y-8"},B5={class:"space-y-4"},N5={class:"space-y-4"},q5={class:"p-4 bg-neutral-100 dark:bg-neutral-900 rounded-lg"},F5={class:"text-sm text-black dark:text-white"},H5=Se({__name:"TestPromptInput",setup(e){const n=p([{type:"string",value:""}]),a=i=>{n.value=i};He(()=>{window.setPromptSegments=a}),$a(()=>{delete window.setPromptSegments});const s=async i=>{await new Promise(h=>setTimeout(h,300));const c=(i||"").toLowerCase();return[{type:"variable",value:"first_name",label:"First Name",description:"The user's first name"},{type:"variable",value:"current_date",label:"current_date",description:"Today's date in ISO format"},{type:"variable",value:"system_time",label:"system_time",description:"Current system time"},{type:"variable",value:"api_key",label:"api_key",description:"API key for external services"},{type:"variable",value:"workspace_id",label:"workspace_id",description:"Current workspace identifier"},{type:"prompt",id:"7102973",label:"Onboarding Prompt",schema:{type:"object",properties:{first_name:{type:"string",description:"the first name of the user"}},required:["first_name"],additionalProperties:!1}},{type:"prompt",id:"error_handler",label:"Error Handler",description:"Error handling prompt",schema:{type:"object",properties:{error_message:{type:"string"}},required:["error_message"]}},{type:"prompt",id:"code_review",label:"Code Review",description:"Code review assistant prompt"},{type:"prompt",id:"data_analysis",label:"Data Analysis",description:"Data analysis insights generator"},{type:"prompt",id:"summary_generator",label:"Summary Generator",description:"Creates concise summaries of long text"}].filter(h=>(h.label||h.id||h.value||"").toLowerCase().includes(c)).slice(0,8)},l=i=>{n.value=i,console.log("Updated:",i)},u=(i,c)=>{console.log("Segment clicked:",i),i.type==="prompt"?alert(`Prompt clicked: ${i.label||i.id}
73
73
 
74
74
  In a real app, this could:
75
75
  - Show a modal with prompt details
76
76
  - Expand inline to show the full prompt
77
77
  - Navigate to the prompt editor`):i.type==="variable"&&alert(`Variable clicked: ${i.label||i.value}
78
78
 
79
- Description: ${i.meta?.description||"No description"}`)};return(i,p)=>(r(),o("div",L5,[e("div",A5,[p[5]||(p[5]=e("h1",{class:"text-3xl font-bold mb-8 text-black dark:text-white"}," PromptInput Component Test ",-1)),e("div",P5,[e("div",j5,[p[0]||(p[0]=e("h2",{class:"text-xl font-semibold text-black dark:text-white"}," Basic Usage ",-1)),p[1]||(p[1]=e("p",{class:"text-neutral-600 dark:text-neutral-400"}," Type @ to trigger the autocomplete menu. Use arrow keys to navigate and Enter to select. ",-1)),e("div",null,[w(Mr,{"model-value":n.value,search:s,placeholder:"Type @ to insert variables or prompts...","onUpdate:modelValue":l,onSegmentClick:u},null,8,["model-value"])])]),e("div",R5,[p[3]||(p[3]=e("h2",{class:"text-xl font-semibold text-black dark:text-white"}," Current Value ",-1)),e("div",O5,[p[2]||(p[2]=e("h3",{class:"text-sm font-medium text-neutral-700 dark:text-neutral-300 mb-2"}," Segments (value): ",-1)),e("pre",D5,C(JSON.stringify(n.value,null,2)),1)])]),p[4]||(p[4]=Ln('<div class="space-y-4"><h2 class="text-xl font-semibold text-black dark:text-white"> Testing Instructions </h2><ul class="list-disc list-inside space-y-2 text-neutral-600 dark:text-neutral-400"><li>Type @ anywhere in the text to open the search dialog</li><li>Continue typing to search for variables or prompts</li><li>Use arrow keys (↑↓) to navigate results</li><li>Press Enter to select a result or click with mouse</li><li>Press Escape to close the dialog</li><li>Click outside the dialog to close it</li><li>Use Backspace/Delete to remove tags</li><li> The dialog will auto-close after typing 5+ characters without selection </li><li><strong>NEW: Click on any tag to see action handling!</strong></li></ul></div><div class="space-y-4"><h2 class="text-xl font-semibold text-black dark:text-white"> Test Scenarios </h2><div class="grid grid-cols-1 md:grid-cols-2 gap-4"><div class="p-4 border-2 border-neutral-300 dark:border-neutral-700 rounded-lg"><h3 class="font-medium text-black dark:text-white mb-2"> Variables </h3><p class="text-sm text-neutral-600 dark:text-neutral-400"> Try: @user, @date, @time, @api, @work </p></div><div class="p-4 border-2 border-neutral-300 dark:border-neutral-700 rounded-lg"><h3 class="font-medium text-black dark:text-white mb-2"> Prompts </h3><p class="text-sm text-neutral-600 dark:text-neutral-400"> Try: @greet, @error, @code, @data, @summ </p></div><div class="p-4 border-2 border-neutral-300 dark:border-neutral-700 rounded-lg"><h3 class="font-medium text-black dark:text-white mb-2"> Mixed Content </h3><p class="text-sm text-neutral-600 dark:text-neutral-400"> Mix text with multiple tags and test editing </p></div><div class="p-4 border-2 border-neutral-300 dark:border-neutral-700 rounded-lg"><h3 class="font-medium text-black dark:text-white mb-2"> Edge Cases </h3><p class="text-sm text-neutral-600 dark:text-neutral-400"> Test @ at start/end, multiple @@ symbols, etc. </p></div></div></div>',2))])])]))}}),B5={class:"relative"},N5={key:0,class:"mt-1 text-sm text-red-500"},q5=Ce({__name:"JsonEditor",props:{modelValue:{},placeholder:{},error:{},rows:{},readonly:{type:Boolean}},emits:["update:modelValue","blur"],setup(t,{emit:n}){self.MonacoEnvironment={getWorker(_,v){return v==="json"?new qn:new Fn}};const a=t,s=n,l=m(null);let u=null,i=!1;const p=m(!1),x={minimap:{enabled:!1},fontSize:14,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',lineHeight:24,padding:{top:12,bottom:12},scrollBeyondLastLine:!1,wordWrap:"on",automaticLayout:!0,formatOnPaste:!0,formatOnType:!0,readOnly:a.readonly,quickSuggestions:{other:"on",comments:"off",strings:"on"},suggestOnTriggerCharacters:!0,acceptSuggestionOnCommitCharacter:!0,tabSize:2,detectIndentation:!1,renderLineHighlight:"none",scrollbar:{vertical:"auto",horizontal:"hidden",verticalScrollbarSize:10}},k=()=>{if(!(!u||a.readonly))try{const _=u.getValue(),v=JSON.parse(_),d=JSON.stringify(v,null,2);d!==_&&(i=!0,u.setValue(d),i=!1)}catch{}},h=()=>{p.value=document.documentElement.classList.contains("dark"),u&&Or.setTheme(p.value?"vs-dark":"vs")},g=()=>{l.value&&(u=Or.create(l.value,{value:a.modelValue||"{}",language:"json",theme:p.value?"vs-dark":"vs",...x})(l.value).__monacoEditor=u,u.onDidChangeModelContent(()=>{if(!i){const _=u.getValue();s("update:modelValue",_)}}),u.onDidBlurEditorText(()=>{s("blur"),k()}))};qe(async()=>{h(),await Ne(),g();const _=new MutationObserver(h);_.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),ut(()=>{_.disconnect(),u&&u.dispose()})}),Ee(()=>a.modelValue,_=>{u&&u.getValue()!==_&&(i=!0,u.setValue(_||""),i=!1)}),Ee(()=>a.readonly,_=>{u&&u.updateOptions({readOnly:_})});const y=a.rows?`${a.rows*1.5}rem`:"18rem";return(_,v)=>(r(),o("div",B5,[e("div",{class:ce(["border rounded overflow-hidden bg-white dark:bg-black",[t.error?"border-red-500":"border-black dark:border-neutral-300"]])},[e("div",{ref_key:"containerRef",ref:l,class:"monaco-editor-container",style:yt({height:I(y)})},null,4)],2),t.error?(r(),o("div",N5,C(t.error),1)):S("",!0)]))}}),ia=ct(q5,[["__scopeId","data-v-1393c576"]]),F5={class:"p-8"},H5={class:"space-y-4"},W5={class:"space-y-4"},K5={class:"space-y-4"},J5=Ce({__name:"TestJsonEditorModal",setup(t){const n=m(!1),a=m(JSON.stringify({name:"Test",value:123},null,2)),s=m(!1),l=m(JSON.stringify({editable:!0,count:0},null,2));return(u,i)=>(r(),o("div",F5,[i[13]||(i[13]=e("h1",{class:"text-3xl font-bold mb-6"},"JsonEditor in Modal Test",-1)),e("div",H5,[e("div",null,[i[7]||(i[7]=e("h2",{class:"text-xl font-semibold mb-2"}," Read-only JsonEditor in Modal ",-1)),i[8]||(i[8]=e("p",{class:"text-neutral-600 dark:text-neutral-400 mb-4"}," This should NOT show unsaved changes warning when closing ",-1)),e("button",{onClick:i[0]||(i[0]=p=>n.value=!0),class:"px-4 py-2 bg-black dark:bg-white text-white dark:text-black border-2 border-black dark:border-white"}," Open Read-only Modal ")]),e("div",null,[i[9]||(i[9]=e("h2",{class:"text-xl font-semibold mb-2"},"Editable JsonEditor in Modal",-1)),i[10]||(i[10]=e("p",{class:"text-neutral-600 dark:text-neutral-400 mb-4"}," This should NOT show unsaved changes warning on initial close, but SHOULD show it after editing ",-1)),e("button",{onClick:i[1]||(i[1]=p=>s.value=!0),class:"px-4 py-2 bg-black dark:bg-white text-white dark:text-black border-2 border-black dark:border-white"}," Open Editable Modal ")])]),w(st,{modelValue:n.value,"onUpdate:modelValue":i[3]||(i[3]=p=>n.value=p),title:"Read-only JSON Schema",width:"max-w-4xl"},{footer:F(()=>[e("button",{onClick:i[2]||(i[2]=p=>n.value=!1),class:"px-4 py-2 border-2 border-black dark:border-white bg-white dark:bg-black text-black dark:text-white"}," Close ")]),default:F(()=>[e("div",W5,[i[11]||(i[11]=e("p",{class:"text-sm text-neutral-600 dark:text-neutral-400"}," This is a read-only JSON editor. No changes can be made. ",-1)),w(ia,{"model-value":a.value,readonly:!0},null,8,["model-value"])])]),_:1},8,["modelValue"]),w(st,{modelValue:s.value,"onUpdate:modelValue":i[6]||(i[6]=p=>s.value=p),title:"Editable JSON Schema",width:"max-w-4xl"},{footer:F(()=>[e("button",{onClick:i[5]||(i[5]=p=>s.value=!1),class:"px-4 py-2 border-2 border-black dark:border-white bg-white dark:bg-black text-black dark:text-white"}," Close ")]),default:F(()=>[e("div",K5,[i[12]||(i[12]=e("p",{class:"text-sm text-neutral-600 dark:text-neutral-400"}," This is an editable JSON editor. Changes will be tracked. ",-1)),w(ia,{modelValue:l.value,"onUpdate:modelValue":i[4]||(i[4]=p=>l.value=p)},null,8,["modelValue"])])]),_:1},8,["modelValue"])]))}}),G5={class:"p-8 max-w-2xl mx-auto"},Y5={class:"mb-6"},Z5={class:"p-4 bg-neutral-100 dark:bg-neutral-800 rounded font-mono text-sm"},X5={key:0},Q5={class:"whitespace-pre-wrap"},e3={key:1,class:"text-neutral-500"},t3={class:"mb-6"},r3={class:"space-y-2"},a3={class:"mt-6"},n3={class:"p-4 bg-green-50 dark:bg-green-900 rounded min-h-[100px]"},o3={key:0,class:"font-mono"},l3={key:1,class:"text-neutral-500"},s3="10000000-0000-0000-0000-000000000101",ua="10000000-0000-0000-0000-000000000102",i3=Ce({__name:"TestPromptInterpolation",setup(t){const n=m([]),a=m(null),s=m(null),l=m(""),u=m("Alice Johnson"),i=m("alice@example.com"),p=m("28"),{data:x,error:k}=ot(Ve(`/api/prompts/${encodeURIComponent(s3)}`)).json(),{data:h,error:g}=ot(Ve(`/api/prompts/${encodeURIComponent(ua)}`)).json();Ee(x,v=>{if(v){a.value=v;try{n.value=JSON.parse(v.prompt)}catch(d){console.error("Failed to parse prompt A:",d)}}},{immediate:!0}),Ee(h,v=>{v&&(s.value=v)},{immediate:!0});function y(v,d){return v.map(b=>{if(b.type==="string")return b.value||"";if(b.type==="variable"){const c=d[b.value];return c===void 0?`{{${b.value}}}`:typeof c=="string"?c:JSON.stringify(c)}else if(b.type==="prompt"){if(b.id===ua&&s.value)try{const c=JSON.parse(s.value.prompt);return y(c,d)}catch{return`[Error loading prompt: ${b.label}]`}return""}return""}).join("")}function _(){const v={name:u.value,email:i.value,age:p.value};l.value=y(n.value,v)}return(v,d)=>(r(),o("div",G5,[d[11]||(d[11]=e("h1",{class:"text-2xl font-bold mb-6"},"Prompt Interpolation Test",-1)),e("div",Y5,[d[4]||(d[4]=e("h2",{class:"text-lg font-semibold mb-2"},"Prompt Template",-1)),e("div",Z5,[a.value?(r(),o("div",X5,[d[3]||(d[3]=e("div",{class:"font-bold mb-2"},"Prompt A:",-1)),e("pre",Q5,C(JSON.stringify(n.value,null,2)),1)])):(r(),o("div",e3,"Loading..."))])]),e("div",t3,[d[8]||(d[8]=e("h2",{class:"text-lg font-semibold mb-2"},"Context Values",-1)),e("div",r3,[e("div",null,[d[5]||(d[5]=e("label",{class:"block text-sm mb-1"},"Name:",-1)),He(e("input",{"onUpdate:modelValue":d[0]||(d[0]=b=>u.value=b),type:"text",class:"w-full px-3 py-2 border rounded"},null,512),[[ht,u.value]])]),e("div",null,[d[6]||(d[6]=e("label",{class:"block text-sm mb-1"},"Email:",-1)),He(e("input",{"onUpdate:modelValue":d[1]||(d[1]=b=>i.value=b),type:"text",class:"w-full px-3 py-2 border rounded"},null,512),[[ht,i.value]])]),e("div",null,[d[7]||(d[7]=e("label",{class:"block text-sm mb-1"},"Age:",-1)),He(e("input",{"onUpdate:modelValue":d[2]||(d[2]=b=>p.value=b),type:"text",class:"w-full px-3 py-2 border rounded"},null,512),[[ht,p.value]])])])]),e("button",{onClick:_,class:"px-4 py-2 bg-black text-white rounded hover:bg-neutral-800"}," Render Prompt "),e("div",a3,[d[9]||(d[9]=e("h2",{class:"text-lg font-semibold mb-2"},"Rendered Output",-1)),e("div",n3,[l.value?(r(),o("div",o3,C(l.value),1)):(r(),o("div",l3,' Click "Render Prompt" to see output '))]),d[10]||(d[10]=e("div",{class:"mt-4 p-4 bg-accent-50 dark:bg-accent-900 rounded text-sm"},[e("div",{class:"font-semibold mb-1"}," Expected Output (when feature is implemented): "),e("div",{class:"font-mono"}," User Profile: Alice Johnson <alice@example.com> (Age: 28) ")],-1))])]))}}),Xa=An({history:Pn(Kt()),routes:[{path:"/login",name:"login",component:z4,meta:{public:!0}},{path:"/",redirect:"/threads"},{path:"/agents",name:"agents",component:Kv},{path:"/threads",name:"threads",component:ra},{path:"/threads/:id",name:"thread-detail",component:ra},{path:"/prompts",name:"prompts",component:hw},{path:"/prompts/:id",name:"prompt-edit",component:kw},{path:"/models",name:"models",component:g_},{path:"/providers",name:"providers",component:j_},{path:"/tools",name:"tools",component:u4},{path:"/settings/users",name:"users",component:v4},{path:"/settings/api-keys",name:"api-keys",component:y4},{path:"/test",name:"test",component:u5},{path:"/test-reference-input",name:"test-reference-input",component:T5},{path:"/debug",name:"debug",component:E5},{path:"/test-prompt-input",name:"test-prompt-input",component:U5},{path:"/test-json-editor-modal",name:"test-json-editor-modal",component:J5},{path:"/test-prompt-interpolation",name:"test-prompt-interpolation",component:i3}]});Xa.beforeEach(async(t,n,a)=>{const s=t.meta.public===!0,l=localStorage.getItem("auth_token");!s&&!l?a({name:"login"}):s&&l&&t.name==="login"?a({name:"threads"}):a()});const u3=window.fetch;window.fetch=async function(t,n){const a=typeof t=="string"?t:t instanceof URL?t.toString():t.url,s=Kt(),l=s==="/"?"/api/":`${s}/api/`,u=a.includes(l)||s==="/"&&a.startsWith("/api/");if(u){const k=localStorage.getItem("auth_token");k&&n?n.headers={...n.headers,Authorization:`Bearer ${k}`}:k&&(n={...n,headers:{Authorization:`Bearer ${k}`}})}const i=await u3(t,n),p=a.includes("/api/auth/"),x=Ve("/login");return i.status===401&&u&&!p&&window.location.pathname!==x&&(localStorage.removeItem("auth_token"),window.location.href=x),i};const pr=jn(Zd);pr.use(vo,{endpoint:Ve("/api")});pr.use(Rn,On(ku));pr.use(Xa);pr.mount("#app");
79
+ Description: ${i.meta?.description||"No description"}`)};return(i,c)=>(r(),o("div",j5,[t("div",D5,[c[5]||(c[5]=t("h1",{class:"text-3xl font-bold mb-8 text-black dark:text-white"}," PromptInput Component Test ",-1)),t("div",U5,[t("div",B5,[c[0]||(c[0]=t("h2",{class:"text-xl font-semibold text-black dark:text-white"}," Basic Usage ",-1)),c[1]||(c[1]=t("p",{class:"text-neutral-600 dark:text-neutral-400"}," Type @ to trigger the autocomplete menu. Use arrow keys to navigate and Enter to select. ",-1)),t("div",null,[k(Pr,{"model-value":n.value,search:s,placeholder:"Type @ to insert variables or prompts...","onUpdate:modelValue":l,onSegmentClick:u},null,8,["model-value"])])]),t("div",N5,[c[3]||(c[3]=t("h2",{class:"text-xl font-semibold text-black dark:text-white"}," Current Value ",-1)),t("div",q5,[c[2]||(c[2]=t("h3",{class:"text-sm font-medium text-neutral-700 dark:text-neutral-300 mb-2"}," Segments (value): ",-1)),t("pre",F5,C(JSON.stringify(n.value,null,2)),1)])]),c[4]||(c[4]=Nn('<div class="space-y-4"><h2 class="text-xl font-semibold text-black dark:text-white"> Testing Instructions </h2><ul class="list-disc list-inside space-y-2 text-neutral-600 dark:text-neutral-400"><li>Type @ anywhere in the text to open the search dialog</li><li>Continue typing to search for variables or prompts</li><li>Use arrow keys (↑↓) to navigate results</li><li>Press Enter to select a result or click with mouse</li><li>Press Escape to close the dialog</li><li>Click outside the dialog to close it</li><li>Use Backspace/Delete to remove tags</li><li> The dialog will auto-close after typing 5+ characters without selection </li><li><strong>NEW: Click on any tag to see action handling!</strong></li></ul></div><div class="space-y-4"><h2 class="text-xl font-semibold text-black dark:text-white"> Test Scenarios </h2><div class="grid grid-cols-1 md:grid-cols-2 gap-4"><div class="p-4 border-2 border-neutral-300 dark:border-neutral-700 rounded-lg"><h3 class="font-medium text-black dark:text-white mb-2"> Variables </h3><p class="text-sm text-neutral-600 dark:text-neutral-400"> Try: @user, @date, @time, @api, @work </p></div><div class="p-4 border-2 border-neutral-300 dark:border-neutral-700 rounded-lg"><h3 class="font-medium text-black dark:text-white mb-2"> Prompts </h3><p class="text-sm text-neutral-600 dark:text-neutral-400"> Try: @greet, @error, @code, @data, @summ </p></div><div class="p-4 border-2 border-neutral-300 dark:border-neutral-700 rounded-lg"><h3 class="font-medium text-black dark:text-white mb-2"> Mixed Content </h3><p class="text-sm text-neutral-600 dark:text-neutral-400"> Mix text with multiple tags and test editing </p></div><div class="p-4 border-2 border-neutral-300 dark:border-neutral-700 rounded-lg"><h3 class="font-medium text-black dark:text-white mb-2"> Edge Cases </h3><p class="text-sm text-neutral-600 dark:text-neutral-400"> Test @ at start/end, multiple @@ symbols, etc. </p></div></div></div>',2))])])]))}}),W5={class:"relative"},K5={key:0,class:"mt-1 text-sm text-red-500"},J5=Se({__name:"JsonEditor",props:{modelValue:{},placeholder:{},error:{},rows:{},readonly:{type:Boolean}},emits:["update:modelValue","blur"],setup(e,{emit:n}){self.MonacoEnvironment={getWorker($,g){return g==="json"?new Xn:new Qn}};const a=e,s=n,l=p(null);let u=null,i=!1;const c=p(!1),f={minimap:{enabled:!1},fontSize:14,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',lineHeight:24,padding:{top:12,bottom:12},scrollBeyondLastLine:!1,wordWrap:"on",automaticLayout:!0,formatOnPaste:!0,formatOnType:!0,readOnly:a.readonly,quickSuggestions:{other:"on",comments:"off",strings:"on"},suggestOnTriggerCharacters:!0,acceptSuggestionOnCommitCharacter:!0,tabSize:2,detectIndentation:!1,renderLineHighlight:"none",scrollbar:{vertical:"auto",horizontal:"hidden",verticalScrollbarSize:10}},h=()=>{if(!(!u||a.readonly))try{const $=u.getValue(),g=JSON.parse($),d=JSON.stringify(g,null,2);d!==$&&(i=!0,u.setValue(d),i=!1)}catch{}},x=()=>{c.value=document.documentElement.classList.contains("dark"),u&&Hr.setTheme(c.value?"vs-dark":"vs")},b=()=>{l.value&&(u=Hr.create(l.value,{value:a.modelValue||"{}",language:"json",theme:c.value?"vs-dark":"vs",...f})(l.value).__monacoEditor=u,u.onDidChangeModelContent(()=>{if(!i){const $=u.getValue();s("update:modelValue",$)}}),u.onDidBlurEditorText(()=>{s("blur"),h()}))};He(async()=>{x(),await Fe(),b();const $=new MutationObserver(x);$.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),ct(()=>{$.disconnect(),u&&u.dispose()})}),Ve(()=>a.modelValue,$=>{u&&u.getValue()!==$&&(i=!0,u.setValue($||""),i=!1)}),Ve(()=>a.readonly,$=>{u&&u.updateOptions({readOnly:$})});const y=a.rows?`${a.rows*1.5}rem`:"18rem";return($,g)=>(r(),o("div",W5,[t("div",{class:pe(["border rounded overflow-hidden bg-white dark:bg-black",[e.error?"border-red-500":"border-black dark:border-neutral-300"]])},[t("div",{ref_key:"containerRef",ref:l,class:"monaco-editor-container",style:_t({height:I(y)})},null,4)],2),e.error?(r(),o("div",K5,C(e.error),1)):S("",!0)]))}}),ha=mt(J5,[["__scopeId","data-v-1393c576"]]),G5={class:"p-8"},Y5={class:"space-y-4"},Z5={class:"space-y-4"},X5={class:"space-y-4"},Q5=Se({__name:"TestJsonEditorModal",setup(e){const n=p(!1),a=p(JSON.stringify({name:"Test",value:123},null,2)),s=p(!1),l=p(JSON.stringify({editable:!0,count:0},null,2));return(u,i)=>(r(),o("div",G5,[i[13]||(i[13]=t("h1",{class:"text-3xl font-bold mb-6"},"JsonEditor in Modal Test",-1)),t("div",Y5,[t("div",null,[i[7]||(i[7]=t("h2",{class:"text-xl font-semibold mb-2"}," Read-only JsonEditor in Modal ",-1)),i[8]||(i[8]=t("p",{class:"text-neutral-600 dark:text-neutral-400 mb-4"}," This should NOT show unsaved changes warning when closing ",-1)),t("button",{onClick:i[0]||(i[0]=c=>n.value=!0),class:"px-4 py-2 bg-black dark:bg-white text-white dark:text-black border-2 border-black dark:border-white"}," Open Read-only Modal ")]),t("div",null,[i[9]||(i[9]=t("h2",{class:"text-xl font-semibold mb-2"},"Editable JsonEditor in Modal",-1)),i[10]||(i[10]=t("p",{class:"text-neutral-600 dark:text-neutral-400 mb-4"}," This should NOT show unsaved changes warning on initial close, but SHOULD show it after editing ",-1)),t("button",{onClick:i[1]||(i[1]=c=>s.value=!0),class:"px-4 py-2 bg-black dark:bg-white text-white dark:text-black border-2 border-black dark:border-white"}," Open Editable Modal ")])]),k(dt,{modelValue:n.value,"onUpdate:modelValue":i[3]||(i[3]=c=>n.value=c),title:"Read-only JSON Schema",width:"max-w-4xl"},{footer:W(()=>[t("button",{onClick:i[2]||(i[2]=c=>n.value=!1),class:"px-4 py-2 border-2 border-black dark:border-white bg-white dark:bg-black text-black dark:text-white"}," Close ")]),default:W(()=>[t("div",Z5,[i[11]||(i[11]=t("p",{class:"text-sm text-neutral-600 dark:text-neutral-400"}," This is a read-only JSON editor. No changes can be made. ",-1)),k(ha,{"model-value":a.value,readonly:!0},null,8,["model-value"])])]),_:1},8,["modelValue"]),k(dt,{modelValue:s.value,"onUpdate:modelValue":i[6]||(i[6]=c=>s.value=c),title:"Editable JSON Schema",width:"max-w-4xl"},{footer:W(()=>[t("button",{onClick:i[5]||(i[5]=c=>s.value=!1),class:"px-4 py-2 border-2 border-black dark:border-white bg-white dark:bg-black text-black dark:text-white"}," Close ")]),default:W(()=>[t("div",X5,[i[12]||(i[12]=t("p",{class:"text-sm text-neutral-600 dark:text-neutral-400"}," This is an editable JSON editor. Changes will be tracked. ",-1)),k(ha,{modelValue:l.value,"onUpdate:modelValue":i[4]||(i[4]=c=>l.value=c)},null,8,["modelValue"])])]),_:1},8,["modelValue"])]))}}),e3={class:"p-8 max-w-2xl mx-auto"},t3={class:"mb-6"},r3={class:"p-4 bg-neutral-100 dark:bg-neutral-800 rounded font-mono text-sm"},a3={key:0},n3={class:"whitespace-pre-wrap"},o3={key:1,class:"text-neutral-500"},l3={class:"mb-6"},s3={class:"space-y-2"},i3={class:"mt-6"},u3={class:"p-4 bg-green-50 dark:bg-green-900 rounded min-h-[100px]"},d3={key:0,class:"font-mono"},c3={key:1,class:"text-neutral-500"},p3="10000000-0000-0000-0000-000000000101",ba="10000000-0000-0000-0000-000000000102",m3=Se({__name:"TestPromptInterpolation",setup(e){const n=p([]),a=p(null),s=p(null),l=p(""),u=p("Alice Johnson"),i=p("alice@example.com"),c=p("28"),{data:f,error:h}=it(ze(`/api/prompts/${encodeURIComponent(p3)}`)).json(),{data:x,error:b}=it(ze(`/api/prompts/${encodeURIComponent(ba)}`)).json();Ve(f,g=>{if(g){a.value=g;try{n.value=JSON.parse(g.prompt)}catch(d){console.error("Failed to parse prompt A:",d)}}},{immediate:!0}),Ve(x,g=>{g&&(s.value=g)},{immediate:!0});function y(g,d){return g.map(w=>{if(w.type==="string")return w.value||"";if(w.type==="variable"){const m=d[w.value];return m===void 0?`{{${w.value}}}`:typeof m=="string"?m:JSON.stringify(m)}else if(w.type==="prompt"){if(w.id===ba&&s.value)try{const m=JSON.parse(s.value.prompt);return y(m,d)}catch{return`[Error loading prompt: ${w.label}]`}return""}return""}).join("")}function $(){const g={name:u.value,email:i.value,age:c.value};l.value=y(n.value,g)}return(g,d)=>(r(),o("div",e3,[d[11]||(d[11]=t("h1",{class:"text-2xl font-bold mb-6"},"Prompt Interpolation Test",-1)),t("div",t3,[d[4]||(d[4]=t("h2",{class:"text-lg font-semibold mb-2"},"Prompt Template",-1)),t("div",r3,[a.value?(r(),o("div",a3,[d[3]||(d[3]=t("div",{class:"font-bold mb-2"},"Prompt A:",-1)),t("pre",n3,C(JSON.stringify(n.value,null,2)),1)])):(r(),o("div",o3,"Loading..."))])]),t("div",l3,[d[8]||(d[8]=t("h2",{class:"text-lg font-semibold mb-2"},"Context Values",-1)),t("div",s3,[t("div",null,[d[5]||(d[5]=t("label",{class:"block text-sm mb-1"},"Name:",-1)),Je(t("input",{"onUpdate:modelValue":d[0]||(d[0]=w=>u.value=w),type:"text",class:"w-full px-3 py-2 border rounded"},null,512),[[yt,u.value]])]),t("div",null,[d[6]||(d[6]=t("label",{class:"block text-sm mb-1"},"Email:",-1)),Je(t("input",{"onUpdate:modelValue":d[1]||(d[1]=w=>i.value=w),type:"text",class:"w-full px-3 py-2 border rounded"},null,512),[[yt,i.value]])]),t("div",null,[d[7]||(d[7]=t("label",{class:"block text-sm mb-1"},"Age:",-1)),Je(t("input",{"onUpdate:modelValue":d[2]||(d[2]=w=>c.value=w),type:"text",class:"w-full px-3 py-2 border rounded"},null,512),[[yt,c.value]])])])]),t("button",{onClick:$,class:"px-4 py-2 bg-black text-white rounded hover:bg-neutral-800"}," Render Prompt "),t("div",i3,[d[9]||(d[9]=t("h2",{class:"text-lg font-semibold mb-2"},"Rendered Output",-1)),t("div",u3,[l.value?(r(),o("div",d3,C(l.value),1)):(r(),o("div",c3,' Click "Render Prompt" to see output '))]),d[10]||(d[10]=t("div",{class:"mt-4 p-4 bg-accent-50 dark:bg-accent-900 rounded text-sm"},[t("div",{class:"font-semibold mb-1"}," Expected Output (when feature is implemented): "),t("div",{class:"font-mono"}," User Profile: Alice Johnson <alice@example.com> (Age: 28) ")],-1))])]))}}),sn=qn({history:Fn(Xt()),routes:[{path:"/login",name:"login",component:P4,meta:{public:!0}},{path:"/",redirect:"/threads"},{path:"/agents",name:"agents",component:df},{path:"/threads",name:"threads",component:ca},{path:"/threads/:id",name:"thread-detail",component:ca},{path:"/prompts",name:"prompts",component:Lw},{path:"/prompts/:id",name:"prompt-edit",component:Rw},{path:"/models",name:"models",component:A_},{path:"/providers",name:"providers",component:N_},{path:"/tools",name:"tools",component:f4},{path:"/settings/users",name:"users",component:y4},{path:"/settings/api-keys",name:"api-keys",component:S4},{path:"/test",name:"test",component:v5},{path:"/test-reference-input",name:"test-reference-input",component:L5},{path:"/debug",name:"debug",component:R5},{path:"/test-prompt-input",name:"test-prompt-input",component:H5},{path:"/test-json-editor-modal",name:"test-json-editor-modal",component:Q5},{path:"/test-prompt-interpolation",name:"test-prompt-interpolation",component:m3}]});sn.beforeEach(async(e,n,a)=>{const s=e.meta.public===!0,l=localStorage.getItem("auth_token");!s&&!l?a({name:"login"}):s&&l&&e.name==="login"?a({name:"threads"}):a()});const v3=window.fetch;window.fetch=async function(e,n){const a=typeof e=="string"?e:e instanceof URL?e.toString():e.url,s=Xt(),l=s==="/"?"/api/":`${s}/api/`,u=a.includes(l)||s==="/"&&a.startsWith("/api/");if(u){const h=localStorage.getItem("auth_token");h&&n?n.headers={...n.headers,Authorization:`Bearer ${h}`}:h&&(n={...n,headers:{Authorization:`Bearer ${h}`}})}const i=await v3(e,n),c=a.includes("/api/auth/"),f=ze("/login");return i.status===401&&u&&!c&&window.location.pathname!==f&&(localStorage.removeItem("auth_token"),window.location.href=f),i};const gr=Hn(mc);gr.use(_o,{endpoint:ze("/api")});gr.use(Wn,Kn(Ru));gr.use(sn);gr.mount("#app");