@standardagents/builder 0.12.0 → 0.12.1

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.
@@ -2,7 +2,7 @@ import{d as me,i as $r,c as B,t as ba,r as p,w as ge,o as Pe,a as Ye,p as xa,b a
2
2
  `;return}const ne=Array.from(M.childNodes);for(const A of ne)q(A);(M.tagName==="DIV"||M.tagName==="P"||M.tagName==="LI")&&M.nextSibling&&(re+=`
3
3
  `);return}},N=Array.from(S.childNodes);for(const W of N)q(W);F();const U=V.some(W=>W.type!=="string")?V:[{type:"string",value:(S.innerText||"").replace(/\r\n/g,`
4
4
  `)}];s.segments=U.length?U:[{type:"string",value:""}],f(),d(),ee()},d=()=>{const E=window.getSelection();if(!E||!E.rangeCount||!l.value)return;const S=E.getRangeAt(0);if(S.startContainer.nodeType!==Node.TEXT_NODE){s.dialogOpen&&g();return}const re=S.startContainer.textContent||"",F=S.startOffset;if(F>0&&re[F-1]==="@")s.atTriggerIndex=F-1,s.searchQuery="",k(),R("");else if(s.dialogOpen&&s.atTriggerIndex>=0)if(S.startContainer.nodeType===Node.TEXT_NODE){const q=S.startContainer.textContent||"",N=S.startOffset;if(N<=s.atTriggerIndex){g();return}const J=q.substring(0,N);if(J.length>s.atTriggerIndex&&J[s.atTriggerIndex]==="@"){const U=J.substring(s.atTriggerIndex+1);U.includes(" ")||U.includes(`
5
- `)||U.length>s.searchQuery.length+5?g():(s.searchQuery=U,R(U))}else g()}else g()},k=async()=>{s.dialogOpen=!0,s.selectedIndex=0,await Le(),_()},g=()=>{s.dialogOpen=!1,s.searchResults=[],s.searchQuery="",s.atTriggerIndex=-1,s.isSearching=!1},_=()=>{if(!u.value||!l.value)return;const E=window.getSelection();if(!E||!E.rangeCount)return;const V=E.getRangeAt(0).getBoundingClientRect(),re=l.value.getBoundingClientRect();s.dialogPosition={x:V.left-re.left,y:V.bottom-re.top+4}};let L=null;const R=async E=>{if(!a.search){s.searchResults=[];return}L&&clearTimeout(L),s.isSearching=!0,L=setTimeout(async()=>{try{const S=await a.search(E);s.searchResults=(S||[]).filter(V=>a.allowedTypes?.includes(V.type))}catch(S){console.error("Search error:",S),s.searchResults=[]}finally{s.isSearching=!1}},200)},K=E=>E.type==="variable"?{type:"variable",value:E.value??E.id??"",label:E.label,schema:E.schema,_uid:m(),meta:E.meta}:{type:"prompt",id:E.id??E.value??"",label:E.label,schema:E.schema,_uid:m(),meta:E.meta},Y=E=>{if(s.atTriggerIndex<0||!l.value)return;const S=window.getSelection();if(!S||!S.rangeCount)return;const V=S.getRangeAt(0);if(V.startContainer.nodeType!==Node.TEXT_NODE)return;const re=V.startContainer,F=re.data.slice(0,s.atTriggerIndex),q=re.data.slice(V.startOffset),N=document.createElement("span"),J=K(E),U=J.type==="prompt"&&J.meta&&!J.meta.isValid;N.className=`prompt-tag${U?" prompt-tag-invalid":""}`,N.setAttribute("contenteditable","false");const W=J._uid||(J._uid=m());N.dataset.segmentUid=W;const M=J.type==="variable"?{type:"variable",value:J.value,label:J.label,schema:J.schema}:{type:"prompt",id:J.id,label:J.label,schema:J.schema};if(N.dataset.segment=encodeURIComponent(JSON.stringify(M)),N.textContent=h(J),U){const ke=document.createElement("span");ke.className="prompt-tag-warning",ke.textContent="⚠️",ke.setAttribute("title",J.meta.validationMessage||"Validation error"),N.appendChild(ke)}const ne=re.parentNode,A=document.createTextNode(q),ce=document.createTextNode(F);ne.insertBefore(ce,re),ne.insertBefore(N,re),ne.insertBefore(A,re),ne.removeChild(re),g(),v({target:l.value});const ue=window.getSelection();if(ue){const ke=document.createRange();ke.setStart(A,0),ke.collapse(!0),ue.removeAllRanges(),ue.addRange(ke)}l.value.focus()},z=E=>{if((E.key==="ArrowLeft"||E.key==="ArrowRight")&&setTimeout(()=>d(),0),s.dialogOpen)E.key==="ArrowDown"?(E.preventDefault(),s.selectedIndex=Math.min(s.selectedIndex+1,s.searchResults.length-1)):E.key==="ArrowUp"?(E.preventDefault(),s.selectedIndex=Math.max(s.selectedIndex-1,0)):E.key==="Enter"?(E.preventDefault(),s.searchResults[s.selectedIndex]&&Y(s.searchResults[s.selectedIndex])):(E.key==="Escape"||E.key==="Esc")&&(E.preventDefault(),g());else if(E.key==="Backspace"||E.key==="Delete"){const S=x();if(E.key==="Backspace"){const V=window.getSelection();if(V&&V.rangeCount){const re=V.getRangeAt(0);if(re.collapsed&&re.startContainer.nodeType===Node.TEXT_NODE&&re.startOffset===0){let F=re.startContainer;for(;F&&F!==l.value;){const q=F.previousSibling;if(q&&q.nodeType===Node.ELEMENT_NODE&&q.classList?.contains("prompt-tag")){E.preventDefault(),q.parentNode?.removeChild(q),v({target:l.value});return}F=F.parentNode}}}}if(!S)return;if(E.key==="Backspace"&&S.offset===0&&S.segmentIndex>0)s.segments[S.segmentIndex-1].type!=="string"&&(E.preventDefault(),s.segments.splice(S.segmentIndex-1,1),f(),ee(),c());else if(E.key==="Delete"&&S.segmentIndex<s.segments.length-1){const V=s.segments[S.segmentIndex];V.type==="string"&&(V.value?.length??0)===S.offset&&s.segments[S.segmentIndex+1].type!=="string"&&(E.preventDefault(),s.segments.splice(S.segmentIndex+1,1),f(),ee(),c())}}},P=E=>{E.preventDefault();const S=E.clipboardData?.getData("text/plain")||"";document.execCommand("insertText",!1,S)},G=E=>{if(!s.dialogOpen)return;const S=u.value;S&&(S.contains(E.target)||g())},ee=()=>{s.ignoreNextWatch=!0;const E=s.segments.map(S=>{const{_uid:V,...re}=S||{};return re});i("update:modelValue",E)},se=()=>{const E=window.getSelection();if(!E||!l.value)return;const S=E.anchorNode;S&&l.value.contains(S)&&d()},de=E=>{(E.key==="Escape"||E.key==="Esc")&&s.dialogOpen&&(E.preventDefault(),g())};Pe(()=>{a.modelValue&&a.modelValue.length&&(s.segments=JSON.parse(JSON.stringify(a.modelValue))),c(),document.addEventListener("mousedown",G),document.addEventListener("selectionchange",se),document.addEventListener("keydown",de,!0)}),Ye(()=>{document.removeEventListener("mousedown",G),document.removeEventListener("selectionchange",se),document.removeEventListener("keydown",de,!0)}),ge(()=>a.modelValue,E=>{if(s.ignoreNextWatch){s.ignoreNextWatch=!1;return}E&&(s.segments=JSON.parse(JSON.stringify(E)),c())},{deep:!0});const Q=B(()=>{const E=["prompt-input-editor","min-h-[100px]",a.disabled?"opacity-50 cursor-not-allowed":""];return a.editorClass?[...E,a.editorClass,"!h-auto"]:[...E,"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(E,S)=>(r(),n("div",Vo,[e("div",{ref_key:"editorRef",ref:l,contenteditable:!t.disabled,onInput:v,onKeydown:z,onPaste:P,onClick:b,onKeyup:S[0]||(S[0]=V=>{V.key==="Escape"?(V.preventDefault(),g()):(V.key==="ArrowLeft"||V.key==="ArrowRight")&&d()}),onCompositionstart:S[1]||(S[1]=V=>s.isComposing=!0),onCompositionend:S[2]||(S[2]=V=>s.isComposing=!1),class:ae(Q.value),"data-placeholder":t.placeholder},[Ae(e("div",null,[je(E.$slots,"segment",{segment:null},void 0,!0)],512),[[Ke,!1]])],42,Mo),s.dialogOpen?(r(),n("div",{key:0,ref_key:"dialogRef",ref:u,class:"absolute z-50",style:st({left:`${s.dialogPosition.x}px`,top:`${s.dialogPosition.y}px`})},[w(wt,{"offset-x":4,"offset-y":4,intensity:.3},{default:D(()=>[e("div",Eo,[s.isSearching?(r(),n("div",Lo," Searching... ")):s.searchResults.length===0?(r(),n("div",Po," No results found ")):(r(),n("div",Ao,[(r(!0),n(ve,null,ye(s.searchResults,(V,re)=>(r(),n("button",{key:V.id||V.value||re,type:"button",onClick:F=>Y(V),class:ae(["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",s.selectedIndex===re?"bg-neutral-100 dark:bg-neutral-900":""])},[e("div",Do,[Z(C(V.label||V.id||V.value)+" ",1),V.type==="prompt"&&V.meta&&!V.meta.isValid?(r(),n("span",{key:0,title:V.meta.validationMessage,class:"text-red-500"},"⚠️",8,Oo)):I("",!0)]),V.description?(r(),n("div",Ro,C(V.description),1)):I("",!0),V.type==="prompt"&&V.meta&&!V.meta.isValid?(r(),n("div",Uo,C(V.meta.validationMessage),1)):I("",!0),e("div",Bo,[e("span",{class:ae(["inline-block px-1.5 py-0.5 rounded",V.type==="variable"?"bg-blue-100 dark:bg-blue-900 text-blue-700 dark:text-blue-300":"bg-purple-100 dark:bg-purple-900 text-purple-700 dark:text-purple-300"])},C(V.type),3)])],10,jo))),128))]))])]),_:1})],4)):I("",!0)]))}}),Xe=(t,o)=>{const a=t.__vccOpts||t;for(const[i,l]of o)a[i]=l;return a},Gt=Xe(Fo,[["__scopeId","data-v-daddc895"]]),No=me({__name:"PromptInputWrapper",props:{context:{}},emits:["segment-click"],setup(t,{emit:o}){const a=t,i=(b,v)=>{const d=a.context;return d[b]!==void 0?d[b]:d.attrs?.[b]!==void 0?d.attrs[b]:v},l=B(()=>a.context.classes??{}),u=B(()=>a.context._value??[]),s=b=>{a.context.node.input(b)},m=B(()=>i("search",void 0)),h=B(()=>i("placeholder","Type @ to insert variables or prompts...")),x=B(()=>i("maxLength",void 0)),c=B(()=>i("allowedTypes",["variable","prompt"])),f=B(()=>a.context.disabled??!1),y=(b,v)=>{const d=a.context;d.attrs?.["onSegment-click"]&&d.attrs["onSegment-click"](b,v)};return(b,v)=>(r(),H(Gt,{"model-value":u.value,search:m.value,placeholder:h.value,disabled:f.value,"max-length":x.value,"allowed-types":c.value,"editor-class":l.value.inner,"onUpdate:modelValue":s,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:Ie(No),props:{context:"$node.context"}}]},Ho={class:"inline-flex items-center justify-center"},Ee=me({__name:"Loader",props:{size:{default:"md"}},setup(t){const o=t,a=B(()=>{switch(o.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(i,l)=>(r(),n("div",Ho,[e("div",{class:ae([a.value,"border-black/20 dark:border-white/20 border-t-black dark:border-t-white rounded-full animate-spin"])},null,2)]))}}),Wo=["type","disabled"],Ko="inline-flex items-center justify-center gap-2 font-medium rounded transition-all disabled:opacity-50 disabled:cursor-not-allowed",De=me({__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:o}){const a=t,i=o,l=B(()=>{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=B(()=>{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""}}),s=B(()=>a.size==="xs"||a.size==="sm"?"xs":"sm"),m=h=>{!a.disabled&&!a.loading&&i("click",h)};return(h,x)=>(r(),n("button",{type:t.type,disabled:t.disabled||t.loading,class:ae([Ko,l.value,u.value,t.fullWidth?"w-full":""]),onClick:m},[t.loading?(r(),H(Ee,{key:0,size:s.value},null,8,["size"])):t.iconLeft?(r(),H(Ue(t.iconLeft),{key:1,class:"w-4 h-4"})):I("",!0),je(h.$slots,"default"),t.iconRight&&!t.loading?(r(),H(Ue(t.iconRight),{key:2,class:"w-4 h-4"})):I("",!0)],10,Wo))}}),Jo=["disabled","aria-label","title"],Yo="inline-flex items-center justify-center rounded transition-colors disabled:opacity-50 disabled:cursor-not-allowed",Br=me({__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:o}){const a=t,i=o,l=B(()=>{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=B(()=>{switch(a.size){case"xs":return"p-0.5";case"sm":return"p-1";case"md":return"p-1.5";default:return""}}),s=B(()=>{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""}}),m=h=>{!a.disabled&&!a.loading&&i("click",h)};return(h,x)=>(r(),n("button",{type:"button",disabled:t.disabled||t.loading,"aria-label":t.label,title:t.label,class:ae([Yo,l.value,u.value]),onClick:m},[t.loading?(r(),H(Ee,{key:0,size:"xs"})):(r(),H(Ue(t.icon),{key:1,class:ae(s.value)},null,8,["class"]))],10,Jo))}}),Go=["for"],Zo={key:0,class:"text-red-500 ml-0.5"},Fr=me({__name:"UiLabel",props:{required:{type:Boolean,default:!1},htmlFor:{}},setup(t){return(o,a)=>(r(),n("label",{for:t.htmlFor,class:"block text-sm font-medium text-neutral-700 dark:text-neutral-300"},[je(o.$slots,"default"),t.required?(r(),n("span",Zo,"*")):I("",!0)],8,Go))}}),Xo={class:"text-xs text-red-500 dark:text-red-400"},tt=me({__name:"UiErrorText",setup(t){return(o,a)=>(r(),n("p",Xo,[je(o.$slots,"default")]))}}),Qo={class:"text-xs text-neutral-500 dark:text-neutral-400"},ze=me({__name:"UiHelpText",setup(t){return(o,a)=>(r(),n("p",Qo,[je(o.$slots,"default")]))}}),en={class:"space-y-1.5"},ct=me({__name:"UiFormField",props:{label:{},error:{},helpText:{},required:{type:Boolean,default:!1},htmlFor:{}},setup(t){return(o,a)=>(r(),n("div",en,[je(o.$slots,"label",{},()=>[t.label?(r(),H(Fr,{key:0,"html-for":t.htmlFor,required:t.required},{default:D(()=>[Z(C(t.label),1)]),_:1},8,["html-for","required"])):I("",!0)]),je(o.$slots,"default"),je(o.$slots,"error",{},()=>[t.error?(r(),H(tt,{key:0},{default:D(()=>[Z(C(t.error),1)]),_:1})):I("",!0)]),je(o.$slots,"help",{},()=>[t.helpText&&!t.error?(r(),H(ze,{key:0},{default:D(()=>[Z(C(t.helpText),1)]),_:1})):I("",!0)])]))}}),tn={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function rn(t,o){return r(),n("svg",tn,[...o[0]||(o[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 Pt=Ie({name:"lucide-x",render:rn}),an={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function on(t,o){return r(),n("svg",an,[...o[0]||(o[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)])])}Ie({name:"lucide-info",render:on});const nn={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function ln(t,o){return r(),n("svg",nn,[...o[0]||(o[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)])])}Ie({name:"lucide-circle-check",render:ln});const sn={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function un(t,o){return r(),n("svg",sn,[...o[0]||(o[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 ir=Ie({name:"lucide-triangle-alert",render:un}),dn={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function cn(t,o){return r(),n("svg",dn,[...o[0]||(o[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)])])}Ie({name:"lucide-circle-x",render:cn});const ft=me({__name:"UiBadge",props:{variant:{default:"default"},size:{default:"sm"},pill:{type:Boolean,default:!1}},setup(t){const o=t,a=B(()=>{switch(o.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""}}),i=B(()=>{switch(o.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(),n("span",{class:ae(["inline-flex items-center font-medium",a.value,i.value,t.pill?"rounded-full":"rounded"])},[je(l.$slots,"default")],2))}}),pn={key:0,class:"border-b border-neutral-200 dark:border-neutral-700"},mn={key:1,class:"border-t border-neutral-200 dark:border-neutral-700"},At=me({__name:"UiDropdownPanel",props:{width:{},maxHeight:{},shadow:{type:[Boolean,Object],default:!0}},setup(t){const o=t,a=B(()=>o.shadow===!0?{offsetX:6,offsetY:6,intensity:.4}:o.shadow&&typeof o.shadow=="object"?o.shadow:null),i=B(()=>!!o.shadow),l=B(()=>["bg-white dark:bg-neutral-900 border border-neutral-300 dark:border-neutral-600 rounded-lg overflow-hidden",o.width]),u=B(()=>[o.maxHeight?"overflow-y-auto":"",o.maxHeight]);return(s,m)=>(r(),H(Ue(i.value?wt:"template"),ka(wa(i.value?a.value:{})),{default:D(()=>[e("div",{class:ae(l.value)},[s.$slots.header?(r(),n("div",pn,[je(s.$slots,"header")])):I("",!0),e("div",{class:ae(u.value)},[je(s.$slots,"default")],2),s.$slots.footer?(r(),n("div",mn,[je(s.$slots,"footer")])):I("",!0)],2)]),_:3},16))}}),vn={class:"flex items-start gap-3"},fn={class:"flex-1 text-sm"},Fe=me({__name:"UiAlertBox",props:{variant:{default:"info"},showIcon:{type:Boolean,default:!0}},setup(t){const o=t,a=B(()=>{switch(o.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"}}),i=B(()=>{switch(o.variant){case"warning":return Sr;case"success":return $a;case"error":return _a;case"info":default:return Cr}}),l=B(()=>{switch(o.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,s)=>(r(),n("div",{class:ae(["px-4 py-3 border rounded-lg",a.value])},[e("div",vn,[t.showIcon?(r(),H(Ue(i.value),{key:0,class:ae(["w-5 h-5 mt-0.5 flex-shrink-0",l.value])},null,8,["class"])):I("",!0),e("div",fn,[je(u.$slots,"default")])])],2))}}),ur=me({__name:"UiMenuItem",props:{active:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},as:{default:"button"}},emits:["click"],setup(t,{emit:o}){const a=t,i=o;function l(u){a.disabled||i("click",u)}return(u,s)=>(r(),H(Ue(t.as),{type:t.as==="button"?"button":void 0,disabled:t.as==="button"?t.disabled:void 0,onClick:l,class:ae(["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:D(()=>[je(u.$slots,"default")]),_:3},8,["type","disabled","class"]))}}),hn={class:"relative inline-flex group"},dr=me({__name:"UiTooltip",props:{content:{},position:{default:"top"}},setup(t){const o=t,a=B(()=>{switch(o.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"}}),i=B(()=>{switch(o.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(),n("div",hn,[je(l.$slots,"default"),e("div",{class:ae(["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"},[Z(C(t.content)+" ",1),e("div",{class:ae(["absolute border-4",i.value])},null,2)],2)]))}}),Nr=me({__name:"UiCodeBlock",props:{inline:{type:Boolean,default:!0}},setup(t){return(o,a)=>(r(),H(Ue(t.inline?"code":"pre"),{class:ae(["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:D(()=>[je(o.$slots,"default")]),_:3},8,["class"]))}}),gn={key:0,class:"block text-zinc-700 dark:text-zinc-300 text-xs font-bold mb-1"},bn={key:0,class:"text-red-500"},xn=["disabled","aria-expanded"],yn={key:0,class:"flex items-center gap-2 text-zinc-400 flex-1 min-w-0"},kn=["src","alt"],wn={class:"block truncate"},_n={key:2,class:"block truncate text-zinc-400 flex-1 min-w-0"},$n=["placeholder"],Cn=["onClick","onMouseenter"],Sn=["src","alt"],Tn={key:1,class:"w-full h-full bg-zinc-200 dark:bg-zinc-700 rounded"},In={class:"flex-1 min-w-0"},Ge=me({__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:o}){const a=t,i=o,l=p(!1),u=p(""),s=p(),m=p(),h=p(),x=p(),c=p(-1),f=B(()=>a.options.find(G=>G.value===a.modelValue)),y=B(()=>{const G=a.activeHighlight&&f.value,ee=a.size==="sm"?"!text-xs !py-1 !px-2":"",se=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,se,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,se,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"]}),b=B(()=>{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))});ge(b,()=>{c.value=-1});const v=()=>{a.disabled||(l.value?g():(l.value=!0,u.value="",c.value=-1,Le(()=>{if(x.value&&(x.value.setAttribute("popover","auto"),x.value.addEventListener("toggle",z),"showPopover"in x.value))try{x.value.showPopover()}catch{}_(),setTimeout(()=>s.value?.focus(),0)})))},d=G=>{i("update:modelValue",G.value),g(),u.value="",c.value=-1},k=G=>{G.stopPropagation(),i("update:modelValue","")},g=()=>{if(x.value){if("hidePopover"in x.value)try{x.value.hidePopover()}catch{}x.value.removeEventListener("toggle",z)}l.value=!1,c.value=-1},_=()=>{if(!h.value||!x.value)return;const G=h.value.getBoundingClientRect(),ee=window.innerWidth;x.value.style.position="fixed",x.value.style.top=`${G.bottom+8}px`,x.value.style.left=`${G.left}px`,x.value.style.margin="0",x.value.style.width="max-content";const se=x.value.offsetWidth,de=G.width,Q=Math.min(400,ee-G.left-16),E=Math.max(de,Math.min(se,Q));x.value.style.width=`${E}px`},L=G=>{m.value&&!m.value.contains(G.target)&&x.value&&!x.value.contains(G.target)&&g()},R=G=>{G.key==="Escape"&&l.value&&(g(),h.value?.focus())},K=G=>{if(!l.value)return;const ee=b.value;if(ee.length!==0)switch(G.key){case"ArrowDown":G.preventDefault(),c.value=c.value<ee.length-1?c.value+1:0,Y();break;case"ArrowUp":G.preventDefault(),c.value=c.value>0?c.value-1:ee.length-1,Y();break;case"Enter":G.preventDefault(),c.value>=0&&c.value<ee.length&&d(ee[c.value]);break}},Y=()=>{Le(()=>{const G=x.value?.querySelector(".highlighted-option");G&&G.scrollIntoView({block:"nearest",behavior:"smooth"})})},z=G=>{G.target===x.value&&(l.value=G.newState==="open",l.value&&_())},P=()=>{l.value&&_()};return Pe(()=>{document.addEventListener("click",L),document.addEventListener("keydown",R),window.addEventListener("resize",P),window.addEventListener("scroll",P,!0)}),Ye(()=>{document.removeEventListener("click",L),document.removeEventListener("keydown",R),window.removeEventListener("resize",P),window.removeEventListener("scroll",P,!0)}),(G,ee)=>(r(),n("div",{ref_key:"dropdownRef",ref:m,class:"relative"},[t.label?(r(),n("label",gn,[Z(C(t.label)+" ",1),t.required?(r(),n("span",bn,"*")):I("",!0)])):I("",!0),e("button",{ref_key:"buttonRef",ref:h,type:"button",onClick:v,disabled:t.disabled,"aria-expanded":l.value,"aria-haspopup":!0,class:ae(y.value)},[e("div",{class:ae(["flex items-center gap-1 w-full",t.size==="sm"?"min-h-[1.25em]":"min-h-[1.5em]"])},[t.loading?(r(),n("span",yn,[w(Ee,{size:"xs"}),ee[1]||(ee[1]=Z(" Loading... ",-1))])):f.value?(r(),n("span",{key:1,class:ae(["flex items-center flex-1 min-w-0",t.size==="sm"?"gap-1.5":"gap-2"])},[f.value.icon?(r(),n("img",{key:0,src:f.value.icon,alt:f.value.label,class:ae(["flex-shrink-0",[t.size==="sm"?"w-4 h-4":"w-5 h-5",f.value.icon.startsWith("data:image/svg+xml")?"dark:invert":""]])},null,10,kn)):I("",!0),e("span",wn,C(f.value.label),1)],2)):(r(),n("span",_n,C(t.placeholder),1)),f.value&&!t.disabled?(r(),n("button",{key:3,type:"button",onClick:k,class:"flex-shrink-0 p-0.5 hover:bg-zinc-100 dark:hover:bg-zinc-800 rounded transition-colors","aria-label":"Clear selection"},[(r(),n("svg",{class:ae(["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))])):I("",!0),(r(),n("svg",{class:ae(["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,xn),l.value?(r(),n("div",{key:1,ref_key:"popoverRef",ref:x,class:"dropdown-popover z-[9999]"},[w(T(At),{"max-height":t.size==="sm"?"max-h-48":"max-h-60",shadow:{offsetX:4,offsetY:4,intensity:.3}},{header:D(()=>[e("div",{class:ae(t.size==="sm"?"p-1.5":"p-2")},[Ae(e("input",{ref_key:"searchInput",ref:s,"onUpdate:modelValue":ee[0]||(ee[0]=se=>u.value=se),type:"text",placeholder:t.searchPlaceholder,onKeydown:K,class:ae(["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,$n),[[Qe,u.value]])],2)]),default:D(()=>[b.value.length===0?(r(),n("div",{key:0,class:ae(["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)):I("",!0),(r(!0),n(ve,null,ye(b.value,(se,de)=>(r(),n("button",{key:se.value,type:"button",onClick:Q=>d(se),onMouseenter:Q=>c.value=de,class:ae(["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":se.value===t.modelValue,"bg-zinc-100 dark:bg-zinc-800 highlighted-option":de===c.value}]])},[e("div",{class:ae(["flex-shrink-0 mt-0.5",t.size==="sm"?"w-4 h-4":"w-5 h-5"])},[se.icon?(r(),n("img",{key:0,src:se.icon,alt:se.label,class:ae(["w-full h-full",se.icon.startsWith("data:image/svg+xml")?"dark:invert":""])},null,10,Sn)):(r(),n("div",Tn))],2),e("div",In,[e("div",{class:ae(["font-medium text-black dark:text-white",t.size==="sm"?"text-xs":"text-sm"])},C(se.label),3),se.description?(r(),n("div",{key:0,class:ae(["text-zinc-500 dark:text-zinc-400 mt-0.5",t.size==="sm"?"text-[10px]":"text-xs"])},C(se.description),3)):I("",!0)])],42,Cn))),128))]),_:1},8,["max-height"])],512)):I("",!0),t.error?(r(),H(T(tt),{key:2,class:"mt-1"},{default:D(()=>[Z(C(t.error),1)]),_:1})):I("",!0)],512))}}),zn=["type","value","placeholder","disabled"],lt=me({__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:o,emit:a}){const i=t,l=a,u=p(null),s=B(()=>["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",i.error?"border-red-500 dark:border-red-400":"border-neutral-300 dark:border-neutral-800",i.disabled?"opacity-50 cursor-not-allowed":""]),m=c=>{const f=c.target;l("update:modelValue",f.value)},h=c=>{l("focus",c)},x=c=>{l("click",c)};return o({inputRef:u}),(c,f)=>(r(),H(T(ct),{label:t.label,error:t.error,required:t.required},{default:D(()=>[e("input",{ref_key:"inputRef",ref:u,type:t.type,value:t.modelValue,placeholder:t.placeholder,disabled:t.disabled,class:ae(s.value),onInput:m,onFocus:h,onClick:x},null,42,zn)]),_:1},8,["label","error","required"]))}}),Vn=["data-property-id","data-nested-property-id"],Mn={class:"p-3 space-y-3"},En={class:"flex items-start gap-2"},Ln={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"},Pn={class:"flex-1 grid grid-cols-1 md:grid-cols-3 gap-2"},An={class:"flex items-center gap-2 mt-2"},jn=["disabled"],Dn={key:0},On={key:0,class:"p-3 bg-neutral-50 dark:bg-neutral-900 rounded-lg space-y-2"},Rn={class:"flex items-center justify-between mb-2"},Un=["disabled"],Bn={key:0,class:"space-y-1"},Fn=["onClick","disabled"],Nn={key:1,class:"p-3 bg-neutral-50 dark:bg-neutral-900 rounded-lg"},qn={class:"text-xs font-medium text-neutral-600 dark:text-neutral-400 mb-2"},Hn={class:"space-y-2"},Wn={class:"flex items-center justify-between"},Kn=["disabled"],Jn={class:"space-y-2"},Yn={key:2,class:"p-3 bg-neutral-50 dark:bg-neutral-900 rounded-lg"},Gn={key:0,class:"mb-2"},Zn=["disabled"],Xn={key:1,class:"space-y-2"},Qn=me({__name:"PropertyEditor",props:Ze({propertyId:{},isNested:{type:Boolean,default:!1},parentId:{},disabled:{type:Boolean,default:!1},enableDrag:{type:Boolean,default:!0}},{modelValue:{required:!0},modelModifiers:{}}),emits:Ze(["remove","description-keydown","add-top-level"],["update:modelValue"]),setup(t,{emit:o}){const a=t,i=o,l=it(t,"modelValue"),u=p(["object","array","enum","anyOf"].includes(l.value.type));p();const s=[{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"}],m=B(()=>["object","array","enum","anyOf"].includes(l.value.type));ge(()=>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 Le();const k=a.isNested?`[data-nested-property-id="${a.propertyId}"] input[placeholder="Description"]`:`[data-property-id="${a.propertyId}"] input[placeholder="Description"]`,g=document.querySelector(k);g&&g.focus()}},{immediate:!0,flush:"sync"});const h=v=>{v.shiftKey&&l.value.type==="object"&&l.value.properties?y():i("add-top-level")},x=()=>{l.value.items||(l.value.items={id:crypto.randomUUID(),name:"",type:"string",description:""})},c=()=>{l.value.enum||(l.value.enum=[]),l.value.enum.push(`value${l.value.enum.length+1}`)},f=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 Le();const d=document.querySelector(`[data-nested-property-id="${v.id}"] input[placeholder="Property name"]`);d&&(d.focus(),d.select())},b=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 k=Be("PropertyEditor",!0);return r(),n("div",{"data-property-id":t.isNested?void 0:t.propertyId,"data-nested-property-id":t.isNested?t.propertyId:void 0,class:ae(["border rounded-lg",t.isNested?"border-neutral-100 dark:border-neutral-900":"border-neutral-200 dark:border-neutral-800"])},[e("div",Mn,[e("div",En,[t.enableDrag?(r(),n("div",Ln,[...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)])])):I("",!0),e("div",Pn,[w(lt,{modelValue:l.value.name,"onUpdate:modelValue":d[0]||(d[0]=g=>l.value.name=g),placeholder:"Property name",disabled:t.disabled},null,8,["modelValue","disabled"]),w(Ge,{modelValue:l.value.type,"onUpdate:modelValue":d[1]||(d[1]=g=>l.value.type=g),options:s,disabled:t.disabled},null,8,["modelValue","disabled"]),w(lt,{modelValue:l.value.description,"onUpdate:modelValue":d[2]||(d[2]=g=>l.value.description=g),placeholder:"Description",disabled:t.disabled,onKeydown:d[3]||(d[3]=Ca(Re(g=>h(g),["prevent"]),["enter"]))},null,8,["modelValue","disabled"])]),e("div",An,[m.value?(r(),n("button",{key:0,onClick:d[4]||(d[4]=g=>u.value=!u.value),type:"button",class:"p-1 hover:bg-neutral-100 dark:hover:bg-neutral-800 rounded transition-colors"},[(r(),n("svg",{class:ae(["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))])):I("",!0),e("button",{onClick:d[5]||(d[5]=g=>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,jn)])]),u.value&&m.value?(r(),n("div",Dn,[l.value.type==="enum"?(r(),n("div",On,[e("div",Rn,[d[13]||(d[13]=e("h4",{class:"text-xs font-medium text-neutral-600 dark:text-neutral-400"}," Enum Values ",-1)),e("button",{onClick:c,type:"button",disabled:t.disabled,class:"px-2 py-0.5 text-xs bg-neutral-800 dark:bg-neutral-200 text-white dark:text-black rounded hover:bg-neutral-700 dark:hover:bg-neutral-300 transition-colors disabled:opacity-50"}," Add Value ",8,Un)]),l.value.enum?(r(),n("div",Bn,[(r(!0),n(ve,null,ye(l.value.enum,(g,_)=>(r(),n("div",{key:_,class:"flex items-center gap-2"},[w(lt,{modelValue:l.value.enum[_],"onUpdate:modelValue":L=>l.value.enum[_]=L,placeholder:"Enum value",disabled:t.disabled,class:"flex-1"},null,8,["modelValue","onUpdate:modelValue","disabled"]),e("button",{onClick:L=>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,Fn)]))),128))])):I("",!0)])):I("",!0),l.value.type==="object"||l.value.type==="anyOf"?(r(),n("div",Nn,[e("h4",qn,C(l.value.type==="anyOf"?"Type Options":"Nested Properties"),1),e("div",Hn,[e("div",Wn,[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,Kn)]),e("div",Jn,[(r(!0),n(ve,null,ye(l.value.type==="anyOf"?l.value.anyOf:l.value.properties,(g,_)=>(r(),H(k,{key:g.id,modelValue:(l.value.type==="anyOf"?l.value.anyOf:l.value.properties)[_],"onUpdate:modelValue":L=>(l.value.type==="anyOf"?l.value.anyOf:l.value.properties)[_]=L,"property-id":g.id,"is-nested":!0,"parent-id":t.propertyId,disabled:t.disabled,"enable-drag":!1,onRemove:L=>b(g.id),onAddTopLevel:d[6]||(d[6]=L=>i("add-top-level"))},null,8,["modelValue","onUpdate:modelValue","property-id","parent-id","disabled","onRemove"]))),128))])])])):I("",!0),l.value.type==="array"?(r(),n("div",Yn,[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?I("",!0):(r(),n("div",Gn,[e("button",{onClick:x,type:"button",disabled:t.disabled,class:"px-2 py-0.5 text-xs bg-neutral-800 dark:bg-neutral-200 text-white dark:text-black rounded hover:bg-neutral-700 dark:hover:bg-neutral-300 transition-colors disabled:opacity-50"}," Define Item Type ",8,Zn)])),l.value.items?(r(),n("div",Xn,[(r(),H(k,{key:`${l.value.items.id}-${l.value.items.type}`,modelValue:l.value.items,"onUpdate:modelValue":d[7]||(d[7]=g=>l.value.items=g),"property-id":l.value.items.id,"is-nested":!0,"parent-id":t.propertyId,disabled:t.disabled,"enable-drag":!1,onRemove:d[8]||(d[8]=g=>l.value.items=null),onAddTopLevel:d[9]||(d[9]=g=>i("add-top-level"))},null,8,["modelValue","property-id","parent-id","disabled"]))])):I("",!0)])):I("",!0)])):I("",!0)])],10,Vn)}}}),el={class:"space-y-2"},tl=["disabled"],rl=me({__name:"PropertyList",props:Ze({disabled:{type:Boolean,default:!1},parentId:{},isNested:{type:Boolean,default:!1}},{modelValue:{required:!0,default:()=>[]},modelModifiers:{}}),emits:Ze(["add-property","description-keydown"],["update:modelValue"]),setup(t,{expose:o,emit:a}){const i=t,l=a,u=it(t,"modelValue"),s=p();let m=!1;Pe(async()=>{}),Ye(()=>{});const h=async()=>{if(m)return;m=!0;const c={id:crypto.randomUUID(),name:`property${u.value.length+1}`,type:"string",description:"",required:!1};u.value=[...u.value,c],await Le();const f=i.parentId?`[data-nested-property-id="${c.id}"]`:`[data-property-id="${c.id}"]`,y=document.querySelector(`${f} input[placeholder="Property name"]`);y&&(y.focus(),y.select()),l("add-property"),m=!1},x=c=>{u.value=u.value.filter(f=>f.id!==c)};return o({addProperty:h}),(c,f)=>(r(),n("div",el,[e("div",{ref_key:"dragAreaRef",ref:s,class:"space-y-2"},[(r(!0),n(ve,null,ye(u.value,y=>(r(),H(Qn,{key:y.id,modelValue:u.value[u.value.indexOf(y)],"onUpdate:modelValue":b=>u.value[u.value.indexOf(y)]=b,"property-id":y.id,"is-nested":t.isNested,"parent-id":t.parentId,disabled:t.disabled,"enable-drag":!t.isNested,onRemove:b=>x(y.id),onAddTopLevel:f[0]||(f[0]=b=>c.$emit("add-property"))},null,8,["modelValue","onUpdate:modelValue","property-id","is-nested","parent-id","disabled","enable-drag","onRemove"]))),128))],512),e("div",{class:ae(t.isNested?"mt-2":"mt-3 pt-3 border-t border-neutral-200 dark:border-neutral-800")},[e("button",{onClick:h,type:"button",disabled:t.disabled,class:ae(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")},[...f[1]||(f[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"})]),Z(" Add Property ")],-1)])],10,tl)],2)]))}}),al={class:"space-y-4"},ol={key:0,class:"flex items-center justify-between"},nl={class:"text-sm font-medium"},ll={key:0,class:"text-red-500"},sl={class:"space-y-2 border border-neutral-200 dark:border-neutral-800 rounded-lg p-4"},il={key:0,class:"flex items-center justify-between mb-2"},ul={key:1,class:"text-center py-12"},dl=["disabled"],cl={class:"mt-4 text-center"},pl={key:3,class:"mt-4"},ml={class:"bg-neutral-50 dark:bg-neutral-900 border border-neutral-200 dark:border-neutral-800 rounded-lg p-4 overflow-x-auto"},vl={class:"text-xs leading-relaxed"},fl=["innerHTML"],qr=me({__name:"JSONSchemaInput",props:Ze({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 o=it(t,"modelValue"),a=p([]),i=p(),l=p(!1),u=()=>{if(o.value?.properties){const v=[];o.value.required;for(const[d,k]of Object.entries(o.value.properties)){const g=k,_={id:crypto.randomUUID(),name:d,type:g.type||"string",description:g.description||""};g.enum&&(_.enum=g.enum),g.anyOf&&(_.type="anyOf",_.anyOf=s(g.anyOf)),g.type==="array"&&g.items&&(_.items=m(g.items)),g.type==="object"&&g.properties&&(_.properties=h(g.properties,g.required||[])),v.push(_)}a.value=v}},s=v=>v.map(d=>typeof d=="object"&&d.type?{id:crypto.randomUUID(),name:"",type:d.type,description:d.description||"",properties:d.properties?h(d.properties,d.required||[]):void 0,items:d.items?m(d.items):void 0,enum:d.enum}:{id:crypto.randomUUID(),name:"",type:"string",description:""}),m=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=s(v.anyOf)),v.type==="array"&&v.items&&(d.items=m(v.items)),v.type==="object"&&v.properties&&(d.properties=h(v.properties,v.required||[])),d},h=(v,d)=>{const k=[];for(const[g,_]of Object.entries(v)){const L=_,R={id:crypto.randomUUID(),name:g,type:L.type||"string",description:L.description||""};L.enum&&(R.enum=L.enum),L.anyOf&&(R.type="anyOf",R.anyOf=s(L.anyOf)),L.type==="array"&&L.items&&(R.items=m(L.items)),L.type==="object"&&L.properties&&(R.properties=h(L.properties,L.required||[])),k.push(R)}return k};u();const x=()=>{const v={type:"object",properties:{},required:[],additionalProperties:!1},{properties:d}=f(a.value);v.properties=d,v.required=Object.keys(d),o.value=v},c=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(c)),v.type==="object"&&v.properties){const{properties:k}=f(v.properties);d.properties=k,d.required=Object.keys(k),d.additionalProperties=!1}return v.type==="array"&&v.items&&(d.items=c(v.items)),d},f=v=>{const d={},k=[];for(const g of v){const _={type:g.type==="anyOf"?void 0:g.type,description:g.description};if(k.push(g.name),g.type==="enum"&&g.enum&&(_.enum=g.enum,_.type="string"),g.type==="anyOf"&&g.anyOf&&g.anyOf.length>0&&(delete _.type,_.anyOf=g.anyOf.map(c)),g.type==="array"&&g.items&&(_.items=c(g.items)),g.type==="object"&&g.properties){const{properties:L}=f(g.properties);_.properties=L,_.required=Object.keys(L),_.additionalProperties=!1}d[g.name]=_}return{properties:d,required:k}};ge(a,()=>{x()},{deep:!0}),x();const y=B(()=>JSON.stringify(o.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>')),b=async()=>{if(a.value.length===0){const v={id:crypto.randomUUID(),name:"property1",type:"string",description:""};a.value.push(v),await Le();const d=document.querySelector(`[data-property-id="${v.id}"] input[placeholder="Property name"]`);d&&(d.focus(),d.select())}else i.value&&i.value.addProperty()};return(v,d)=>(r(),n("div",al,[t.label?(r(),n("div",ol,[e("label",nl,[Z(C(t.label)+" ",1),t.required?(r(),n("span",ll,"*")):I("",!0)])])):I("",!0),e("div",sl,[a.value.length>0?(r(),n("div",il,[...d[2]||(d[2]=[e("h3",{class:"text-sm font-medium text-neutral-700 dark:text-neutral-300"}," Properties ",-1)])])):I("",!0),a.value.length===0?(r(),n("div",ul,[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:b,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"})]),Z(" Add Property ")],-1)])],8,dl)])):I("",!0),a.value.length>0?(r(),H(rl,{key:2,ref_key:"propertyListRef",ref:i,modelValue:a.value,"onUpdate:modelValue":d[0]||(d[0]=k=>a.value=k),disabled:t.disabled,onAddProperty:b},null,8,["modelValue","disabled"])):I("",!0),e("div",cl,[e("button",{onClick:d[1]||(d[1]=k=>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(),n("div",pl,[e("div",ml,[e("pre",vl,[e("code",{class:"font-mono",innerHTML:y.value},null,8,fl)])])])):I("",!0)])]))}}),hl=gt(Ie(qr),{props:["label","disabled","required"],family:"text",features:[]}),gl={class:"space-y-2"},bl={key:0,class:"space-y-2"},xl={key:0,class:"block text-sm font-medium"},yl={key:0,class:"text-red-500"},kl=["src","alt"],wl={class:"flex-1 text-sm"},_l={key:0,class:"text-xs text-neutral-500 dark:text-neutral-400 ml-1"},$l=["onClick","aria-label"],ht=me({__name:"MultipleSelectionsInput",props:Ze({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:Ze(["removeItem"],["update:modelValue"]),setup(t,{emit:o}){const a=t,i=o,l=it(t,"modelValue"),u=p();Tr(async()=>{u.value,await Le(),await Ir({parent:u,values:l,dragHandle:".drag-handle"})});const s=B(()=>Array.isArray(l.value)?l.value.length>0&&typeof l.value[0]=="object"?l.value:l.value.map(c=>{const f=a.options.find(y=>y.value===c);return{id:c,label:f?.label||c,description:f?.description,icon:f?.icon}}):[]),m=B(()=>{const c=s.value.map(f=>f.id);return a.options.filter(f=>!c.includes(f.value))}),h=c=>{if(!c)return;const f=a.options.find(y=>y.value===c);if(f)if(l.value.length===0||typeof l.value[0]=="string")l.value=[...l.value,c];else{const y={id:c,label:f.label,description:f.description,icon:f.icon};l.value=[...l.value,y]}},x=c=>{typeof l.value[0]=="string"?l.value=l.value.filter(f=>f!==c):l.value=l.value.filter(f=>f.id!==c),i("removeItem",c)};return(c,f)=>(r(),n("div",gl,[s.value.length>0?(r(),n("div",bl,[t.label?(r(),n("label",xl,[Z(C(t.label)+" ",1),t.required?(r(),n("span",yl,"*")):I("",!0)])):I("",!0),e("div",{class:"space-y-1",ref_key:"dragAreaRef",ref:u},[(r(!0),n(ve,null,ye(s.value,y=>(r(),n("div",{key:y.id,class:ae(["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":""])},[f[1]||(f[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(),n("img",{key:0,src:y.icon,alt:y.label,class:"w-4 h-4 flex-shrink-0"},null,8,kl)):I("",!0),e("span",wl,[Z(C(y.label)+" ",1),y.description?(r(),n("span",_l," ("+C(y.description)+") ",1)):I("",!0)]),t.disabled?I("",!0):(r(),n("button",{key:1,onClick:b=>x(y.id),type:"button",class:"p-1 hover:bg-neutral-200 dark:hover:bg-neutral-800 rounded transition-colors","aria-label":`Remove ${y.label}`},[...f[0]||(f[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,$l))],2))),128))],512)])):I("",!0),w(Ge,{"model-value":"","onUpdate:modelValue":h,label:s.value.length>0?t.addLabel:t.label,options:m.value,placeholder:t.placeholder,"search-placeholder":t.searchPlaceholder,disabled:t.disabled||m.value.length===0,loading:t.loading},null,8,["label","options","placeholder","search-placeholder","disabled","loading"]),t.error?(r(),H(T(tt),{key:1},{default:D(()=>[Z(C(t.error),1)]),_:1})):I("",!0)]))}});function Cl(){return window.__AGENTBUILDER_CONFIG__||{mountPoint:"/agentbuilder"}}function _t(){return Cl().mountPoint}function fe(t){const o=_t(),a=t.startsWith("/")?t:`/${t}`;return o==="/"?a:`${o}${a}`}const Sl=me({__name:"ModelSelectorInput",props:Ze({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 o=t,a=it(t,"modelValue"),i=p([]),l=p(!1),u=B(()=>i.value.map(h=>({value:h.id,label:h.name,description:h.provider_id||h.provider,icon:h.iconId}))),s=async()=>{l.value=!0;try{const h=await fetch(fe("/api/models"));if(h.ok){const x=await h.json();i.value=x.models||[]}}catch(h){console.error("Error fetching models:",h)}finally{l.value=!1}},m=h=>{};return Pe(()=>{s()}),ge(()=>o.allowMultiple,()=>{o.allowMultiple&&typeof a.value=="string"?a.value=a.value?[a.value]:[]:!o.allowMultiple&&Array.isArray(a.value)&&(a.value=a.value[0]||"")}),(h,x)=>(r(),n(ve,null,[t.allowMultiple?(r(),H(ht,{key:0,modelValue:a.value,"onUpdate:modelValue":x[0]||(x[0]=c=>a.value=c),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:m},null,8,["modelValue","label","placeholder","error","required","disabled","options","loading"])):(r(),H(Ge,{key:1,modelValue:a.value,"onUpdate:modelValue":x[1]||(x[1]=c=>a.value=c),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(),H(T(tt),{key:2,class:"mt-1"},{default:D(()=>[Z(C(t.error),1)]),_:1})):I("",!0)],64))}}),Tl=me({__name:"AgentSelectorInput",props:Ze({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 o=t,a=it(t,"modelValue"),i=p([]),l=p(!1),u=B(()=>i.value.map(h=>({value:h.id,label:h.title,description:h.tool_description||`Handoff to ${h.title} agent`}))),s=async()=>{l.value=!0;try{const h=fe(`/api/agents${o.agentType?`?type=${o.agentType}`:""}`),x=await fetch(h);if(x.ok){const c=await x.json();i.value=c.agents||[]}}catch(h){console.error("Error fetching agents:",h)}finally{l.value=!1}},m=h=>{};return Pe(()=>{s()}),ge(()=>o.allowMultiple,()=>{o.allowMultiple&&typeof a.value=="string"?a.value=a.value?[a.value]:[]:!o.allowMultiple&&Array.isArray(a.value)&&(a.value=a.value[0]||"")},{immediate:!0}),(h,x)=>(r(),n(ve,null,[t.allowMultiple?(r(),H(ht,{key:0,modelValue:a.value,"onUpdate:modelValue":x[0]||(x[0]=c=>a.value=c),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:m},null,8,["modelValue","label","placeholder","error","required","disabled","options","loading"])):(r(),H(Ge,{key:1,modelValue:a.value,"onUpdate:modelValue":x[1]||(x[1]=c=>a.value=c),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(),H(T(tt),{key:2,class:"mt-1"},{default:D(()=>[Z(C(t.error),1)]),_:1})):I("",!0)],64))}}),Il=me({__name:"ToolSelectorInput",props:Ze({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 o=t,a=it(t,"modelValue"),i=p([]),l=p(!1),u=B(()=>i.value.map(h=>{let x=h.name;return h.type==="prompt"?x=`${h.name} (prompt)`:h.type==="mcp"&&(x=`${h.name} (mcp)`),{value:h.name,label:x,description:h.description}})),s=async()=>{l.value=!0;try{const h=await fetch(fe("/api/tools"));if(h.ok){const x=await h.json();i.value=Object.entries(x).map(([c,f])=>({name:c,description:f.description||"",type:f.type,model:f.model}))}}catch(h){console.error("Error fetching tools:",h)}finally{l.value=!1}},m=h=>{};return Pe(()=>{s()}),ge(()=>o.allowMultiple,()=>{o.allowMultiple&&typeof a.value=="string"?a.value=a.value?[a.value]:[]:!o.allowMultiple&&Array.isArray(a.value)&&(a.value=a.value[0]||"")},{immediate:!0}),(h,x)=>(r(),n(ve,null,[t.allowMultiple?(r(),H(ht,{key:0,modelValue:a.value,"onUpdate:modelValue":x[0]||(x[0]=c=>a.value=c),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:m},null,8,["modelValue","label","placeholder","error","required","disabled","options","loading"])):(r(),H(Ge,{key:1,modelValue:a.value,"onUpdate:modelValue":x[1]||(x[1]=c=>a.value=c),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(),H(T(tt),{key:2,class:"mt-1"},{default:D(()=>[Z(C(t.error),1)]),_:1})):I("",!0)],64))}}),zl=gt(Ie(Sl),{props:["label","placeholder","error","required","disabled","allowMultiple"],family:"dropdown",features:[]}),Vl=gt(Ie(Tl),{props:["label","placeholder","error","required","disabled","allowMultiple","agentType"],family:"dropdown",features:[]}),Ml=gt(Ie(Il),{props:["label","placeholder","error","required","disabled","allowMultiple"],family:"dropdown",features:[]}),El={class:"space-y-4"},Ll={class:"flex items-start gap-2"},Pl={class:"flex-1"},Al=["onClick","disabled","title"],jl={key:0,class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},Dl={key:1,class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},Ol={key:0,class:"text-xs text-neutral-400 dark:text-neutral-500 mt-1"},Rl={key:0,class:"text-amber-500 dark:text-amber-400 ml-1"},Ul={class:"flex-1"},Bl={class:"flex-1"},Fl=["onClick","disabled"],Nl=["disabled"],Zt=me({__name:"TenvPropertyList",props:{modelValue:{},inherited:{default:()=>[]},allowCustom:{type:Boolean,default:!0},disabled:{type:Boolean,default:!1}},emits:["update:modelValue"],setup(t,{emit:o}){const a=t,i=o,l=p(new Set),u=p([]),s=B(()=>new Set(a.inherited.map(d=>d.name)));ge(()=>a.modelValue,d=>{const k=Object.keys(d).filter(_=>!s.value.has(_)),g=new Set(u.value.map(_=>_.name));for(const _ of k)g.has(_)||u.value.push({id:crypto.randomUUID(),name:_,value:String(d[_]??"")})},{immediate:!0,deep:!0});const m=d=>{if(l.value.has(d)){l.value.delete(d);const k=a.inherited.find(g=>g.name===d);k&&h(d,k.value)}else l.value.add(d)},h=(d,k)=>{const g={...a.modelValue};k===void 0||k===""?delete g[d]:g[d]=k,i("update:modelValue",g)},x=d=>a.modelValue[d.name]!==void 0?String(a.modelValue[d.name]):d.value!==void 0?String(d.value):"",c=(d,k)=>{h(d.name,k||void 0)},f=()=>{u.value.push({id:crypto.randomUUID(),name:"",value:""})},y=d=>{const k=u.value.find(g=>g.id===d);if(k&&k.name){const g={...a.modelValue};delete g[k.name],i("update:modelValue",g)}u.value=u.value.filter(g=>g.id!==d)},b=(d,k,g)=>{const _=u.value.find(R=>R.id===d);if(!_)return;_.name=g;const L={...a.modelValue};k&&delete L[k],g&&_.value&&(L[g]=_.value),i("update:modelValue",L)},v=(d,k)=>{const g=u.value.find(_=>_.id===d);g&&(g.value=k,g.name&&h(g.name,k||void 0))};return(d,k)=>(r(),n("div",El,[(r(!0),n(ve,null,ye(t.inherited,g=>(r(),n("div",{key:g.name,class:"relative"},[e("div",Ll,[e("div",Pl,[w(lt,{"model-value":x(g),label:g.name,placeholder:g.description||"Enter value...",disabled:t.disabled||!l.value.has(g.name),required:g.required,"onUpdate:modelValue":_=>c(g,_)},null,8,["model-value","label","placeholder","disabled","required","onUpdate:modelValue"])]),e("button",{type:"button",onClick:_=>m(g.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(g.name)?"Lock (use inherited value)":"Unlock to override"},[l.value.has(g.name)?(r(),n("svg",Dl,[...k[1]||(k[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(),n("svg",jl,[...k[0]||(k[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,Al)]),g.source?(r(),n("p",Ol,[Z(" From: "+C(g.source)+" ",1),g.required?(r(),n("span",Rl,"(required)")):I("",!0)])):I("",!0)]))),128)),(r(!0),n(ve,null,ye(u.value,g=>(r(),n("div",{key:g.id,class:"flex items-start gap-2"},[e("div",Ul,[w(lt,{"model-value":g.name,label:"Name",placeholder:"Variable name",disabled:t.disabled,"onUpdate:modelValue":_=>b(g.id,g.name,_)},null,8,["model-value","disabled","onUpdate:modelValue"])]),e("div",Bl,[w(lt,{"model-value":g.value,label:"Value",placeholder:"Variable value",disabled:t.disabled,"onUpdate:modelValue":_=>v(g.id,_)},null,8,["model-value","disabled","onUpdate:modelValue"])]),e("button",{type:"button",onClick:_=>y(g.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"},[...k[2]||(k[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,Fl)]))),128)),t.allowCustom?(r(),n("button",{key:0,type:"button",onClick:f,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"},[...k[3]||(k[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"})]),Z(" Add custom variable ")],-1)])],8,Nl)):I("",!0)]))}}),ql=gt(Ie(Zt),{props:["inherited","allowCustom","disabled"],family:"text",features:[]}),Hl={class:"space-y-3 mt-3 pt-3 border-t border-neutral-200 dark:border-neutral-700"},Wl={class:"space-y-2 pl-4 border-l-2 border-accent-200 dark:border-accent-700"},Kl={class:"space-y-2 pl-4 border-l-2 border-neutral-200 dark:border-neutral-700"},Jl=me({__name:"PromptToolOptions",props:{toolName:{},toolConfig:{},toolType:{default:"prompt"},disabled:{type:Boolean}},emits:["update:option"],setup(t,{emit:o}){const a=t,i=o,l=p(null),u=p(!0),s=B(()=>l.value?.properties?Object.entries(l.value.properties).map(([x,c])=>({value:x,label:x,attrs:{description:c.description||c.type||""}})):[]),m=async()=>{try{let x=a.toolName;if(a.toolType==="handoff"||a.toolType==="subagent"){const f=await fetch(fe(`/api/agents/${encodeURIComponent(a.toolName)}`));if(f.ok){if(x=(await f.json())?.agent?.side_a_agent_prompt,!x){u.value=!1;return}}else{u.value=!1;return}}const c=await fetch(fe(`/api/prompts/${encodeURIComponent(x)}`));if(c.ok){const f=await c.json();f?.prompt?.required_schema&&(l.value=f.prompt.required_schema)}}catch(x){console.error("Error fetching prompt schema:",x)}finally{u.value=!1}};Pe(()=>{m()});const h=(x,c)=>{i("update:option",x,c)};return(x,c)=>{const f=Be("FormKit");return r(),n("div",Hl,[e("div",Wl,[c[5]||(c[5]=e("p",{class:"text-xs font-medium text-neutral-600 dark:text-neutral-400 mb-2"}," Initialization Options: ",-1)),w(f,{type:"selectSearch",value:t.toolConfig.init_user_message_property||"",onInput:c[0]||(c[0]=y=>h("init_user_message_property",y||null)),label:"User message property",placeholder:"Don't inject a user message",options:s.value,disabled:t.disabled||u.value||s.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(f,{type:"selectSearch",value:t.toolConfig.init_attachments_property||"",onInput:c[1]||(c[1]=y=>h("init_attachments_property",y||null)),label:"Attachments property",placeholder:"Don't attach files",options:s.value,disabled:t.disabled||u.value||s.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"])]),e("div",Kl,[c[6]||(c[6]=e("p",{class:"text-xs font-medium text-neutral-600 dark:text-neutral-400 mb-2"}," Sub-Prompt Response Options: ",-1)),w(f,{type:"checkbox",value:t.toolConfig.include_text_response,onInput:c[2]||(c[2]=y=>h("include_text_response",y)),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(f,{type:"checkbox",value:t.toolConfig.include_tool_calls,onInput:c[3]||(c[3]=y=>h("include_tool_calls",y)),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(f,{type:"checkbox",value:t.toolConfig.include_errors,onInput:c[4]||(c[4]=y=>h("include_errors",y)),label:"Include errors",help:"Include error information if the sub-prompt fails",disabled:t.disabled,"outer-class":"$reset mb-0"},null,8,["value","disabled"])])])}}});async function Je(t,o={}){const a=localStorage.getItem("auth_token"),i={"Content-Type":"application/json",...o.headers};a&&(i.Authorization=`Bearer ${a}`);const l=t.startsWith("/")?t:`/${t}`,u=await fetch(fe(`/api${l}`),{...o,headers:i});if(u.status===401)throw localStorage.removeItem("auth_token"),window.location.href=fe("/login"),new Error("Unauthorized");return u}const Yl={class:"space-y-4"},Gl={class:"block text-sm font-medium mb-2"},Zl={key:0,class:"text-red-500"},Xl={class:"flex items-start justify-between"},Ql={class:"flex items-center gap-2 flex-1"},es={class:"flex-1"},ts={key:0,class:"text-xs text-neutral-500 dark:text-neutral-400 font-normal"},rs={key:1,class:"text-xs text-neutral-500 dark:text-neutral-400 font-normal"},as={key:2,class:"text-xs text-neutral-500 dark:text-neutral-400 font-normal"},os={key:3,class:"text-xs text-neutral-500 dark:text-neutral-400 font-normal"},ns={key:4,class:"text-xs text-neutral-500 dark:text-neutral-400 font-normal"},ls={key:0,class:"text-xs text-neutral-600 dark:text-neutral-400 mt-1"},ss={key:1,class:"text-xs text-amber-600 dark:text-amber-400 mt-1 flex items-center gap-1"},is=["onClick","disabled","aria-label"],us={key:0,class:"mt-3 pt-3 border-t border-neutral-200 dark:border-neutral-700"},ds={class:"space-y-2"},cs={key:0,class:"text-xs text-amber-500 dark:text-amber-400 whitespace-nowrap",title:"Required at agent or thread level"},ps={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"},Hr=me({__name:"ToolSelectorWithOptions",props:Ze({label:{default:"Available Tools"},placeholder:{default:"Select a tool"},error:{},required:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},modelId:{},providerId:{}},{modelValue:{required:!0,default:()=>[]},modelModifiers:{}}),emits:Ze(["unavailable-tools"],["update:modelValue"]),setup(t,{expose:o,emit:a}){const i=t,l=it(t,"modelValue"),u=p([]),s=p([]),m=p(!1),h=p(!1),x=p(),c=p(""),f=B(()=>[...u.value,...s.value]),y=B(()=>new Set(f.value.map(Q=>k(Q)))),b=Q=>(Q.startsWith("provider:"),y.value.has(Q)),v=B(()=>l.value.filter(Q=>!b(Q.name)).map(Q=>Q.name)),d=a;ge(v,Q=>{Q.length>0&&d("unavailable-tools",Q)},{immediate:!0}),Tr(async()=>{x.value,await Le(),x.value&&l.value.length>0&&await Ir({parent:x,values:l,dragHandle:".drag-handle"})});const k=Q=>Q.type==="provider"?`provider:${Q.name}`:Q.type==="mcp"?`mcp:${Q.name}`:Q.name,g=Q=>Q.startsWith("provider:")?Q.slice(9):Q.startsWith("mcp:")?Q.slice(4):Q,_=Q=>Q.startsWith("provider:")?"provider":Q.startsWith("mcp:")?"mcp":"tool",L=B(()=>{const Q=new Set(l.value.map(E=>E.name));return f.value.filter(E=>!Q.has(k(E))).map(E=>{let S=E.name;return E.type==="prompt"?S=`${E.name} (prompt)`:E.type==="mcp"?S=`${E.name} (mcp)`:E.type==="provider"?S=`${E.name} (provider)`:E.type==="handoff"?S=`${E.name} (handoff agent)`:E.type==="subagent"&&(S=`${E.name} (subagent)`),{value:k(E),label:S,attrs:{description:E.description}}})}),R=async()=>{m.value=!0;try{const Q=await Je("/tools");if(Q.ok){const E=await Q.json();u.value=Object.entries(E).map(([S,V])=>({name:S,description:V.description||"",type:V.type,model:V.model}))}}catch(Q){console.error("Error fetching tools:",Q)}finally{m.value=!1}},K=async()=>{if(!i.providerId||!i.modelId){s.value=[];return}h.value=!0;try{const Q=await Je(`/providers/${i.providerId}/tools?model=${encodeURIComponent(i.modelId)}`);if(Q.ok){const E=await Q.json();s.value=(E.tools||[]).map(S=>({name:S.name,description:S.description||"",type:"provider",tenvs:S.tenvs||[]}))}else s.value=[]}catch(Q){console.error("Error fetching provider tools:",Q),s.value=[]}finally{h.value=!1}};ge([()=>i.providerId,()=>i.modelId],async([Q,E])=>{Q&&E?await K():s.value=[]},{immediate:!0});const Y=Q=>{if(!Q||l.value.find(V=>V.name===Q))return;const E=P(Q),S={};if(E?.tenvs&&E.tenvs.length>0)for(const V of E.tenvs)S[V.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,...Object.keys(S).length>0?{tenvs:S}:{}}],Le(()=>{c.value=""})},z=Q=>{l.value=l.value.filter(E=>E.name!==Q)},P=Q=>{const E=f.value.find(S=>k(S)===Q);return E||f.value.find(S=>S.name===Q)},G=(Q,E,S)=>{l.value=l.value.map(V=>{if(V.name===Q){const re={...V.tenvs||{},[E]:S||void 0};for(const F of Object.keys(re))re[F]||delete re[F];return{...V,tenvs:Object.keys(re).length>0?re:void 0}}return V})},ee=(Q,E,S)=>{l.value=l.value.map(V=>V.name===Q?{...V,[E]:S}:V)};return o({removeUnavailableTools:()=>{l.value=l.value.filter(Q=>b(Q.name))},getAvailableToolsOnly:()=>l.value.filter(Q=>b(Q.name)),unavailableTools:v}),Pe(()=>{R()}),(Q,E)=>{const S=Be("FormKit");return r(),n("div",Yl,[e("div",null,[e("label",Gl,[Z(C(t.label)+" ",1),t.required?(r(),n("span",Zl,"*")):I("",!0)]),l.value.length>0?(r(),n("div",{key:0,class:"space-y-3 mb-4",ref_key:"dragAreaRef",ref:x},[(r(!0),n(ve,null,ye(l.value,V=>(r(),n("div",{key:V.name,class:ae(["border rounded-lg p-4 transition-colors",b(V.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",Xl,[e("div",Ql,[e("div",{class:ae(["drag-handle",b(V.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"])},[...E[1]||(E[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",es,[e("h4",{class:ae(["font-medium text-sm",!b(V.name)&&"text-neutral-500 dark:text-neutral-400"])},[Z(C(g(V.name))+" ",1),_(V.name)==="provider"?(r(),n("span",ts,"(provider)")):_(V.name)==="mcp"?(r(),n("span",rs,"(mcp)")):P(V.name)?.type==="prompt"?(r(),n("span",as,"(prompt)")):P(V.name)?.type==="handoff"?(r(),n("span",os,"(handoff agent)")):P(V.name)?.type==="subagent"?(r(),n("span",ns,"(subagent)")):I("",!0)],2),P(V.name)?.description?(r(),n("p",ls,C(P(V.name)?.description),1)):I("",!0),b(V.name)?I("",!0):(r(),n("p",ss,[...E[2]||(E[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),Z(" Not available for selected model - will be removed on save ",-1)])]))])]),e("button",{onClick:re=>z(V.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 ${g(V.name)}`},[...E[3]||(E[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,is)]),P(V.name)?.type==="provider"&&P(V.name)?.tenvs?.length?(r(),n("div",us,[E[4]||(E[4]=e("p",{class:"text-xs text-neutral-500 dark:text-neutral-400 mb-2 font-medium"},[Z(" Environment Variables "),e("span",{class:"text-neutral-400"},"(optional at prompt level)")],-1)),e("div",ds,[(r(!0),n(ve,null,ye(P(V.name)?.tenvs,re=>(r(),n("div",{key:re.name,class:"flex items-center gap-2"},[w(S,{type:"text",value:V.tenvs?.[re.name]||"",onInput:F=>G(V.name,re.name,F),label:re.name,placeholder:re.description||"Enter value...",disabled:t.disabled,"outer-class":"$reset flex-1 mb-0"},null,8,["value","onInput","label","placeholder","disabled"]),re.required?(r(),n("span",cs," required* ")):I("",!0)]))),128))])])):I("",!0),P(V.name)?.type==="prompt"||P(V.name)?.type==="handoff"||P(V.name)?.type==="subagent"?(r(),H(Jl,{key:1,"tool-name":V.name,"tool-config":V,"tool-type":P(V.name)?.type,disabled:t.disabled,"onUpdate:option":(re,F)=>ee(V.name,re,F)},null,8,["tool-name","tool-config","tool-type","disabled","onUpdate:option"])):I("",!0)],2))),128))],512)):I("",!0),w(S,{type:"selectSearch",modelValue:c.value,"onUpdate:modelValue":E[0]||(E[0]=V=>c.value=V),onInput:Y,placeholder:l.value.length>0?"Add another tool...":t.placeholder,"search-placeholder":"Search tools...",options:L.value,disabled:t.disabled||m.value||L.value.length===0,loading:m.value,"outer-class":"$reset"},null,8,["modelValue","placeholder","options","disabled","loading"]),t.error?(r(),H(T(tt),{key:1,class:"mt-1"},{default:D(()=>[Z(C(t.error),1)]),_:1})):I("",!0)]),l.value.length===0&&!m.value&&L.value.length===0?(r(),n("div",ps," No tools available. Create tools in your agentbuilder/tools directory. ")):I("",!0)])}}}),ms=gt(Ie(Hr),{props:["label","placeholder","error","required","disabled","modelId","providerId"],family:"dropdown",features:[]}),vs=me({__name:"SelectInputWrapper",props:{context:{}},setup(t){const o=t,a=(b,v)=>{const d=o.context;return d[b]!==void 0?d[b]:d.attrs?.[b]!==void 0?d.attrs[b]:v},i=B(()=>o.context.classes??{}),l=B(()=>a("options",[])),u=B(()=>o.context._value??""),s=b=>{o.context.node.input(b)},m=B(()=>a("placeholder","Select an option")),h=B(()=>a("searchPlaceholder","Search...")),x=B(()=>a("loading",!1)),c=B(()=>o.context.disabled??!1),f=B(()=>a("size","md")),y=B(()=>a("activeHighlight",!1));return(b,v)=>(r(),H(Ge,{"model-value":u.value,options:l.value,placeholder:m.value,"search-placeholder":h.value,loading:x.value,disabled:c.value,"trigger-class":i.value.inner,size:f.value,"active-highlight":y.value,"onUpdate:modelValue":s},null,8,["model-value","options","placeholder","search-placeholder","loading","disabled","trigger-class","size","active-highlight"]))}}),fs={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:Ie(vs),props:{context:"$node.context"}}]},hs={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function gs(t,o){return r(),n("svg",hs,[...o[0]||(o[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 bs=Ie({name:"lucide-search",render:gs}),xs=["data-suffix-icon"],ys=["id","value","placeholder","disabled"],ks=me({__name:"SearchInputWrapper",props:{context:{}},setup(t){const o=t,a=(x,c)=>{const f=o.context;return f[x]!==void 0?f[x]:f.attrs?.[x]!==void 0?f.attrs[x]:c},i=B(()=>o.context.classes??{}),l=B(()=>o.context._value??""),u=x=>{const c=x.target.value;o.context.node.input(c)},s=()=>{o.context.node.input("")},m=B(()=>a("placeholder","Search...")),h=B(()=>o.context.disabled??!1);return(x,c)=>(r(),n("div",{class:ae(i.value.inner),"data-prefix-icon":"true","data-suffix-icon":!!l.value},[e("span",{class:ae(i.value.prefixIcon)},[w(T(bs))],2),e("input",{type:"text",id:t.context.id,value:l.value,onInput:u,placeholder:m.value,disabled:h.value,class:ae(i.value.input)},null,42,ys),l.value?(r(),n("button",{key:0,type:"button",onClick:s,class:ae([i.value.suffixIcon,"hover:text-zinc-600 dark:hover:text-zinc-300 cursor-pointer"])},[w(T(Pt))],2)):I("",!0)],10,xs))}}),ws={type:"input",family:"text",props:["placeholder","size"],schema:()=>[{$el:"label",if:"$label",attrs:{class:"$classes.label",for:"$id"},children:"$label"},{$cmp:Ie(ks),props:{context:"$node.context"}}]},_s=me({__name:"SortableMultiSelectWrapper",props:{context:{}},setup(t){const o=t,a=B(()=>o.context.options??[]),i=B(()=>o.context.placeholder??"Select an option"),l=B(()=>o.context.searchPlaceholder??"Search..."),u=B(()=>o.context.addLabel??"Add another"),s=B(()=>o.context.loading??!1),m=B(()=>o.context.disabled??!1),h=B({get:()=>o.context._value??[],set:x=>o.context.node.input(x)});return(x,c)=>(r(),H(ht,{modelValue:h.value,"onUpdate:modelValue":c[0]||(c[0]=f=>h.value=f),options:a.value,placeholder:i.value,"search-placeholder":l.value,"add-label":u.value,loading:s.value,disabled:m.value},null,8,["modelValue","options","placeholder","search-placeholder","add-label","loading","disabled"]))}}),$s={type:"input",family:"dropdown",props:["options","placeholder","searchPlaceholder","addLabel","loading"],schema:()=>[{$el:"label",if:"$label",attrs:{class:"$classes.label",for:"$id"},children:"$label"},{$cmp:Ie(_s),props:{context:"$node.context"}}]},Cs={class:"flex items-center gap-2 py-1 pl-2 pr-1"},Ss={class:"flex-1 grid grid-cols-1 md:grid-cols-3 gap-2"},Ts={class:"flex items-center gap-0.5 shrink-0"},Is={key:1,class:"w-7"},zs={class:"pl-2 pb-1"},Vs={key:0},Ms={class:"space-y-1.5"},Es=["onClick"],Ls=["onClick"],Ps={key:1},As=["onClick"],js={key:2},Ds=["onClick"],Os={key:3},Rs={class:"flex items-center gap-2 py-1 pl-2 pr-1"},Us={class:"flex-1 grid grid-cols-1 md:grid-cols-2 gap-2"},Bs={class:"flex items-center gap-0.5 shrink-0"},Fs={key:1,class:"w-7"},Ns={class:"pl-2 pb-1"},qs={key:0},Hs={class:"space-y-1.5"},Ws=["onClick"],Ks=["onClick"],Js={key:1},Ys=["onClick"],Gs={key:2},Zs=["onClick"],Xs={key:3},Qs=["onClick"],ei=me({__name:"SchemaPropertyRow",props:{typeOptions:{},depth:{},index:{}},emits:["remove"],setup(t){const o=t,a=p(!1),i=p("string"),l=p("string"),u=p(!1),s=v=>{i.value=v,x(v)&&(a.value=!0)},m=v=>{l.value=v,x(v)&&(u.value=!0)},h=v=>{v.value?.type&&(l.value=v.value.type,x(l.value)&&(u.value=!0)),v.on("input",({payload:d})=>{d?.type&&d.type!==l.value&&m(d.type)})},x=v=>["object","array","enum","anyOf"].includes(v),c=["#3b82f6","#8b5cf6","#ec4899","#f97316","#10b981"],f=B(()=>o.depth||0),y=v=>c[v%c.length],b=B(()=>y(f.value));return(v,d)=>{const k=Be("FormKit"),g=Be("SchemaPropertyRow",!0);return r(),H(k,{type:"group",index:t.index,onNode:d[3]||(d[3]=_=>{_.value?.type&&(i.value=_.value.type,x(i.value)&&(a.value=!0)),_.on("input",({payload:L})=>{L?.type&&L.type!==i.value&&s(L.type)})})},{default:D(({value:_})=>[e("div",{class:ae(["schema-row",f.value>0?"border-l-[3px] ml-2":""]),style:st(f.value>0?{borderColor:b.value}:{})},[e("div",Cs,[e("div",Ss,[w(k,{type:"text",name:"name",placeholder:"Property name","outer-class":"$reset"}),w(k,{type:"selectSearch",name:"type",options:t.typeOptions,placeholder:"Type","outer-class":"$reset",onInput:s},null,8,["options"]),w(k,{type:"text",name:"description",placeholder:"Description","outer-class":"$reset"})]),e("div",Ts,[x(i.value)?(r(),n("button",{key:0,onClick:d[0]||(d[0]=L=>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(),n("svg",{class:ae(["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(),n("div",Is)),e("button",{onClick:d[1]||(d[1]=L=>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)])])])]),Ae(e("div",zs,[i.value==="enum"?(r(),n("div",Vs,[d[7]||(d[7]=e("div",{class:"text-[11px] font-medium text-neutral-400 uppercase tracking-wider mb-2"}," Enum Values ",-1)),w(k,{type:"list",name:"enumValues",dynamic:""},{default:D(({items:L,value:R,node:K})=>[e("div",Ms,[(r(!0),n(ve,null,ye(L,(Y,z)=>(r(),n("div",{key:Y,class:"flex items-center gap-2"},[w(k,{type:"group",index:z},{default:D(()=>[w(k,{type:"text",name:"value",placeholder:"Value","outer-class":"$reset flex-1"})]),_:1},8,["index"]),e("button",{onClick:P=>K.input(R.filter((G,ee)=>ee!==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]=[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,Es)]))),128))]),e("button",{onClick:Y=>K.input((R||[]).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,Ls)]),_:1})])):I("",!0),i.value==="object"?(r(),n("div",Ps,[w(k,{type:"list",name:"properties",dynamic:""},{default:D(({items:L,value:R,node:K})=>[e("div",null,[(r(!0),n(ve,null,ye(L,(Y,z)=>(r(),H(g,{key:Y,index:z,"type-options":t.typeOptions,depth:f.value+1,onRemove:P=>K.input(R.filter((G,ee)=>ee!==z))},null,8,["index","type-options","depth","onRemove"]))),128))]),e("button",{onClick:Y=>K.input((R||[]).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,As)]),_:1})])):I("",!0),i.value==="anyOf"?(r(),n("div",js,[d[8]||(d[8]=e("div",{class:"text-[11px] font-medium text-neutral-400 uppercase tracking-wider mb-2"}," Type Options ",-1)),w(k,{type:"list",name:"anyOfTypes",dynamic:""},{default:D(({items:L,value:R,node:K})=>[e("div",null,[(r(!0),n(ve,null,ye(L,(Y,z)=>(r(),H(g,{key:Y,index:z,"type-options":t.typeOptions,depth:f.value+1,onRemove:P=>K.input(R.filter((G,ee)=>ee!==z))},null,8,["index","type-options","depth","onRemove"]))),128))]),e("button",{onClick:Y=>K.input((R||[]).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,Ds)]),_:1})])):I("",!0),i.value==="array"?(r(),n("div",Os,[d[14]||(d[14]=e("div",{class:"text-[11px] font-medium text-neutral-400 uppercase tracking-wider mb-2"}," Array Item Type ",-1)),w(k,{type:"group",name:"items",onNode:h},{default:D(({value:L,node:R})=>[e("div",{class:"schema-row border-l-[3px] ml-2",style:st({borderColor:y(f.value+1)})},[e("div",Rs,[e("div",Us,[w(k,{type:"selectSearch",name:"type",options:t.typeOptions,placeholder:"Item type","outer-class":"$reset",onInput:m},null,8,["options"]),w(k,{type:"text",name:"description",placeholder:"Description","outer-class":"$reset"})]),e("div",Bs,[x(l.value)?(r(),n("button",{key:0,onClick:d[2]||(d[2]=K=>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(),n("svg",{class:ae(["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(),n("div",Fs))])]),Ae(e("div",Ns,[l.value==="enum"?(r(),n("div",qs,[d[11]||(d[11]=e("div",{class:"text-[11px] font-medium text-neutral-400 uppercase tracking-wider mb-2"}," Enum Values ",-1)),w(k,{type:"list",name:"enumValues",dynamic:""},{default:D(({items:K,value:Y,node:z})=>[e("div",Hs,[(r(!0),n(ve,null,ye(K,(P,G)=>(r(),n("div",{key:P,class:"flex items-center gap-2"},[w(k,{type:"group",index:G},{default:D(()=>[w(k,{type:"text",name:"value",placeholder:"Value","outer-class":"$reset flex-1"})]),_:1},8,["index"]),e("button",{onClick:ee=>z.input(Y.filter((se,de)=>de!==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,Ws)]))),128))]),e("button",{onClick:P=>z.input((Y||[]).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,Ks)]),_:1})])):I("",!0),l.value==="object"?(r(),n("div",Js,[w(k,{type:"list",name:"properties",dynamic:""},{default:D(({items:K,value:Y,node:z})=>[e("div",null,[(r(!0),n(ve,null,ye(K,(P,G)=>(r(),H(g,{key:P,index:G,"type-options":t.typeOptions,depth:f.value+2,onRemove:ee=>z.input(Y.filter((se,de)=>de!==G))},null,8,["index","type-options","depth","onRemove"]))),128))]),e("button",{onClick:P=>z.input((Y||[]).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,Ys)]),_:1})])):I("",!0),l.value==="anyOf"?(r(),n("div",Gs,[d[12]||(d[12]=e("div",{class:"text-[11px] font-medium text-neutral-400 uppercase tracking-wider mb-2"}," Type Options ",-1)),w(k,{type:"list",name:"anyOfTypes",dynamic:""},{default:D(({items:K,value:Y,node:z})=>[e("div",null,[(r(!0),n(ve,null,ye(K,(P,G)=>(r(),H(g,{key:P,index:G,"type-options":t.typeOptions,depth:f.value+2,onRemove:ee=>z.input(Y.filter((se,de)=>de!==G))},null,8,["index","type-options","depth","onRemove"]))),128))]),e("button",{onClick:P=>z.input((Y||[]).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,Zs)]),_:1})])):I("",!0),l.value==="array"?(r(),n("div",Xs,[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(k,{type:"list",name:"items",dynamic:""},{default:D(({items:K,value:Y,node:z})=>[e("div",null,[(r(!0),n(ve,null,ye(K,(P,G)=>(r(),H(g,{key:P,index:G,"type-options":t.typeOptions,depth:f.value+2,onRemove:ee=>z.input(Y.filter((se,de)=>de!==G))},null,8,["index","type-options","depth","onRemove"]))),128))]),e("button",{onClick:P=>z.input((Y||[]).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,Qs)]),_:1})])):I("",!0)],512),[[Ke,u.value&&x(l.value)]])],4)]),_:1})])):I("",!0)],512),[[Ke,a.value&&x(i.value)]])],6)]),_:1},8,["index"])}}}),ti=Xe(ei,[["__scopeId","data-v-a52ecd3f"]]),ri={"data-schema-editor":"",class:"space-y-4"},ai={class:"space-y-2 border border-neutral-200 dark:border-neutral-800 rounded-lg p-4"},oi={key:0,class:"flex items-center justify-between mb-2"},ni={key:1,class:"text-center py-12"},li={class:"divide-y divide-neutral-100 dark:divide-neutral-800"},si={class:"mt-3 pt-3 border-t border-neutral-200 dark:border-neutral-800"},ii=["onClick"],ui={class:"mt-4 text-center"},di={key:3,class:"mt-4"},ci={class:"bg-neutral-50 dark:bg-neutral-900 border border-neutral-200 dark:border-neutral-800 rounded-lg p-4 overflow-x-auto"},pi={class:"text-xs leading-relaxed"},mi=["innerHTML"],vi=me({__name:"FormKitSchemaEditor",props:{context:{}},setup(t){const o=[{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,i=p(!1),l=x=>x?.properties?Object.entries(x.properties).map(([c,f])=>{const y={name:c,type:f.enum?"enum":f.anyOf?"anyOf":f.type||"string",description:f.description||""};return f.enum&&(y.enumValues=f.enum.map(b=>({value:b}))),f.anyOf&&(y.anyOfTypes=f.anyOf.map(b=>({type:b.type||"string",description:b.description||""}))),f.type==="object"&&f.properties&&(y.properties=l(f)),f.type==="array"&&f.items&&(y.items={type:f.items.type||"string",description:f.items.description||""},f.items.properties&&(y.items.properties=l(f.items))),y}):[],u=x=>{const c={type:"object",properties:{},required:[],additionalProperties:!1};for(const f of x||[]){if(!f.name)continue;const y={type:f.type==="enum"||f.type==="anyOf"?void 0:f.type,description:f.description||void 0};if(f.type==="enum"&&f.enumValues&&(y.type="string",y.enum=f.enumValues.map(b=>b.value)),f.type==="anyOf"&&f.anyOfTypes&&(y.anyOf=f.anyOfTypes.map(b=>({type:b.type,description:b.description||void 0}))),f.type==="object"&&f.properties){const b=u(f.properties);y.properties=b.properties,y.required=b.required,y.additionalProperties=!1}if(f.type==="array"&&f.items&&(y.items={type:f.items.type,description:f.items.description||void 0},f.items.properties)){const b=u(f.items.properties);y.items.properties=b.properties,y.items.required=b.required}Object.keys(y).forEach(b=>y[b]===void 0&&delete y[b]),c.properties[f.name]=y,c.required.push(f.name)}return c},s=B({get:()=>{const x=a.context._value;return l(x)},set:x=>{const c=u(x);a.context.node.input(c)}}),m=B(()=>{const x=a.context._value||{type:"object",properties:{},required:[]};return JSON.stringify(x,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>')}),h=()=>{s.value=[{name:"property1",type:"string",description:""}]};return(x,c)=>{const f=Be("FormKit");return r(),n("div",ri,[e("div",ai,[s.value.length>0?(r(),n("div",oi,[...c[3]||(c[3]=[e("h3",{class:"text-sm font-medium text-neutral-700 dark:text-neutral-300"}," Properties ",-1)])])):I("",!0),s.value.length===0?(r(),n("div",ni,[c[5]||(c[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)),c[6]||(c[6]=e("p",{class:"text-neutral-500 dark:text-neutral-400 text-sm mb-4"}," No properties defined ",-1)),e("button",{onClick:c[0]||(c[0]=y=>h()),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"},[...c[4]||(c[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"})]),Z(" Add Property ")],-1)])])])):I("",!0),s.value.length>0?(r(),H(f,{key:2,type:"list",value:s.value,onInput:c[1]||(c[1]=y=>s.value=y),dynamic:""},{default:D(({items:y,value:b,node:v})=>[e("div",li,[(r(!0),n(ve,null,ye(y,(d,k)=>(r(),H(ti,{key:d,index:k,"type-options":o,depth:0,onRemove:g=>v.input(b.filter((_,L)=>L!==k))},null,8,["index","onRemove"]))),128))]),e("div",si,[e("button",{onClick:d=>v.input(b.concat({name:`property${b.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,ii)])]),_:1},8,["value"])):I("",!0),e("div",ui,[e("button",{onClick:c[2]||(c[2]=y=>i.value=!i.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(i.value?"Hide":"Show")+" JSON Schema ",1)]),i.value?(r(),n("div",di,[e("div",ci,[e("pre",pi,[e("code",{class:"font-mono",innerHTML:m.value},null,8,mi)])])])):I("",!0)])])}}}),fi={type:"input",family:"text",props:["label","disabled","required"],schema:()=>[{$el:"label",if:"$label",attrs:{class:"$classes.label",for:"$id"},children:"$label"},{$cmp:Ie(vi),props:{context:"$node.context"}}]},hi={promptInput:qo,jsonSchema:hl,modelSelector:zl,agentSelector:Vl,toolSelector:Ml,tenvPropertyList:ql,toolSelectorWithOptions:ms,selectSearch:fs,searchInput:ws,sortableMultiSelect:$s,schemaEditor:fi};console.warn("[FormKit] VITE_FORMKIT_PRO_KEY not set - Pro inputs will not work");const gi=eo("",ro),bi={config:{rootClasses:yo},plugins:[gi],rules:Io,messages:{en:zo},inputs:hi,icons:{...to}},xi={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function yi(t,o){return r(),n("svg",xi,[...o[0]||(o[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 mt=Ie({name:"lucide-bot",render:yi}),ki={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function wi(t,o){return r(),n("svg",ki,[...o[0]||(o[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 Et=Ie({name:"lucide-message-square",render:wi}),_i={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function $i(t,o){return r(),n("svg",_i,[...o[0]||(o[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 Ci=Ie({name:"lucide-cpu",render:$i}),Si={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Ti(t,o){return r(),n("svg",Si,[...o[0]||(o[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 Ii=Ie({name:"lucide-server",render:Ti}),zi={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Vi(t,o){return r(),n("svg",zi,[...o[0]||(o[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 qt=Ie({name:"lucide-wrench",render:Vi}),Mi={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Ei(t,o){return r(),n("svg",Mi,[...o[0]||(o[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 Ht=Ie({name:"lucide-settings",render:Ei}),Li={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Pi(t,o){return r(),n("svg",Li,[...o[0]||(o[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 Wr=Ie({name:"lucide-chevron-left",render:Pi}),Ai={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function ji(t,o){return r(),n("svg",Ai,[...o[0]||(o[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 Di=Ie({name:"lucide-sun",render:ji}),Oi={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Ri(t,o){return r(),n("svg",Oi,[...o[0]||(o[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 Ui=Ie({name:"lucide-moon",render:Ri}),Bi={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Fi(t,o){return r(),n("svg",Bi,[...o[0]||(o[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 Ni=Ie({name:"lucide-activity",render:Fi}),qi={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Hi(t,o){return r(),n("svg",qi,[...o[0]||(o[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 Wi=Ie({name:"lucide-function-square",render:Hi}),Ki={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Ji(t,o){return r(),n("svg",Ki,[...o[0]||(o[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 Yi=Ie({name:"lucide-log-out",render:Ji}),Gi={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Zi(t,o){return r(),n("svg",Gi,[...o[0]||(o[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 Xi=Ie({name:"lucide-users",render:Zi}),Qi={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function eu(t,o){return r(),n("svg",Qi,[...o[0]||(o[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 tu=Ie({name:"lucide-key",render:eu}),ru={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function au(t,o){return r(),n("svg",ru,[...o[0]||(o[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 ou=Ie({name:"lucide-book-open",render:au}),nu={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function lu(t,o){return r(),n("svg",nu,[...o[0]||(o[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 su=Ie({name:"lucide-external-link",render:lu}),Kr="agentbuilder-accent-theme",Jr=["amber","lime","emerald","sky","blue","indigo","purple","fuchsia","pink","white"],Wt=p("purple");let cr=!1;function Yr(t){typeof document>"u"||(t==="purple"?delete document.documentElement.dataset.accent:document.documentElement.dataset.accent=t)}function iu(t){try{localStorage.setItem(Kr,t)}catch{}}function uu(){try{const t=localStorage.getItem(Kr);if(t&&Jr.includes(t))return t}catch{}return"purple"}function Gr(){if(cr)return;cr=!0;const t=uu();Wt.value=t,Yr(t)}function du(){Gr();function t(o){Wt.value=o,Yr(o),iu(o)}return{theme:Wt,themes:Jr,setTheme:t}}const Zr="/agents/assets/img/agent-builder-logo-light.svg",Xr="/agents/assets/img/agent-builder-logo-dark.svg",cu="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",pu="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",mu=["src"],vu=["src"],fu={class:"flex-1 flex flex-col justify-between pt-2 pb-4"},hu={class:"flex flex-col gap-1 px-2"},gu={key:0},bu=["onClick","title"],xu={key:0,class:"flex-1 whitespace-nowrap overflow-hidden text-ellipsis text-left"},yu={key:0,class:"ml-4 space-y-0.5"},ku=["onClick"],wu={class:"whitespace-nowrap overflow-hidden text-ellipsis"},_u=["onClick","title"],$u={key:0,class:"whitespace-nowrap overflow-hidden text-ellipsis"},Cu={class:"flex flex-col gap-1 px-2"},Su=["title"],Tu={key:0,class:"flex-1 whitespace-nowrap overflow-hidden text-ellipsis"},Iu={class:"relative settings-menu-container"},zu={key:0,class:"absolute bottom-full mb-2 left-0 z-50"},Vu={class:"px-4 py-3 border-b border-neutral-200 dark:border-neutral-700"},Mu=["title"],Eu={class:"relative z-10 flex items-center justify-center w-8 h-full"},Lu={class:"relative z-10 flex items-center justify-center w-8 h-full"},Pu={class:"px-4 pt-3 pb-4 border-b border-neutral-200 dark:border-neutral-700"},Au={class:"grid grid-cols-5 gap-3"},ju=["onClick","title"],Du={key:0,class:"w-2 h-2 rounded-full bg-white shadow-sm"},Ou={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"},Ru=me({__name:"Sidebar",props:{isCollapsed:{type:Boolean},isDark:{type:Boolean}},emits:["toggle-sidebar","toggle-theme"],setup(t,{emit:o}){function a(se){if(se.startsWith("/src/")||se.startsWith("data:"))return se;const de=_t();return de==="/"?se.replace("/agents/","/"):se.replace("/agents/",`${de}/`)}const i=a(Zr),l=a(Xr),u=a(cu),s=a(pu),m=t,h=ut(),x=bt(),c=B(()=>h.name);function f(se){const de=h.path;return de===se.path||de.startsWith(se.path+"/")}const y=B(()=>m.isDark?l:i),b=B(()=>m.isDark?s:u),v=[{id:"threads",label:"Threads",icon:Ni,path:"/threads"},{id:"agents",label:"Agents",icon:mt,path:"/agents"},{id:"prompts",label:"Prompts",icon:Et,path:"/prompts"},{id:"tools",label:"Tools",icon:qt,path:"/tools",hasSubnav:!0,subnav:[{id:"tools-functions",label:"Functions",icon:Wi,path:"/tools#functions"},{id:"tools-prompts",label:"Prompts",icon:Et,path:"/tools#prompts"},{id:"tools-agents",label:"Agents",icon:mt,path:"/tools#agents"}]},{id:"models",label:"Models",icon:Ci,path:"/models"},{id:"providers",label:"Providers",icon:Ii,path:"/providers"}],d=se=>{x.push(se)},k=se=>{x.push(se),_.value=!1},g=B(()=>typeof c.value=="string"&&(c.value==="tools"||c.value.startsWith("tools-"))),_=p(!1),{theme:L,themes:R,setTheme:K}=du(),Y={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=B(()=>c.value==="users"||c.value==="api-keys"),P=()=>{_.value=!_.value},G=()=>{localStorage.removeItem("auth_token"),x.push("/login")},ee=se=>{const de=se.target;_.value&&!de.closest(".settings-menu-container")&&(_.value=!1)};return Pe(()=>{document.addEventListener("click",ee)}),Ye(()=>{document.removeEventListener("click",ee)}),(se,de)=>(r(),n("aside",{class:ae(["flex flex-col transition-all duration-300 pt-2.5",t.isCollapsed?"w-16":"w-60"])},[e("div",{class:ae(`flex items-center justify-between ${t.isCollapsed?"px-2 py-4":"p-4"}`)},[t.isCollapsed?I("",!0):(r(),n("img",{key:0,src:y.value,alt:"AgentBuilder",class:"h-8 mr-2 mt-0.5"},null,8,mu)),e("button",{onClick:de[0]||(de[0]=Q=>se.$emit("toggle-sidebar")),class:ae(`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(),n("img",{key:1,src:b.value,alt:"AgentBuilder",class:"w-7 h-7 m-auto"},null,8,vu)):(r(),H(T(Wr),{key:0,class:"w-5 h-5"}))],2)],2),e("nav",fu,[e("div",hu,[(r(),n(ve,null,ye(v,Q=>(r(),n(ve,{key:Q.id},[Q.hasSubnav?(r(),n("div",gu,[e("button",{onClick:E=>d(Q.path),class:ae(["flex items-center gap-3 px-3 py-3 rounded text-sm font-medium transition-all w-full",g.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(),H(Ue(Q.icon),{class:"w-5 h-5 flex-shrink-0"})),t.isCollapsed?I("",!0):(r(),n("span",xu,C(Q.label),1))],10,bu),!t.isCollapsed&&Q.subnav?(r(),n("div",yu,[(r(!0),n(ve,null,ye(Q.subnav,E=>(r(),n("button",{key:E.id,onClick:S=>d(E.path),class:ae(["flex items-center gap-3 px-3 py-1.5 text-sm transition-all w-full",c.value===E.id?"bg-black text-white dark:bg-white dark:text-black rounded":"hover:underline"])},[(r(),H(Ue(E.icon),{class:"w-4 h-4 flex-shrink-0"})),e("span",wu,C(E.label),1)],10,ku))),128))])):I("",!0)])):(r(),n("button",{key:1,onClick:E=>d(Q.path),class:ae(["flex items-center gap-3 px-3 py-3 rounded text-sm font-medium transition-all",f(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(),H(Ue(Q.icon),{class:"w-5 h-5 flex-shrink-0"})),t.isCollapsed?I("",!0):(r(),n("span",$u,C(Q.label),1))],10,_u))],64))),64))]),e("div",Cu,[e("a",{href:"https://docs.standardagentbuilder.com/",target:"_blank",rel:"noopener noreferrer",class:ae(["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(T(ou),{class:"w-5 h-5 flex-shrink-0"}),t.isCollapsed?I("",!0):(r(),n("span",Tu," Docs ")),t.isCollapsed?I("",!0):(r(),H(T(su),{key:1,class:"w-3 h-3 flex-shrink-0 opacity-50"}))],10,Su),e("div",{class:ae(["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",Iu,[e("button",{onClick:Re(P,["stop"]),class:ae(["p-2 rounded transition-colors flex items-center",_.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"},[w(T(Ht),{class:"w-5 h-5 flex-shrink-0"})],2),_.value?(r(),n("div",zu,[w(T(At),{width:"min-w-[200px]",shadow:{offsetX:6,offsetY:6,intensity:.4}},{default:D(()=>[e("div",Vu,[de[4]||(de[4]=e("div",{class:"text-xs font-bold text-neutral-600 dark:text-neutral-400 pb-3"}," Appearance ",-1)),e("button",{onClick:de[1]||(de[1]=Re(Q=>se.$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:ae(["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",Eu,[w(T(Di),{class:ae(["w-4 h-4",t.isDark?"text-neutral-500":"text-black"])},null,8,["class"])]),e("span",Lu,[w(T(Ui),{class:ae(["w-4 h-4",t.isDark?"text-white":"text-neutral-400"])},null,8,["class"])])],8,Mu)]),e("div",Pu,[de[5]||(de[5]=e("div",{class:"text-xs font-bold text-neutral-600 dark:text-neutral-400 pb-3"}," Accent Color ",-1)),e("div",Au,[(r(!0),n(ve,null,ye(T(R),Q=>(r(),n("button",{key:Q,onClick:Re(E=>T(K)(Q),["stop"]),class:ae(["w-6 h-6 rounded-full transition-all flex items-center justify-center ring-1 ring-black/10 dark:ring-white/10",[Y[Q],T(L)===Q?"ring-2 ring-black/50 dark:ring-white/50":"hover:scale-110"]]),title:Q.charAt(0).toUpperCase()+Q.slice(1)},[T(L)===Q?(r(),n("span",Du)):I("",!0)],10,ju))),128))])]),e("button",{onClick:de[2]||(de[2]=Q=>k("/settings/users")),class:ae(["flex items-center gap-3 px-4 py-2 text-sm transition-all w-full text-left",c.value==="users"?"bg-black text-white dark:bg-white dark:text-black":"hover:bg-black/5 dark:hover:bg-white/10"])},[w(T(Xi),{class:"w-4 h-4 flex-shrink-0"}),de[6]||(de[6]=e("span",{class:"whitespace-nowrap"},"Users",-1))],2),e("button",{onClick:de[3]||(de[3]=Q=>k("/settings/api-keys")),class:ae(["flex items-center gap-3 px-4 py-2 text-sm transition-all w-full text-left",c.value==="api-keys"?"bg-black text-white dark:bg-white dark:text-black":"hover:bg-black/5 dark:hover:bg-white/10"])},[w(T(tu),{class:"w-4 h-4 flex-shrink-0"}),de[7]||(de[7]=e("span",{class:"whitespace-nowrap"},"API Keys",-1))],2)]),_:1})])):I("",!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(T(Yi),{class:"w-5 h-5 flex-shrink-0"}),t.isCollapsed?I("",!0):(r(),n("span",Ou,"Logout"))])],2)])])],2))}}),Uu={class:"warning-banner-container"},Bu={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"},Fu={class:"flex items-center gap-2"},Nu=["onClick"],qu=me({__name:"WarningBanner",setup(t){const o=p([]),a=p(new Set),i=async()=>{if(localStorage.getItem("auth_token"))try{const h=await fetch(fe("/api/diagnostics"));if(h.ok){const x=await h.json();o.value=x.warnings||[]}}catch{}},l=m=>{const h=`${m.type}:${m.details?.name||m.message}`;a.value.add(h)},u=m=>{const h=`${m.type}:${m.details?.name||m.message}`;return!a.value.has(h)},s=m=>{if(m.type==="duplicate_tool_name"){const h=m.details?.sources?.join(" and ")||"multiple sources";return`Duplicate tool name "${m.details?.name}" (defined as both ${h}). This may cause unexpected behavior.`}return m.message};return Pe(()=>{i()}),(m,h)=>(r(),n("div",Uu,[(r(!0),n(ve,null,ye(o.value,x=>(r(),n(ve,{key:`${x.type}:${x.details?.name}`},[u(x)?(r(),n("div",Bu,[e("div",Fu,[h[0]||(h[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(s(x)),1)]),e("button",{onClick:c=>l(x),class:"text-amber-600 dark:text-amber-400 hover:text-amber-800 dark:hover:text-amber-200 p-1",title:"Dismiss"},[...h[1]||(h[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,Nu)])):I("",!0)],64))),128))]))}}),Hu={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"},Wu={class:"flex-1 overflow-auto"},Ku=me({__name:"App",setup(t){Gr();const o=ut(),a=p(!1),i=p(!1),l=B(()=>o.name!=="login"),u=()=>{a.value=!a.value},s=()=>{i.value=!i.value,i.value?(document.documentElement.classList.add("dark"),localStorage.setItem("theme","dark")):(document.documentElement.classList.remove("dark"),localStorage.setItem("theme","light"))};return Pe(()=>{const m=localStorage.getItem("theme");(m==="dark"||!m&&window.matchMedia("(prefers-color-scheme: dark)").matches)&&(i.value=!0,document.documentElement.classList.add("dark"))}),(m,h)=>(r(),n("div",{class:ae(["app-container relative flex h-screen font-sans bg-neutral-50/80 text-black dark:bg-black dark:text-white",{"is-dark":i.value}])},[l.value?(r(),H(Ru,{key:0,"is-collapsed":a.value,"is-dark":i.value,onToggleSidebar:u,onToggleTheme:s},null,8,["is-collapsed","is-dark"])):I("",!0),l.value?(r(),n("main",Hu,[w(qu),e("div",Wu,[w(T(tr))])])):(r(),H(T(tr),{key:1}))],2))}}),Ju=Xe(Ku,[["__scopeId","data-v-2125e5d3"]]),Yu={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Gu(t,o){return r(),n("svg",Yu,[...o[0]||(o[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 Zu=Ie({name:"lucide-trash-2",render:Gu}),Xu={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Qu(t,o){return r(),n("svg",Xu,[...o[0]||(o[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 ed=Ie({name:"lucide-edit",render:Qu}),td={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function rd(t,o){return r(),n("svg",td,[...o[0]||(o[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 Kt=Ie({name:"lucide-eye",render:rd}),ad={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function od(t,o){return r(),n("svg",ad,[...o[0]||(o[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 nd=Ie({name:"lucide-chevron-up",render:od}),ld={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function sd(t,o){return r(),n("svg",ld,[...o[0]||(o[0]=[e("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"m6 9l6 6l6-6"},null,-1)])])}const id=Ie({name:"lucide-chevron-down",render:sd}),ud={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function dd(t,o){return r(),n("svg",ud,[...o[0]||(o[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 cd=Ie({name:"lucide-chevrons-up-down",render:dd}),pd={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function md(t,o){return r(),n("svg",pd,[...o[0]||(o[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 vd=Ie({name:"lucide-inbox",render:md}),fd={key:0,class:"w-full max-w-md"},hd={class:"flex items-center justify-between p-4 border-b border-red-200 dark:border-red-900 flex-shrink-0"},gd={class:"text-xl font-bold text-red-600"},bd={class:"p-6"},xd={class:"text-neutral-700 dark:text-neutral-300 mb-6"},yd={class:"flex justify-end gap-3"},Xt=me({__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:o}){const a=t,i=o,l=()=>{i("update:modelValue",!1)},u=()=>{i("confirm"),l()},s=()=>{i("cancel"),l()},m=h=>{h.key==="Escape"&&a.modelValue&&s()};return ge(()=>a.modelValue,h=>{h?(document.addEventListener("keydown",m),document.body.style.overflow="hidden"):(document.removeEventListener("keydown",m),document.body.style.overflow="")}),(h,x)=>(r(),H(kt,{to:"body"},[w(et,{"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:D(()=>[t.modelValue?(r(),n("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:s},[w(et,{"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:D(()=>[t.modelValue?(r(),n("div",fd,[w(wt,{"offset-x":8,"offset-y":8,intensity:.35},{default:D(()=>[e("div",{class:"bg-white dark:bg-neutral-900 border border-red-400 dark:border-red-500 rounded-lg flex flex-col",onClick:x[0]||(x[0]=Re(()=>{},["stop"]))},[e("div",hd,[e("h2",gd,C(t.title),1),w(T(Br),{icon:T(Pt),label:"Close dialog",variant:"danger",onClick:s},null,8,["icon"])]),e("div",bd,[e("p",xd,C(t.message),1),e("div",yd,[w(T(De),{variant:"secondary",onClick:s},{default:D(()=>[Z(C(t.cancelText),1)]),_:1}),w(T(De),{variant:"danger",onClick:u},{default:D(()=>[Z(C(t.confirmText),1)]),_:1})])])])]),_:1})])):I("",!0)]),_:1})])):I("",!0)]),_:1})]))}}),kd={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function wd(t,o){return r(),n("svg",kd,[...o[0]||(o[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 _d=Ie({name:"lucide-chevron-right",render:wd}),$d={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Cd(t,o){return r(),n("svg",$d,[...o[0]||(o[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 Sd=Ie({name:"lucide-chevrons-left",render:Cd}),Td={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Id(t,o){return r(),n("svg",Td,[...o[0]||(o[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 zd=Ie({name:"lucide-chevrons-right",render:Id}),Vd={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"},Md={class:"text-neutral-500 dark:text-neutral-400 text-xs font-medium"},Ed={class:"text-neutral-700 dark:text-neutral-300"},Ld={class:"text-neutral-700 dark:text-neutral-300"},Pd={class:"text-neutral-700 dark:text-neutral-300"},Ad={class:"flex items-center gap-0.5"},jd=["disabled"],Dd=["disabled"],Od={class:"flex items-center gap-0.5 mx-1"},Rd={key:0,class:"px-2 text-neutral-400 dark:text-neutral-500 text-xs"},Ud=["onClick"],Bd=["disabled"],Fd=["disabled"],Nd={class:"flex items-center gap-2"},qd=["value"],Hd=["value"],Wd=me({__name:"DataTablePagination",props:{page:{},pageSize:{},totalItems:{},pageSizeOptions:{default:()=>[10,25,50,100]}},emits:["update:page","update:pageSize"],setup(t,{emit:o}){const a=t,i=o,l=B(()=>Math.ceil(a.totalItems/a.pageSize)),u=B(()=>a.totalItems===0?0:(a.page-1)*a.pageSize+1),s=B(()=>Math.min(a.page*a.pageSize,a.totalItems)),m=B(()=>a.page>1),h=B(()=>a.page<l.value),x=B(()=>{const k=[],g=l.value,_=a.page;if(g<=7)for(let L=1;L<=g;L++)k.push(L);else{k.push(1),_>3&&k.push("...");const L=Math.max(2,_-1),R=Math.min(g-1,_+1);for(let K=L;K<=R;K++)k.includes(K)||k.push(K);_<g-2&&k.push("..."),k.includes(g)||k.push(g)}return k}),c=k=>{k>=1&&k<=l.value&&i("update:page",k)},f=()=>c(1),y=()=>c(a.page-1),b=()=>c(a.page+1),v=()=>c(l.value),d=k=>{const g=k.target;i("update:pageSize",parseInt(g.value,10)),i("update:page",1)};return(k,g)=>t.totalItems>0?(r(),n("div",Vd,[e("div",Md,[g[0]||(g[0]=Z(" Showing ",-1)),e("span",Ed,C(u.value),1),g[1]||(g[1]=Z(" to ",-1)),e("span",Ld,C(s.value),1),g[2]||(g[2]=Z(" of ",-1)),e("span",Pd,C(t.totalItems),1)]),e("div",Ad,[e("button",{type:"button",onClick:f,disabled:!m.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(T(Sd),{class:"w-4 h-4 text-neutral-500 dark:text-neutral-400"})],8,jd),e("button",{type:"button",onClick:y,disabled:!m.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(T(Wr),{class:"w-4 h-4 text-neutral-500 dark:text-neutral-400"})],8,Dd),e("div",Od,[(r(!0),n(ve,null,ye(x.value,(_,L)=>(r(),n(ve,{key:L},[_==="..."?(r(),n("span",Rd," ... ")):(r(),n("button",{key:1,type:"button",onClick:R=>c(_),class:ae(["min-w-[1.75rem] px-2 py-1 rounded-md text-xs font-medium transition-all duration-150",_===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(_),11,Ud))],64))),128))]),e("button",{type:"button",onClick:b,disabled:!h.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(T(_d),{class:"w-4 h-4 text-neutral-500 dark:text-neutral-400"})],8,Bd),e("button",{type:"button",onClick:v,disabled:!h.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(T(zd),{class:"w-4 h-4 text-neutral-500 dark:text-neutral-400"})],8,Fd)]),e("div",Nd,[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),n(ve,null,ye(t.pageSizeOptions,_=>(r(),n("option",{key:_,value:_},C(_),9,Hd))),128))],40,qd),g[3]||(g[3]=e("span",{class:"text-neutral-500 dark:text-neutral-400 text-xs"},"per page",-1))])])):I("",!0)}}),Kd={class:"w-full"},Jd={key:0,class:"flex flex-wrap items-start justify-between gap-4 mb-5"},Yd={class:"flex items-center gap-3"},Gd={class:"flex items-center gap-2"},Zd={key:0,class:"text-xl font-bold tracking-tight"},Xd={key:1,class:"text-xs font-mono text-neutral-400 dark:text-neutral-500"},Qd={key:0,class:"text-sm text-neutral-500 dark:text-neutral-400 mt-0.5"},ec={key:0,class:"flex items-center gap-2"},tc={key:1,class:"mb-4"},rc={class:"flex flex-wrap items-center gap-3"},ac={key:0,class:"flex-1 min-w-[200px] max-w-md"},oc={key:2,class:"flex items-center gap-2 ml-auto"},nc={class:"text-sm text-neutral-500 dark:text-neutral-400 font-medium"},lc={class:"flex items-center gap-1.5"},sc=["onClick"],ic={class:"rounded-xl border border-neutral-300 dark:border-neutral-700 overflow-hidden bg-white dark:bg-transparent"},uc={class:"overflow-x-auto"},dc={class:"w-full"},cc={class:"bg-neutral-50 dark:bg-neutral-800/50 border-b border-neutral-300 dark:border-neutral-700"},pc={key:0,class:"px-4 py-2.5 w-12"},mc={class:"flex items-center justify-center"},vc=["checked","indeterminate"],fc=["onClick"],hc={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"},gc={class:"divide-y divide-neutral-200 dark:divide-neutral-800"},bc={key:0},xc=["colspan"],yc={class:"flex flex-col items-center justify-center gap-3 text-neutral-400"},kc={key:1},wc=["colspan"],_c={class:"flex flex-col items-center justify-center gap-3 text-neutral-400"},$c={class:"w-12 h-12 rounded-full bg-neutral-100 dark:bg-neutral-800 flex items-center justify-center"},Cc={class:"text-sm"},Sc=["onClick"],Tc={key:0,class:"absolute left-0 top-0 bottom-0 w-0.5 bg-accent-500"},Ic={class:"flex items-center justify-center"},zc=["checked","onChange"],Vc=["innerHTML"],Mc={class:"inline-flex gap-0.5"},Ec=["disabled","onClick","title"],Lc=["disabled","onClick","title"],ot=me({__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:o}){const a=t,i=o,l=p(!1),u=p(""),s=p(null),m=$=>{if(typeof $!="string")return $;switch($){case"edit":return ed;case"delete":return Zu;case"view":return Kt;default:return null}},h=($,j)=>{const he=$[j.key];return j.formatter?j.formatter(he,$):he??"-"},x=$=>{switch($){case"center":return"text-center";case"right":return"text-right";default:return"text-left"}},c=($,j)=>j.cellClass?typeof j.cellClass=="function"?j.cellClass($):j.cellClass:"",f=async($,j)=>{if($.confirm){const he=typeof $.confirmMessage=="function"?$.confirmMessage(j):$.confirmMessage||`Are you sure you want to ${$.label.toLowerCase()}?`;u.value=he,s.value=async()=>{await $.handler(j)},l.value=!0}else await $.handler(j)},y=async()=>{s.value&&(await s.value(),s.value=null),l.value=!1},b=()=>{s.value=null,l.value=!1},v=($,j)=>$.visible===void 0?!0:typeof $.visible=="function"?$.visible(j):$.visible,d=($,j)=>$.disabled===void 0?!1:typeof $.disabled=="function"?$.disabled(j):$.disabled,k=p(null),g=p("asc"),_=B(()=>a.sortKey??k.value),L=B(()=>a.sortKey!==void 0?a.sortDirection:g.value),R=$=>a.sortable&&$.sortable===!0,K=$=>{if(!R($))return;const j=$.key;let he="asc";_.value===j&&(he=L.value==="asc"?"desc":"asc"),k.value=j,g.value=he,i("update:sortKey",j),i("update:sortDirection",he),i("sort",{key:j,direction:he})},Y=$=>_.value!==$.key?cd:L.value==="asc"?nd:id,z=B(()=>{if(!_.value||!a.sortable)return S.value;const $=_.value,j=L.value;return[...S.value].sort((he,X)=>{const pe=he[$],le=X[$];if(pe==null&&le==null)return 0;if(pe==null)return j==="asc"?1:-1;if(le==null)return j==="asc"?-1:1;let we=0;return typeof pe=="string"&&typeof le=="string"?we=pe.localeCompare(le,void 0,{sensitivity:"base"}):typeof pe=="number"&&typeof le=="number"?we=pe-le:we=String(pe).localeCompare(String(le)),j==="asc"?we:-we})}),P=p(a.searchQuery),G=p({}),ee=zr($=>{i("update:searchQuery",$),i("search",$)},300),se=$=>{P.value=$,ee($)},de=()=>{P.value="",i("update:searchQuery",""),i("search","")},Q=B(()=>a.columns.filter($=>$.filterable===!0).map($=>{const j=new Map;a.data.forEach(X=>{const pe=X[$.key];if(pe!=null){const le=$.formatter?$.formatter(pe,X):String(pe);if(!j.has(le)){const we=$.filterIcon?$.filterIcon(pe,X):void 0;j.set(le,{value:le,icon:we})}}});const he=Array.from(j.entries()).sort((X,pe)=>X[0].localeCompare(pe[0]));return{key:$.key,label:$.label,options:he.map(([X,pe])=>({value:X,label:X,icon:pe.icon}))}})),E=($,j)=>{if(j===""){const{[$]:he,...X}=G.value;G.value=X}else G.value={...G.value,[$]:j}},S=B(()=>{let $=a.data;const j=Object.entries(G.value);if(j.length>0&&($=$.filter(he=>j.every(([X,pe])=>{const le=a.columns.find(ie=>ie.key===X);if(!le)return!0;const we=he[X];return we==null?!1:(le.formatter?le.formatter(we,he):String(we))===pe}))),a.searchable&&P.value.trim()){const he=P.value.toLowerCase().trim();$=$.filter(X=>a.columns.some(pe=>{if(pe.searchable===!1)return!1;const le=X[pe.key];return le==null?!1:(pe.formatter?pe.formatter(le,X):String(le)).toLowerCase().includes(he)}))}return $}),V=B(()=>{let $=0;return P.value&&$++,$+=Object.keys(G.value).length,$}),re=()=>{de(),G.value={}},F=$=>$[a.rowKey],q=$=>{const j=F($);return a.selectedRows.some(he=>he[a.rowKey]===j)},N=B(()=>z.value.length>0&&a.selectedRows.length===z.value.length),J=B(()=>a.selectedRows.length>0&&a.selectedRows.length<z.value.length),U=$=>{const j=F($);let he;q($)?he=a.selectedRows.filter(X=>X[a.rowKey]!==j):he=[...a.selectedRows,$],i("update:selectedRows",he),i("selection-change",he)},W=()=>{const $=N.value?[]:[...z.value];i("update:selectedRows",$),i("selection-change",$)},M=async $=>{if($.confirm){const j=$.confirmMessage||`Are you sure you want to ${$.label.toLowerCase()} ${a.selectedRows.length} item(s)?`;u.value=j,s.value=async()=>{await $.handler(a.selectedRows)},l.value=!0}else await $.handler(a.selectedRows)},ne=$=>{i("update:page",$),i("page-change",$)},A=$=>{i("update:pageSize",$)},ce=B(()=>a.title||a.description||a.primaryAction),ue=B(()=>a.actions&&a.actions.length>0),ke=B(()=>a.actions?.filter($=>$.variant!=="danger")||[]),be=B(()=>a.actions?.filter($=>$.variant==="danger")||[]),O=B(()=>{let $=a.columns.length;return a.selectable&&$++,ue.value&&$++,$});return($,j)=>{const he=Be("FormKit");return r(),n("div",Kd,[ce.value?(r(),n("div",Jd,[e("div",Yd,[e("div",null,[e("div",Gd,[t.title?(r(),n("h2",Zd,C(t.title),1)):I("",!0),!t.loading&&t.data.length>0?(r(),n("span",Xd,[V.value>0&&S.value.length!==t.data.length?(r(),n(ve,{key:0},[Z(" ("+C(S.value.length)+" of "+C(t.data.length)+") ",1)],64)):(r(),n(ve,{key:1},[Z(" ("+C(t.data.length)+") ",1)],64))])):I("",!0)]),t.description?(r(),n("p",Qd,C(t.description),1)):I("",!0)])]),t.primaryAction?(r(),n("div",ec,[je($.$slots,"header-actions"),w(T(De),{onClick:t.primaryAction.handler},{default:D(()=>[t.primaryAction.icon?(r(),H(Ue(t.primaryAction.icon),{key:0,class:"w-4 h-4 mr-2"})):I("",!0),Z(" "+C(t.primaryAction.label),1)]),_:1},8,["onClick"])])):I("",!0)])):I("",!0),t.searchable||Q.value.length>0?(r(),n("div",tc,[e("div",rc,[t.searchable?(r(),n("div",ac,[w(he,{type:"searchInput",value:P.value,placeholder:t.searchPlaceholder,onInput:se},null,8,["value","placeholder"])])):I("",!0),(r(!0),n(ve,null,ye(Q.value,X=>(r(),n("div",{key:X.key,class:"min-w-[220px]"},[w(he,{type:"selectSearch",value:G.value[X.key]||"",options:X.options,placeholder:`All ${X.label}s`,onInput:pe=>E(X.key,pe)},null,8,["value","options","placeholder","onInput"])]))),128)),V.value>0?(r(),n("button",{key:1,type:"button",onClick:re,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 ")):I("",!0),t.selectable&&t.selectedRows.length>0&&t.bulkActions.length>0?(r(),n("div",oc,[e("span",nc,C(t.selectedRows.length)+" selected ",1),e("div",lc,[(r(!0),n(ve,null,ye(t.bulkActions,(X,pe)=>(r(),n("button",{key:pe,type:"button",onClick:le=>M(X),class:ae(["inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-sm font-medium transition-all duration-150",X.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(),H(Ue(X.icon),{class:"w-4 h-4"})),Z(" "+C(X.label),1)],10,sc))),128))])])):I("",!0)])])):I("",!0),je($.$slots,"toolbar"),e("div",ic,[e("div",uc,[e("table",dc,[e("thead",cc,[e("tr",null,[t.selectable?(r(),n("th",pc,[e("div",mc,[e("input",{type:"checkbox",checked:N.value,indeterminate:J.value,onChange:W,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,vc)])])):I("",!0),(r(!0),n(ve,null,ye(t.columns,X=>(r(),n("th",{key:X.key,class:ae(["px-4 py-2.5 font-medium text-xs uppercase tracking-wide text-neutral-500 dark:text-neutral-400",x(X.align),X.width||"",R(X)?"cursor-pointer select-none group":""]),onClick:pe=>K(X)},[e("div",{class:ae(["inline-flex items-center gap-1",X.align==="right"?"flex-row-reverse":"",R(X)?"hover:text-neutral-700 dark:hover:text-neutral-200 transition-colors":""])},[e("span",null,C(X.label),1),R(X)?(r(),n("span",{key:0,class:ae(["inline-flex items-center justify-center w-5 h-5 rounded transition-all duration-150",_.value===X.key?"bg-accent-100 dark:bg-accent-900/50":"group-hover:bg-neutral-200 dark:group-hover:bg-neutral-700"])},[(r(),H(Ue(Y(X)),{class:ae(["w-3.5 h-3.5",_.value===X.key?"text-accent-600 dark:text-accent-400":"text-neutral-400 dark:text-neutral-500"])},null,8,["class"]))],2)):I("",!0)],2)],10,fc))),128)),ue.value?(r(),n("th",hc," Actions ")):I("",!0)])]),e("tbody",gc,[t.loading?(r(),n("tr",bc,[e("td",{colspan:O.value,class:"px-4 py-16"},[je($.$slots,"loading",{},()=>[e("div",yc,[w(Ee,{size:"md"}),j[3]||(j[3]=e("span",{class:"text-sm"},"Loading data...",-1))])])],8,xc)])):z.value.length===0?(r(),n("tr",kc,[e("td",{colspan:O.value,class:"px-4 py-16"},[je($.$slots,"empty",{},()=>[e("div",_c,[e("div",$c,[w(T(vd),{class:"w-6 h-6"})]),e("p",Cc,C(t.emptyMessage),1),V.value>0?(r(),n("button",{key:0,onClick:re,type:"button",class:"text-xs text-accent-600 dark:text-accent-400 hover:underline font-medium"}," Clear filters ")):I("",!0)])])],8,wc)])):(r(!0),n(ve,{key:2},ye(z.value,(X,pe)=>(r(),n("tr",{key:X[t.rowKey]??pe,class:ae(["transition-all duration-150 cursor-pointer relative",q(X)?"bg-accent-50 dark:bg-accent-950/30":"hover:bg-neutral-50 dark:hover:bg-neutral-900/50"]),onClick:le=>i("row-click",X)},[q(X)?(r(),n("div",Tc)):I("",!0),t.selectable?(r(),n("td",{key:1,class:"px-4 py-3",onClick:j[0]||(j[0]=Re(()=>{},["stop"]))},[e("div",Ic,[e("input",{type:"checkbox",checked:q(X),onChange:le=>U(X),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,zc)])])):I("",!0),(r(!0),n(ve,null,ye(t.columns,le=>(r(),n("td",{key:le.key,class:ae(["px-4 py-3 text-sm",x(le.align),c(X,le),q(X)?"text-accent-900 dark:text-accent-100":"text-neutral-700 dark:text-neutral-300"])},[je($.$slots,`cell-${le.key}`,{value:X[le.key],row:X,column:le},()=>[le.html?(r(),n("span",{key:0,innerHTML:h(X,le)},null,8,Vc)):(r(),n(ve,{key:1},[Z(C(h(X,le)),1)],64))])],2))),128)),ue.value?(r(),n("td",{key:2,class:"px-4 py-3 text-right",onClick:j[1]||(j[1]=Re(()=>{},["stop"]))},[e("div",Mc,[(r(!0),n(ve,null,ye(ke.value,(le,we)=>Ae((r(),n("button",{key:`non-delete-${we}`,disabled:d(le,X),onClick:oe=>f(le,X),class:ae(["p-1.5 rounded-md transition-all duration-150",d(le,X)?"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:le.label},[(r(),H(Ue(m(le.icon)),{class:"w-4 h-4"}))],10,Ec)),[[Ke,v(le,X)]])),128)),je($.$slots,"extra-actions",{row:X}),(r(!0),n(ve,null,ye(be.value,(le,we)=>Ae((r(),n("button",{key:`delete-${we}`,disabled:d(le,X),onClick:oe=>f(le,X),class:ae(["p-1.5 rounded-md transition-all duration-150",d(le,X)?"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:le.label},[(r(),H(Ue(m(le.icon)),{class:"w-4 h-4"}))],10,Lc)),[[Ke,v(le,X)]])),128))])])):I("",!0)],10,Sc))),128))])])]),t.paginated?(r(),H(Wd,{key:0,page:t.page,"page-size":t.pageSize,"total-items":t.totalItems,"page-size-options":t.pageSizeOptions,"onUpdate:page":ne,"onUpdate:pageSize":A},null,8,["page","page-size","total-items","page-size-options"])):I("",!0)]),w(Xt,{modelValue:l.value,"onUpdate:modelValue":j[2]||(j[2]=X=>l.value=X),title:"Confirm Action",message:u.value,"confirm-text":"Confirm","cancel-text":"Cancel",onConfirm:y,onCancel:b},null,8,["modelValue","message"])])}}}),Pc={},Ac={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 jc(t,o){return r(),n("svg",Ac,[...o[0]||(o[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 Dc=Xe(Pc,[["render",jc]]),Oc={},Rc={xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",fill:"currentColor"};function Uc(t,o){return r(),n("svg",Rc,[...o[0]||(o[0]=[e("path",{d:"M4 4h16v16H4V4zm2 2v12h4v-10h3v10h5V6H6z"},null,-1)])])}const Bc=Xe(Oc,[["render",Uc]]),Fc={class:"py-1"},Nc=me({__name:"ShareDropdown",props:{packageId:{}},emits:["download","publish"],setup(t,{emit:o}){const a=o,i=p(null),l=p(null);function u(){if(!i.value||!l.value)return;const x=i.value.getBoundingClientRect();let f=x.right-160;const y=8;f<y&&(f=y),l.value.style.top=`${x.bottom+4}px`,l.value.style.left=`${f}px`}function s(){l.value&&(l.value.matches(":popover-open")?l.value.hidePopover():(u(),l.value.showPopover()))}function m(x){l.value?.hidePopover(),a(x)}function h(){l.value?.matches(":popover-open")&&u()}return Pe(()=>{window.addEventListener("scroll",h,!0),window.addEventListener("resize",h)}),Ye(()=>{window.removeEventListener("scroll",h,!0),window.removeEventListener("resize",h)}),(x,c)=>(r(),n(ve,null,[e("button",{ref_key:"triggerButton",ref:i,type:"button",onClick:s,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(Dc,{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(T(At),{width:"w-40",shadow:{offsetX:4,offsetY:4,intensity:.3}},{default:D(()=>[e("div",Fc,[w(T(ur),{onClick:c[0]||(c[0]=f=>m("download"))},{default:D(()=>[w(T(Sa),{class:"w-4 h-4 text-neutral-500"}),c[2]||(c[2]=e("span",null,"Download",-1))]),_:1}),w(T(ur),{onClick:c[1]||(c[1]=f=>m("publish"))},{default:D(()=>[w(Bc,{class:"w-4 h-4 text-neutral-500"}),c[3]||(c[3]=e("span",null,"Publish",-1))]),_:1})])]),_:1})],512)],64))}}),qc={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Hc(t,o){return r(),n("svg",qc,[...o[0]||(o[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 pr=Ie({name:"lucide-package",render:Hc}),Wc={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Kc(t,o){return r(),n("svg",Wc,[...o[0]||(o[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 Jc=Ie({name:"lucide-package-open",render:Kc}),Yc={class:"flex items-center gap-2"},Gc=me({__name:"AgentsDataTable",props:{title:{},description:{},primaryAction:{}},emits:["add","edit","delete","pack","unpack","publish"],setup(t,{expose:o,emit:a}){const i=a,l=p([]),u=p(!1),s=[{key:"title",label:"Title",width:"w-1/5",sortable:!0},{key:"type",label:"Type",width:"w-1/12",sortable:!0,formatter:b=>b==="dual_ai"?"Dual AI":"AI+Human"},{key:"side_a_agent_prompt_name",label:"Side A",width:"w-1/5",formatter:b=>b||"-"},{key:"side_b_agent_prompt_name",label:"Side B",width:"w-1/5",formatter:b=>b||"Human"},{key:"created_at",label:"Created",width:"w-1/6",sortable:!0,searchable:!1,formatter:b=>b?new Date(b*1e3).toLocaleDateString():"-"}],m=[{icon:pr,label:"Pack",handler:b=>i("pack",b),visible:b=>!b.packed},{icon:Jc,label:"Unpack",handler:b=>i("unpack",b),visible:b=>!!b.packed},{icon:"edit",label:"Edit",handler:b=>i("edit",b),visible:b=>!b.packed},{icon:"delete",label:"Delete",handler:async b=>{await x(b)},confirm:!0,confirmMessage:"Are you sure you want to delete this agent?",variant:"danger",visible:b=>!b.packed},{icon:"delete",label:"Delete Package",handler:async b=>{await c(b)},confirm:!0,confirmMessage:"Are you sure you want to delete this packed agent and all its contents?",variant:"danger",visible:b=>!!b.packed&&b.source==="local"}],h=async()=>{u.value=!0;try{const b=await fetch(fe("/api/agents"));if(b.ok){const v=await b.json();l.value=v.agents||[]}}catch(b){console.error("Error fetching agents:",b)}finally{u.value=!1}},x=async b=>{try{const v=await fetch(fe(`/api/agents/${b.id}`),{method:"DELETE"});if(v.ok)await h();else{const d=await v.json();alert(d.error||"Failed to delete agent")}}catch(v){console.error("Error deleting agent:",v),alert("Failed to delete agent")}},c=async b=>{if(b.packageId)try{const v=await fetch(fe(`/api/pack/${encodeURIComponent(b.packageId)}`),{method:"DELETE"});if(v.ok)await h();else{const d=await v.json();alert(d.error||"Failed to delete packed agent")}}catch(v){console.error("Error deleting packed agent:",v),alert("Failed to delete packed agent")}},f=b=>{b.packageId&&(window.location.href=fe(`/api/pack/${encodeURIComponent(b.packageId)}/download`))},y=b=>{i("publish",b)};return Pe(()=>{h()}),o({refresh:h}),(b,v)=>(r(),n("div",null,[w(ot,{title:t.title,description:t.description,"primary-action":t.primaryAction,columns:s,data:l.value,actions:m,loading:u.value,sortable:"",searchable:"","search-placeholder":"Search agents...","empty-message":"No agents available. Create your first agent to get started."},{"cell-title":D(({row:d})=>[e("div",Yc,[d.packed?(r(),H(T(pr),{key:0,class:"w-4 h-4 text-blue-500 flex-shrink-0",title:`Packed agent from ${d.packageId}`},null,8,["title"])):I("",!0),e("span",null,C(d.title),1)])]),"extra-actions":D(({row:d})=>[d.packed?(r(),H(Nc,{key:0,"package-id":d.packageId,onDownload:k=>f(d),onPublish:k=>y(d)},null,8,["package-id","onDownload","onPublish"])):I("",!0)]),_:1},8,["title","description","primary-action","data","loading"])]))}}),Zc={class:"flex items-center justify-between p-4 border-b border-neutral-200 dark:border-neutral-700 flex-shrink-0"},Xc={class:"text-xl font-bold"},Qc={key:0,class:"p-6 border-t border-neutral-200 dark:border-neutral-700 flex-shrink-0"},He=me({__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:o}){const a=t,i=o,l=p(),u=p(!1),s=p(new Map),m=()=>l.value&&(l.value.querySelector("input")||l.value.querySelector("textarea")||l.value.querySelector("select")||l.value.querySelector("[contenteditable]")||l.value.querySelector(".monaco-editor")),h=()=>{if(!l.value)return;l.value.querySelectorAll(".monaco-editor-container").forEach(K=>{const Y=K.__monacoEditor;if(Y&&typeof Y.getValue=="function"){const z=Y.getValue();s.value.set(K,z)}})},x=()=>{if(!l.value)return!1;const R=l.value.querySelectorAll(".monaco-editor-container");for(const K of R){const Y=K.__monacoEditor;if(Y&&typeof Y.getValue=="function"){const z=Y.getValue(),P=s.value.get(K);if(P===void 0||(Y.getRawOptions?.()||{}).readOnly===!0)continue;if(z!==P)return!0}}return!1},c=R=>{const K=R;return K.type==="checkbox"||K.type==="radio"?K.checked!==K.defaultChecked:(K.tagName==="SELECT",K.value!==K.defaultValue)},f=()=>{if(a.hasChanges!==void 0)return a.hasChanges;if(!l.value)return!1;if(x())return!0;const R=l.value.querySelectorAll("input, textarea, select");for(const K of R)if(c(K))return!0;return!1},y=()=>{m()&&f()?u.value=!0:b()},b=()=>{i("update:modelValue",!1),i("close")},v=()=>{u.value=!1,b()},d=()=>{u.value=!1},k=R=>{R.key==="Escape"&&a.modelValue&&(m()||b())};ge(()=>a.modelValue,async R=>{R?(document.addEventListener("keydown",k),document.body.style.overflow="hidden",await Le(),setTimeout(()=>{h()},100)):(document.removeEventListener("keydown",k),document.body.style.overflow="",s.value.clear())});const g=p(!1),_=R=>{g.value=R.target===R.currentTarget},L=R=>{R.target===R.currentTarget&&g.value&&(m()||b()),g.value=!1};return(R,K)=>(r(),H(kt,{to:"body"},[w(et,{"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:D(()=>[t.modelValue?(r(),n("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:_,onClick:L},[w(et,{"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:D(()=>[t.modelValue?(r(),n("div",{key:0,class:ae(["w-full",t.width,"max-h-[85vh] flex flex-col"])},[w(wt,{"offset-x":8,"offset-y":8,intensity:.35},{default:D(()=>[e("div",{ref_key:"modalRef",ref:l,class:ae(["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",Zc,[e("h2",Xc,C(t.title),1),w(T(Br),{icon:T(Pt),label:"Close modal",variant:"ghost",onClick:y},null,8,["icon"])]),e("div",{class:ae(["flex-1 min-h-0",t.contentPadding?"overflow-y-auto p-6":"overflow-hidden flex flex-col"])},[je(R.$slots,"default")],2),R.$slots.footer?(r(),n("div",Qc,[je(R.$slots,"footer")])):I("",!0)],2)]),_:3})],2)):I("",!0)]),_:3})],32)):I("",!0)]),_:3}),w(Xt,{modelValue:u.value,"onUpdate:modelValue":K[0]||(K[0]=Y=>u.value=Y),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"])]))}}),e0=["id"],t0={class:"px-5 py-3 border-b border-neutral-100 dark:border-neutral-800"},r0={class:"text-sm font-semibold text-neutral-900 dark:text-neutral-100 flex items-center gap-2"},a0={class:"p-5"},o0={key:0,class:"px-5 py-3 border-t border-neutral-100 dark:border-neutral-800 bg-neutral-50 dark:bg-neutral-800/50"},rt=me({__name:"ModalCard",props:{id:{},title:{},icon:{}},setup(t){return(o,a)=>(r(),n("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",t0,[e("h3",r0,[t.icon?(r(),H(Ue(t.icon),{key:0,class:"w-4 h-4 text-neutral-500"})):I("",!0),Z(" "+C(t.title),1)])]),e("div",a0,[je(o.$slots,"default")]),o.$slots.footer?(r(),n("div",o0,[je(o.$slots,"footer")])):I("",!0)],8,e0))}}),n0={class:"flex flex-col gap-1 px-2"},l0=["onClick"],s0={class:"whitespace-nowrap overflow-hidden text-ellipsis"},Qr=me({__name:"ModalTabs",props:{tabs:{},activeTab:{}},emits:["select"],setup(t,{emit:o}){const a=o;return(i,l)=>(r(),n("div",n0,[(r(!0),n(ve,null,ye(t.tabs,u=>(r(),n("button",{key:u.id,type:"button",onClick:Re(s=>a("select",u.id),["prevent"]),class:ae(["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(),H(Ue(u.icon),{class:"w-4 h-4 flex-shrink-0"})),e("span",s0,C(u.label),1)],10,l0))),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"},xt=me({__name:"ModalSubHeader",props:{title:{}},setup(t){return(o,a)=>(r(),n("h4",i0,C(t.title),1))}});function ea(t,o){const a=p(o[0]),i=()=>{const u=t.value;if(!u)return;const s=o.filter(f=>document.getElementById(`section-${f}`)!==null);if(s.length===0)return;if(u.scrollHeight-u.scrollTop-u.clientHeight<50){a.value=s[s.length-1];return}const h=u.getBoundingClientRect(),x=h.top+h.height*.3;let c=s[0];for(const f of s)document.getElementById(`section-${f}`).getBoundingClientRect().top<=x&&(c=f);a.value=c},l=u=>{const s=document.getElementById(`section-${u}`);if(s&&t.value){const m=t.value.getBoundingClientRect().top,h=s.getBoundingClientRect().top,x=t.value.scrollTop+(h-m);t.value.scrollTo({top:x,behavior:"smooth"})}};return ge(t,(u,s)=>{s&&s.removeEventListener("scroll",i),u&&(u.addEventListener("scroll",i),i())}),Vr(()=>{t.value?.removeEventListener("scroll",i)}),{activeTab:a,scrollToSection:l}}const u0={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function d0(t,o){return r(),n("svg",u0,[...o[0]||(o[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 Lt=Ie({name:"lucide-file-text",render:d0}),c0={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function p0(t,o){return r(),n("svg",c0,[...o[0]||(o[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 mr=Ie({name:"lucide-user",render:p0}),m0={key:0,class:"min-h-[500px] flex items-center justify-center"},v0={class:"flex flex-1 min-h-0"},f0={class:"w-44 flex-shrink-0 border-r border-neutral-200 dark:border-neutral-700 py-4"},h0={class:"space-y-4"},g0={class:"space-y-5"},b0={class:"grid grid-cols-2 gap-4"},x0={key:0},y0={key:1},k0={key:2},w0={class:"space-y-5"},_0={class:"grid grid-cols-2 gap-4"},$0={class:"space-y-4 pt-4 border-t border-neutral-100 dark:border-neutral-800"},C0={key:0,class:"ml-6 mt-3 space-y-3"},S0={key:2},T0={class:"grid grid-cols-2 gap-4 pt-4 border-t border-neutral-100 dark:border-neutral-800"},I0={class:"space-y-5"},z0={class:"grid grid-cols-2 gap-4"},V0={class:"space-y-4 pt-4 border-t border-neutral-100 dark:border-neutral-800"},M0={key:0,class:"ml-6 mt-3 space-y-3"},E0={key:2},L0={class:"grid grid-cols-2 gap-4 pt-4 border-t border-neutral-100 dark:border-neutral-800"},P0={class:"space-y-3"},A0={key:0,class:"text-xs text-neutral-500"},j0={class:"flex justify-between"},D0=me({__name:"AgentModal",props:{modelValue:{type:Boolean},editAgent:{},mode:{},apiError:{}},emits:["update:modelValue","save"],setup(t,{emit:o}){const a=t,i=o,l=B(()=>a.mode==="edit"),u=p(!1),s=p(null),m=["basics","side-a","side-b","env"],{activeTab:h,scrollToSection:x}=ea(s,m),c=B(()=>{const Ce=[{id:"basics",label:"Basics",icon:Lt},{id:"side-a",label:"Side A",icon:mt},{id:"side-b",label:"Side B",icon:d.value==="ai_human"?mr:mt}];return($.value.length>0||Object.keys(j.value).length>0)&&Ce.push({id:"env",label:"Environment",icon:Ht}),Ce}),f=p(""),y=p(""),b=p(""),v=p(""),d=p("dual_ai"),k=p(!1),g=p(""),_=p(""),L=p(null),R=p(""),K=p(""),Y=p(""),z=p(""),P=p(!0),G=p(!1),ee=p(""),se=p(""),de=p(""),Q=p(""),E=p(!1),S=p(null),V=p(""),re=p(""),F=p(""),q=p(""),N=p(""),J=p(""),U=p(!0),W=p(!1),M=p(""),ne=p(""),A=p(""),ce=p(""),ue=p(null),ke=p(""),be=p(""),O=p(""),$=p([]),j=p({}),he=p(!1),{data:X,execute:pe}=Ne(fe("/api/prompts"),{immediate:!1}).json(),{data:le,execute:we}=Ne(fe("/api/tools?schema=true"),{immediate:!1}).json(),oe=p(null),ie=p(!1),Ve=p(null),_e=p(!1),$e=p(!1),xe=B(()=>{if(!X.value)return[{value:"",label:"Select a prompt..."}];const Ce=X.value?.prompts||[];return[{value:"",label:"None"},...Ce.map(te=>({value:te.id,label:te.name}))]}),Me=Ce=>le.value?le.value[Ce]:null,We=B(()=>!oe.value||!oe.value.tools?[{value:"",label:"None"}]:[{value:"",label:"None"},...oe.value.tools.map(Ce=>{const te=typeof Ce=="string"?Ce:Ce.name;return{value:te,label:te}})]),$t=B(()=>!Ve.value||!Ve.value.tools?[{value:"",label:"None"}]:[{value:"",label:"None"},...Ve.value.tools.map(Ce=>{const te=typeof Ce=="string"?Ce:Ce.name;return{value:te,label:te}})]),ia=B(()=>{if(!ee.value)return[];const Ce=Me(ee.value);return!Ce||!Ce.schema||!Ce.schema.properties?[]:Object.keys(Ce.schema.properties).map(te=>({value:te,label:te}))}),ua=B(()=>{if(!M.value)return[];const Ce=Me(M.value);return!Ce||!Ce.schema||!Ce.schema.properties?[]:Object.keys(Ce.schema.properties).map(te=>({value:te,label:te}))}),Ot=async()=>{const Ce=[Y.value,N.value].filter(Boolean);if(Ce.length===0){$.value=[];return}he.value=!0;try{const te=[],Se=new Set;for(const Te of Ce){const qe=await Je(`/prompts/${Te}/tenvs`);if(qe.ok){const Rt=await qe.json();for(const at of Rt.tenvs||[])Se.has(at.name)||(Se.add(at.name),te.push({name:at.name,value:at.value,required:at.required,description:at.description,source:at.source}))}}$.value=te}catch(te){console.error("Error fetching tenvs from prompts:",te),$.value=[]}finally{he.value=!1}},da=[{value:"dual_ai",label:"AI + AI (Subagent)"},{value:"ai_human",label:"AI + Human"}],ca=Ce=>{let te=Ce.toLowerCase().replace(/\s+/g,"_").replace(/[^a-z0-9_]/g,"");return!te.endsWith("_agent")&&te.length>0&&(te=te+"_agent"),te},pa=Ce=>!Ce||Ce==="_agent"?(b.value="Name is required",!1):/^[a-z][a-z0-9_]*_agent$/.test(Ce)?(b.value="",!0):(b.value="Name must start with a letter",!1),Ct=()=>{y.value="",f.value="",b.value="",v.value="",d.value="dual_ai",k.value=!1,g.value="",_.value="",L.value=null,R.value="",K.value="",Y.value="",z.value="",P.value=!0,G.value=!1,ee.value="",se.value="",de.value="",Q.value="",E.value=!1,S.value=null,V.value="",re.value="",F.value="",oe.value=null,q.value="",N.value="",J.value="",U.value=!0,W.value=!1,M.value="",ne.value="",A.value="",ce.value="",ue.value=null,ke.value="",be.value="",O.value="",Ve.value=null,$.value=[],j.value={}},ma=async()=>{if(a.editAgent?.id){u.value=!0,$e.value=!0;try{const Ce=await fetch(fe(`/api/agents/${a.editAgent.id}`));if(Ce.ok){const te=await Ce.json(),Se=te.agent||te;y.value=Se.name||"",f.value=Se.name||"",v.value=Se.title||"",d.value=Se.type||"dual_ai",k.value=Se.expose_as_tool||!1,g.value=Se.tool_description||"",L.value=Se.max_session_turns;const Te=Se.side_a_stop_tool||"",qe=Se.side_a_stop_tool_response_property||"",Rt=Se.side_b_stop_tool||"",at=Se.side_b_stop_tool_response_property||"",ha=Se.side_a_end_conversation_tool||"",ga=Se.side_b_end_conversation_tool||"";K.value=Se.side_a_label||"",q.value=Se.side_b_label||"",Y.value=Se.side_a_agent_prompt||"",N.value=Se.side_b_agent_prompt||"",P.value=!!Se.side_a_stop_on_response,G.value=!!Se.side_a_stop_tool,E.value=!!Se.side_a_manual_stop_condition,S.value=Se.side_a_max_steps,U.value=!!Se.side_b_stop_on_response,W.value=!!Se.side_b_stop_tool,ue.value=Se.side_b_max_steps,await Le(),ee.value=Te,de.value=qe,M.value=Rt,A.value=at,re.value=ha,be.value=ga,Se.tenvs&&typeof Se.tenvs=="object"&&(j.value=Se.tenvs),await Ot()}}catch(Ce){console.error("Error loading agent data:",Ce)}finally{u.value=!1,$e.value=!1}}},va=async()=>{b.value="",R.value="",z.value="",se.value="",Q.value="",V.value="",F.value="",J.value="",ne.value="",ce.value="",ke.value="",O.value="";let Ce=!1;pa(y.value)||(Ce=!0);const te=y.value;d.value==="dual_ai"&&L.value!==null&&L.value!==void 0&&L.value<=0&&(R.value="Max session turns must be a positive number",Ce=!0),Y.value||(z.value="Please select an agent prompt",Ce=!0);const Se=P.value||ee.value,Te=d.value==="ai_human"&&E.value;if(!Se&&!Te&&(z.value="At least one stop condition is required (or check manual stop condition for ai_human agents)",Ce=!0),ee.value&&!de.value&&(Q.value="Response property required when using stop tool",Ce=!0),S.value!==null&&S.value<=0&&(V.value="Max steps must be a positive number",Ce=!0),d.value==="dual_ai"&&!re.value&&!be.value&&(F.value="At least one side must have an end conversation tool",O.value="At least one side must have an end conversation tool",Ce=!0),d.value==="dual_ai"&&(N.value||(J.value="Please select an agent prompt",Ce=!0),M.value&&!A.value&&(ce.value="Response property required when using stop tool",Ce=!0),ue.value!==null&&ue.value<=0&&(ke.value="Max steps must be a positive number",Ce=!0)),Ce)return;const qe={name:te,title:v.value||null,type:d.value,expose_as_tool:k.value,tool_description:k.value?g.value:null,max_session_turns:d.value==="dual_ai"?L.value:null,side_a_label:K.value||null,side_a_agent_prompt:Y.value,side_a_stop_on_response:P.value,side_a_stop_tool:ee.value||null,side_a_stop_tool_response_property:de.value||null,side_a_manual_stop_condition:E.value,side_a_max_steps:S.value,side_a_end_conversation_tool:re.value||null};d.value==="dual_ai"&&(qe.side_b_label=q.value||null,qe.side_b_agent_prompt=N.value,qe.side_b_stop_on_response=U.value,qe.side_b_stop_tool=M.value||null,qe.side_b_stop_tool_response_property=A.value||null,qe.side_b_max_steps=ue.value,qe.side_b_end_conversation_tool=be.value||null),Object.keys(j.value).length>0&&(qe.tenvs=j.value),l.value&&a.editAgent?.id&&(qe.id=a.editAgent.id),i("save",qe)},fa=()=>{Ct(),i("update:modelValue",!1)};return ge(Y,async Ce=>{if($e.value||(ee.value="",de.value=""),!Ce){oe.value=null;return}ie.value=!0;try{const te=await fetch(fe(`/api/prompts/${Ce}`));te.ok&&(oe.value=await te.json())}catch(te){console.error("Error fetching Side A prompt:",te)}finally{ie.value=!1}$e.value||await Ot()}),ge(N,async Ce=>{if($e.value||(M.value="",A.value=""),!Ce){Ve.value=null;return}_e.value=!0;try{const te=await fetch(fe(`/api/prompts/${Ce}`));te.ok&&(Ve.value=await te.json())}catch(te){console.error("Error fetching Side B prompt:",te)}finally{_e.value=!1}$e.value||await Ot()}),ge(G,Ce=>{Ce||(ee.value="",de.value="")}),ge(W,Ce=>{Ce||(M.value="",A.value="")}),ge(()=>a.modelValue,async Ce=>{Ce?(await Promise.all([pe(),we()]),l.value?(Ct(),await ma()):Ct()):Ct()}),(Ce,te)=>{const Se=Be("FormKit");return r(),H(He,{"model-value":t.modelValue,"onUpdate:modelValue":te[26]||(te[26]=Te=>Ce.$emit("update:modelValue",Te)),title:l.value?"Edit Agent":"Create Agent",width:"max-w-5xl","content-padding":!1},{footer:D(()=>[e("div",j0,[w(T(De),{variant:"ghost",size:"sm",onClick:fa},{default:D(()=>[...te[55]||(te[55]=[Z(" Cancel ",-1)])]),_:1}),w(T(De),{variant:"primary",size:"sm",disabled:u.value,loading:u.value,onClick:va},{default:D(()=>[Z(C(l.value?"Update Agent":"Create Agent"),1)]),_:1},8,["disabled","loading"])])]),default:D(()=>[u.value?(r(),n("div",m0,[...te[27]||(te[27]=[e("span",{class:"text-neutral-500"},"Loading agent data...",-1)])])):(r(),H(Se,{key:1,type:"form",actions:!1,"form-class":"$reset flex-1 min-h-0 flex flex-col"},{default:D(()=>[e("div",v0,[e("nav",f0,[w(T(Qr),{tabs:c.value,"active-tab":T(h),onSelect:T(x)},null,8,["tabs","active-tab","onSelect"])]),e("div",{ref_key:"contentRef",ref:s,class:"flex-1 overflow-y-auto p-5 bg-neutral-100 dark:bg-neutral-950"},[e("div",h0,[t.apiError?(r(),H(T(Fe),{key:0,variant:"error"},{default:D(()=>[Z(C(t.apiError),1)]),_:1})):I("",!0),w(T(rt),{id:"section-basics",title:"Basics",icon:T(Lt)},{default:D(()=>[e("div",g0,[e("div",null,[w(Se,{type:"text",modelValue:y.value,"onUpdate:modelValue":te[0]||(te[0]=Te=>y.value=Te),label:"Agent Name",disabled:l.value,validation:"required","validation-messages":{required:"Name is required"},"outer-class":"$reset",onBlur:te[1]||(te[1]=Te=>y.value=ca(y.value))},null,8,["modelValue","disabled"]),b.value?(r(),H(T(ze),{key:0,class:"mt-1 text-red-600 dark:text-red-400"},{default:D(()=>[Z(C(b.value),1)]),_:1})):l.value?(r(),H(T(ze),{key:2,class:"mt-1"},{default:D(()=>[...te[29]||(te[29]=[Z(" Agent names cannot be changed after creation (used as foreign key for threads) ",-1)])]),_:1})):(r(),H(T(ze),{key:1,class:"mt-1"},{default:D(()=>[...te[28]||(te[28]=[Z(" Automatically formatted to snake_case with _agent suffix (e.g., research_agent) ",-1)])]),_:1}))]),e("div",b0,[e("div",null,[w(Se,{type:"text",modelValue:v.value,"onUpdate:modelValue":te[2]||(te[2]=Te=>v.value=Te),label:"Display Title (Optional)","outer-class":"$reset"},null,8,["modelValue"]),w(T(ze),{class:"mt-1"},{default:D(()=>[...te[30]||(te[30]=[Z(" Human-readable title shown in the UI ",-1)])]),_:1})]),e("div",null,[w(Se,{type:"selectSearch",modelValue:d.value,"onUpdate:modelValue":te[3]||(te[3]=Te=>d.value=Te),label:"Agent Type",options:da,"outer-class":"$reset"},null,8,["modelValue"]),w(T(ze),{class:"mt-1"},{default:D(()=>[...te[31]||(te[31]=[Z(" AI + AI or AI + Human conversation ",-1)])]),_:1})])]),d.value==="dual_ai"?(r(),n("div",x0,[w(Se,{type:"checkbox",modelValue:k.value,"onUpdate:modelValue":te[4]||(te[4]=Te=>k.value=Te),label:"Expose as Tool","outer-class":"$reset"},null,8,["modelValue"]),w(T(ze),{class:"mt-1"},{default:D(()=>[...te[32]||(te[32]=[Z(" Make this subagent available as a tool that can be called by other prompts or agents ",-1)])]),_:1})])):I("",!0),k.value&&d.value==="dual_ai"?(r(),n("div",y0,[w(Se,{type:"textarea",modelValue:g.value,"onUpdate:modelValue":te[5]||(te[5]=Te=>g.value=Te),label:"Tool Description",placeholder:"Describe what this agent does when called as a tool",rows:3,"outer-class":"$reset"},null,8,["modelValue"]),_.value?(r(),H(T(ze),{key:0,class:"mt-1 text-red-600 dark:text-red-400"},{default:D(()=>[Z(C(_.value),1)]),_:1})):(r(),H(T(ze),{key:1,class:"mt-1"},{default:D(()=>[...te[33]||(te[33]=[Z(" This description helps other agents understand when to use this agent ",-1)])]),_:1}))])):I("",!0),d.value==="dual_ai"?(r(),n("div",k0,[w(Se,{type:"number",modelValue:L.value,"onUpdate:modelValue":te[6]||(te[6]=Te=>L.value=Te),label:"Max Session Turns",placeholder:"Unlimited","outer-class":"$reset"},null,8,["modelValue"]),R.value?(r(),H(T(ze),{key:0,class:"mt-1 text-red-600 dark:text-red-400"},{default:D(()=>[Z(C(R.value),1)]),_:1})):(r(),H(T(ze),{key:1,class:"mt-1"},{default:D(()=>[...te[34]||(te[34]=[Z(" Maximum number of back-and-forth exchanges between the two agents before the conversation ends ",-1)])]),_:1}))])):I("",!0)])]),_:1},8,["icon"]),w(T(rt),{id:"section-side-a",title:"Side A (AI)",icon:T(mt)},{default:D(()=>[e("div",w0,[e("div",_0,[e("div",null,[w(Se,{type:"text",modelValue:K.value,"onUpdate:modelValue":te[7]||(te[7]=Te=>K.value=Te),label:"Side Label (Optional)",placeholder:"e.g., ATC, Pilot, Customer","outer-class":"$reset"},null,8,["modelValue"]),w(T(ze),{class:"mt-1"},{default:D(()=>[...te[35]||(te[35]=[Z(" Custom label for this side ",-1)])]),_:1})]),e("div",null,[w(Se,{type:"selectSearch",modelValue:Y.value,"onUpdate:modelValue":te[8]||(te[8]=Te=>Y.value=Te),label:"Agent Prompt",options:xe.value,validation:"required","validation-messages":{required:"Please select an agent prompt"},"outer-class":"$reset"},null,8,["modelValue","options"]),z.value?(r(),H(T(ze),{key:0,class:"mt-1 text-red-600 dark:text-red-400"},{default:D(()=>[Z(C(z.value),1)]),_:1})):(r(),H(T(ze),{key:1,class:"mt-1"},{default:D(()=>[...te[36]||(te[36]=[Z(" Defines this agent's behavior ",-1)])]),_:1}))])]),e("div",$0,[w(T(xt),{title:"Stop Conditions"}),w(T(ze),null,{default:D(()=>[...te[37]||(te[37]=[Z(" 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(Se,{type:"checkbox",modelValue:P.value,"onUpdate:modelValue":te[9]||(te[9]=Te=>P.value=Te),label:"Stop when agent returns content","outer-class":"$reset"},null,8,["modelValue"]),w(T(ze),{class:"ml-6"},{default:D(()=>[...te[38]||(te[38]=[Z(" Agent stops when it returns a response without calling tools ",-1)])]),_:1})]),e("div",null,[w(Se,{type:"checkbox",modelValue:G.value,"onUpdate:modelValue":te[10]||(te[10]=Te=>G.value=Te),label:"Stop on specific tool call","outer-class":"$reset"},null,8,["modelValue"]),G.value?(r(),n("div",C0,[w(Se,{type:"selectSearch",modelValue:ee.value,"onUpdate:modelValue":te[11]||(te[11]=Te=>ee.value=Te),label:"Stop Tool",options:We.value,placeholder:"Select a tool...",disabled:ie.value||!Y.value,"outer-class":"$reset"},null,8,["modelValue","options","disabled"]),se.value?(r(),H(T(ze),{key:0,class:"text-red-600 dark:text-red-400"},{default:D(()=>[Z(C(se.value),1)]),_:1})):(r(),H(T(ze),{key:1},{default:D(()=>[...te[39]||(te[39]=[Z(" Agent stops when this tool is called ",-1)])]),_:1})),ee.value?(r(),n("div",S0,[w(Se,{type:"selectSearch",modelValue:de.value,"onUpdate:modelValue":te[12]||(te[12]=Te=>de.value=Te),label:"Response Property",options:ia.value,placeholder:"Select property...","outer-class":"$reset"},null,8,["modelValue","options"]),Q.value?(r(),H(T(ze),{key:0,class:"mt-1 text-red-600 dark:text-red-400"},{default:D(()=>[Z(C(Q.value),1)]),_:1})):(r(),H(T(ze),{key:1,class:"mt-1"},{default:D(()=>[...te[40]||(te[40]=[Z(" Property from tool arguments to return as final response ",-1)])]),_:1}))])):I("",!0)])):I("",!0)]),d.value==="ai_human"&&!P.value&&!G.value?(r(),H(T(Fe),{key:0,variant:"warning",class:"mt-3"},{default:D(()=>[w(Se,{type:"checkbox",modelValue:E.value,"onUpdate:modelValue":te[13]||(te[13]=Te=>E.value=Te),label:"I have manually implemented a stop condition","outer-class":"$reset"},null,8,["modelValue"]),te[41]||(te[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})):I("",!0)]),e("div",T0,[e("div",null,[w(Se,{type:"number",modelValue:S.value,"onUpdate:modelValue":te[14]||(te[14]=Te=>S.value=Te),label:"Max Steps",placeholder:"Unlimited","outer-class":"$reset"},null,8,["modelValue"]),V.value?(r(),H(T(ze),{key:0,class:"mt-1 text-red-600 dark:text-red-400"},{default:D(()=>[Z(C(V.value),1)]),_:1})):(r(),H(T(ze),{key:1,class:"mt-1"},{default:D(()=>[...te[42]||(te[42]=[Z(" Safety limit before yielding ",-1)])]),_:1}))]),e("div",null,[w(Se,{type:"selectSearch",modelValue:re.value,"onUpdate:modelValue":te[15]||(te[15]=Te=>re.value=Te),label:"End Conversation Tool",options:We.value,placeholder:"Select a tool...",disabled:ie.value||!Y.value,"outer-class":"$reset"},null,8,["modelValue","options","disabled"]),F.value?(r(),H(T(ze),{key:0,class:"mt-1 text-red-600 dark:text-red-400"},{default:D(()=>[Z(C(F.value),1)]),_:1})):(r(),H(T(ze),{key:1,class:"mt-1"},{default:D(()=>[...te[43]||(te[43]=[Z(" Ends entire conversation when called ",-1)])]),_:1}))])])])]),_:1},8,["icon"]),w(T(rt),{id:"section-side-b",title:d.value==="ai_human"?"Side B (Human)":"Side B (AI)",icon:d.value==="ai_human"?T(mr):T(mt)},{default:D(()=>[e("div",I0,[d.value==="ai_human"?(r(),n(ve,{key:0},[e("div",null,[w(Se,{type:"text",modelValue:q.value,"onUpdate:modelValue":te[16]||(te[16]=Te=>q.value=Te),label:"Side Label (Optional)",placeholder:"e.g., Customer, User","outer-class":"$reset"},null,8,["modelValue"]),w(T(ze),{class:"mt-1"},{default:D(()=>[...te[44]||(te[44]=[Z(" Custom label for this side ",-1)])]),_:1})]),te[45]||(te[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(),n(ve,{key:1},[e("div",z0,[e("div",null,[w(Se,{type:"text",modelValue:q.value,"onUpdate:modelValue":te[17]||(te[17]=Te=>q.value=Te),label:"Side Label (Optional)",placeholder:"e.g., ATC, Pilot, Customer","outer-class":"$reset"},null,8,["modelValue"]),w(T(ze),{class:"mt-1"},{default:D(()=>[...te[46]||(te[46]=[Z(" Custom label for this side ",-1)])]),_:1})]),e("div",null,[w(Se,{type:"selectSearch",modelValue:N.value,"onUpdate:modelValue":te[18]||(te[18]=Te=>N.value=Te),label:"Agent Prompt",options:xe.value,validation:"required","validation-messages":{required:"Please select an agent prompt"},"outer-class":"$reset"},null,8,["modelValue","options"]),J.value?(r(),H(T(ze),{key:0,class:"mt-1 text-red-600 dark:text-red-400"},{default:D(()=>[Z(C(J.value),1)]),_:1})):(r(),H(T(ze),{key:1,class:"mt-1"},{default:D(()=>[...te[47]||(te[47]=[Z(" Defines this agent's behavior ",-1)])]),_:1}))])]),e("div",V0,[w(T(xt),{title:"Stop Conditions"}),w(T(ze),null,{default:D(()=>[...te[48]||(te[48]=[Z(" 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(Se,{type:"checkbox",modelValue:U.value,"onUpdate:modelValue":te[19]||(te[19]=Te=>U.value=Te),label:"Stop when agent returns content","outer-class":"$reset"},null,8,["modelValue"]),w(T(ze),{class:"ml-6"},{default:D(()=>[...te[49]||(te[49]=[Z(" Agent stops when it returns a response without calling tools ",-1)])]),_:1})]),e("div",null,[w(Se,{type:"checkbox",modelValue:W.value,"onUpdate:modelValue":te[20]||(te[20]=Te=>W.value=Te),label:"Stop on specific tool call","outer-class":"$reset"},null,8,["modelValue"]),W.value?(r(),n("div",M0,[w(Se,{type:"selectSearch",modelValue:M.value,"onUpdate:modelValue":te[21]||(te[21]=Te=>M.value=Te),label:"Stop Tool",options:$t.value,placeholder:"Select a tool...",disabled:_e.value||!N.value,"outer-class":"$reset"},null,8,["modelValue","options","disabled"]),ne.value?(r(),H(T(ze),{key:0,class:"text-red-600 dark:text-red-400"},{default:D(()=>[Z(C(ne.value),1)]),_:1})):(r(),H(T(ze),{key:1},{default:D(()=>[...te[50]||(te[50]=[Z(" Agent stops when this tool is called ",-1)])]),_:1})),M.value?(r(),n("div",E0,[w(Se,{type:"selectSearch",modelValue:A.value,"onUpdate:modelValue":te[22]||(te[22]=Te=>A.value=Te),label:"Response Property",options:ua.value,placeholder:"Select property...","outer-class":"$reset"},null,8,["modelValue","options"]),ce.value?(r(),H(T(ze),{key:0,class:"mt-1 text-red-600 dark:text-red-400"},{default:D(()=>[Z(C(ce.value),1)]),_:1})):(r(),H(T(ze),{key:1,class:"mt-1"},{default:D(()=>[...te[51]||(te[51]=[Z(" Property from tool arguments to return as final response ",-1)])]),_:1}))])):I("",!0)])):I("",!0)])]),e("div",L0,[e("div",null,[w(Se,{type:"number",modelValue:ue.value,"onUpdate:modelValue":te[23]||(te[23]=Te=>ue.value=Te),label:"Max Steps",placeholder:"Unlimited","outer-class":"$reset"},null,8,["modelValue"]),ke.value?(r(),H(T(ze),{key:0,class:"mt-1 text-red-600 dark:text-red-400"},{default:D(()=>[Z(C(ke.value),1)]),_:1})):(r(),H(T(ze),{key:1,class:"mt-1"},{default:D(()=>[...te[52]||(te[52]=[Z(" Safety limit before yielding ",-1)])]),_:1}))]),e("div",null,[w(Se,{type:"selectSearch",modelValue:be.value,"onUpdate:modelValue":te[24]||(te[24]=Te=>be.value=Te),label:"End Conversation Tool",options:$t.value,placeholder:"Select a tool...",disabled:_e.value||!N.value,"outer-class":"$reset"},null,8,["modelValue","options","disabled"]),O.value?(r(),H(T(ze),{key:0,class:"mt-1 text-red-600 dark:text-red-400"},{default:D(()=>[Z(C(O.value),1)]),_:1})):(r(),H(T(ze),{key:1,class:"mt-1"},{default:D(()=>[...te[53]||(te[53]=[Z(" Ends entire conversation when called ",-1)])]),_:1}))])])],64))])]),_:1},8,["title","icon"]),$.value.length>0||Object.keys(j.value).length>0?(r(),H(T(rt),{key:1,id:"section-env",title:"Environment",icon:T(Ht)},{default:D(()=>[e("div",P0,[te[54]||(te[54]=e("p",{class:"text-sm text-neutral-500 dark:text-neutral-400"}," Configure values for tools that require thread environment variables. Values from prompts are shown locked - click to unlock and override. ",-1)),he.value?(r(),n("span",A0,"Loading...")):I("",!0),w(Zt,{modelValue:j.value,"onUpdate:modelValue":te[25]||(te[25]=Te=>j.value=Te),inherited:$.value,"allow-custom":!0,disabled:u.value},null,8,["modelValue","inherited","disabled"])])]),_:1},8,["icon"])):I("",!0)])],512)])]),_:1}))]),_:1},8,["model-value","title"])}}}),ta=me({__name:"ExtractCopyToggle",props:{value:{},disabled:{type:Boolean}},emits:["update:value"],setup(t,{emit:o}){const a=o,i=l=>{a("update:value",l)};return(l,u)=>{const s=Be("FormKit");return r(),H(s,{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:i},null,8,["value","disabled"])}}}),O0={class:"font-mono text-sm"},R0={class:"flex items-center gap-2 py-1.5"},U0={class:"text-neutral-600 dark:text-neutral-400"},B0={class:"ml-auto"},ra=me({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:Oe("div",{class:"ml-4"},t.children.map((o,a)=>Oe("div",{class:"relative",key:o.uid},[a<t.children.length-1?Oe("div",{class:"absolute left-0 top-0 bottom-0 border-l border-neutral-300 dark:border-neutral-700"}):Oe("div",{class:"absolute left-0 top-0 h-3 border-l border-neutral-300 dark:border-neutral-700"}),Oe("div",{class:"absolute left-0 top-3 w-4 border-t border-neutral-300 dark:border-neutral-700"}),Oe("div",{class:"pl-5"},[Oe("div",{class:"flex items-center gap-2 py-1.5"},[Oe("span",{class:"text-neutral-600 dark:text-neutral-400"},o.name),Oe(ft,{variant:t.getTypeColor(o.type),size:"sm"},()=>o.type),t.isShared(o)?Oe("span",{class:"text-xs text-amber-600 dark:text-amber-400",title:`Used by: ${o.sharedWith.join(", ")}`},`(used in ${o.sharedWith.length} other${o.sharedWith.length>1?"s":""})`):null,o.isDuplicate?null:Oe("div",{class:"ml-auto"},[Oe(ta,{value:t.getSelection(o),disabled:t.isShared(o),"onUpdate:value":i=>t.setSelection(o,i),title:t.isShared(o)?"Cannot extract items shared with other agents":""})])]),o.children.length>0?Oe(ra,{children:o.children,getSelection:t.getSelection,setSelection:t.setSelection,isShared:t.isShared,getTypeColor:t.getTypeColor}):null])])))}}),F0=me({__name:"DependencyTree",props:{analysis:{},selections:{}},emits:["update:selection"],setup(t,{emit:o}){const a=t,i=o,l=B(()=>{const c=a.analysis,f=[];let y=0;const b=(L,R)=>{for(const K of L){const Y=`${R}:${K.name}`;f.push({...K,type:R,uid:`${Y}:${y++}`})}};b(c.constituents.agents,"agent"),b(c.constituents.prompts,"prompt"),b(c.constituents.tools,"tool"),b(c.constituents.models,"model"),b(c.constituents.hooks,"hook");const v=new Map,d=`agent:${c.agent}`;for(const L of f){const R=L.parentKey||d;`${L.type}:${L.name}`===d&&!L.parentKey||(v.has(R)||v.set(R,[]),v.get(R).push(L))}const k=new Set,g=L=>{const R=`${L.type}:${L.name}`,K=k.has(R);k.add(R);const Y=[],z=v.get(R)||[];for(const P of z)Y.push(g(P));return{name:L.name,type:L.type,filePath:L.filePath,sharedWith:L.sharedWith,discoveredVia:L.discoveredVia,children:Y,uid:L.uid,isDuplicate:K}},_=f.find(L=>L.type==="agent"&&L.name===c.agent&&!L.parentKey);return _?g(_):{name:c.agent,type:"agent",filePath:"",sharedWith:[],discoveredVia:"static",children:[],uid:"root",isDuplicate:!1}}),u=c=>`${c.type}:${c.name}`,s=c=>a.selections.get(u(c))||"extract",m=(c,f)=>{i("update:selection",u(c),f)},h=c=>c.sharedWith.length>0,x=c=>{switch(c){case"agent":return"accent";case"prompt":return"secondary";case"tool":return"success";case"model":return"warning";case"hook":return"default"}};return(c,f)=>(r(),n("div",O0,[e("div",R0,[e("span",U0,C(l.value.name),1),w(T(ft),{variant:x(l.value.type),size:"sm"},{default:D(()=>[Z(C(l.value.type),1)]),_:1},8,["variant"]),e("div",B0,[w(ta,{value:s(l.value),"onUpdate:value":f[0]||(f[0]=y=>m(l.value,y))},null,8,["value"])])]),(r(),H(Ue(T(ra)),{children:l.value.children,"get-selection":s,"set-selection":m,"is-shared":h,"get-type-color":x},null,8,["children"]))]))}}),N0={key:0,class:"flex items-center justify-center py-12"},q0={key:1,class:"py-4"},H0={key:2,class:"py-4 space-y-4"},W0={class:"space-y-2"},K0={class:"text-sm opacity-80"},J0={class:"text-sm opacity-80"},Y0={key:3,class:"space-y-6"},G0={class:"space-y-4"},Z0={class:"grid grid-cols-2 gap-4"},X0={class:"col-span-2"},Q0=["value"],ep={class:"col-span-2"},tp={class:"col-span-2"},rp={key:0,class:"mt-3 space-y-3"},ap={class:"flex gap-2 border-b border-neutral-200 dark:border-neutral-700"},op={key:0},np=["innerHTML"],lp={class:"space-y-4"},sp={class:"list-disc list-inside space-y-1"},ip={class:"border border-neutral-200 dark:border-neutral-700 rounded-lg p-4 bg-neutral-50 dark:bg-neutral-900/50"},up={class:"flex justify-between"},dp=me({__name:"PackModal",props:{modelValue:{type:Boolean},agent:{}},emits:["update:modelValue","packed"],setup(t,{emit:o}){Vt.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"}],i=t,l=o,u=B({get:()=>i.modelValue,set:q=>l("update:modelValue",q)}),s=p(null),m=p(!1),h=p(!1),x=p(null),c=p(null),f=p(""),y=p("1.0.0"),b=p("MIT"),v=p(""),d=p(""),k=p("edit"),g=p(!1),_=p(null),L=p(null),R=B(()=>d.value?Vt(d.value):""),K=p(new Map);ge(()=>i.modelValue,async q=>{q&&i.agent?await Promise.all([z(),P()]):Y()});const Y=()=>{s.value=null,x.value=null,c.value=null,K.value=new Map,f.value="",y.value="1.0.0",b.value="MIT",v.value="",d.value="",k.value="edit",g.value=!1,_.value=null,L.value=null},z=async()=>{if(i.agent){m.value=!0,x.value=null;try{const q=await fetch(fe(`/api/pack/${i.agent.id}/analyze`)),N=await q.json();if(!q.ok){x.value=N.error||"Failed to analyze agent";return}if(s.value=N,N.generatedReadme)d.value=N.generatedReadme;else{const J=G(i.agent?.id||"agent");d.value=ee(J,i.agent?.id||"agent",N.agentDescription)}de(N)}catch(q){x.value=q instanceof Error?q.message:"Failed to analyze agent"}finally{m.value=!1}}},P=async()=>{if(i.agent)try{const q=await fetch(fe(`/api/pack/${i.agent.id}/metadata`));if(q.ok){const N=await q.json();f.value=N.packageName,y.value=se(N.version),b.value=N.license||"MIT",v.value=N.licenseOwner||""}else f.value=G(i.agent.id),y.value="1.0.0",b.value="MIT",v.value=""}catch{f.value=G(i.agent?.id||"agent"),y.value="1.0.0",b.value="MIT",v.value=""}},G=q=>`standardagent-${q.toLowerCase().replace(/_/g,"-")}`,ee=(q,N,J)=>`# ${q}
5
+ `)||U.length>s.searchQuery.length+5?g():(s.searchQuery=U,R(U))}else g()}else g()},k=async()=>{s.dialogOpen=!0,s.selectedIndex=0,await Le(),_()},g=()=>{s.dialogOpen=!1,s.searchResults=[],s.searchQuery="",s.atTriggerIndex=-1,s.isSearching=!1},_=()=>{if(!u.value||!l.value)return;const E=window.getSelection();if(!E||!E.rangeCount)return;const V=E.getRangeAt(0).getBoundingClientRect(),re=l.value.getBoundingClientRect();s.dialogPosition={x:V.left-re.left,y:V.bottom-re.top+4}};let L=null;const R=async E=>{if(!a.search){s.searchResults=[];return}L&&clearTimeout(L),s.isSearching=!0,L=setTimeout(async()=>{try{const S=await a.search(E);s.searchResults=(S||[]).filter(V=>a.allowedTypes?.includes(V.type))}catch(S){console.error("Search error:",S),s.searchResults=[]}finally{s.isSearching=!1}},200)},K=E=>E.type==="variable"?{type:"variable",value:E.value??E.id??"",label:E.label,schema:E.schema,_uid:m(),meta:E.meta}:{type:"prompt",id:E.id??E.value??"",label:E.label,schema:E.schema,_uid:m(),meta:E.meta},Y=E=>{if(s.atTriggerIndex<0||!l.value)return;const S=window.getSelection();if(!S||!S.rangeCount)return;const V=S.getRangeAt(0);if(V.startContainer.nodeType!==Node.TEXT_NODE)return;const re=V.startContainer,F=re.data.slice(0,s.atTriggerIndex),q=re.data.slice(V.startOffset),N=document.createElement("span"),J=K(E),U=J.type==="prompt"&&J.meta&&!J.meta.isValid;N.className=`prompt-tag${U?" prompt-tag-invalid":""}`,N.setAttribute("contenteditable","false");const W=J._uid||(J._uid=m());N.dataset.segmentUid=W;const M=J.type==="variable"?{type:"variable",value:J.value,label:J.label,schema:J.schema}:{type:"prompt",id:J.id,label:J.label,schema:J.schema};if(N.dataset.segment=encodeURIComponent(JSON.stringify(M)),N.textContent=h(J),U){const ke=document.createElement("span");ke.className="prompt-tag-warning",ke.textContent="⚠️",ke.setAttribute("title",J.meta.validationMessage||"Validation error"),N.appendChild(ke)}const ne=re.parentNode,A=document.createTextNode(q),ce=document.createTextNode(F);ne.insertBefore(ce,re),ne.insertBefore(N,re),ne.insertBefore(A,re),ne.removeChild(re),g(),v({target:l.value});const ue=window.getSelection();if(ue){const ke=document.createRange();ke.setStart(A,0),ke.collapse(!0),ue.removeAllRanges(),ue.addRange(ke)}l.value.focus()},z=E=>{if((E.key==="ArrowLeft"||E.key==="ArrowRight")&&setTimeout(()=>d(),0),s.dialogOpen)E.key==="ArrowDown"?(E.preventDefault(),s.selectedIndex=Math.min(s.selectedIndex+1,s.searchResults.length-1)):E.key==="ArrowUp"?(E.preventDefault(),s.selectedIndex=Math.max(s.selectedIndex-1,0)):E.key==="Enter"?(E.preventDefault(),s.searchResults[s.selectedIndex]&&Y(s.searchResults[s.selectedIndex])):(E.key==="Escape"||E.key==="Esc")&&(E.preventDefault(),g());else if(E.key==="Backspace"||E.key==="Delete"){const S=x();if(E.key==="Backspace"){const V=window.getSelection();if(V&&V.rangeCount){const re=V.getRangeAt(0);if(re.collapsed&&re.startContainer.nodeType===Node.TEXT_NODE&&re.startOffset===0){let F=re.startContainer;for(;F&&F!==l.value;){const q=F.previousSibling;if(q&&q.nodeType===Node.ELEMENT_NODE&&q.classList?.contains("prompt-tag")){E.preventDefault(),q.parentNode?.removeChild(q),v({target:l.value});return}F=F.parentNode}}}}if(!S)return;if(E.key==="Backspace"&&S.offset===0&&S.segmentIndex>0)s.segments[S.segmentIndex-1].type!=="string"&&(E.preventDefault(),s.segments.splice(S.segmentIndex-1,1),f(),ee(),c());else if(E.key==="Delete"&&S.segmentIndex<s.segments.length-1){const V=s.segments[S.segmentIndex];V.type==="string"&&(V.value?.length??0)===S.offset&&s.segments[S.segmentIndex+1].type!=="string"&&(E.preventDefault(),s.segments.splice(S.segmentIndex+1,1),f(),ee(),c())}}},P=E=>{E.preventDefault();const S=E.clipboardData?.getData("text/plain")||"";document.execCommand("insertText",!1,S)},G=E=>{if(!s.dialogOpen)return;const S=u.value;S&&(S.contains(E.target)||g())},ee=()=>{s.ignoreNextWatch=!0;const E=s.segments.map(S=>{const{_uid:V,...re}=S||{};return re});i("update:modelValue",E)},se=()=>{const E=window.getSelection();if(!E||!l.value)return;const S=E.anchorNode;S&&l.value.contains(S)&&d()},de=E=>{(E.key==="Escape"||E.key==="Esc")&&s.dialogOpen&&(E.preventDefault(),g())};Pe(()=>{a.modelValue&&a.modelValue.length&&(s.segments=JSON.parse(JSON.stringify(a.modelValue))),c(),document.addEventListener("mousedown",G),document.addEventListener("selectionchange",se),document.addEventListener("keydown",de,!0)}),Ye(()=>{document.removeEventListener("mousedown",G),document.removeEventListener("selectionchange",se),document.removeEventListener("keydown",de,!0)}),ge(()=>a.modelValue,E=>{if(s.ignoreNextWatch){s.ignoreNextWatch=!1;return}E&&(s.segments=JSON.parse(JSON.stringify(E)),c())},{deep:!0});const Q=B(()=>{const E=["prompt-input-editor","min-h-[100px]",a.disabled?"opacity-50 cursor-not-allowed":""];return a.editorClass?[...E,a.editorClass,"!h-auto"]:[...E,"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(E,S)=>(r(),n("div",Vo,[e("div",{ref_key:"editorRef",ref:l,contenteditable:!t.disabled,onInput:v,onKeydown:z,onPaste:P,onClick:b,onKeyup:S[0]||(S[0]=V=>{V.key==="Escape"?(V.preventDefault(),g()):(V.key==="ArrowLeft"||V.key==="ArrowRight")&&d()}),onCompositionstart:S[1]||(S[1]=V=>s.isComposing=!0),onCompositionend:S[2]||(S[2]=V=>s.isComposing=!1),class:ae(Q.value),"data-placeholder":t.placeholder},[Ae(e("div",null,[je(E.$slots,"segment",{segment:null},void 0,!0)],512),[[Ke,!1]])],42,Mo),s.dialogOpen?(r(),n("div",{key:0,ref_key:"dialogRef",ref:u,class:"absolute z-50",style:st({left:`${s.dialogPosition.x}px`,top:`${s.dialogPosition.y}px`})},[w(wt,{"offset-x":4,"offset-y":4,intensity:.3},{default:D(()=>[e("div",Eo,[s.isSearching?(r(),n("div",Lo," Searching... ")):s.searchResults.length===0?(r(),n("div",Po," No results found ")):(r(),n("div",Ao,[(r(!0),n(ve,null,ye(s.searchResults,(V,re)=>(r(),n("button",{key:V.id||V.value||re,type:"button",onClick:F=>Y(V),class:ae(["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",s.selectedIndex===re?"bg-neutral-100 dark:bg-neutral-900":""])},[e("div",Do,[Z(C(V.label||V.id||V.value)+" ",1),V.type==="prompt"&&V.meta&&!V.meta.isValid?(r(),n("span",{key:0,title:V.meta.validationMessage,class:"text-red-500"},"⚠️",8,Oo)):I("",!0)]),V.description?(r(),n("div",Ro,C(V.description),1)):I("",!0),V.type==="prompt"&&V.meta&&!V.meta.isValid?(r(),n("div",Uo,C(V.meta.validationMessage),1)):I("",!0),e("div",Bo,[e("span",{class:ae(["inline-block px-1.5 py-0.5 rounded",V.type==="variable"?"bg-blue-100 dark:bg-blue-900 text-blue-700 dark:text-blue-300":"bg-purple-100 dark:bg-purple-900 text-purple-700 dark:text-purple-300"])},C(V.type),3)])],10,jo))),128))]))])]),_:1})],4)):I("",!0)]))}}),Xe=(t,o)=>{const a=t.__vccOpts||t;for(const[i,l]of o)a[i]=l;return a},Gt=Xe(Fo,[["__scopeId","data-v-daddc895"]]),No=me({__name:"PromptInputWrapper",props:{context:{}},emits:["segment-click"],setup(t,{emit:o}){const a=t,i=(b,v)=>{const d=a.context;return d[b]!==void 0?d[b]:d.attrs?.[b]!==void 0?d.attrs[b]:v},l=B(()=>a.context.classes??{}),u=B(()=>a.context._value??[]),s=b=>{a.context.node.input(b)},m=B(()=>i("search",void 0)),h=B(()=>i("placeholder","Type @ to insert variables or prompts...")),x=B(()=>i("maxLength",void 0)),c=B(()=>i("allowedTypes",["variable","prompt"])),f=B(()=>a.context.disabled??!1),y=(b,v)=>{const d=a.context;d.attrs?.["onSegment-click"]&&d.attrs["onSegment-click"](b,v)};return(b,v)=>(r(),H(Gt,{"model-value":u.value,search:m.value,placeholder:h.value,disabled:f.value,"max-length":x.value,"allowed-types":c.value,"editor-class":l.value.inner,"onUpdate:modelValue":s,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:Ie(No),props:{context:"$node.context"}}]},Ho={class:"inline-flex items-center justify-center"},Ee=me({__name:"Loader",props:{size:{default:"md"}},setup(t){const o=t,a=B(()=>{switch(o.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(i,l)=>(r(),n("div",Ho,[e("div",{class:ae([a.value,"border-black/20 dark:border-white/20 border-t-black dark:border-t-white rounded-full animate-spin"])},null,2)]))}}),Wo=["type","disabled"],Ko="inline-flex items-center justify-center gap-2 font-medium rounded transition-all disabled:opacity-50 disabled:cursor-not-allowed",De=me({__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:o}){const a=t,i=o,l=B(()=>{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=B(()=>{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""}}),s=B(()=>a.size==="xs"||a.size==="sm"?"xs":"sm"),m=h=>{!a.disabled&&!a.loading&&i("click",h)};return(h,x)=>(r(),n("button",{type:t.type,disabled:t.disabled||t.loading,class:ae([Ko,l.value,u.value,t.fullWidth?"w-full":""]),onClick:m},[t.loading?(r(),H(Ee,{key:0,size:s.value},null,8,["size"])):t.iconLeft?(r(),H(Ue(t.iconLeft),{key:1,class:"w-4 h-4"})):I("",!0),je(h.$slots,"default"),t.iconRight&&!t.loading?(r(),H(Ue(t.iconRight),{key:2,class:"w-4 h-4"})):I("",!0)],10,Wo))}}),Jo=["disabled","aria-label","title"],Yo="inline-flex items-center justify-center rounded transition-colors disabled:opacity-50 disabled:cursor-not-allowed",Br=me({__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:o}){const a=t,i=o,l=B(()=>{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=B(()=>{switch(a.size){case"xs":return"p-0.5";case"sm":return"p-1";case"md":return"p-1.5";default:return""}}),s=B(()=>{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""}}),m=h=>{!a.disabled&&!a.loading&&i("click",h)};return(h,x)=>(r(),n("button",{type:"button",disabled:t.disabled||t.loading,"aria-label":t.label,title:t.label,class:ae([Yo,l.value,u.value]),onClick:m},[t.loading?(r(),H(Ee,{key:0,size:"xs"})):(r(),H(Ue(t.icon),{key:1,class:ae(s.value)},null,8,["class"]))],10,Jo))}}),Go=["for"],Zo={key:0,class:"text-red-500 ml-0.5"},Fr=me({__name:"UiLabel",props:{required:{type:Boolean,default:!1},htmlFor:{}},setup(t){return(o,a)=>(r(),n("label",{for:t.htmlFor,class:"block text-sm font-medium text-neutral-700 dark:text-neutral-300"},[je(o.$slots,"default"),t.required?(r(),n("span",Zo,"*")):I("",!0)],8,Go))}}),Xo={class:"text-xs text-red-500 dark:text-red-400"},tt=me({__name:"UiErrorText",setup(t){return(o,a)=>(r(),n("p",Xo,[je(o.$slots,"default")]))}}),Qo={class:"text-xs text-neutral-500 dark:text-neutral-400"},ze=me({__name:"UiHelpText",setup(t){return(o,a)=>(r(),n("p",Qo,[je(o.$slots,"default")]))}}),en={class:"space-y-1.5"},ct=me({__name:"UiFormField",props:{label:{},error:{},helpText:{},required:{type:Boolean,default:!1},htmlFor:{}},setup(t){return(o,a)=>(r(),n("div",en,[je(o.$slots,"label",{},()=>[t.label?(r(),H(Fr,{key:0,"html-for":t.htmlFor,required:t.required},{default:D(()=>[Z(C(t.label),1)]),_:1},8,["html-for","required"])):I("",!0)]),je(o.$slots,"default"),je(o.$slots,"error",{},()=>[t.error?(r(),H(tt,{key:0},{default:D(()=>[Z(C(t.error),1)]),_:1})):I("",!0)]),je(o.$slots,"help",{},()=>[t.helpText&&!t.error?(r(),H(ze,{key:0},{default:D(()=>[Z(C(t.helpText),1)]),_:1})):I("",!0)])]))}}),tn={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function rn(t,o){return r(),n("svg",tn,[...o[0]||(o[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 Pt=Ie({name:"lucide-x",render:rn}),an={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function on(t,o){return r(),n("svg",an,[...o[0]||(o[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)])])}Ie({name:"lucide-info",render:on});const nn={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function ln(t,o){return r(),n("svg",nn,[...o[0]||(o[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)])])}Ie({name:"lucide-circle-check",render:ln});const sn={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function un(t,o){return r(),n("svg",sn,[...o[0]||(o[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 ir=Ie({name:"lucide-triangle-alert",render:un}),dn={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function cn(t,o){return r(),n("svg",dn,[...o[0]||(o[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)])])}Ie({name:"lucide-circle-x",render:cn});const ft=me({__name:"UiBadge",props:{variant:{default:"default"},size:{default:"sm"},pill:{type:Boolean,default:!1}},setup(t){const o=t,a=B(()=>{switch(o.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""}}),i=B(()=>{switch(o.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(),n("span",{class:ae(["inline-flex items-center font-medium",a.value,i.value,t.pill?"rounded-full":"rounded"])},[je(l.$slots,"default")],2))}}),pn={key:0,class:"border-b border-neutral-200 dark:border-neutral-700"},mn={key:1,class:"border-t border-neutral-200 dark:border-neutral-700"},At=me({__name:"UiDropdownPanel",props:{width:{},maxHeight:{},shadow:{type:[Boolean,Object],default:!0}},setup(t){const o=t,a=B(()=>o.shadow===!0?{offsetX:6,offsetY:6,intensity:.4}:o.shadow&&typeof o.shadow=="object"?o.shadow:null),i=B(()=>!!o.shadow),l=B(()=>["bg-white dark:bg-neutral-900 border border-neutral-300 dark:border-neutral-600 rounded-lg overflow-hidden",o.width]),u=B(()=>[o.maxHeight?"overflow-y-auto":"",o.maxHeight]);return(s,m)=>(r(),H(Ue(i.value?wt:"template"),ka(wa(i.value?a.value:{})),{default:D(()=>[e("div",{class:ae(l.value)},[s.$slots.header?(r(),n("div",pn,[je(s.$slots,"header")])):I("",!0),e("div",{class:ae(u.value)},[je(s.$slots,"default")],2),s.$slots.footer?(r(),n("div",mn,[je(s.$slots,"footer")])):I("",!0)],2)]),_:3},16))}}),vn={class:"flex items-start gap-3"},fn={class:"flex-1 text-sm"},Fe=me({__name:"UiAlertBox",props:{variant:{default:"info"},showIcon:{type:Boolean,default:!0}},setup(t){const o=t,a=B(()=>{switch(o.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"}}),i=B(()=>{switch(o.variant){case"warning":return Sr;case"success":return $a;case"error":return _a;case"info":default:return Cr}}),l=B(()=>{switch(o.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,s)=>(r(),n("div",{class:ae(["px-4 py-3 border rounded-lg",a.value])},[e("div",vn,[t.showIcon?(r(),H(Ue(i.value),{key:0,class:ae(["w-5 h-5 mt-0.5 flex-shrink-0",l.value])},null,8,["class"])):I("",!0),e("div",fn,[je(u.$slots,"default")])])],2))}}),ur=me({__name:"UiMenuItem",props:{active:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},as:{default:"button"}},emits:["click"],setup(t,{emit:o}){const a=t,i=o;function l(u){a.disabled||i("click",u)}return(u,s)=>(r(),H(Ue(t.as),{type:t.as==="button"?"button":void 0,disabled:t.as==="button"?t.disabled:void 0,onClick:l,class:ae(["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:D(()=>[je(u.$slots,"default")]),_:3},8,["type","disabled","class"]))}}),hn={class:"relative inline-flex group"},dr=me({__name:"UiTooltip",props:{content:{},position:{default:"top"}},setup(t){const o=t,a=B(()=>{switch(o.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"}}),i=B(()=>{switch(o.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(),n("div",hn,[je(l.$slots,"default"),e("div",{class:ae(["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"},[Z(C(t.content)+" ",1),e("div",{class:ae(["absolute border-4",i.value])},null,2)],2)]))}}),Nr=me({__name:"UiCodeBlock",props:{inline:{type:Boolean,default:!0}},setup(t){return(o,a)=>(r(),H(Ue(t.inline?"code":"pre"),{class:ae(["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:D(()=>[je(o.$slots,"default")]),_:3},8,["class"]))}}),gn={key:0,class:"block text-zinc-700 dark:text-zinc-300 text-xs font-bold mb-1"},bn={key:0,class:"text-red-500"},xn=["disabled","aria-expanded"],yn={key:0,class:"flex items-center gap-2 text-zinc-400 flex-1 min-w-0"},kn=["src","alt"],wn={class:"block truncate"},_n={key:2,class:"block truncate text-zinc-400 flex-1 min-w-0"},$n=["placeholder"],Cn=["onClick","onMouseenter"],Sn=["src","alt"],Tn={key:1,class:"w-full h-full bg-zinc-200 dark:bg-zinc-700 rounded"},In={class:"flex-1 min-w-0"},Ge=me({__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:o}){const a=t,i=o,l=p(!1),u=p(""),s=p(),m=p(),h=p(),x=p(),c=p(-1),f=B(()=>a.options.find(G=>G.value===a.modelValue)),y=B(()=>{const G=a.activeHighlight&&f.value,ee=a.size==="sm"?"!text-xs !py-1 !px-2":"",se=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,se,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,se,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"]}),b=B(()=>{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))});ge(b,()=>{c.value=-1});const v=()=>{a.disabled||(l.value?g():(l.value=!0,u.value="",c.value=-1,Le(()=>{if(x.value&&(x.value.setAttribute("popover","auto"),x.value.addEventListener("toggle",z),"showPopover"in x.value))try{x.value.showPopover()}catch{}_(),setTimeout(()=>s.value?.focus(),0)})))},d=G=>{i("update:modelValue",G.value),g(),u.value="",c.value=-1},k=G=>{G.stopPropagation(),i("update:modelValue","")},g=()=>{if(x.value){if("hidePopover"in x.value)try{x.value.hidePopover()}catch{}x.value.removeEventListener("toggle",z)}l.value=!1,c.value=-1},_=()=>{if(!h.value||!x.value)return;const G=h.value.getBoundingClientRect(),ee=window.innerWidth;x.value.style.position="fixed",x.value.style.top=`${G.bottom+8}px`,x.value.style.left=`${G.left}px`,x.value.style.margin="0",x.value.style.width="max-content";const se=x.value.offsetWidth,de=G.width,Q=Math.min(400,ee-G.left-16),E=Math.max(de,Math.min(se,Q));x.value.style.width=`${E}px`},L=G=>{m.value&&!m.value.contains(G.target)&&x.value&&!x.value.contains(G.target)&&g()},R=G=>{G.key==="Escape"&&l.value&&(g(),h.value?.focus())},K=G=>{if(!l.value)return;const ee=b.value;if(ee.length!==0)switch(G.key){case"ArrowDown":G.preventDefault(),c.value=c.value<ee.length-1?c.value+1:0,Y();break;case"ArrowUp":G.preventDefault(),c.value=c.value>0?c.value-1:ee.length-1,Y();break;case"Enter":G.preventDefault(),c.value>=0&&c.value<ee.length&&d(ee[c.value]);break}},Y=()=>{Le(()=>{const G=x.value?.querySelector(".highlighted-option");G&&G.scrollIntoView({block:"nearest",behavior:"smooth"})})},z=G=>{G.target===x.value&&(l.value=G.newState==="open",l.value&&_())},P=()=>{l.value&&_()};return Pe(()=>{document.addEventListener("click",L),document.addEventListener("keydown",R),window.addEventListener("resize",P),window.addEventListener("scroll",P,!0)}),Ye(()=>{document.removeEventListener("click",L),document.removeEventListener("keydown",R),window.removeEventListener("resize",P),window.removeEventListener("scroll",P,!0)}),(G,ee)=>(r(),n("div",{ref_key:"dropdownRef",ref:m,class:"relative"},[t.label?(r(),n("label",gn,[Z(C(t.label)+" ",1),t.required?(r(),n("span",bn,"*")):I("",!0)])):I("",!0),e("button",{ref_key:"buttonRef",ref:h,type:"button",onClick:v,disabled:t.disabled,"aria-expanded":l.value,"aria-haspopup":!0,class:ae(y.value)},[e("div",{class:ae(["flex items-center gap-1 w-full",t.size==="sm"?"min-h-[1.25em]":"min-h-[1.5em]"])},[t.loading?(r(),n("span",yn,[w(Ee,{size:"xs"}),ee[1]||(ee[1]=Z(" Loading... ",-1))])):f.value?(r(),n("span",{key:1,class:ae(["flex items-center flex-1 min-w-0",t.size==="sm"?"gap-1.5":"gap-2"])},[f.value.icon?(r(),n("img",{key:0,src:f.value.icon,alt:f.value.label,class:ae(["flex-shrink-0",[t.size==="sm"?"w-4 h-4":"w-5 h-5",f.value.icon.startsWith("data:image/svg+xml")?"dark:invert":""]])},null,10,kn)):I("",!0),e("span",wn,C(f.value.label),1)],2)):(r(),n("span",_n,C(t.placeholder),1)),f.value&&!t.disabled?(r(),n("button",{key:3,type:"button",onClick:k,class:"flex-shrink-0 p-0.5 hover:bg-zinc-100 dark:hover:bg-zinc-800 rounded transition-colors","aria-label":"Clear selection"},[(r(),n("svg",{class:ae(["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))])):I("",!0),(r(),n("svg",{class:ae(["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,xn),l.value?(r(),n("div",{key:1,ref_key:"popoverRef",ref:x,class:"dropdown-popover z-[9999]"},[w(T(At),{"max-height":t.size==="sm"?"max-h-48":"max-h-60",shadow:{offsetX:4,offsetY:4,intensity:.3}},{header:D(()=>[e("div",{class:ae(t.size==="sm"?"p-1.5":"p-2")},[Ae(e("input",{ref_key:"searchInput",ref:s,"onUpdate:modelValue":ee[0]||(ee[0]=se=>u.value=se),type:"text",placeholder:t.searchPlaceholder,onKeydown:K,class:ae(["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,$n),[[Qe,u.value]])],2)]),default:D(()=>[b.value.length===0?(r(),n("div",{key:0,class:ae(["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)):I("",!0),(r(!0),n(ve,null,ye(b.value,(se,de)=>(r(),n("button",{key:se.value,type:"button",onClick:Q=>d(se),onMouseenter:Q=>c.value=de,class:ae(["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":se.value===t.modelValue,"bg-zinc-100 dark:bg-zinc-800 highlighted-option":de===c.value}]])},[e("div",{class:ae(["flex-shrink-0 mt-0.5",t.size==="sm"?"w-4 h-4":"w-5 h-5"])},[se.icon?(r(),n("img",{key:0,src:se.icon,alt:se.label,class:ae(["w-full h-full",se.icon.startsWith("data:image/svg+xml")?"dark:invert":""])},null,10,Sn)):(r(),n("div",Tn))],2),e("div",In,[e("div",{class:ae(["font-medium text-black dark:text-white",t.size==="sm"?"text-xs":"text-sm"])},C(se.label),3),se.description?(r(),n("div",{key:0,class:ae(["text-zinc-500 dark:text-zinc-400 mt-0.5",t.size==="sm"?"text-[10px]":"text-xs"])},C(se.description),3)):I("",!0)])],42,Cn))),128))]),_:1},8,["max-height"])],512)):I("",!0),t.error?(r(),H(T(tt),{key:2,class:"mt-1"},{default:D(()=>[Z(C(t.error),1)]),_:1})):I("",!0)],512))}}),zn=["type","value","placeholder","disabled"],lt=me({__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:o,emit:a}){const i=t,l=a,u=p(null),s=B(()=>["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",i.error?"border-red-500 dark:border-red-400":"border-neutral-300 dark:border-neutral-800",i.disabled?"opacity-50 cursor-not-allowed":""]),m=c=>{const f=c.target;l("update:modelValue",f.value)},h=c=>{l("focus",c)},x=c=>{l("click",c)};return o({inputRef:u}),(c,f)=>(r(),H(T(ct),{label:t.label,error:t.error,required:t.required},{default:D(()=>[e("input",{ref_key:"inputRef",ref:u,type:t.type,value:t.modelValue,placeholder:t.placeholder,disabled:t.disabled,class:ae(s.value),onInput:m,onFocus:h,onClick:x},null,42,zn)]),_:1},8,["label","error","required"]))}}),Vn=["data-property-id","data-nested-property-id"],Mn={class:"p-3 space-y-3"},En={class:"flex items-start gap-2"},Ln={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"},Pn={class:"flex-1 grid grid-cols-1 md:grid-cols-3 gap-2"},An={class:"flex items-center gap-2 mt-2"},jn=["disabled"],Dn={key:0},On={key:0,class:"p-3 bg-neutral-50 dark:bg-neutral-900 rounded-lg space-y-2"},Rn={class:"flex items-center justify-between mb-2"},Un=["disabled"],Bn={key:0,class:"space-y-1"},Fn=["onClick","disabled"],Nn={key:1,class:"p-3 bg-neutral-50 dark:bg-neutral-900 rounded-lg"},qn={class:"text-xs font-medium text-neutral-600 dark:text-neutral-400 mb-2"},Hn={class:"space-y-2"},Wn={class:"flex items-center justify-between"},Kn=["disabled"],Jn={class:"space-y-2"},Yn={key:2,class:"p-3 bg-neutral-50 dark:bg-neutral-900 rounded-lg"},Gn={key:0,class:"mb-2"},Zn=["disabled"],Xn={key:1,class:"space-y-2"},Qn=me({__name:"PropertyEditor",props:Ze({propertyId:{},isNested:{type:Boolean,default:!1},parentId:{},disabled:{type:Boolean,default:!1},enableDrag:{type:Boolean,default:!0}},{modelValue:{required:!0},modelModifiers:{}}),emits:Ze(["remove","description-keydown","add-top-level"],["update:modelValue"]),setup(t,{emit:o}){const a=t,i=o,l=it(t,"modelValue"),u=p(["object","array","enum","anyOf"].includes(l.value.type));p();const s=[{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"}],m=B(()=>["object","array","enum","anyOf"].includes(l.value.type));ge(()=>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 Le();const k=a.isNested?`[data-nested-property-id="${a.propertyId}"] input[placeholder="Description"]`:`[data-property-id="${a.propertyId}"] input[placeholder="Description"]`,g=document.querySelector(k);g&&g.focus()}},{immediate:!0,flush:"sync"});const h=v=>{v.shiftKey&&l.value.type==="object"&&l.value.properties?y():i("add-top-level")},x=()=>{l.value.items||(l.value.items={id:crypto.randomUUID(),name:"",type:"string",description:""})},c=()=>{l.value.enum||(l.value.enum=[]),l.value.enum.push(`value${l.value.enum.length+1}`)},f=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 Le();const d=document.querySelector(`[data-nested-property-id="${v.id}"] input[placeholder="Property name"]`);d&&(d.focus(),d.select())},b=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 k=Be("PropertyEditor",!0);return r(),n("div",{"data-property-id":t.isNested?void 0:t.propertyId,"data-nested-property-id":t.isNested?t.propertyId:void 0,class:ae(["border rounded-lg",t.isNested?"border-neutral-100 dark:border-neutral-900":"border-neutral-200 dark:border-neutral-800"])},[e("div",Mn,[e("div",En,[t.enableDrag?(r(),n("div",Ln,[...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)])])):I("",!0),e("div",Pn,[w(lt,{modelValue:l.value.name,"onUpdate:modelValue":d[0]||(d[0]=g=>l.value.name=g),placeholder:"Property name",disabled:t.disabled},null,8,["modelValue","disabled"]),w(Ge,{modelValue:l.value.type,"onUpdate:modelValue":d[1]||(d[1]=g=>l.value.type=g),options:s,disabled:t.disabled},null,8,["modelValue","disabled"]),w(lt,{modelValue:l.value.description,"onUpdate:modelValue":d[2]||(d[2]=g=>l.value.description=g),placeholder:"Description",disabled:t.disabled,onKeydown:d[3]||(d[3]=Ca(Re(g=>h(g),["prevent"]),["enter"]))},null,8,["modelValue","disabled"])]),e("div",An,[m.value?(r(),n("button",{key:0,onClick:d[4]||(d[4]=g=>u.value=!u.value),type:"button",class:"p-1 hover:bg-neutral-100 dark:hover:bg-neutral-800 rounded transition-colors"},[(r(),n("svg",{class:ae(["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))])):I("",!0),e("button",{onClick:d[5]||(d[5]=g=>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,jn)])]),u.value&&m.value?(r(),n("div",Dn,[l.value.type==="enum"?(r(),n("div",On,[e("div",Rn,[d[13]||(d[13]=e("h4",{class:"text-xs font-medium text-neutral-600 dark:text-neutral-400"}," Enum Values ",-1)),e("button",{onClick:c,type:"button",disabled:t.disabled,class:"px-2 py-0.5 text-xs bg-neutral-800 dark:bg-neutral-200 text-white dark:text-black rounded hover:bg-neutral-700 dark:hover:bg-neutral-300 transition-colors disabled:opacity-50"}," Add Value ",8,Un)]),l.value.enum?(r(),n("div",Bn,[(r(!0),n(ve,null,ye(l.value.enum,(g,_)=>(r(),n("div",{key:_,class:"flex items-center gap-2"},[w(lt,{modelValue:l.value.enum[_],"onUpdate:modelValue":L=>l.value.enum[_]=L,placeholder:"Enum value",disabled:t.disabled,class:"flex-1"},null,8,["modelValue","onUpdate:modelValue","disabled"]),e("button",{onClick:L=>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,Fn)]))),128))])):I("",!0)])):I("",!0),l.value.type==="object"||l.value.type==="anyOf"?(r(),n("div",Nn,[e("h4",qn,C(l.value.type==="anyOf"?"Type Options":"Nested Properties"),1),e("div",Hn,[e("div",Wn,[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,Kn)]),e("div",Jn,[(r(!0),n(ve,null,ye(l.value.type==="anyOf"?l.value.anyOf:l.value.properties,(g,_)=>(r(),H(k,{key:g.id,modelValue:(l.value.type==="anyOf"?l.value.anyOf:l.value.properties)[_],"onUpdate:modelValue":L=>(l.value.type==="anyOf"?l.value.anyOf:l.value.properties)[_]=L,"property-id":g.id,"is-nested":!0,"parent-id":t.propertyId,disabled:t.disabled,"enable-drag":!1,onRemove:L=>b(g.id),onAddTopLevel:d[6]||(d[6]=L=>i("add-top-level"))},null,8,["modelValue","onUpdate:modelValue","property-id","parent-id","disabled","onRemove"]))),128))])])])):I("",!0),l.value.type==="array"?(r(),n("div",Yn,[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?I("",!0):(r(),n("div",Gn,[e("button",{onClick:x,type:"button",disabled:t.disabled,class:"px-2 py-0.5 text-xs bg-neutral-800 dark:bg-neutral-200 text-white dark:text-black rounded hover:bg-neutral-700 dark:hover:bg-neutral-300 transition-colors disabled:opacity-50"}," Define Item Type ",8,Zn)])),l.value.items?(r(),n("div",Xn,[(r(),H(k,{key:`${l.value.items.id}-${l.value.items.type}`,modelValue:l.value.items,"onUpdate:modelValue":d[7]||(d[7]=g=>l.value.items=g),"property-id":l.value.items.id,"is-nested":!0,"parent-id":t.propertyId,disabled:t.disabled,"enable-drag":!1,onRemove:d[8]||(d[8]=g=>l.value.items=null),onAddTopLevel:d[9]||(d[9]=g=>i("add-top-level"))},null,8,["modelValue","property-id","parent-id","disabled"]))])):I("",!0)])):I("",!0)])):I("",!0)])],10,Vn)}}}),el={class:"space-y-2"},tl=["disabled"],rl=me({__name:"PropertyList",props:Ze({disabled:{type:Boolean,default:!1},parentId:{},isNested:{type:Boolean,default:!1}},{modelValue:{required:!0,default:()=>[]},modelModifiers:{}}),emits:Ze(["add-property","description-keydown"],["update:modelValue"]),setup(t,{expose:o,emit:a}){const i=t,l=a,u=it(t,"modelValue"),s=p();let m=!1;Pe(async()=>{}),Ye(()=>{});const h=async()=>{if(m)return;m=!0;const c={id:crypto.randomUUID(),name:`property${u.value.length+1}`,type:"string",description:"",required:!1};u.value=[...u.value,c],await Le();const f=i.parentId?`[data-nested-property-id="${c.id}"]`:`[data-property-id="${c.id}"]`,y=document.querySelector(`${f} input[placeholder="Property name"]`);y&&(y.focus(),y.select()),l("add-property"),m=!1},x=c=>{u.value=u.value.filter(f=>f.id!==c)};return o({addProperty:h}),(c,f)=>(r(),n("div",el,[e("div",{ref_key:"dragAreaRef",ref:s,class:"space-y-2"},[(r(!0),n(ve,null,ye(u.value,y=>(r(),H(Qn,{key:y.id,modelValue:u.value[u.value.indexOf(y)],"onUpdate:modelValue":b=>u.value[u.value.indexOf(y)]=b,"property-id":y.id,"is-nested":t.isNested,"parent-id":t.parentId,disabled:t.disabled,"enable-drag":!t.isNested,onRemove:b=>x(y.id),onAddTopLevel:f[0]||(f[0]=b=>c.$emit("add-property"))},null,8,["modelValue","onUpdate:modelValue","property-id","is-nested","parent-id","disabled","enable-drag","onRemove"]))),128))],512),e("div",{class:ae(t.isNested?"mt-2":"mt-3 pt-3 border-t border-neutral-200 dark:border-neutral-800")},[e("button",{onClick:h,type:"button",disabled:t.disabled,class:ae(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")},[...f[1]||(f[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"})]),Z(" Add Property ")],-1)])],10,tl)],2)]))}}),al={class:"space-y-4"},ol={key:0,class:"flex items-center justify-between"},nl={class:"text-sm font-medium"},ll={key:0,class:"text-red-500"},sl={class:"space-y-2 border border-neutral-200 dark:border-neutral-800 rounded-lg p-4"},il={key:0,class:"flex items-center justify-between mb-2"},ul={key:1,class:"text-center py-12"},dl=["disabled"],cl={class:"mt-4 text-center"},pl={key:3,class:"mt-4"},ml={class:"bg-neutral-50 dark:bg-neutral-900 border border-neutral-200 dark:border-neutral-800 rounded-lg p-4 overflow-x-auto"},vl={class:"text-xs leading-relaxed"},fl=["innerHTML"],qr=me({__name:"JSONSchemaInput",props:Ze({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 o=it(t,"modelValue"),a=p([]),i=p(),l=p(!1),u=()=>{if(o.value?.properties){const v=[];o.value.required;for(const[d,k]of Object.entries(o.value.properties)){const g=k,_={id:crypto.randomUUID(),name:d,type:g.type||"string",description:g.description||""};g.enum&&(_.enum=g.enum),g.anyOf&&(_.type="anyOf",_.anyOf=s(g.anyOf)),g.type==="array"&&g.items&&(_.items=m(g.items)),g.type==="object"&&g.properties&&(_.properties=h(g.properties,g.required||[])),v.push(_)}a.value=v}},s=v=>v.map(d=>typeof d=="object"&&d.type?{id:crypto.randomUUID(),name:"",type:d.type,description:d.description||"",properties:d.properties?h(d.properties,d.required||[]):void 0,items:d.items?m(d.items):void 0,enum:d.enum}:{id:crypto.randomUUID(),name:"",type:"string",description:""}),m=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=s(v.anyOf)),v.type==="array"&&v.items&&(d.items=m(v.items)),v.type==="object"&&v.properties&&(d.properties=h(v.properties,v.required||[])),d},h=(v,d)=>{const k=[];for(const[g,_]of Object.entries(v)){const L=_,R={id:crypto.randomUUID(),name:g,type:L.type||"string",description:L.description||""};L.enum&&(R.enum=L.enum),L.anyOf&&(R.type="anyOf",R.anyOf=s(L.anyOf)),L.type==="array"&&L.items&&(R.items=m(L.items)),L.type==="object"&&L.properties&&(R.properties=h(L.properties,L.required||[])),k.push(R)}return k};u();const x=()=>{const v={type:"object",properties:{},required:[],additionalProperties:!1},{properties:d}=f(a.value);v.properties=d,v.required=Object.keys(d),o.value=v},c=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(c)),v.type==="object"&&v.properties){const{properties:k}=f(v.properties);d.properties=k,d.required=Object.keys(k),d.additionalProperties=!1}return v.type==="array"&&v.items&&(d.items=c(v.items)),d},f=v=>{const d={},k=[];for(const g of v){const _={type:g.type==="anyOf"?void 0:g.type,description:g.description};if(k.push(g.name),g.type==="enum"&&g.enum&&(_.enum=g.enum,_.type="string"),g.type==="anyOf"&&g.anyOf&&g.anyOf.length>0&&(delete _.type,_.anyOf=g.anyOf.map(c)),g.type==="array"&&g.items&&(_.items=c(g.items)),g.type==="object"&&g.properties){const{properties:L}=f(g.properties);_.properties=L,_.required=Object.keys(L),_.additionalProperties=!1}d[g.name]=_}return{properties:d,required:k}};ge(a,()=>{x()},{deep:!0}),x();const y=B(()=>JSON.stringify(o.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>')),b=async()=>{if(a.value.length===0){const v={id:crypto.randomUUID(),name:"property1",type:"string",description:""};a.value.push(v),await Le();const d=document.querySelector(`[data-property-id="${v.id}"] input[placeholder="Property name"]`);d&&(d.focus(),d.select())}else i.value&&i.value.addProperty()};return(v,d)=>(r(),n("div",al,[t.label?(r(),n("div",ol,[e("label",nl,[Z(C(t.label)+" ",1),t.required?(r(),n("span",ll,"*")):I("",!0)])])):I("",!0),e("div",sl,[a.value.length>0?(r(),n("div",il,[...d[2]||(d[2]=[e("h3",{class:"text-sm font-medium text-neutral-700 dark:text-neutral-300"}," Properties ",-1)])])):I("",!0),a.value.length===0?(r(),n("div",ul,[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:b,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"})]),Z(" Add Property ")],-1)])],8,dl)])):I("",!0),a.value.length>0?(r(),H(rl,{key:2,ref_key:"propertyListRef",ref:i,modelValue:a.value,"onUpdate:modelValue":d[0]||(d[0]=k=>a.value=k),disabled:t.disabled,onAddProperty:b},null,8,["modelValue","disabled"])):I("",!0),e("div",cl,[e("button",{onClick:d[1]||(d[1]=k=>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(),n("div",pl,[e("div",ml,[e("pre",vl,[e("code",{class:"font-mono",innerHTML:y.value},null,8,fl)])])])):I("",!0)])]))}}),hl=gt(Ie(qr),{props:["label","disabled","required"],family:"text",features:[]}),gl={class:"space-y-2"},bl={key:0,class:"space-y-2"},xl={key:0,class:"block text-sm font-medium"},yl={key:0,class:"text-red-500"},kl=["src","alt"],wl={class:"flex-1 text-sm"},_l={key:0,class:"text-xs text-neutral-500 dark:text-neutral-400 ml-1"},$l=["onClick","aria-label"],ht=me({__name:"MultipleSelectionsInput",props:Ze({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:Ze(["removeItem"],["update:modelValue"]),setup(t,{emit:o}){const a=t,i=o,l=it(t,"modelValue"),u=p();Tr(async()=>{u.value,await Le(),await Ir({parent:u,values:l,dragHandle:".drag-handle"})});const s=B(()=>Array.isArray(l.value)?l.value.length>0&&typeof l.value[0]=="object"?l.value:l.value.map(c=>{const f=a.options.find(y=>y.value===c);return{id:c,label:f?.label||c,description:f?.description,icon:f?.icon}}):[]),m=B(()=>{const c=s.value.map(f=>f.id);return a.options.filter(f=>!c.includes(f.value))}),h=c=>{if(!c)return;const f=a.options.find(y=>y.value===c);if(f)if(l.value.length===0||typeof l.value[0]=="string")l.value=[...l.value,c];else{const y={id:c,label:f.label,description:f.description,icon:f.icon};l.value=[...l.value,y]}},x=c=>{typeof l.value[0]=="string"?l.value=l.value.filter(f=>f!==c):l.value=l.value.filter(f=>f.id!==c),i("removeItem",c)};return(c,f)=>(r(),n("div",gl,[s.value.length>0?(r(),n("div",bl,[t.label?(r(),n("label",xl,[Z(C(t.label)+" ",1),t.required?(r(),n("span",yl,"*")):I("",!0)])):I("",!0),e("div",{class:"space-y-1",ref_key:"dragAreaRef",ref:u},[(r(!0),n(ve,null,ye(s.value,y=>(r(),n("div",{key:y.id,class:ae(["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":""])},[f[1]||(f[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(),n("img",{key:0,src:y.icon,alt:y.label,class:"w-4 h-4 flex-shrink-0"},null,8,kl)):I("",!0),e("span",wl,[Z(C(y.label)+" ",1),y.description?(r(),n("span",_l," ("+C(y.description)+") ",1)):I("",!0)]),t.disabled?I("",!0):(r(),n("button",{key:1,onClick:b=>x(y.id),type:"button",class:"p-1 hover:bg-neutral-200 dark:hover:bg-neutral-800 rounded transition-colors","aria-label":`Remove ${y.label}`},[...f[0]||(f[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,$l))],2))),128))],512)])):I("",!0),w(Ge,{"model-value":"","onUpdate:modelValue":h,label:s.value.length>0?t.addLabel:t.label,options:m.value,placeholder:t.placeholder,"search-placeholder":t.searchPlaceholder,disabled:t.disabled||m.value.length===0,loading:t.loading},null,8,["label","options","placeholder","search-placeholder","disabled","loading"]),t.error?(r(),H(T(tt),{key:1},{default:D(()=>[Z(C(t.error),1)]),_:1})):I("",!0)]))}});function Cl(){return window.__AGENTBUILDER_CONFIG__||{mountPoint:"/agentbuilder"}}function _t(){return Cl().mountPoint}function fe(t){const o=_t(),a=t.startsWith("/")?t:`/${t}`;return o==="/"?a:`${o}${a}`}const Sl=me({__name:"ModelSelectorInput",props:Ze({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 o=t,a=it(t,"modelValue"),i=p([]),l=p(!1),u=B(()=>i.value.map(h=>({value:h.id,label:h.name,description:h.provider_id||h.provider,icon:h.iconId}))),s=async()=>{l.value=!0;try{const h=await fetch(fe("/api/models"));if(h.ok){const x=await h.json();i.value=x.models||[]}}catch(h){console.error("Error fetching models:",h)}finally{l.value=!1}},m=h=>{};return Pe(()=>{s()}),ge(()=>o.allowMultiple,()=>{o.allowMultiple&&typeof a.value=="string"?a.value=a.value?[a.value]:[]:!o.allowMultiple&&Array.isArray(a.value)&&(a.value=a.value[0]||"")}),(h,x)=>(r(),n(ve,null,[t.allowMultiple?(r(),H(ht,{key:0,modelValue:a.value,"onUpdate:modelValue":x[0]||(x[0]=c=>a.value=c),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:m},null,8,["modelValue","label","placeholder","error","required","disabled","options","loading"])):(r(),H(Ge,{key:1,modelValue:a.value,"onUpdate:modelValue":x[1]||(x[1]=c=>a.value=c),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(),H(T(tt),{key:2,class:"mt-1"},{default:D(()=>[Z(C(t.error),1)]),_:1})):I("",!0)],64))}}),Tl=me({__name:"AgentSelectorInput",props:Ze({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 o=t,a=it(t,"modelValue"),i=p([]),l=p(!1),u=B(()=>i.value.map(h=>({value:h.id,label:h.title,description:h.tool_description||`Handoff to ${h.title} agent`}))),s=async()=>{l.value=!0;try{const h=fe(`/api/agents${o.agentType?`?type=${o.agentType}`:""}`),x=await fetch(h);if(x.ok){const c=await x.json();i.value=c.agents||[]}}catch(h){console.error("Error fetching agents:",h)}finally{l.value=!1}},m=h=>{};return Pe(()=>{s()}),ge(()=>o.allowMultiple,()=>{o.allowMultiple&&typeof a.value=="string"?a.value=a.value?[a.value]:[]:!o.allowMultiple&&Array.isArray(a.value)&&(a.value=a.value[0]||"")},{immediate:!0}),(h,x)=>(r(),n(ve,null,[t.allowMultiple?(r(),H(ht,{key:0,modelValue:a.value,"onUpdate:modelValue":x[0]||(x[0]=c=>a.value=c),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:m},null,8,["modelValue","label","placeholder","error","required","disabled","options","loading"])):(r(),H(Ge,{key:1,modelValue:a.value,"onUpdate:modelValue":x[1]||(x[1]=c=>a.value=c),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(),H(T(tt),{key:2,class:"mt-1"},{default:D(()=>[Z(C(t.error),1)]),_:1})):I("",!0)],64))}}),Il=me({__name:"ToolSelectorInput",props:Ze({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 o=t,a=it(t,"modelValue"),i=p([]),l=p(!1),u=B(()=>i.value.map(h=>{let x=h.name;return h.type==="prompt"?x=`${h.name} (prompt)`:h.type==="mcp"&&(x=`${h.name} (mcp)`),{value:h.name,label:x,description:h.description}})),s=async()=>{l.value=!0;try{const h=await fetch(fe("/api/tools"));if(h.ok){const x=await h.json();i.value=Object.entries(x).map(([c,f])=>({name:c,description:f.description||"",type:f.type,model:f.model}))}}catch(h){console.error("Error fetching tools:",h)}finally{l.value=!1}},m=h=>{};return Pe(()=>{s()}),ge(()=>o.allowMultiple,()=>{o.allowMultiple&&typeof a.value=="string"?a.value=a.value?[a.value]:[]:!o.allowMultiple&&Array.isArray(a.value)&&(a.value=a.value[0]||"")},{immediate:!0}),(h,x)=>(r(),n(ve,null,[t.allowMultiple?(r(),H(ht,{key:0,modelValue:a.value,"onUpdate:modelValue":x[0]||(x[0]=c=>a.value=c),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:m},null,8,["modelValue","label","placeholder","error","required","disabled","options","loading"])):(r(),H(Ge,{key:1,modelValue:a.value,"onUpdate:modelValue":x[1]||(x[1]=c=>a.value=c),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(),H(T(tt),{key:2,class:"mt-1"},{default:D(()=>[Z(C(t.error),1)]),_:1})):I("",!0)],64))}}),zl=gt(Ie(Sl),{props:["label","placeholder","error","required","disabled","allowMultiple"],family:"dropdown",features:[]}),Vl=gt(Ie(Tl),{props:["label","placeholder","error","required","disabled","allowMultiple","agentType"],family:"dropdown",features:[]}),Ml=gt(Ie(Il),{props:["label","placeholder","error","required","disabled","allowMultiple"],family:"dropdown",features:[]}),El={class:"space-y-4"},Ll={class:"flex items-start gap-2"},Pl={class:"flex-1"},Al=["onClick","disabled","title"],jl={key:0,class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},Dl={key:1,class:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24"},Ol={key:0,class:"text-xs text-neutral-400 dark:text-neutral-500 mt-1"},Rl={key:0,class:"text-amber-500 dark:text-amber-400 ml-1"},Ul={class:"flex-1"},Bl={class:"flex-1"},Fl=["onClick","disabled"],Nl=["disabled"],Zt=me({__name:"TenvPropertyList",props:{modelValue:{},inherited:{default:()=>[]},allowCustom:{type:Boolean,default:!0},disabled:{type:Boolean,default:!1}},emits:["update:modelValue"],setup(t,{emit:o}){const a=t,i=o,l=p(new Set),u=p([]),s=B(()=>new Set(a.inherited.map(d=>d.name)));ge(()=>a.modelValue,d=>{const k=Object.keys(d).filter(_=>!s.value.has(_)),g=new Set(u.value.map(_=>_.name));for(const _ of k)g.has(_)||u.value.push({id:crypto.randomUUID(),name:_,value:String(d[_]??"")})},{immediate:!0,deep:!0});const m=d=>{if(l.value.has(d)){l.value.delete(d);const k=a.inherited.find(g=>g.name===d);k&&h(d,k.value)}else l.value.add(d)},h=(d,k)=>{const g={...a.modelValue};k===void 0||k===""?delete g[d]:g[d]=k,i("update:modelValue",g)},x=d=>a.modelValue[d.name]!==void 0?String(a.modelValue[d.name]):d.value!==void 0?String(d.value):"",c=(d,k)=>{h(d.name,k||void 0)},f=()=>{u.value.push({id:crypto.randomUUID(),name:"",value:""})},y=d=>{const k=u.value.find(g=>g.id===d);if(k&&k.name){const g={...a.modelValue};delete g[k.name],i("update:modelValue",g)}u.value=u.value.filter(g=>g.id!==d)},b=(d,k,g)=>{const _=u.value.find(R=>R.id===d);if(!_)return;_.name=g;const L={...a.modelValue};k&&delete L[k],g&&_.value&&(L[g]=_.value),i("update:modelValue",L)},v=(d,k)=>{const g=u.value.find(_=>_.id===d);g&&(g.value=k,g.name&&h(g.name,k||void 0))};return(d,k)=>(r(),n("div",El,[(r(!0),n(ve,null,ye(t.inherited,g=>(r(),n("div",{key:g.name,class:"relative"},[e("div",Ll,[e("div",Pl,[w(lt,{"model-value":x(g),label:g.name,placeholder:g.description||"Enter value...",disabled:t.disabled||!l.value.has(g.name),required:g.required,"onUpdate:modelValue":_=>c(g,_)},null,8,["model-value","label","placeholder","disabled","required","onUpdate:modelValue"])]),e("button",{type:"button",onClick:_=>m(g.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(g.name)?"Lock (use inherited value)":"Unlock to override"},[l.value.has(g.name)?(r(),n("svg",Dl,[...k[1]||(k[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(),n("svg",jl,[...k[0]||(k[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,Al)]),g.source?(r(),n("p",Ol,[Z(" From: "+C(g.source)+" ",1),g.required?(r(),n("span",Rl,"(required)")):I("",!0)])):I("",!0)]))),128)),(r(!0),n(ve,null,ye(u.value,g=>(r(),n("div",{key:g.id,class:"flex items-start gap-2"},[e("div",Ul,[w(lt,{"model-value":g.name,label:"Name",placeholder:"Variable name",disabled:t.disabled,"onUpdate:modelValue":_=>b(g.id,g.name,_)},null,8,["model-value","disabled","onUpdate:modelValue"])]),e("div",Bl,[w(lt,{"model-value":g.value,label:"Value",placeholder:"Variable value",disabled:t.disabled,"onUpdate:modelValue":_=>v(g.id,_)},null,8,["model-value","disabled","onUpdate:modelValue"])]),e("button",{type:"button",onClick:_=>y(g.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"},[...k[2]||(k[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,Fl)]))),128)),t.allowCustom?(r(),n("button",{key:0,type:"button",onClick:f,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"},[...k[3]||(k[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"})]),Z(" Add custom variable ")],-1)])],8,Nl)):I("",!0)]))}}),ql=gt(Ie(Zt),{props:["inherited","allowCustom","disabled"],family:"text",features:[]}),Hl={class:"space-y-3 mt-3 pt-3 border-t border-neutral-200 dark:border-neutral-700"},Wl={class:"space-y-2 pl-4 border-l-2 border-accent-200 dark:border-accent-700"},Kl={class:"space-y-2 pl-4 border-l-2 border-neutral-200 dark:border-neutral-700"},Jl=me({__name:"PromptToolOptions",props:{toolName:{},toolConfig:{},toolType:{default:"prompt"},disabled:{type:Boolean}},emits:["update:option"],setup(t,{emit:o}){const a=t,i=o,l=p(null),u=p(!0),s=B(()=>l.value?.properties?Object.entries(l.value.properties).map(([x,c])=>({value:x,label:x,attrs:{description:c.description||c.type||""}})):[]),m=async()=>{try{let x=a.toolName;if(a.toolType==="handoff"||a.toolType==="subagent"){const f=await fetch(fe(`/api/agents/${encodeURIComponent(a.toolName)}`));if(f.ok){if(x=(await f.json())?.agent?.side_a_agent_prompt,!x){u.value=!1;return}}else{u.value=!1;return}}const c=await fetch(fe(`/api/prompts/${encodeURIComponent(x)}`));if(c.ok){const f=await c.json();f?.prompt?.required_schema&&(l.value=f.prompt.required_schema)}}catch(x){console.error("Error fetching prompt schema:",x)}finally{u.value=!1}};Pe(()=>{m()});const h=(x,c)=>{i("update:option",x,c)};return(x,c)=>{const f=Be("FormKit");return r(),n("div",Hl,[e("div",Wl,[c[5]||(c[5]=e("p",{class:"text-xs font-medium text-neutral-600 dark:text-neutral-400 mb-2"}," Initialization Options: ",-1)),w(f,{type:"selectSearch",value:t.toolConfig.init_user_message_property||"",onInput:c[0]||(c[0]=y=>h("init_user_message_property",y||null)),label:"User message property",placeholder:"Don't inject a user message",options:s.value,disabled:t.disabled||u.value||s.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(f,{type:"selectSearch",value:t.toolConfig.init_attachments_property||"",onInput:c[1]||(c[1]=y=>h("init_attachments_property",y||null)),label:"Attachments property",placeholder:"Don't attach files",options:s.value,disabled:t.disabled||u.value||s.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"])]),e("div",Kl,[c[6]||(c[6]=e("p",{class:"text-xs font-medium text-neutral-600 dark:text-neutral-400 mb-2"}," Sub-Prompt Response Options: ",-1)),w(f,{type:"checkbox",value:t.toolConfig.include_text_response,onInput:c[2]||(c[2]=y=>h("include_text_response",y)),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(f,{type:"checkbox",value:t.toolConfig.include_tool_calls,onInput:c[3]||(c[3]=y=>h("include_tool_calls",y)),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(f,{type:"checkbox",value:t.toolConfig.include_errors,onInput:c[4]||(c[4]=y=>h("include_errors",y)),label:"Include errors",help:"Include error information if the sub-prompt fails",disabled:t.disabled,"outer-class":"$reset mb-0"},null,8,["value","disabled"])])])}}});async function Je(t,o={}){const a=localStorage.getItem("auth_token"),i={"Content-Type":"application/json",...o.headers};a&&(i.Authorization=`Bearer ${a}`);const l=t.startsWith("/")?t:`/${t}`,u=await fetch(fe(`/api${l}`),{...o,headers:i});if(u.status===401)throw localStorage.removeItem("auth_token"),window.location.href=fe("/login"),new Error("Unauthorized");return u}const Yl={class:"space-y-4"},Gl={class:"block text-sm font-medium mb-2"},Zl={key:0,class:"text-red-500"},Xl={class:"flex items-start justify-between"},Ql={class:"flex items-center gap-2 flex-1"},es={class:"flex-1"},ts={key:0,class:"text-xs text-neutral-500 dark:text-neutral-400 font-normal"},rs={key:1,class:"text-xs text-neutral-500 dark:text-neutral-400 font-normal"},as={key:2,class:"text-xs text-neutral-500 dark:text-neutral-400 font-normal"},os={key:3,class:"text-xs text-neutral-500 dark:text-neutral-400 font-normal"},ns={key:4,class:"text-xs text-neutral-500 dark:text-neutral-400 font-normal"},ls={key:0,class:"text-xs text-neutral-600 dark:text-neutral-400 mt-1"},ss={key:1,class:"text-xs text-amber-600 dark:text-amber-400 mt-1 flex items-center gap-1"},is=["onClick","disabled","aria-label"],us={key:0,class:"mt-3 pt-3 border-t border-neutral-200 dark:border-neutral-700"},ds={class:"space-y-2"},cs={key:0,class:"text-xs text-amber-500 dark:text-amber-400 whitespace-nowrap",title:"Required at agent or thread level"},ps={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"},Hr=me({__name:"ToolSelectorWithOptions",props:Ze({label:{default:"Available Tools"},placeholder:{default:"Select a tool"},error:{},required:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},modelId:{},providerId:{}},{modelValue:{required:!0,default:()=>[]},modelModifiers:{}}),emits:Ze(["unavailable-tools"],["update:modelValue"]),setup(t,{expose:o,emit:a}){const i=t,l=it(t,"modelValue"),u=p([]),s=p([]),m=p(!1),h=p(!1),x=p(),c=p(""),f=B(()=>[...u.value,...s.value]),y=B(()=>new Set(f.value.map(Q=>k(Q)))),b=Q=>(Q.startsWith("provider:"),y.value.has(Q)),v=B(()=>l.value.filter(Q=>!b(Q.name)).map(Q=>Q.name)),d=a;ge(v,Q=>{Q.length>0&&d("unavailable-tools",Q)},{immediate:!0}),Tr(async()=>{x.value,await Le(),x.value&&l.value.length>0&&await Ir({parent:x,values:l,dragHandle:".drag-handle"})});const k=Q=>Q.type==="provider"?`provider:${Q.name}`:Q.type==="mcp"?`mcp:${Q.name}`:Q.name,g=Q=>Q.startsWith("provider:")?Q.slice(9):Q.startsWith("mcp:")?Q.slice(4):Q,_=Q=>Q.startsWith("provider:")?"provider":Q.startsWith("mcp:")?"mcp":"tool",L=B(()=>{const Q=new Set(l.value.map(E=>E.name));return f.value.filter(E=>!Q.has(k(E))).map(E=>{let S=E.name;return E.type==="prompt"?S=`${E.name} (prompt)`:E.type==="mcp"?S=`${E.name} (mcp)`:E.type==="provider"?S=`${E.name} (provider)`:E.type==="handoff"?S=`${E.name} (handoff agent)`:E.type==="subagent"&&(S=`${E.name} (subagent)`),{value:k(E),label:S,attrs:{description:E.description}}})}),R=async()=>{m.value=!0;try{const Q=await Je("/tools");if(Q.ok){const E=await Q.json();u.value=Object.entries(E).map(([S,V])=>({name:S,description:V.description||"",type:V.type,model:V.model}))}}catch(Q){console.error("Error fetching tools:",Q)}finally{m.value=!1}},K=async()=>{if(!i.providerId||!i.modelId){s.value=[];return}h.value=!0;try{const Q=await Je(`/providers/${i.providerId}/tools?model=${encodeURIComponent(i.modelId)}`);if(Q.ok){const E=await Q.json();s.value=(E.tools||[]).map(S=>({name:S.name,description:S.description||"",type:"provider",tenvs:S.tenvs||[]}))}else s.value=[]}catch(Q){console.error("Error fetching provider tools:",Q),s.value=[]}finally{h.value=!1}};ge([()=>i.providerId,()=>i.modelId],async([Q,E])=>{Q&&E?await K():s.value=[]},{immediate:!0});const Y=Q=>{if(!Q||l.value.find(V=>V.name===Q))return;const E=P(Q),S={};if(E?.tenvs&&E.tenvs.length>0)for(const V of E.tenvs)S[V.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,...Object.keys(S).length>0?{tenvs:S}:{}}],Le(()=>{c.value=""})},z=Q=>{l.value=l.value.filter(E=>E.name!==Q)},P=Q=>{const E=f.value.find(S=>k(S)===Q);return E||f.value.find(S=>S.name===Q)},G=(Q,E,S)=>{l.value=l.value.map(V=>{if(V.name===Q){const re={...V.tenvs||{},[E]:S||void 0};for(const F of Object.keys(re))re[F]||delete re[F];return{...V,tenvs:Object.keys(re).length>0?re:void 0}}return V})},ee=(Q,E,S)=>{l.value=l.value.map(V=>V.name===Q?{...V,[E]:S}:V)};return o({removeUnavailableTools:()=>{l.value=l.value.filter(Q=>b(Q.name))},getAvailableToolsOnly:()=>l.value.filter(Q=>b(Q.name)),unavailableTools:v}),Pe(()=>{R()}),(Q,E)=>{const S=Be("FormKit");return r(),n("div",Yl,[e("div",null,[e("label",Gl,[Z(C(t.label)+" ",1),t.required?(r(),n("span",Zl,"*")):I("",!0)]),l.value.length>0?(r(),n("div",{key:0,class:"space-y-3 mb-4",ref_key:"dragAreaRef",ref:x},[(r(!0),n(ve,null,ye(l.value,V=>(r(),n("div",{key:V.name,class:ae(["border rounded-lg p-4 transition-colors",b(V.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",Xl,[e("div",Ql,[e("div",{class:ae(["drag-handle",b(V.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"])},[...E[1]||(E[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",es,[e("h4",{class:ae(["font-medium text-sm",!b(V.name)&&"text-neutral-500 dark:text-neutral-400"])},[Z(C(g(V.name))+" ",1),_(V.name)==="provider"?(r(),n("span",ts,"(provider)")):_(V.name)==="mcp"?(r(),n("span",rs,"(mcp)")):P(V.name)?.type==="prompt"?(r(),n("span",as,"(prompt)")):P(V.name)?.type==="handoff"?(r(),n("span",os,"(handoff agent)")):P(V.name)?.type==="subagent"?(r(),n("span",ns,"(subagent)")):I("",!0)],2),P(V.name)?.description?(r(),n("p",ls,C(P(V.name)?.description),1)):I("",!0),b(V.name)?I("",!0):(r(),n("p",ss,[...E[2]||(E[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),Z(" Not available for selected model - will be removed on save ",-1)])]))])]),e("button",{onClick:re=>z(V.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 ${g(V.name)}`},[...E[3]||(E[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,is)]),P(V.name)?.type==="provider"&&P(V.name)?.tenvs?.length?(r(),n("div",us,[E[4]||(E[4]=e("p",{class:"text-xs text-neutral-500 dark:text-neutral-400 mb-2 font-medium"},[Z(" Environment Variables "),e("span",{class:"text-neutral-400"},"(optional at prompt level)")],-1)),e("div",ds,[(r(!0),n(ve,null,ye(P(V.name)?.tenvs,re=>(r(),n("div",{key:re.name,class:"flex items-center gap-2"},[w(S,{type:"text",value:V.tenvs?.[re.name]||"",onInput:F=>G(V.name,re.name,F),label:re.name,placeholder:re.description||"Enter value...",disabled:t.disabled,"outer-class":"$reset flex-1 mb-0"},null,8,["value","onInput","label","placeholder","disabled"]),re.required?(r(),n("span",cs," required* ")):I("",!0)]))),128))])])):I("",!0),P(V.name)?.type==="prompt"||P(V.name)?.type==="handoff"||P(V.name)?.type==="subagent"?(r(),H(Jl,{key:1,"tool-name":V.name,"tool-config":V,"tool-type":P(V.name)?.type,disabled:t.disabled,"onUpdate:option":(re,F)=>ee(V.name,re,F)},null,8,["tool-name","tool-config","tool-type","disabled","onUpdate:option"])):I("",!0)],2))),128))],512)):I("",!0),w(S,{type:"selectSearch",modelValue:c.value,"onUpdate:modelValue":E[0]||(E[0]=V=>c.value=V),onInput:Y,placeholder:l.value.length>0?"Add another tool...":t.placeholder,"search-placeholder":"Search tools...",options:L.value,disabled:t.disabled||m.value||L.value.length===0,loading:m.value,"outer-class":"$reset"},null,8,["modelValue","placeholder","options","disabled","loading"]),t.error?(r(),H(T(tt),{key:1,class:"mt-1"},{default:D(()=>[Z(C(t.error),1)]),_:1})):I("",!0)]),l.value.length===0&&!m.value&&L.value.length===0?(r(),n("div",ps," No tools available. Create tools in your agentbuilder/tools directory. ")):I("",!0)])}}}),ms=gt(Ie(Hr),{props:["label","placeholder","error","required","disabled","modelId","providerId"],family:"dropdown",features:[]}),vs=me({__name:"SelectInputWrapper",props:{context:{}},setup(t){const o=t,a=(b,v)=>{const d=o.context;return d[b]!==void 0?d[b]:d.attrs?.[b]!==void 0?d.attrs[b]:v},i=B(()=>o.context.classes??{}),l=B(()=>a("options",[])),u=B(()=>o.context._value??""),s=b=>{o.context.node.input(b)},m=B(()=>a("placeholder","Select an option")),h=B(()=>a("searchPlaceholder","Search...")),x=B(()=>a("loading",!1)),c=B(()=>o.context.disabled??!1),f=B(()=>a("size","md")),y=B(()=>a("activeHighlight",!1));return(b,v)=>(r(),H(Ge,{"model-value":u.value,options:l.value,placeholder:m.value,"search-placeholder":h.value,loading:x.value,disabled:c.value,"trigger-class":i.value.inner,size:f.value,"active-highlight":y.value,"onUpdate:modelValue":s},null,8,["model-value","options","placeholder","search-placeholder","loading","disabled","trigger-class","size","active-highlight"]))}}),fs={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:Ie(vs),props:{context:"$node.context"}}]},hs={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function gs(t,o){return r(),n("svg",hs,[...o[0]||(o[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 bs=Ie({name:"lucide-search",render:gs}),xs=["data-suffix-icon"],ys=["id","value","placeholder","disabled"],ks=me({__name:"SearchInputWrapper",props:{context:{}},setup(t){const o=t,a=(x,c)=>{const f=o.context;return f[x]!==void 0?f[x]:f.attrs?.[x]!==void 0?f.attrs[x]:c},i=B(()=>o.context.classes??{}),l=B(()=>o.context._value??""),u=x=>{const c=x.target.value;o.context.node.input(c)},s=()=>{o.context.node.input("")},m=B(()=>a("placeholder","Search...")),h=B(()=>o.context.disabled??!1);return(x,c)=>(r(),n("div",{class:ae(i.value.inner),"data-prefix-icon":"true","data-suffix-icon":!!l.value},[e("span",{class:ae(i.value.prefixIcon)},[w(T(bs))],2),e("input",{type:"text",id:t.context.id,value:l.value,onInput:u,placeholder:m.value,disabled:h.value,class:ae(i.value.input)},null,42,ys),l.value?(r(),n("button",{key:0,type:"button",onClick:s,class:ae([i.value.suffixIcon,"hover:text-zinc-600 dark:hover:text-zinc-300 cursor-pointer"])},[w(T(Pt))],2)):I("",!0)],10,xs))}}),ws={type:"input",family:"text",props:["placeholder","size"],schema:()=>[{$el:"label",if:"$label",attrs:{class:"$classes.label",for:"$id"},children:"$label"},{$cmp:Ie(ks),props:{context:"$node.context"}}]},_s=me({__name:"SortableMultiSelectWrapper",props:{context:{}},setup(t){const o=t,a=B(()=>o.context.options??[]),i=B(()=>o.context.placeholder??"Select an option"),l=B(()=>o.context.searchPlaceholder??"Search..."),u=B(()=>o.context.addLabel??"Add another"),s=B(()=>o.context.loading??!1),m=B(()=>o.context.disabled??!1),h=B({get:()=>o.context._value??[],set:x=>o.context.node.input(x)});return(x,c)=>(r(),H(ht,{modelValue:h.value,"onUpdate:modelValue":c[0]||(c[0]=f=>h.value=f),options:a.value,placeholder:i.value,"search-placeholder":l.value,"add-label":u.value,loading:s.value,disabled:m.value},null,8,["modelValue","options","placeholder","search-placeholder","add-label","loading","disabled"]))}}),$s={type:"input",family:"dropdown",props:["options","placeholder","searchPlaceholder","addLabel","loading"],schema:()=>[{$el:"label",if:"$label",attrs:{class:"$classes.label",for:"$id"},children:"$label"},{$cmp:Ie(_s),props:{context:"$node.context"}}]},Cs={class:"flex items-center gap-2 py-1 pl-2 pr-1"},Ss={class:"flex-1 grid grid-cols-1 md:grid-cols-3 gap-2"},Ts={class:"flex items-center gap-0.5 shrink-0"},Is={key:1,class:"w-7"},zs={class:"pl-2 pb-1"},Vs={key:0},Ms={class:"space-y-1.5"},Es=["onClick"],Ls=["onClick"],Ps={key:1},As=["onClick"],js={key:2},Ds=["onClick"],Os={key:3},Rs={class:"flex items-center gap-2 py-1 pl-2 pr-1"},Us={class:"flex-1 grid grid-cols-1 md:grid-cols-2 gap-2"},Bs={class:"flex items-center gap-0.5 shrink-0"},Fs={key:1,class:"w-7"},Ns={class:"pl-2 pb-1"},qs={key:0},Hs={class:"space-y-1.5"},Ws=["onClick"],Ks=["onClick"],Js={key:1},Ys=["onClick"],Gs={key:2},Zs=["onClick"],Xs={key:3},Qs=["onClick"],ei=me({__name:"SchemaPropertyRow",props:{typeOptions:{},depth:{},index:{}},emits:["remove"],setup(t){const o=t,a=p(!1),i=p("string"),l=p("string"),u=p(!1),s=v=>{i.value=v,x(v)&&(a.value=!0)},m=v=>{l.value=v,x(v)&&(u.value=!0)},h=v=>{v.value?.type&&(l.value=v.value.type,x(l.value)&&(u.value=!0)),v.on("input",({payload:d})=>{d?.type&&d.type!==l.value&&m(d.type)})},x=v=>["object","array","enum","anyOf"].includes(v),c=["#3b82f6","#8b5cf6","#ec4899","#f97316","#10b981"],f=B(()=>o.depth||0),y=v=>c[v%c.length],b=B(()=>y(f.value));return(v,d)=>{const k=Be("FormKit"),g=Be("SchemaPropertyRow",!0);return r(),H(k,{type:"group",index:t.index,onNode:d[3]||(d[3]=_=>{_.value?.type&&(i.value=_.value.type,x(i.value)&&(a.value=!0)),_.on("input",({payload:L})=>{L?.type&&L.type!==i.value&&s(L.type)})})},{default:D(({value:_})=>[e("div",{class:ae(["schema-row",f.value>0?"border-l-[3px] ml-2":""]),style:st(f.value>0?{borderColor:b.value}:{})},[e("div",Cs,[e("div",Ss,[w(k,{type:"text",name:"name",placeholder:"Property name","outer-class":"$reset"}),w(k,{type:"selectSearch",name:"type",options:t.typeOptions,placeholder:"Type","outer-class":"$reset",onInput:s},null,8,["options"]),w(k,{type:"text",name:"description",placeholder:"Description","outer-class":"$reset"})]),e("div",Ts,[x(i.value)?(r(),n("button",{key:0,onClick:d[0]||(d[0]=L=>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(),n("svg",{class:ae(["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(),n("div",Is)),e("button",{onClick:d[1]||(d[1]=L=>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)])])])]),Ae(e("div",zs,[i.value==="enum"?(r(),n("div",Vs,[d[7]||(d[7]=e("div",{class:"text-[11px] font-medium text-neutral-400 uppercase tracking-wider mb-2"}," Enum Values ",-1)),w(k,{type:"list",name:"enumValues",dynamic:""},{default:D(({items:L,value:R,node:K})=>[e("div",Ms,[(r(!0),n(ve,null,ye(L,(Y,z)=>(r(),n("div",{key:Y,class:"flex items-center gap-2"},[w(k,{type:"group",index:z},{default:D(()=>[w(k,{type:"text",name:"value",placeholder:"Value","outer-class":"$reset flex-1"})]),_:1},8,["index"]),e("button",{onClick:P=>K.input(R.filter((G,ee)=>ee!==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]=[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,Es)]))),128))]),e("button",{onClick:Y=>K.input((R||[]).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,Ls)]),_:1})])):I("",!0),i.value==="object"?(r(),n("div",Ps,[w(k,{type:"list",name:"properties",dynamic:""},{default:D(({items:L,value:R,node:K})=>[e("div",null,[(r(!0),n(ve,null,ye(L,(Y,z)=>(r(),H(g,{key:Y,index:z,"type-options":t.typeOptions,depth:f.value+1,onRemove:P=>K.input(R.filter((G,ee)=>ee!==z))},null,8,["index","type-options","depth","onRemove"]))),128))]),e("button",{onClick:Y=>K.input((R||[]).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,As)]),_:1})])):I("",!0),i.value==="anyOf"?(r(),n("div",js,[d[8]||(d[8]=e("div",{class:"text-[11px] font-medium text-neutral-400 uppercase tracking-wider mb-2"}," Type Options ",-1)),w(k,{type:"list",name:"anyOfTypes",dynamic:""},{default:D(({items:L,value:R,node:K})=>[e("div",null,[(r(!0),n(ve,null,ye(L,(Y,z)=>(r(),H(g,{key:Y,index:z,"type-options":t.typeOptions,depth:f.value+1,onRemove:P=>K.input(R.filter((G,ee)=>ee!==z))},null,8,["index","type-options","depth","onRemove"]))),128))]),e("button",{onClick:Y=>K.input((R||[]).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,Ds)]),_:1})])):I("",!0),i.value==="array"?(r(),n("div",Os,[d[14]||(d[14]=e("div",{class:"text-[11px] font-medium text-neutral-400 uppercase tracking-wider mb-2"}," Array Item Type ",-1)),w(k,{type:"group",name:"items",onNode:h},{default:D(({value:L,node:R})=>[e("div",{class:"schema-row border-l-[3px] ml-2",style:st({borderColor:y(f.value+1)})},[e("div",Rs,[e("div",Us,[w(k,{type:"selectSearch",name:"type",options:t.typeOptions,placeholder:"Item type","outer-class":"$reset",onInput:m},null,8,["options"]),w(k,{type:"text",name:"description",placeholder:"Description","outer-class":"$reset"})]),e("div",Bs,[x(l.value)?(r(),n("button",{key:0,onClick:d[2]||(d[2]=K=>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(),n("svg",{class:ae(["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(),n("div",Fs))])]),Ae(e("div",Ns,[l.value==="enum"?(r(),n("div",qs,[d[11]||(d[11]=e("div",{class:"text-[11px] font-medium text-neutral-400 uppercase tracking-wider mb-2"}," Enum Values ",-1)),w(k,{type:"list",name:"enumValues",dynamic:""},{default:D(({items:K,value:Y,node:z})=>[e("div",Hs,[(r(!0),n(ve,null,ye(K,(P,G)=>(r(),n("div",{key:P,class:"flex items-center gap-2"},[w(k,{type:"group",index:G},{default:D(()=>[w(k,{type:"text",name:"value",placeholder:"Value","outer-class":"$reset flex-1"})]),_:1},8,["index"]),e("button",{onClick:ee=>z.input(Y.filter((se,de)=>de!==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,Ws)]))),128))]),e("button",{onClick:P=>z.input((Y||[]).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,Ks)]),_:1})])):I("",!0),l.value==="object"?(r(),n("div",Js,[w(k,{type:"list",name:"properties",dynamic:""},{default:D(({items:K,value:Y,node:z})=>[e("div",null,[(r(!0),n(ve,null,ye(K,(P,G)=>(r(),H(g,{key:P,index:G,"type-options":t.typeOptions,depth:f.value+2,onRemove:ee=>z.input(Y.filter((se,de)=>de!==G))},null,8,["index","type-options","depth","onRemove"]))),128))]),e("button",{onClick:P=>z.input((Y||[]).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,Ys)]),_:1})])):I("",!0),l.value==="anyOf"?(r(),n("div",Gs,[d[12]||(d[12]=e("div",{class:"text-[11px] font-medium text-neutral-400 uppercase tracking-wider mb-2"}," Type Options ",-1)),w(k,{type:"list",name:"anyOfTypes",dynamic:""},{default:D(({items:K,value:Y,node:z})=>[e("div",null,[(r(!0),n(ve,null,ye(K,(P,G)=>(r(),H(g,{key:P,index:G,"type-options":t.typeOptions,depth:f.value+2,onRemove:ee=>z.input(Y.filter((se,de)=>de!==G))},null,8,["index","type-options","depth","onRemove"]))),128))]),e("button",{onClick:P=>z.input((Y||[]).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,Zs)]),_:1})])):I("",!0),l.value==="array"?(r(),n("div",Xs,[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(k,{type:"list",name:"items",dynamic:""},{default:D(({items:K,value:Y,node:z})=>[e("div",null,[(r(!0),n(ve,null,ye(K,(P,G)=>(r(),H(g,{key:P,index:G,"type-options":t.typeOptions,depth:f.value+2,onRemove:ee=>z.input(Y.filter((se,de)=>de!==G))},null,8,["index","type-options","depth","onRemove"]))),128))]),e("button",{onClick:P=>z.input((Y||[]).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,Qs)]),_:1})])):I("",!0)],512),[[Ke,u.value&&x(l.value)]])],4)]),_:1})])):I("",!0)],512),[[Ke,a.value&&x(i.value)]])],6)]),_:1},8,["index"])}}}),ti=Xe(ei,[["__scopeId","data-v-a52ecd3f"]]),ri={"data-schema-editor":"",class:"space-y-4"},ai={class:"space-y-2 border border-neutral-200 dark:border-neutral-800 rounded-lg p-4"},oi={key:0,class:"flex items-center justify-between mb-2"},ni={key:1,class:"text-center py-12"},li={class:"divide-y divide-neutral-100 dark:divide-neutral-800"},si={class:"mt-3 pt-3 border-t border-neutral-200 dark:border-neutral-800"},ii=["onClick"],ui={class:"mt-4 text-center"},di={key:3,class:"mt-4"},ci={class:"bg-neutral-50 dark:bg-neutral-900 border border-neutral-200 dark:border-neutral-800 rounded-lg p-4 overflow-x-auto"},pi={class:"text-xs leading-relaxed"},mi=["innerHTML"],vi=me({__name:"FormKitSchemaEditor",props:{context:{}},setup(t){const o=[{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,i=p(!1),l=x=>x?.properties?Object.entries(x.properties).map(([c,f])=>{const y={name:c,type:f.enum?"enum":f.anyOf?"anyOf":f.type||"string",description:f.description||""};return f.enum&&(y.enumValues=f.enum.map(b=>({value:b}))),f.anyOf&&(y.anyOfTypes=f.anyOf.map(b=>({type:b.type||"string",description:b.description||""}))),f.type==="object"&&f.properties&&(y.properties=l(f)),f.type==="array"&&f.items&&(y.items={type:f.items.type||"string",description:f.items.description||""},f.items.properties&&(y.items.properties=l(f.items))),y}):[],u=x=>{const c={type:"object",properties:{},required:[],additionalProperties:!1};for(const f of x||[]){if(!f.name)continue;const y={type:f.type==="enum"||f.type==="anyOf"?void 0:f.type,description:f.description||void 0};if(f.type==="enum"&&f.enumValues&&(y.type="string",y.enum=f.enumValues.map(b=>b.value)),f.type==="anyOf"&&f.anyOfTypes&&(y.anyOf=f.anyOfTypes.map(b=>({type:b.type,description:b.description||void 0}))),f.type==="object"&&f.properties){const b=u(f.properties);y.properties=b.properties,y.required=b.required,y.additionalProperties=!1}if(f.type==="array"&&f.items&&(y.items={type:f.items.type,description:f.items.description||void 0},f.items.properties)){const b=u(f.items.properties);y.items.properties=b.properties,y.items.required=b.required}Object.keys(y).forEach(b=>y[b]===void 0&&delete y[b]),c.properties[f.name]=y,c.required.push(f.name)}return c},s=B({get:()=>{const x=a.context._value;return l(x)},set:x=>{const c=u(x);a.context.node.input(c)}}),m=B(()=>{const x=a.context._value||{type:"object",properties:{},required:[]};return JSON.stringify(x,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>')}),h=()=>{s.value=[{name:"property1",type:"string",description:""}]};return(x,c)=>{const f=Be("FormKit");return r(),n("div",ri,[e("div",ai,[s.value.length>0?(r(),n("div",oi,[...c[3]||(c[3]=[e("h3",{class:"text-sm font-medium text-neutral-700 dark:text-neutral-300"}," Properties ",-1)])])):I("",!0),s.value.length===0?(r(),n("div",ni,[c[5]||(c[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)),c[6]||(c[6]=e("p",{class:"text-neutral-500 dark:text-neutral-400 text-sm mb-4"}," No properties defined ",-1)),e("button",{onClick:c[0]||(c[0]=y=>h()),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"},[...c[4]||(c[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"})]),Z(" Add Property ")],-1)])])])):I("",!0),s.value.length>0?(r(),H(f,{key:2,type:"list",value:s.value,onInput:c[1]||(c[1]=y=>s.value=y),dynamic:""},{default:D(({items:y,value:b,node:v})=>[e("div",li,[(r(!0),n(ve,null,ye(y,(d,k)=>(r(),H(ti,{key:d,index:k,"type-options":o,depth:0,onRemove:g=>v.input(b.filter((_,L)=>L!==k))},null,8,["index","onRemove"]))),128))]),e("div",si,[e("button",{onClick:d=>v.input(b.concat({name:`property${b.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,ii)])]),_:1},8,["value"])):I("",!0),e("div",ui,[e("button",{onClick:c[2]||(c[2]=y=>i.value=!i.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(i.value?"Hide":"Show")+" JSON Schema ",1)]),i.value?(r(),n("div",di,[e("div",ci,[e("pre",pi,[e("code",{class:"font-mono",innerHTML:m.value},null,8,mi)])])])):I("",!0)])])}}}),fi={type:"input",family:"text",props:["label","disabled","required"],schema:()=>[{$el:"label",if:"$label",attrs:{class:"$classes.label",for:"$id"},children:"$label"},{$cmp:Ie(vi),props:{context:"$node.context"}}]},hi={promptInput:qo,jsonSchema:hl,modelSelector:zl,agentSelector:Vl,toolSelector:Ml,tenvPropertyList:ql,toolSelectorWithOptions:ms,selectSearch:fs,searchInput:ws,sortableMultiSelect:$s,schemaEditor:fi},gi=eo("fk-2d3e4e0bb",ro),bi={config:{rootClasses:yo},plugins:[gi],rules:Io,messages:{en:zo},inputs:hi,icons:{...to}},xi={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function yi(t,o){return r(),n("svg",xi,[...o[0]||(o[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 mt=Ie({name:"lucide-bot",render:yi}),ki={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function wi(t,o){return r(),n("svg",ki,[...o[0]||(o[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 Et=Ie({name:"lucide-message-square",render:wi}),_i={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function $i(t,o){return r(),n("svg",_i,[...o[0]||(o[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 Ci=Ie({name:"lucide-cpu",render:$i}),Si={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Ti(t,o){return r(),n("svg",Si,[...o[0]||(o[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 Ii=Ie({name:"lucide-server",render:Ti}),zi={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Vi(t,o){return r(),n("svg",zi,[...o[0]||(o[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 qt=Ie({name:"lucide-wrench",render:Vi}),Mi={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Ei(t,o){return r(),n("svg",Mi,[...o[0]||(o[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 Ht=Ie({name:"lucide-settings",render:Ei}),Li={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Pi(t,o){return r(),n("svg",Li,[...o[0]||(o[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 Wr=Ie({name:"lucide-chevron-left",render:Pi}),Ai={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function ji(t,o){return r(),n("svg",Ai,[...o[0]||(o[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 Di=Ie({name:"lucide-sun",render:ji}),Oi={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Ri(t,o){return r(),n("svg",Oi,[...o[0]||(o[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 Ui=Ie({name:"lucide-moon",render:Ri}),Bi={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Fi(t,o){return r(),n("svg",Bi,[...o[0]||(o[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 Ni=Ie({name:"lucide-activity",render:Fi}),qi={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Hi(t,o){return r(),n("svg",qi,[...o[0]||(o[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 Wi=Ie({name:"lucide-function-square",render:Hi}),Ki={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Ji(t,o){return r(),n("svg",Ki,[...o[0]||(o[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 Yi=Ie({name:"lucide-log-out",render:Ji}),Gi={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Zi(t,o){return r(),n("svg",Gi,[...o[0]||(o[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 Xi=Ie({name:"lucide-users",render:Zi}),Qi={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function eu(t,o){return r(),n("svg",Qi,[...o[0]||(o[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 tu=Ie({name:"lucide-key",render:eu}),ru={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function au(t,o){return r(),n("svg",ru,[...o[0]||(o[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 ou=Ie({name:"lucide-book-open",render:au}),nu={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function lu(t,o){return r(),n("svg",nu,[...o[0]||(o[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 su=Ie({name:"lucide-external-link",render:lu}),Kr="agentbuilder-accent-theme",Jr=["amber","lime","emerald","sky","blue","indigo","purple","fuchsia","pink","white"],Wt=p("purple");let cr=!1;function Yr(t){typeof document>"u"||(t==="purple"?delete document.documentElement.dataset.accent:document.documentElement.dataset.accent=t)}function iu(t){try{localStorage.setItem(Kr,t)}catch{}}function uu(){try{const t=localStorage.getItem(Kr);if(t&&Jr.includes(t))return t}catch{}return"purple"}function Gr(){if(cr)return;cr=!0;const t=uu();Wt.value=t,Yr(t)}function du(){Gr();function t(o){Wt.value=o,Yr(o),iu(o)}return{theme:Wt,themes:Jr,setTheme:t}}const Zr="/agents/assets/img/agent-builder-logo-light.svg",Xr="/agents/assets/img/agent-builder-logo-dark.svg",cu="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",pu="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",mu=["src"],vu=["src"],fu={class:"flex-1 flex flex-col justify-between pt-2 pb-4"},hu={class:"flex flex-col gap-1 px-2"},gu={key:0},bu=["onClick","title"],xu={key:0,class:"flex-1 whitespace-nowrap overflow-hidden text-ellipsis text-left"},yu={key:0,class:"ml-4 space-y-0.5"},ku=["onClick"],wu={class:"whitespace-nowrap overflow-hidden text-ellipsis"},_u=["onClick","title"],$u={key:0,class:"whitespace-nowrap overflow-hidden text-ellipsis"},Cu={class:"flex flex-col gap-1 px-2"},Su=["title"],Tu={key:0,class:"flex-1 whitespace-nowrap overflow-hidden text-ellipsis"},Iu={class:"relative settings-menu-container"},zu={key:0,class:"absolute bottom-full mb-2 left-0 z-50"},Vu={class:"px-4 py-3 border-b border-neutral-200 dark:border-neutral-700"},Mu=["title"],Eu={class:"relative z-10 flex items-center justify-center w-8 h-full"},Lu={class:"relative z-10 flex items-center justify-center w-8 h-full"},Pu={class:"px-4 pt-3 pb-4 border-b border-neutral-200 dark:border-neutral-700"},Au={class:"grid grid-cols-5 gap-3"},ju=["onClick","title"],Du={key:0,class:"w-2 h-2 rounded-full bg-white shadow-sm"},Ou={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"},Ru=me({__name:"Sidebar",props:{isCollapsed:{type:Boolean},isDark:{type:Boolean}},emits:["toggle-sidebar","toggle-theme"],setup(t,{emit:o}){function a(se){if(se.startsWith("/src/")||se.startsWith("data:"))return se;const de=_t();return de==="/"?se.replace("/agents/","/"):se.replace("/agents/",`${de}/`)}const i=a(Zr),l=a(Xr),u=a(cu),s=a(pu),m=t,h=ut(),x=bt(),c=B(()=>h.name);function f(se){const de=h.path;return de===se.path||de.startsWith(se.path+"/")}const y=B(()=>m.isDark?l:i),b=B(()=>m.isDark?s:u),v=[{id:"threads",label:"Threads",icon:Ni,path:"/threads"},{id:"agents",label:"Agents",icon:mt,path:"/agents"},{id:"prompts",label:"Prompts",icon:Et,path:"/prompts"},{id:"tools",label:"Tools",icon:qt,path:"/tools",hasSubnav:!0,subnav:[{id:"tools-functions",label:"Functions",icon:Wi,path:"/tools#functions"},{id:"tools-prompts",label:"Prompts",icon:Et,path:"/tools#prompts"},{id:"tools-agents",label:"Agents",icon:mt,path:"/tools#agents"}]},{id:"models",label:"Models",icon:Ci,path:"/models"},{id:"providers",label:"Providers",icon:Ii,path:"/providers"}],d=se=>{x.push(se)},k=se=>{x.push(se),_.value=!1},g=B(()=>typeof c.value=="string"&&(c.value==="tools"||c.value.startsWith("tools-"))),_=p(!1),{theme:L,themes:R,setTheme:K}=du(),Y={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=B(()=>c.value==="users"||c.value==="api-keys"),P=()=>{_.value=!_.value},G=()=>{localStorage.removeItem("auth_token"),x.push("/login")},ee=se=>{const de=se.target;_.value&&!de.closest(".settings-menu-container")&&(_.value=!1)};return Pe(()=>{document.addEventListener("click",ee)}),Ye(()=>{document.removeEventListener("click",ee)}),(se,de)=>(r(),n("aside",{class:ae(["flex flex-col transition-all duration-300 pt-2.5",t.isCollapsed?"w-16":"w-60"])},[e("div",{class:ae(`flex items-center justify-between ${t.isCollapsed?"px-2 py-4":"p-4"}`)},[t.isCollapsed?I("",!0):(r(),n("img",{key:0,src:y.value,alt:"AgentBuilder",class:"h-8 mr-2 mt-0.5"},null,8,mu)),e("button",{onClick:de[0]||(de[0]=Q=>se.$emit("toggle-sidebar")),class:ae(`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(),n("img",{key:1,src:b.value,alt:"AgentBuilder",class:"w-7 h-7 m-auto"},null,8,vu)):(r(),H(T(Wr),{key:0,class:"w-5 h-5"}))],2)],2),e("nav",fu,[e("div",hu,[(r(),n(ve,null,ye(v,Q=>(r(),n(ve,{key:Q.id},[Q.hasSubnav?(r(),n("div",gu,[e("button",{onClick:E=>d(Q.path),class:ae(["flex items-center gap-3 px-3 py-3 rounded text-sm font-medium transition-all w-full",g.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(),H(Ue(Q.icon),{class:"w-5 h-5 flex-shrink-0"})),t.isCollapsed?I("",!0):(r(),n("span",xu,C(Q.label),1))],10,bu),!t.isCollapsed&&Q.subnav?(r(),n("div",yu,[(r(!0),n(ve,null,ye(Q.subnav,E=>(r(),n("button",{key:E.id,onClick:S=>d(E.path),class:ae(["flex items-center gap-3 px-3 py-1.5 text-sm transition-all w-full",c.value===E.id?"bg-black text-white dark:bg-white dark:text-black rounded":"hover:underline"])},[(r(),H(Ue(E.icon),{class:"w-4 h-4 flex-shrink-0"})),e("span",wu,C(E.label),1)],10,ku))),128))])):I("",!0)])):(r(),n("button",{key:1,onClick:E=>d(Q.path),class:ae(["flex items-center gap-3 px-3 py-3 rounded text-sm font-medium transition-all",f(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(),H(Ue(Q.icon),{class:"w-5 h-5 flex-shrink-0"})),t.isCollapsed?I("",!0):(r(),n("span",$u,C(Q.label),1))],10,_u))],64))),64))]),e("div",Cu,[e("a",{href:"https://docs.standardagentbuilder.com/",target:"_blank",rel:"noopener noreferrer",class:ae(["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(T(ou),{class:"w-5 h-5 flex-shrink-0"}),t.isCollapsed?I("",!0):(r(),n("span",Tu," Docs ")),t.isCollapsed?I("",!0):(r(),H(T(su),{key:1,class:"w-3 h-3 flex-shrink-0 opacity-50"}))],10,Su),e("div",{class:ae(["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",Iu,[e("button",{onClick:Re(P,["stop"]),class:ae(["p-2 rounded transition-colors flex items-center",_.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"},[w(T(Ht),{class:"w-5 h-5 flex-shrink-0"})],2),_.value?(r(),n("div",zu,[w(T(At),{width:"min-w-[200px]",shadow:{offsetX:6,offsetY:6,intensity:.4}},{default:D(()=>[e("div",Vu,[de[4]||(de[4]=e("div",{class:"text-xs font-bold text-neutral-600 dark:text-neutral-400 pb-3"}," Appearance ",-1)),e("button",{onClick:de[1]||(de[1]=Re(Q=>se.$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:ae(["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",Eu,[w(T(Di),{class:ae(["w-4 h-4",t.isDark?"text-neutral-500":"text-black"])},null,8,["class"])]),e("span",Lu,[w(T(Ui),{class:ae(["w-4 h-4",t.isDark?"text-white":"text-neutral-400"])},null,8,["class"])])],8,Mu)]),e("div",Pu,[de[5]||(de[5]=e("div",{class:"text-xs font-bold text-neutral-600 dark:text-neutral-400 pb-3"}," Accent Color ",-1)),e("div",Au,[(r(!0),n(ve,null,ye(T(R),Q=>(r(),n("button",{key:Q,onClick:Re(E=>T(K)(Q),["stop"]),class:ae(["w-6 h-6 rounded-full transition-all flex items-center justify-center ring-1 ring-black/10 dark:ring-white/10",[Y[Q],T(L)===Q?"ring-2 ring-black/50 dark:ring-white/50":"hover:scale-110"]]),title:Q.charAt(0).toUpperCase()+Q.slice(1)},[T(L)===Q?(r(),n("span",Du)):I("",!0)],10,ju))),128))])]),e("button",{onClick:de[2]||(de[2]=Q=>k("/settings/users")),class:ae(["flex items-center gap-3 px-4 py-2 text-sm transition-all w-full text-left",c.value==="users"?"bg-black text-white dark:bg-white dark:text-black":"hover:bg-black/5 dark:hover:bg-white/10"])},[w(T(Xi),{class:"w-4 h-4 flex-shrink-0"}),de[6]||(de[6]=e("span",{class:"whitespace-nowrap"},"Users",-1))],2),e("button",{onClick:de[3]||(de[3]=Q=>k("/settings/api-keys")),class:ae(["flex items-center gap-3 px-4 py-2 text-sm transition-all w-full text-left",c.value==="api-keys"?"bg-black text-white dark:bg-white dark:text-black":"hover:bg-black/5 dark:hover:bg-white/10"])},[w(T(tu),{class:"w-4 h-4 flex-shrink-0"}),de[7]||(de[7]=e("span",{class:"whitespace-nowrap"},"API Keys",-1))],2)]),_:1})])):I("",!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(T(Yi),{class:"w-5 h-5 flex-shrink-0"}),t.isCollapsed?I("",!0):(r(),n("span",Ou,"Logout"))])],2)])])],2))}}),Uu={class:"warning-banner-container"},Bu={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"},Fu={class:"flex items-center gap-2"},Nu=["onClick"],qu=me({__name:"WarningBanner",setup(t){const o=p([]),a=p(new Set),i=async()=>{if(localStorage.getItem("auth_token"))try{const h=await fetch(fe("/api/diagnostics"));if(h.ok){const x=await h.json();o.value=x.warnings||[]}}catch{}},l=m=>{const h=`${m.type}:${m.details?.name||m.message}`;a.value.add(h)},u=m=>{const h=`${m.type}:${m.details?.name||m.message}`;return!a.value.has(h)},s=m=>{if(m.type==="duplicate_tool_name"){const h=m.details?.sources?.join(" and ")||"multiple sources";return`Duplicate tool name "${m.details?.name}" (defined as both ${h}). This may cause unexpected behavior.`}return m.message};return Pe(()=>{i()}),(m,h)=>(r(),n("div",Uu,[(r(!0),n(ve,null,ye(o.value,x=>(r(),n(ve,{key:`${x.type}:${x.details?.name}`},[u(x)?(r(),n("div",Bu,[e("div",Fu,[h[0]||(h[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(s(x)),1)]),e("button",{onClick:c=>l(x),class:"text-amber-600 dark:text-amber-400 hover:text-amber-800 dark:hover:text-amber-200 p-1",title:"Dismiss"},[...h[1]||(h[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,Nu)])):I("",!0)],64))),128))]))}}),Hu={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"},Wu={class:"flex-1 overflow-auto"},Ku=me({__name:"App",setup(t){Gr();const o=ut(),a=p(!1),i=p(!1),l=B(()=>o.name!=="login"),u=()=>{a.value=!a.value},s=()=>{i.value=!i.value,i.value?(document.documentElement.classList.add("dark"),localStorage.setItem("theme","dark")):(document.documentElement.classList.remove("dark"),localStorage.setItem("theme","light"))};return Pe(()=>{const m=localStorage.getItem("theme");(m==="dark"||!m&&window.matchMedia("(prefers-color-scheme: dark)").matches)&&(i.value=!0,document.documentElement.classList.add("dark"))}),(m,h)=>(r(),n("div",{class:ae(["app-container relative flex h-screen font-sans bg-neutral-50/80 text-black dark:bg-black dark:text-white",{"is-dark":i.value}])},[l.value?(r(),H(Ru,{key:0,"is-collapsed":a.value,"is-dark":i.value,onToggleSidebar:u,onToggleTheme:s},null,8,["is-collapsed","is-dark"])):I("",!0),l.value?(r(),n("main",Hu,[w(qu),e("div",Wu,[w(T(tr))])])):(r(),H(T(tr),{key:1}))],2))}}),Ju=Xe(Ku,[["__scopeId","data-v-2125e5d3"]]),Yu={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Gu(t,o){return r(),n("svg",Yu,[...o[0]||(o[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 Zu=Ie({name:"lucide-trash-2",render:Gu}),Xu={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Qu(t,o){return r(),n("svg",Xu,[...o[0]||(o[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 ed=Ie({name:"lucide-edit",render:Qu}),td={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function rd(t,o){return r(),n("svg",td,[...o[0]||(o[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 Kt=Ie({name:"lucide-eye",render:rd}),ad={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function od(t,o){return r(),n("svg",ad,[...o[0]||(o[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 nd=Ie({name:"lucide-chevron-up",render:od}),ld={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function sd(t,o){return r(),n("svg",ld,[...o[0]||(o[0]=[e("path",{fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"m6 9l6 6l6-6"},null,-1)])])}const id=Ie({name:"lucide-chevron-down",render:sd}),ud={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function dd(t,o){return r(),n("svg",ud,[...o[0]||(o[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 cd=Ie({name:"lucide-chevrons-up-down",render:dd}),pd={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function md(t,o){return r(),n("svg",pd,[...o[0]||(o[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 vd=Ie({name:"lucide-inbox",render:md}),fd={key:0,class:"w-full max-w-md"},hd={class:"flex items-center justify-between p-4 border-b border-red-200 dark:border-red-900 flex-shrink-0"},gd={class:"text-xl font-bold text-red-600"},bd={class:"p-6"},xd={class:"text-neutral-700 dark:text-neutral-300 mb-6"},yd={class:"flex justify-end gap-3"},Xt=me({__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:o}){const a=t,i=o,l=()=>{i("update:modelValue",!1)},u=()=>{i("confirm"),l()},s=()=>{i("cancel"),l()},m=h=>{h.key==="Escape"&&a.modelValue&&s()};return ge(()=>a.modelValue,h=>{h?(document.addEventListener("keydown",m),document.body.style.overflow="hidden"):(document.removeEventListener("keydown",m),document.body.style.overflow="")}),(h,x)=>(r(),H(kt,{to:"body"},[w(et,{"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:D(()=>[t.modelValue?(r(),n("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:s},[w(et,{"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:D(()=>[t.modelValue?(r(),n("div",fd,[w(wt,{"offset-x":8,"offset-y":8,intensity:.35},{default:D(()=>[e("div",{class:"bg-white dark:bg-neutral-900 border border-red-400 dark:border-red-500 rounded-lg flex flex-col",onClick:x[0]||(x[0]=Re(()=>{},["stop"]))},[e("div",hd,[e("h2",gd,C(t.title),1),w(T(Br),{icon:T(Pt),label:"Close dialog",variant:"danger",onClick:s},null,8,["icon"])]),e("div",bd,[e("p",xd,C(t.message),1),e("div",yd,[w(T(De),{variant:"secondary",onClick:s},{default:D(()=>[Z(C(t.cancelText),1)]),_:1}),w(T(De),{variant:"danger",onClick:u},{default:D(()=>[Z(C(t.confirmText),1)]),_:1})])])])]),_:1})])):I("",!0)]),_:1})])):I("",!0)]),_:1})]))}}),kd={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function wd(t,o){return r(),n("svg",kd,[...o[0]||(o[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 _d=Ie({name:"lucide-chevron-right",render:wd}),$d={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Cd(t,o){return r(),n("svg",$d,[...o[0]||(o[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 Sd=Ie({name:"lucide-chevrons-left",render:Cd}),Td={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Id(t,o){return r(),n("svg",Td,[...o[0]||(o[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 zd=Ie({name:"lucide-chevrons-right",render:Id}),Vd={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"},Md={class:"text-neutral-500 dark:text-neutral-400 text-xs font-medium"},Ed={class:"text-neutral-700 dark:text-neutral-300"},Ld={class:"text-neutral-700 dark:text-neutral-300"},Pd={class:"text-neutral-700 dark:text-neutral-300"},Ad={class:"flex items-center gap-0.5"},jd=["disabled"],Dd=["disabled"],Od={class:"flex items-center gap-0.5 mx-1"},Rd={key:0,class:"px-2 text-neutral-400 dark:text-neutral-500 text-xs"},Ud=["onClick"],Bd=["disabled"],Fd=["disabled"],Nd={class:"flex items-center gap-2"},qd=["value"],Hd=["value"],Wd=me({__name:"DataTablePagination",props:{page:{},pageSize:{},totalItems:{},pageSizeOptions:{default:()=>[10,25,50,100]}},emits:["update:page","update:pageSize"],setup(t,{emit:o}){const a=t,i=o,l=B(()=>Math.ceil(a.totalItems/a.pageSize)),u=B(()=>a.totalItems===0?0:(a.page-1)*a.pageSize+1),s=B(()=>Math.min(a.page*a.pageSize,a.totalItems)),m=B(()=>a.page>1),h=B(()=>a.page<l.value),x=B(()=>{const k=[],g=l.value,_=a.page;if(g<=7)for(let L=1;L<=g;L++)k.push(L);else{k.push(1),_>3&&k.push("...");const L=Math.max(2,_-1),R=Math.min(g-1,_+1);for(let K=L;K<=R;K++)k.includes(K)||k.push(K);_<g-2&&k.push("..."),k.includes(g)||k.push(g)}return k}),c=k=>{k>=1&&k<=l.value&&i("update:page",k)},f=()=>c(1),y=()=>c(a.page-1),b=()=>c(a.page+1),v=()=>c(l.value),d=k=>{const g=k.target;i("update:pageSize",parseInt(g.value,10)),i("update:page",1)};return(k,g)=>t.totalItems>0?(r(),n("div",Vd,[e("div",Md,[g[0]||(g[0]=Z(" Showing ",-1)),e("span",Ed,C(u.value),1),g[1]||(g[1]=Z(" to ",-1)),e("span",Ld,C(s.value),1),g[2]||(g[2]=Z(" of ",-1)),e("span",Pd,C(t.totalItems),1)]),e("div",Ad,[e("button",{type:"button",onClick:f,disabled:!m.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(T(Sd),{class:"w-4 h-4 text-neutral-500 dark:text-neutral-400"})],8,jd),e("button",{type:"button",onClick:y,disabled:!m.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(T(Wr),{class:"w-4 h-4 text-neutral-500 dark:text-neutral-400"})],8,Dd),e("div",Od,[(r(!0),n(ve,null,ye(x.value,(_,L)=>(r(),n(ve,{key:L},[_==="..."?(r(),n("span",Rd," ... ")):(r(),n("button",{key:1,type:"button",onClick:R=>c(_),class:ae(["min-w-[1.75rem] px-2 py-1 rounded-md text-xs font-medium transition-all duration-150",_===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(_),11,Ud))],64))),128))]),e("button",{type:"button",onClick:b,disabled:!h.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(T(_d),{class:"w-4 h-4 text-neutral-500 dark:text-neutral-400"})],8,Bd),e("button",{type:"button",onClick:v,disabled:!h.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(T(zd),{class:"w-4 h-4 text-neutral-500 dark:text-neutral-400"})],8,Fd)]),e("div",Nd,[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),n(ve,null,ye(t.pageSizeOptions,_=>(r(),n("option",{key:_,value:_},C(_),9,Hd))),128))],40,qd),g[3]||(g[3]=e("span",{class:"text-neutral-500 dark:text-neutral-400 text-xs"},"per page",-1))])])):I("",!0)}}),Kd={class:"w-full"},Jd={key:0,class:"flex flex-wrap items-start justify-between gap-4 mb-5"},Yd={class:"flex items-center gap-3"},Gd={class:"flex items-center gap-2"},Zd={key:0,class:"text-xl font-bold tracking-tight"},Xd={key:1,class:"text-xs font-mono text-neutral-400 dark:text-neutral-500"},Qd={key:0,class:"text-sm text-neutral-500 dark:text-neutral-400 mt-0.5"},ec={key:0,class:"flex items-center gap-2"},tc={key:1,class:"mb-4"},rc={class:"flex flex-wrap items-center gap-3"},ac={key:0,class:"flex-1 min-w-[200px] max-w-md"},oc={key:2,class:"flex items-center gap-2 ml-auto"},nc={class:"text-sm text-neutral-500 dark:text-neutral-400 font-medium"},lc={class:"flex items-center gap-1.5"},sc=["onClick"],ic={class:"rounded-xl border border-neutral-300 dark:border-neutral-700 overflow-hidden bg-white dark:bg-transparent"},uc={class:"overflow-x-auto"},dc={class:"w-full"},cc={class:"bg-neutral-50 dark:bg-neutral-800/50 border-b border-neutral-300 dark:border-neutral-700"},pc={key:0,class:"px-4 py-2.5 w-12"},mc={class:"flex items-center justify-center"},vc=["checked","indeterminate"],fc=["onClick"],hc={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"},gc={class:"divide-y divide-neutral-200 dark:divide-neutral-800"},bc={key:0},xc=["colspan"],yc={class:"flex flex-col items-center justify-center gap-3 text-neutral-400"},kc={key:1},wc=["colspan"],_c={class:"flex flex-col items-center justify-center gap-3 text-neutral-400"},$c={class:"w-12 h-12 rounded-full bg-neutral-100 dark:bg-neutral-800 flex items-center justify-center"},Cc={class:"text-sm"},Sc=["onClick"],Tc={key:0,class:"absolute left-0 top-0 bottom-0 w-0.5 bg-accent-500"},Ic={class:"flex items-center justify-center"},zc=["checked","onChange"],Vc=["innerHTML"],Mc={class:"inline-flex gap-0.5"},Ec=["disabled","onClick","title"],Lc=["disabled","onClick","title"],ot=me({__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:o}){const a=t,i=o,l=p(!1),u=p(""),s=p(null),m=$=>{if(typeof $!="string")return $;switch($){case"edit":return ed;case"delete":return Zu;case"view":return Kt;default:return null}},h=($,j)=>{const he=$[j.key];return j.formatter?j.formatter(he,$):he??"-"},x=$=>{switch($){case"center":return"text-center";case"right":return"text-right";default:return"text-left"}},c=($,j)=>j.cellClass?typeof j.cellClass=="function"?j.cellClass($):j.cellClass:"",f=async($,j)=>{if($.confirm){const he=typeof $.confirmMessage=="function"?$.confirmMessage(j):$.confirmMessage||`Are you sure you want to ${$.label.toLowerCase()}?`;u.value=he,s.value=async()=>{await $.handler(j)},l.value=!0}else await $.handler(j)},y=async()=>{s.value&&(await s.value(),s.value=null),l.value=!1},b=()=>{s.value=null,l.value=!1},v=($,j)=>$.visible===void 0?!0:typeof $.visible=="function"?$.visible(j):$.visible,d=($,j)=>$.disabled===void 0?!1:typeof $.disabled=="function"?$.disabled(j):$.disabled,k=p(null),g=p("asc"),_=B(()=>a.sortKey??k.value),L=B(()=>a.sortKey!==void 0?a.sortDirection:g.value),R=$=>a.sortable&&$.sortable===!0,K=$=>{if(!R($))return;const j=$.key;let he="asc";_.value===j&&(he=L.value==="asc"?"desc":"asc"),k.value=j,g.value=he,i("update:sortKey",j),i("update:sortDirection",he),i("sort",{key:j,direction:he})},Y=$=>_.value!==$.key?cd:L.value==="asc"?nd:id,z=B(()=>{if(!_.value||!a.sortable)return S.value;const $=_.value,j=L.value;return[...S.value].sort((he,X)=>{const pe=he[$],le=X[$];if(pe==null&&le==null)return 0;if(pe==null)return j==="asc"?1:-1;if(le==null)return j==="asc"?-1:1;let we=0;return typeof pe=="string"&&typeof le=="string"?we=pe.localeCompare(le,void 0,{sensitivity:"base"}):typeof pe=="number"&&typeof le=="number"?we=pe-le:we=String(pe).localeCompare(String(le)),j==="asc"?we:-we})}),P=p(a.searchQuery),G=p({}),ee=zr($=>{i("update:searchQuery",$),i("search",$)},300),se=$=>{P.value=$,ee($)},de=()=>{P.value="",i("update:searchQuery",""),i("search","")},Q=B(()=>a.columns.filter($=>$.filterable===!0).map($=>{const j=new Map;a.data.forEach(X=>{const pe=X[$.key];if(pe!=null){const le=$.formatter?$.formatter(pe,X):String(pe);if(!j.has(le)){const we=$.filterIcon?$.filterIcon(pe,X):void 0;j.set(le,{value:le,icon:we})}}});const he=Array.from(j.entries()).sort((X,pe)=>X[0].localeCompare(pe[0]));return{key:$.key,label:$.label,options:he.map(([X,pe])=>({value:X,label:X,icon:pe.icon}))}})),E=($,j)=>{if(j===""){const{[$]:he,...X}=G.value;G.value=X}else G.value={...G.value,[$]:j}},S=B(()=>{let $=a.data;const j=Object.entries(G.value);if(j.length>0&&($=$.filter(he=>j.every(([X,pe])=>{const le=a.columns.find(ie=>ie.key===X);if(!le)return!0;const we=he[X];return we==null?!1:(le.formatter?le.formatter(we,he):String(we))===pe}))),a.searchable&&P.value.trim()){const he=P.value.toLowerCase().trim();$=$.filter(X=>a.columns.some(pe=>{if(pe.searchable===!1)return!1;const le=X[pe.key];return le==null?!1:(pe.formatter?pe.formatter(le,X):String(le)).toLowerCase().includes(he)}))}return $}),V=B(()=>{let $=0;return P.value&&$++,$+=Object.keys(G.value).length,$}),re=()=>{de(),G.value={}},F=$=>$[a.rowKey],q=$=>{const j=F($);return a.selectedRows.some(he=>he[a.rowKey]===j)},N=B(()=>z.value.length>0&&a.selectedRows.length===z.value.length),J=B(()=>a.selectedRows.length>0&&a.selectedRows.length<z.value.length),U=$=>{const j=F($);let he;q($)?he=a.selectedRows.filter(X=>X[a.rowKey]!==j):he=[...a.selectedRows,$],i("update:selectedRows",he),i("selection-change",he)},W=()=>{const $=N.value?[]:[...z.value];i("update:selectedRows",$),i("selection-change",$)},M=async $=>{if($.confirm){const j=$.confirmMessage||`Are you sure you want to ${$.label.toLowerCase()} ${a.selectedRows.length} item(s)?`;u.value=j,s.value=async()=>{await $.handler(a.selectedRows)},l.value=!0}else await $.handler(a.selectedRows)},ne=$=>{i("update:page",$),i("page-change",$)},A=$=>{i("update:pageSize",$)},ce=B(()=>a.title||a.description||a.primaryAction),ue=B(()=>a.actions&&a.actions.length>0),ke=B(()=>a.actions?.filter($=>$.variant!=="danger")||[]),be=B(()=>a.actions?.filter($=>$.variant==="danger")||[]),O=B(()=>{let $=a.columns.length;return a.selectable&&$++,ue.value&&$++,$});return($,j)=>{const he=Be("FormKit");return r(),n("div",Kd,[ce.value?(r(),n("div",Jd,[e("div",Yd,[e("div",null,[e("div",Gd,[t.title?(r(),n("h2",Zd,C(t.title),1)):I("",!0),!t.loading&&t.data.length>0?(r(),n("span",Xd,[V.value>0&&S.value.length!==t.data.length?(r(),n(ve,{key:0},[Z(" ("+C(S.value.length)+" of "+C(t.data.length)+") ",1)],64)):(r(),n(ve,{key:1},[Z(" ("+C(t.data.length)+") ",1)],64))])):I("",!0)]),t.description?(r(),n("p",Qd,C(t.description),1)):I("",!0)])]),t.primaryAction?(r(),n("div",ec,[je($.$slots,"header-actions"),w(T(De),{onClick:t.primaryAction.handler},{default:D(()=>[t.primaryAction.icon?(r(),H(Ue(t.primaryAction.icon),{key:0,class:"w-4 h-4 mr-2"})):I("",!0),Z(" "+C(t.primaryAction.label),1)]),_:1},8,["onClick"])])):I("",!0)])):I("",!0),t.searchable||Q.value.length>0?(r(),n("div",tc,[e("div",rc,[t.searchable?(r(),n("div",ac,[w(he,{type:"searchInput",value:P.value,placeholder:t.searchPlaceholder,onInput:se},null,8,["value","placeholder"])])):I("",!0),(r(!0),n(ve,null,ye(Q.value,X=>(r(),n("div",{key:X.key,class:"min-w-[220px]"},[w(he,{type:"selectSearch",value:G.value[X.key]||"",options:X.options,placeholder:`All ${X.label}s`,onInput:pe=>E(X.key,pe)},null,8,["value","options","placeholder","onInput"])]))),128)),V.value>0?(r(),n("button",{key:1,type:"button",onClick:re,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 ")):I("",!0),t.selectable&&t.selectedRows.length>0&&t.bulkActions.length>0?(r(),n("div",oc,[e("span",nc,C(t.selectedRows.length)+" selected ",1),e("div",lc,[(r(!0),n(ve,null,ye(t.bulkActions,(X,pe)=>(r(),n("button",{key:pe,type:"button",onClick:le=>M(X),class:ae(["inline-flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-sm font-medium transition-all duration-150",X.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(),H(Ue(X.icon),{class:"w-4 h-4"})),Z(" "+C(X.label),1)],10,sc))),128))])])):I("",!0)])])):I("",!0),je($.$slots,"toolbar"),e("div",ic,[e("div",uc,[e("table",dc,[e("thead",cc,[e("tr",null,[t.selectable?(r(),n("th",pc,[e("div",mc,[e("input",{type:"checkbox",checked:N.value,indeterminate:J.value,onChange:W,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,vc)])])):I("",!0),(r(!0),n(ve,null,ye(t.columns,X=>(r(),n("th",{key:X.key,class:ae(["px-4 py-2.5 font-medium text-xs uppercase tracking-wide text-neutral-500 dark:text-neutral-400",x(X.align),X.width||"",R(X)?"cursor-pointer select-none group":""]),onClick:pe=>K(X)},[e("div",{class:ae(["inline-flex items-center gap-1",X.align==="right"?"flex-row-reverse":"",R(X)?"hover:text-neutral-700 dark:hover:text-neutral-200 transition-colors":""])},[e("span",null,C(X.label),1),R(X)?(r(),n("span",{key:0,class:ae(["inline-flex items-center justify-center w-5 h-5 rounded transition-all duration-150",_.value===X.key?"bg-accent-100 dark:bg-accent-900/50":"group-hover:bg-neutral-200 dark:group-hover:bg-neutral-700"])},[(r(),H(Ue(Y(X)),{class:ae(["w-3.5 h-3.5",_.value===X.key?"text-accent-600 dark:text-accent-400":"text-neutral-400 dark:text-neutral-500"])},null,8,["class"]))],2)):I("",!0)],2)],10,fc))),128)),ue.value?(r(),n("th",hc," Actions ")):I("",!0)])]),e("tbody",gc,[t.loading?(r(),n("tr",bc,[e("td",{colspan:O.value,class:"px-4 py-16"},[je($.$slots,"loading",{},()=>[e("div",yc,[w(Ee,{size:"md"}),j[3]||(j[3]=e("span",{class:"text-sm"},"Loading data...",-1))])])],8,xc)])):z.value.length===0?(r(),n("tr",kc,[e("td",{colspan:O.value,class:"px-4 py-16"},[je($.$slots,"empty",{},()=>[e("div",_c,[e("div",$c,[w(T(vd),{class:"w-6 h-6"})]),e("p",Cc,C(t.emptyMessage),1),V.value>0?(r(),n("button",{key:0,onClick:re,type:"button",class:"text-xs text-accent-600 dark:text-accent-400 hover:underline font-medium"}," Clear filters ")):I("",!0)])])],8,wc)])):(r(!0),n(ve,{key:2},ye(z.value,(X,pe)=>(r(),n("tr",{key:X[t.rowKey]??pe,class:ae(["transition-all duration-150 cursor-pointer relative",q(X)?"bg-accent-50 dark:bg-accent-950/30":"hover:bg-neutral-50 dark:hover:bg-neutral-900/50"]),onClick:le=>i("row-click",X)},[q(X)?(r(),n("div",Tc)):I("",!0),t.selectable?(r(),n("td",{key:1,class:"px-4 py-3",onClick:j[0]||(j[0]=Re(()=>{},["stop"]))},[e("div",Ic,[e("input",{type:"checkbox",checked:q(X),onChange:le=>U(X),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,zc)])])):I("",!0),(r(!0),n(ve,null,ye(t.columns,le=>(r(),n("td",{key:le.key,class:ae(["px-4 py-3 text-sm",x(le.align),c(X,le),q(X)?"text-accent-900 dark:text-accent-100":"text-neutral-700 dark:text-neutral-300"])},[je($.$slots,`cell-${le.key}`,{value:X[le.key],row:X,column:le},()=>[le.html?(r(),n("span",{key:0,innerHTML:h(X,le)},null,8,Vc)):(r(),n(ve,{key:1},[Z(C(h(X,le)),1)],64))])],2))),128)),ue.value?(r(),n("td",{key:2,class:"px-4 py-3 text-right",onClick:j[1]||(j[1]=Re(()=>{},["stop"]))},[e("div",Mc,[(r(!0),n(ve,null,ye(ke.value,(le,we)=>Ae((r(),n("button",{key:`non-delete-${we}`,disabled:d(le,X),onClick:oe=>f(le,X),class:ae(["p-1.5 rounded-md transition-all duration-150",d(le,X)?"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:le.label},[(r(),H(Ue(m(le.icon)),{class:"w-4 h-4"}))],10,Ec)),[[Ke,v(le,X)]])),128)),je($.$slots,"extra-actions",{row:X}),(r(!0),n(ve,null,ye(be.value,(le,we)=>Ae((r(),n("button",{key:`delete-${we}`,disabled:d(le,X),onClick:oe=>f(le,X),class:ae(["p-1.5 rounded-md transition-all duration-150",d(le,X)?"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:le.label},[(r(),H(Ue(m(le.icon)),{class:"w-4 h-4"}))],10,Lc)),[[Ke,v(le,X)]])),128))])])):I("",!0)],10,Sc))),128))])])]),t.paginated?(r(),H(Wd,{key:0,page:t.page,"page-size":t.pageSize,"total-items":t.totalItems,"page-size-options":t.pageSizeOptions,"onUpdate:page":ne,"onUpdate:pageSize":A},null,8,["page","page-size","total-items","page-size-options"])):I("",!0)]),w(Xt,{modelValue:l.value,"onUpdate:modelValue":j[2]||(j[2]=X=>l.value=X),title:"Confirm Action",message:u.value,"confirm-text":"Confirm","cancel-text":"Cancel",onConfirm:y,onCancel:b},null,8,["modelValue","message"])])}}}),Pc={},Ac={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 jc(t,o){return r(),n("svg",Ac,[...o[0]||(o[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 Dc=Xe(Pc,[["render",jc]]),Oc={},Rc={xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",fill:"currentColor"};function Uc(t,o){return r(),n("svg",Rc,[...o[0]||(o[0]=[e("path",{d:"M4 4h16v16H4V4zm2 2v12h4v-10h3v10h5V6H6z"},null,-1)])])}const Bc=Xe(Oc,[["render",Uc]]),Fc={class:"py-1"},Nc=me({__name:"ShareDropdown",props:{packageId:{}},emits:["download","publish"],setup(t,{emit:o}){const a=o,i=p(null),l=p(null);function u(){if(!i.value||!l.value)return;const x=i.value.getBoundingClientRect();let f=x.right-160;const y=8;f<y&&(f=y),l.value.style.top=`${x.bottom+4}px`,l.value.style.left=`${f}px`}function s(){l.value&&(l.value.matches(":popover-open")?l.value.hidePopover():(u(),l.value.showPopover()))}function m(x){l.value?.hidePopover(),a(x)}function h(){l.value?.matches(":popover-open")&&u()}return Pe(()=>{window.addEventListener("scroll",h,!0),window.addEventListener("resize",h)}),Ye(()=>{window.removeEventListener("scroll",h,!0),window.removeEventListener("resize",h)}),(x,c)=>(r(),n(ve,null,[e("button",{ref_key:"triggerButton",ref:i,type:"button",onClick:s,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(Dc,{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(T(At),{width:"w-40",shadow:{offsetX:4,offsetY:4,intensity:.3}},{default:D(()=>[e("div",Fc,[w(T(ur),{onClick:c[0]||(c[0]=f=>m("download"))},{default:D(()=>[w(T(Sa),{class:"w-4 h-4 text-neutral-500"}),c[2]||(c[2]=e("span",null,"Download",-1))]),_:1}),w(T(ur),{onClick:c[1]||(c[1]=f=>m("publish"))},{default:D(()=>[w(Bc,{class:"w-4 h-4 text-neutral-500"}),c[3]||(c[3]=e("span",null,"Publish",-1))]),_:1})])]),_:1})],512)],64))}}),qc={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Hc(t,o){return r(),n("svg",qc,[...o[0]||(o[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 pr=Ie({name:"lucide-package",render:Hc}),Wc={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function Kc(t,o){return r(),n("svg",Wc,[...o[0]||(o[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 Jc=Ie({name:"lucide-package-open",render:Kc}),Yc={class:"flex items-center gap-2"},Gc=me({__name:"AgentsDataTable",props:{title:{},description:{},primaryAction:{}},emits:["add","edit","delete","pack","unpack","publish"],setup(t,{expose:o,emit:a}){const i=a,l=p([]),u=p(!1),s=[{key:"title",label:"Title",width:"w-1/5",sortable:!0},{key:"type",label:"Type",width:"w-1/12",sortable:!0,formatter:b=>b==="dual_ai"?"Dual AI":"AI+Human"},{key:"side_a_agent_prompt_name",label:"Side A",width:"w-1/5",formatter:b=>b||"-"},{key:"side_b_agent_prompt_name",label:"Side B",width:"w-1/5",formatter:b=>b||"Human"},{key:"created_at",label:"Created",width:"w-1/6",sortable:!0,searchable:!1,formatter:b=>b?new Date(b*1e3).toLocaleDateString():"-"}],m=[{icon:pr,label:"Pack",handler:b=>i("pack",b),visible:b=>!b.packed},{icon:Jc,label:"Unpack",handler:b=>i("unpack",b),visible:b=>!!b.packed},{icon:"edit",label:"Edit",handler:b=>i("edit",b),visible:b=>!b.packed},{icon:"delete",label:"Delete",handler:async b=>{await x(b)},confirm:!0,confirmMessage:"Are you sure you want to delete this agent?",variant:"danger",visible:b=>!b.packed},{icon:"delete",label:"Delete Package",handler:async b=>{await c(b)},confirm:!0,confirmMessage:"Are you sure you want to delete this packed agent and all its contents?",variant:"danger",visible:b=>!!b.packed&&b.source==="local"}],h=async()=>{u.value=!0;try{const b=await fetch(fe("/api/agents"));if(b.ok){const v=await b.json();l.value=v.agents||[]}}catch(b){console.error("Error fetching agents:",b)}finally{u.value=!1}},x=async b=>{try{const v=await fetch(fe(`/api/agents/${b.id}`),{method:"DELETE"});if(v.ok)await h();else{const d=await v.json();alert(d.error||"Failed to delete agent")}}catch(v){console.error("Error deleting agent:",v),alert("Failed to delete agent")}},c=async b=>{if(b.packageId)try{const v=await fetch(fe(`/api/pack/${encodeURIComponent(b.packageId)}`),{method:"DELETE"});if(v.ok)await h();else{const d=await v.json();alert(d.error||"Failed to delete packed agent")}}catch(v){console.error("Error deleting packed agent:",v),alert("Failed to delete packed agent")}},f=b=>{b.packageId&&(window.location.href=fe(`/api/pack/${encodeURIComponent(b.packageId)}/download`))},y=b=>{i("publish",b)};return Pe(()=>{h()}),o({refresh:h}),(b,v)=>(r(),n("div",null,[w(ot,{title:t.title,description:t.description,"primary-action":t.primaryAction,columns:s,data:l.value,actions:m,loading:u.value,sortable:"",searchable:"","search-placeholder":"Search agents...","empty-message":"No agents available. Create your first agent to get started."},{"cell-title":D(({row:d})=>[e("div",Yc,[d.packed?(r(),H(T(pr),{key:0,class:"w-4 h-4 text-blue-500 flex-shrink-0",title:`Packed agent from ${d.packageId}`},null,8,["title"])):I("",!0),e("span",null,C(d.title),1)])]),"extra-actions":D(({row:d})=>[d.packed?(r(),H(Nc,{key:0,"package-id":d.packageId,onDownload:k=>f(d),onPublish:k=>y(d)},null,8,["package-id","onDownload","onPublish"])):I("",!0)]),_:1},8,["title","description","primary-action","data","loading"])]))}}),Zc={class:"flex items-center justify-between p-4 border-b border-neutral-200 dark:border-neutral-700 flex-shrink-0"},Xc={class:"text-xl font-bold"},Qc={key:0,class:"p-6 border-t border-neutral-200 dark:border-neutral-700 flex-shrink-0"},He=me({__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:o}){const a=t,i=o,l=p(),u=p(!1),s=p(new Map),m=()=>l.value&&(l.value.querySelector("input")||l.value.querySelector("textarea")||l.value.querySelector("select")||l.value.querySelector("[contenteditable]")||l.value.querySelector(".monaco-editor")),h=()=>{if(!l.value)return;l.value.querySelectorAll(".monaco-editor-container").forEach(K=>{const Y=K.__monacoEditor;if(Y&&typeof Y.getValue=="function"){const z=Y.getValue();s.value.set(K,z)}})},x=()=>{if(!l.value)return!1;const R=l.value.querySelectorAll(".monaco-editor-container");for(const K of R){const Y=K.__monacoEditor;if(Y&&typeof Y.getValue=="function"){const z=Y.getValue(),P=s.value.get(K);if(P===void 0||(Y.getRawOptions?.()||{}).readOnly===!0)continue;if(z!==P)return!0}}return!1},c=R=>{const K=R;return K.type==="checkbox"||K.type==="radio"?K.checked!==K.defaultChecked:(K.tagName==="SELECT",K.value!==K.defaultValue)},f=()=>{if(a.hasChanges!==void 0)return a.hasChanges;if(!l.value)return!1;if(x())return!0;const R=l.value.querySelectorAll("input, textarea, select");for(const K of R)if(c(K))return!0;return!1},y=()=>{m()&&f()?u.value=!0:b()},b=()=>{i("update:modelValue",!1),i("close")},v=()=>{u.value=!1,b()},d=()=>{u.value=!1},k=R=>{R.key==="Escape"&&a.modelValue&&(m()||b())};ge(()=>a.modelValue,async R=>{R?(document.addEventListener("keydown",k),document.body.style.overflow="hidden",await Le(),setTimeout(()=>{h()},100)):(document.removeEventListener("keydown",k),document.body.style.overflow="",s.value.clear())});const g=p(!1),_=R=>{g.value=R.target===R.currentTarget},L=R=>{R.target===R.currentTarget&&g.value&&(m()||b()),g.value=!1};return(R,K)=>(r(),H(kt,{to:"body"},[w(et,{"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:D(()=>[t.modelValue?(r(),n("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:_,onClick:L},[w(et,{"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:D(()=>[t.modelValue?(r(),n("div",{key:0,class:ae(["w-full",t.width,"max-h-[85vh] flex flex-col"])},[w(wt,{"offset-x":8,"offset-y":8,intensity:.35},{default:D(()=>[e("div",{ref_key:"modalRef",ref:l,class:ae(["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",Zc,[e("h2",Xc,C(t.title),1),w(T(Br),{icon:T(Pt),label:"Close modal",variant:"ghost",onClick:y},null,8,["icon"])]),e("div",{class:ae(["flex-1 min-h-0",t.contentPadding?"overflow-y-auto p-6":"overflow-hidden flex flex-col"])},[je(R.$slots,"default")],2),R.$slots.footer?(r(),n("div",Qc,[je(R.$slots,"footer")])):I("",!0)],2)]),_:3})],2)):I("",!0)]),_:3})],32)):I("",!0)]),_:3}),w(Xt,{modelValue:u.value,"onUpdate:modelValue":K[0]||(K[0]=Y=>u.value=Y),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"])]))}}),e0=["id"],t0={class:"px-5 py-3 border-b border-neutral-100 dark:border-neutral-800"},r0={class:"text-sm font-semibold text-neutral-900 dark:text-neutral-100 flex items-center gap-2"},a0={class:"p-5"},o0={key:0,class:"px-5 py-3 border-t border-neutral-100 dark:border-neutral-800 bg-neutral-50 dark:bg-neutral-800/50"},rt=me({__name:"ModalCard",props:{id:{},title:{},icon:{}},setup(t){return(o,a)=>(r(),n("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",t0,[e("h3",r0,[t.icon?(r(),H(Ue(t.icon),{key:0,class:"w-4 h-4 text-neutral-500"})):I("",!0),Z(" "+C(t.title),1)])]),e("div",a0,[je(o.$slots,"default")]),o.$slots.footer?(r(),n("div",o0,[je(o.$slots,"footer")])):I("",!0)],8,e0))}}),n0={class:"flex flex-col gap-1 px-2"},l0=["onClick"],s0={class:"whitespace-nowrap overflow-hidden text-ellipsis"},Qr=me({__name:"ModalTabs",props:{tabs:{},activeTab:{}},emits:["select"],setup(t,{emit:o}){const a=o;return(i,l)=>(r(),n("div",n0,[(r(!0),n(ve,null,ye(t.tabs,u=>(r(),n("button",{key:u.id,type:"button",onClick:Re(s=>a("select",u.id),["prevent"]),class:ae(["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(),H(Ue(u.icon),{class:"w-4 h-4 flex-shrink-0"})),e("span",s0,C(u.label),1)],10,l0))),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"},xt=me({__name:"ModalSubHeader",props:{title:{}},setup(t){return(o,a)=>(r(),n("h4",i0,C(t.title),1))}});function ea(t,o){const a=p(o[0]),i=()=>{const u=t.value;if(!u)return;const s=o.filter(f=>document.getElementById(`section-${f}`)!==null);if(s.length===0)return;if(u.scrollHeight-u.scrollTop-u.clientHeight<50){a.value=s[s.length-1];return}const h=u.getBoundingClientRect(),x=h.top+h.height*.3;let c=s[0];for(const f of s)document.getElementById(`section-${f}`).getBoundingClientRect().top<=x&&(c=f);a.value=c},l=u=>{const s=document.getElementById(`section-${u}`);if(s&&t.value){const m=t.value.getBoundingClientRect().top,h=s.getBoundingClientRect().top,x=t.value.scrollTop+(h-m);t.value.scrollTo({top:x,behavior:"smooth"})}};return ge(t,(u,s)=>{s&&s.removeEventListener("scroll",i),u&&(u.addEventListener("scroll",i),i())}),Vr(()=>{t.value?.removeEventListener("scroll",i)}),{activeTab:a,scrollToSection:l}}const u0={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function d0(t,o){return r(),n("svg",u0,[...o[0]||(o[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 Lt=Ie({name:"lucide-file-text",render:d0}),c0={viewBox:"0 0 24 24",width:"1.2em",height:"1.2em"};function p0(t,o){return r(),n("svg",c0,[...o[0]||(o[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 mr=Ie({name:"lucide-user",render:p0}),m0={key:0,class:"min-h-[500px] flex items-center justify-center"},v0={class:"flex flex-1 min-h-0"},f0={class:"w-44 flex-shrink-0 border-r border-neutral-200 dark:border-neutral-700 py-4"},h0={class:"space-y-4"},g0={class:"space-y-5"},b0={class:"grid grid-cols-2 gap-4"},x0={key:0},y0={key:1},k0={key:2},w0={class:"space-y-5"},_0={class:"grid grid-cols-2 gap-4"},$0={class:"space-y-4 pt-4 border-t border-neutral-100 dark:border-neutral-800"},C0={key:0,class:"ml-6 mt-3 space-y-3"},S0={key:2},T0={class:"grid grid-cols-2 gap-4 pt-4 border-t border-neutral-100 dark:border-neutral-800"},I0={class:"space-y-5"},z0={class:"grid grid-cols-2 gap-4"},V0={class:"space-y-4 pt-4 border-t border-neutral-100 dark:border-neutral-800"},M0={key:0,class:"ml-6 mt-3 space-y-3"},E0={key:2},L0={class:"grid grid-cols-2 gap-4 pt-4 border-t border-neutral-100 dark:border-neutral-800"},P0={class:"space-y-3"},A0={key:0,class:"text-xs text-neutral-500"},j0={class:"flex justify-between"},D0=me({__name:"AgentModal",props:{modelValue:{type:Boolean},editAgent:{},mode:{},apiError:{}},emits:["update:modelValue","save"],setup(t,{emit:o}){const a=t,i=o,l=B(()=>a.mode==="edit"),u=p(!1),s=p(null),m=["basics","side-a","side-b","env"],{activeTab:h,scrollToSection:x}=ea(s,m),c=B(()=>{const Ce=[{id:"basics",label:"Basics",icon:Lt},{id:"side-a",label:"Side A",icon:mt},{id:"side-b",label:"Side B",icon:d.value==="ai_human"?mr:mt}];return($.value.length>0||Object.keys(j.value).length>0)&&Ce.push({id:"env",label:"Environment",icon:Ht}),Ce}),f=p(""),y=p(""),b=p(""),v=p(""),d=p("dual_ai"),k=p(!1),g=p(""),_=p(""),L=p(null),R=p(""),K=p(""),Y=p(""),z=p(""),P=p(!0),G=p(!1),ee=p(""),se=p(""),de=p(""),Q=p(""),E=p(!1),S=p(null),V=p(""),re=p(""),F=p(""),q=p(""),N=p(""),J=p(""),U=p(!0),W=p(!1),M=p(""),ne=p(""),A=p(""),ce=p(""),ue=p(null),ke=p(""),be=p(""),O=p(""),$=p([]),j=p({}),he=p(!1),{data:X,execute:pe}=Ne(fe("/api/prompts"),{immediate:!1}).json(),{data:le,execute:we}=Ne(fe("/api/tools?schema=true"),{immediate:!1}).json(),oe=p(null),ie=p(!1),Ve=p(null),_e=p(!1),$e=p(!1),xe=B(()=>{if(!X.value)return[{value:"",label:"Select a prompt..."}];const Ce=X.value?.prompts||[];return[{value:"",label:"None"},...Ce.map(te=>({value:te.id,label:te.name}))]}),Me=Ce=>le.value?le.value[Ce]:null,We=B(()=>!oe.value||!oe.value.tools?[{value:"",label:"None"}]:[{value:"",label:"None"},...oe.value.tools.map(Ce=>{const te=typeof Ce=="string"?Ce:Ce.name;return{value:te,label:te}})]),$t=B(()=>!Ve.value||!Ve.value.tools?[{value:"",label:"None"}]:[{value:"",label:"None"},...Ve.value.tools.map(Ce=>{const te=typeof Ce=="string"?Ce:Ce.name;return{value:te,label:te}})]),ia=B(()=>{if(!ee.value)return[];const Ce=Me(ee.value);return!Ce||!Ce.schema||!Ce.schema.properties?[]:Object.keys(Ce.schema.properties).map(te=>({value:te,label:te}))}),ua=B(()=>{if(!M.value)return[];const Ce=Me(M.value);return!Ce||!Ce.schema||!Ce.schema.properties?[]:Object.keys(Ce.schema.properties).map(te=>({value:te,label:te}))}),Ot=async()=>{const Ce=[Y.value,N.value].filter(Boolean);if(Ce.length===0){$.value=[];return}he.value=!0;try{const te=[],Se=new Set;for(const Te of Ce){const qe=await Je(`/prompts/${Te}/tenvs`);if(qe.ok){const Rt=await qe.json();for(const at of Rt.tenvs||[])Se.has(at.name)||(Se.add(at.name),te.push({name:at.name,value:at.value,required:at.required,description:at.description,source:at.source}))}}$.value=te}catch(te){console.error("Error fetching tenvs from prompts:",te),$.value=[]}finally{he.value=!1}},da=[{value:"dual_ai",label:"AI + AI (Subagent)"},{value:"ai_human",label:"AI + Human"}],ca=Ce=>{let te=Ce.toLowerCase().replace(/\s+/g,"_").replace(/[^a-z0-9_]/g,"");return!te.endsWith("_agent")&&te.length>0&&(te=te+"_agent"),te},pa=Ce=>!Ce||Ce==="_agent"?(b.value="Name is required",!1):/^[a-z][a-z0-9_]*_agent$/.test(Ce)?(b.value="",!0):(b.value="Name must start with a letter",!1),Ct=()=>{y.value="",f.value="",b.value="",v.value="",d.value="dual_ai",k.value=!1,g.value="",_.value="",L.value=null,R.value="",K.value="",Y.value="",z.value="",P.value=!0,G.value=!1,ee.value="",se.value="",de.value="",Q.value="",E.value=!1,S.value=null,V.value="",re.value="",F.value="",oe.value=null,q.value="",N.value="",J.value="",U.value=!0,W.value=!1,M.value="",ne.value="",A.value="",ce.value="",ue.value=null,ke.value="",be.value="",O.value="",Ve.value=null,$.value=[],j.value={}},ma=async()=>{if(a.editAgent?.id){u.value=!0,$e.value=!0;try{const Ce=await fetch(fe(`/api/agents/${a.editAgent.id}`));if(Ce.ok){const te=await Ce.json(),Se=te.agent||te;y.value=Se.name||"",f.value=Se.name||"",v.value=Se.title||"",d.value=Se.type||"dual_ai",k.value=Se.expose_as_tool||!1,g.value=Se.tool_description||"",L.value=Se.max_session_turns;const Te=Se.side_a_stop_tool||"",qe=Se.side_a_stop_tool_response_property||"",Rt=Se.side_b_stop_tool||"",at=Se.side_b_stop_tool_response_property||"",ha=Se.side_a_end_conversation_tool||"",ga=Se.side_b_end_conversation_tool||"";K.value=Se.side_a_label||"",q.value=Se.side_b_label||"",Y.value=Se.side_a_agent_prompt||"",N.value=Se.side_b_agent_prompt||"",P.value=!!Se.side_a_stop_on_response,G.value=!!Se.side_a_stop_tool,E.value=!!Se.side_a_manual_stop_condition,S.value=Se.side_a_max_steps,U.value=!!Se.side_b_stop_on_response,W.value=!!Se.side_b_stop_tool,ue.value=Se.side_b_max_steps,await Le(),ee.value=Te,de.value=qe,M.value=Rt,A.value=at,re.value=ha,be.value=ga,Se.tenvs&&typeof Se.tenvs=="object"&&(j.value=Se.tenvs),await Ot()}}catch(Ce){console.error("Error loading agent data:",Ce)}finally{u.value=!1,$e.value=!1}}},va=async()=>{b.value="",R.value="",z.value="",se.value="",Q.value="",V.value="",F.value="",J.value="",ne.value="",ce.value="",ke.value="",O.value="";let Ce=!1;pa(y.value)||(Ce=!0);const te=y.value;d.value==="dual_ai"&&L.value!==null&&L.value!==void 0&&L.value<=0&&(R.value="Max session turns must be a positive number",Ce=!0),Y.value||(z.value="Please select an agent prompt",Ce=!0);const Se=P.value||ee.value,Te=d.value==="ai_human"&&E.value;if(!Se&&!Te&&(z.value="At least one stop condition is required (or check manual stop condition for ai_human agents)",Ce=!0),ee.value&&!de.value&&(Q.value="Response property required when using stop tool",Ce=!0),S.value!==null&&S.value<=0&&(V.value="Max steps must be a positive number",Ce=!0),d.value==="dual_ai"&&!re.value&&!be.value&&(F.value="At least one side must have an end conversation tool",O.value="At least one side must have an end conversation tool",Ce=!0),d.value==="dual_ai"&&(N.value||(J.value="Please select an agent prompt",Ce=!0),M.value&&!A.value&&(ce.value="Response property required when using stop tool",Ce=!0),ue.value!==null&&ue.value<=0&&(ke.value="Max steps must be a positive number",Ce=!0)),Ce)return;const qe={name:te,title:v.value||null,type:d.value,expose_as_tool:k.value,tool_description:k.value?g.value:null,max_session_turns:d.value==="dual_ai"?L.value:null,side_a_label:K.value||null,side_a_agent_prompt:Y.value,side_a_stop_on_response:P.value,side_a_stop_tool:ee.value||null,side_a_stop_tool_response_property:de.value||null,side_a_manual_stop_condition:E.value,side_a_max_steps:S.value,side_a_end_conversation_tool:re.value||null};d.value==="dual_ai"&&(qe.side_b_label=q.value||null,qe.side_b_agent_prompt=N.value,qe.side_b_stop_on_response=U.value,qe.side_b_stop_tool=M.value||null,qe.side_b_stop_tool_response_property=A.value||null,qe.side_b_max_steps=ue.value,qe.side_b_end_conversation_tool=be.value||null),Object.keys(j.value).length>0&&(qe.tenvs=j.value),l.value&&a.editAgent?.id&&(qe.id=a.editAgent.id),i("save",qe)},fa=()=>{Ct(),i("update:modelValue",!1)};return ge(Y,async Ce=>{if($e.value||(ee.value="",de.value=""),!Ce){oe.value=null;return}ie.value=!0;try{const te=await fetch(fe(`/api/prompts/${Ce}`));te.ok&&(oe.value=await te.json())}catch(te){console.error("Error fetching Side A prompt:",te)}finally{ie.value=!1}$e.value||await Ot()}),ge(N,async Ce=>{if($e.value||(M.value="",A.value=""),!Ce){Ve.value=null;return}_e.value=!0;try{const te=await fetch(fe(`/api/prompts/${Ce}`));te.ok&&(Ve.value=await te.json())}catch(te){console.error("Error fetching Side B prompt:",te)}finally{_e.value=!1}$e.value||await Ot()}),ge(G,Ce=>{Ce||(ee.value="",de.value="")}),ge(W,Ce=>{Ce||(M.value="",A.value="")}),ge(()=>a.modelValue,async Ce=>{Ce?(await Promise.all([pe(),we()]),l.value?(Ct(),await ma()):Ct()):Ct()}),(Ce,te)=>{const Se=Be("FormKit");return r(),H(He,{"model-value":t.modelValue,"onUpdate:modelValue":te[26]||(te[26]=Te=>Ce.$emit("update:modelValue",Te)),title:l.value?"Edit Agent":"Create Agent",width:"max-w-5xl","content-padding":!1},{footer:D(()=>[e("div",j0,[w(T(De),{variant:"ghost",size:"sm",onClick:fa},{default:D(()=>[...te[55]||(te[55]=[Z(" Cancel ",-1)])]),_:1}),w(T(De),{variant:"primary",size:"sm",disabled:u.value,loading:u.value,onClick:va},{default:D(()=>[Z(C(l.value?"Update Agent":"Create Agent"),1)]),_:1},8,["disabled","loading"])])]),default:D(()=>[u.value?(r(),n("div",m0,[...te[27]||(te[27]=[e("span",{class:"text-neutral-500"},"Loading agent data...",-1)])])):(r(),H(Se,{key:1,type:"form",actions:!1,"form-class":"$reset flex-1 min-h-0 flex flex-col"},{default:D(()=>[e("div",v0,[e("nav",f0,[w(T(Qr),{tabs:c.value,"active-tab":T(h),onSelect:T(x)},null,8,["tabs","active-tab","onSelect"])]),e("div",{ref_key:"contentRef",ref:s,class:"flex-1 overflow-y-auto p-5 bg-neutral-100 dark:bg-neutral-950"},[e("div",h0,[t.apiError?(r(),H(T(Fe),{key:0,variant:"error"},{default:D(()=>[Z(C(t.apiError),1)]),_:1})):I("",!0),w(T(rt),{id:"section-basics",title:"Basics",icon:T(Lt)},{default:D(()=>[e("div",g0,[e("div",null,[w(Se,{type:"text",modelValue:y.value,"onUpdate:modelValue":te[0]||(te[0]=Te=>y.value=Te),label:"Agent Name",disabled:l.value,validation:"required","validation-messages":{required:"Name is required"},"outer-class":"$reset",onBlur:te[1]||(te[1]=Te=>y.value=ca(y.value))},null,8,["modelValue","disabled"]),b.value?(r(),H(T(ze),{key:0,class:"mt-1 text-red-600 dark:text-red-400"},{default:D(()=>[Z(C(b.value),1)]),_:1})):l.value?(r(),H(T(ze),{key:2,class:"mt-1"},{default:D(()=>[...te[29]||(te[29]=[Z(" Agent names cannot be changed after creation (used as foreign key for threads) ",-1)])]),_:1})):(r(),H(T(ze),{key:1,class:"mt-1"},{default:D(()=>[...te[28]||(te[28]=[Z(" Automatically formatted to snake_case with _agent suffix (e.g., research_agent) ",-1)])]),_:1}))]),e("div",b0,[e("div",null,[w(Se,{type:"text",modelValue:v.value,"onUpdate:modelValue":te[2]||(te[2]=Te=>v.value=Te),label:"Display Title (Optional)","outer-class":"$reset"},null,8,["modelValue"]),w(T(ze),{class:"mt-1"},{default:D(()=>[...te[30]||(te[30]=[Z(" Human-readable title shown in the UI ",-1)])]),_:1})]),e("div",null,[w(Se,{type:"selectSearch",modelValue:d.value,"onUpdate:modelValue":te[3]||(te[3]=Te=>d.value=Te),label:"Agent Type",options:da,"outer-class":"$reset"},null,8,["modelValue"]),w(T(ze),{class:"mt-1"},{default:D(()=>[...te[31]||(te[31]=[Z(" AI + AI or AI + Human conversation ",-1)])]),_:1})])]),d.value==="dual_ai"?(r(),n("div",x0,[w(Se,{type:"checkbox",modelValue:k.value,"onUpdate:modelValue":te[4]||(te[4]=Te=>k.value=Te),label:"Expose as Tool","outer-class":"$reset"},null,8,["modelValue"]),w(T(ze),{class:"mt-1"},{default:D(()=>[...te[32]||(te[32]=[Z(" Make this subagent available as a tool that can be called by other prompts or agents ",-1)])]),_:1})])):I("",!0),k.value&&d.value==="dual_ai"?(r(),n("div",y0,[w(Se,{type:"textarea",modelValue:g.value,"onUpdate:modelValue":te[5]||(te[5]=Te=>g.value=Te),label:"Tool Description",placeholder:"Describe what this agent does when called as a tool",rows:3,"outer-class":"$reset"},null,8,["modelValue"]),_.value?(r(),H(T(ze),{key:0,class:"mt-1 text-red-600 dark:text-red-400"},{default:D(()=>[Z(C(_.value),1)]),_:1})):(r(),H(T(ze),{key:1,class:"mt-1"},{default:D(()=>[...te[33]||(te[33]=[Z(" This description helps other agents understand when to use this agent ",-1)])]),_:1}))])):I("",!0),d.value==="dual_ai"?(r(),n("div",k0,[w(Se,{type:"number",modelValue:L.value,"onUpdate:modelValue":te[6]||(te[6]=Te=>L.value=Te),label:"Max Session Turns",placeholder:"Unlimited","outer-class":"$reset"},null,8,["modelValue"]),R.value?(r(),H(T(ze),{key:0,class:"mt-1 text-red-600 dark:text-red-400"},{default:D(()=>[Z(C(R.value),1)]),_:1})):(r(),H(T(ze),{key:1,class:"mt-1"},{default:D(()=>[...te[34]||(te[34]=[Z(" Maximum number of back-and-forth exchanges between the two agents before the conversation ends ",-1)])]),_:1}))])):I("",!0)])]),_:1},8,["icon"]),w(T(rt),{id:"section-side-a",title:"Side A (AI)",icon:T(mt)},{default:D(()=>[e("div",w0,[e("div",_0,[e("div",null,[w(Se,{type:"text",modelValue:K.value,"onUpdate:modelValue":te[7]||(te[7]=Te=>K.value=Te),label:"Side Label (Optional)",placeholder:"e.g., ATC, Pilot, Customer","outer-class":"$reset"},null,8,["modelValue"]),w(T(ze),{class:"mt-1"},{default:D(()=>[...te[35]||(te[35]=[Z(" Custom label for this side ",-1)])]),_:1})]),e("div",null,[w(Se,{type:"selectSearch",modelValue:Y.value,"onUpdate:modelValue":te[8]||(te[8]=Te=>Y.value=Te),label:"Agent Prompt",options:xe.value,validation:"required","validation-messages":{required:"Please select an agent prompt"},"outer-class":"$reset"},null,8,["modelValue","options"]),z.value?(r(),H(T(ze),{key:0,class:"mt-1 text-red-600 dark:text-red-400"},{default:D(()=>[Z(C(z.value),1)]),_:1})):(r(),H(T(ze),{key:1,class:"mt-1"},{default:D(()=>[...te[36]||(te[36]=[Z(" Defines this agent's behavior ",-1)])]),_:1}))])]),e("div",$0,[w(T(xt),{title:"Stop Conditions"}),w(T(ze),null,{default:D(()=>[...te[37]||(te[37]=[Z(" 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(Se,{type:"checkbox",modelValue:P.value,"onUpdate:modelValue":te[9]||(te[9]=Te=>P.value=Te),label:"Stop when agent returns content","outer-class":"$reset"},null,8,["modelValue"]),w(T(ze),{class:"ml-6"},{default:D(()=>[...te[38]||(te[38]=[Z(" Agent stops when it returns a response without calling tools ",-1)])]),_:1})]),e("div",null,[w(Se,{type:"checkbox",modelValue:G.value,"onUpdate:modelValue":te[10]||(te[10]=Te=>G.value=Te),label:"Stop on specific tool call","outer-class":"$reset"},null,8,["modelValue"]),G.value?(r(),n("div",C0,[w(Se,{type:"selectSearch",modelValue:ee.value,"onUpdate:modelValue":te[11]||(te[11]=Te=>ee.value=Te),label:"Stop Tool",options:We.value,placeholder:"Select a tool...",disabled:ie.value||!Y.value,"outer-class":"$reset"},null,8,["modelValue","options","disabled"]),se.value?(r(),H(T(ze),{key:0,class:"text-red-600 dark:text-red-400"},{default:D(()=>[Z(C(se.value),1)]),_:1})):(r(),H(T(ze),{key:1},{default:D(()=>[...te[39]||(te[39]=[Z(" Agent stops when this tool is called ",-1)])]),_:1})),ee.value?(r(),n("div",S0,[w(Se,{type:"selectSearch",modelValue:de.value,"onUpdate:modelValue":te[12]||(te[12]=Te=>de.value=Te),label:"Response Property",options:ia.value,placeholder:"Select property...","outer-class":"$reset"},null,8,["modelValue","options"]),Q.value?(r(),H(T(ze),{key:0,class:"mt-1 text-red-600 dark:text-red-400"},{default:D(()=>[Z(C(Q.value),1)]),_:1})):(r(),H(T(ze),{key:1,class:"mt-1"},{default:D(()=>[...te[40]||(te[40]=[Z(" Property from tool arguments to return as final response ",-1)])]),_:1}))])):I("",!0)])):I("",!0)]),d.value==="ai_human"&&!P.value&&!G.value?(r(),H(T(Fe),{key:0,variant:"warning",class:"mt-3"},{default:D(()=>[w(Se,{type:"checkbox",modelValue:E.value,"onUpdate:modelValue":te[13]||(te[13]=Te=>E.value=Te),label:"I have manually implemented a stop condition","outer-class":"$reset"},null,8,["modelValue"]),te[41]||(te[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})):I("",!0)]),e("div",T0,[e("div",null,[w(Se,{type:"number",modelValue:S.value,"onUpdate:modelValue":te[14]||(te[14]=Te=>S.value=Te),label:"Max Steps",placeholder:"Unlimited","outer-class":"$reset"},null,8,["modelValue"]),V.value?(r(),H(T(ze),{key:0,class:"mt-1 text-red-600 dark:text-red-400"},{default:D(()=>[Z(C(V.value),1)]),_:1})):(r(),H(T(ze),{key:1,class:"mt-1"},{default:D(()=>[...te[42]||(te[42]=[Z(" Safety limit before yielding ",-1)])]),_:1}))]),e("div",null,[w(Se,{type:"selectSearch",modelValue:re.value,"onUpdate:modelValue":te[15]||(te[15]=Te=>re.value=Te),label:"End Conversation Tool",options:We.value,placeholder:"Select a tool...",disabled:ie.value||!Y.value,"outer-class":"$reset"},null,8,["modelValue","options","disabled"]),F.value?(r(),H(T(ze),{key:0,class:"mt-1 text-red-600 dark:text-red-400"},{default:D(()=>[Z(C(F.value),1)]),_:1})):(r(),H(T(ze),{key:1,class:"mt-1"},{default:D(()=>[...te[43]||(te[43]=[Z(" Ends entire conversation when called ",-1)])]),_:1}))])])])]),_:1},8,["icon"]),w(T(rt),{id:"section-side-b",title:d.value==="ai_human"?"Side B (Human)":"Side B (AI)",icon:d.value==="ai_human"?T(mr):T(mt)},{default:D(()=>[e("div",I0,[d.value==="ai_human"?(r(),n(ve,{key:0},[e("div",null,[w(Se,{type:"text",modelValue:q.value,"onUpdate:modelValue":te[16]||(te[16]=Te=>q.value=Te),label:"Side Label (Optional)",placeholder:"e.g., Customer, User","outer-class":"$reset"},null,8,["modelValue"]),w(T(ze),{class:"mt-1"},{default:D(()=>[...te[44]||(te[44]=[Z(" Custom label for this side ",-1)])]),_:1})]),te[45]||(te[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(),n(ve,{key:1},[e("div",z0,[e("div",null,[w(Se,{type:"text",modelValue:q.value,"onUpdate:modelValue":te[17]||(te[17]=Te=>q.value=Te),label:"Side Label (Optional)",placeholder:"e.g., ATC, Pilot, Customer","outer-class":"$reset"},null,8,["modelValue"]),w(T(ze),{class:"mt-1"},{default:D(()=>[...te[46]||(te[46]=[Z(" Custom label for this side ",-1)])]),_:1})]),e("div",null,[w(Se,{type:"selectSearch",modelValue:N.value,"onUpdate:modelValue":te[18]||(te[18]=Te=>N.value=Te),label:"Agent Prompt",options:xe.value,validation:"required","validation-messages":{required:"Please select an agent prompt"},"outer-class":"$reset"},null,8,["modelValue","options"]),J.value?(r(),H(T(ze),{key:0,class:"mt-1 text-red-600 dark:text-red-400"},{default:D(()=>[Z(C(J.value),1)]),_:1})):(r(),H(T(ze),{key:1,class:"mt-1"},{default:D(()=>[...te[47]||(te[47]=[Z(" Defines this agent's behavior ",-1)])]),_:1}))])]),e("div",V0,[w(T(xt),{title:"Stop Conditions"}),w(T(ze),null,{default:D(()=>[...te[48]||(te[48]=[Z(" 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(Se,{type:"checkbox",modelValue:U.value,"onUpdate:modelValue":te[19]||(te[19]=Te=>U.value=Te),label:"Stop when agent returns content","outer-class":"$reset"},null,8,["modelValue"]),w(T(ze),{class:"ml-6"},{default:D(()=>[...te[49]||(te[49]=[Z(" Agent stops when it returns a response without calling tools ",-1)])]),_:1})]),e("div",null,[w(Se,{type:"checkbox",modelValue:W.value,"onUpdate:modelValue":te[20]||(te[20]=Te=>W.value=Te),label:"Stop on specific tool call","outer-class":"$reset"},null,8,["modelValue"]),W.value?(r(),n("div",M0,[w(Se,{type:"selectSearch",modelValue:M.value,"onUpdate:modelValue":te[21]||(te[21]=Te=>M.value=Te),label:"Stop Tool",options:$t.value,placeholder:"Select a tool...",disabled:_e.value||!N.value,"outer-class":"$reset"},null,8,["modelValue","options","disabled"]),ne.value?(r(),H(T(ze),{key:0,class:"text-red-600 dark:text-red-400"},{default:D(()=>[Z(C(ne.value),1)]),_:1})):(r(),H(T(ze),{key:1},{default:D(()=>[...te[50]||(te[50]=[Z(" Agent stops when this tool is called ",-1)])]),_:1})),M.value?(r(),n("div",E0,[w(Se,{type:"selectSearch",modelValue:A.value,"onUpdate:modelValue":te[22]||(te[22]=Te=>A.value=Te),label:"Response Property",options:ua.value,placeholder:"Select property...","outer-class":"$reset"},null,8,["modelValue","options"]),ce.value?(r(),H(T(ze),{key:0,class:"mt-1 text-red-600 dark:text-red-400"},{default:D(()=>[Z(C(ce.value),1)]),_:1})):(r(),H(T(ze),{key:1,class:"mt-1"},{default:D(()=>[...te[51]||(te[51]=[Z(" Property from tool arguments to return as final response ",-1)])]),_:1}))])):I("",!0)])):I("",!0)])]),e("div",L0,[e("div",null,[w(Se,{type:"number",modelValue:ue.value,"onUpdate:modelValue":te[23]||(te[23]=Te=>ue.value=Te),label:"Max Steps",placeholder:"Unlimited","outer-class":"$reset"},null,8,["modelValue"]),ke.value?(r(),H(T(ze),{key:0,class:"mt-1 text-red-600 dark:text-red-400"},{default:D(()=>[Z(C(ke.value),1)]),_:1})):(r(),H(T(ze),{key:1,class:"mt-1"},{default:D(()=>[...te[52]||(te[52]=[Z(" Safety limit before yielding ",-1)])]),_:1}))]),e("div",null,[w(Se,{type:"selectSearch",modelValue:be.value,"onUpdate:modelValue":te[24]||(te[24]=Te=>be.value=Te),label:"End Conversation Tool",options:$t.value,placeholder:"Select a tool...",disabled:_e.value||!N.value,"outer-class":"$reset"},null,8,["modelValue","options","disabled"]),O.value?(r(),H(T(ze),{key:0,class:"mt-1 text-red-600 dark:text-red-400"},{default:D(()=>[Z(C(O.value),1)]),_:1})):(r(),H(T(ze),{key:1,class:"mt-1"},{default:D(()=>[...te[53]||(te[53]=[Z(" Ends entire conversation when called ",-1)])]),_:1}))])])],64))])]),_:1},8,["title","icon"]),$.value.length>0||Object.keys(j.value).length>0?(r(),H(T(rt),{key:1,id:"section-env",title:"Environment",icon:T(Ht)},{default:D(()=>[e("div",P0,[te[54]||(te[54]=e("p",{class:"text-sm text-neutral-500 dark:text-neutral-400"}," Configure values for tools that require thread environment variables. Values from prompts are shown locked - click to unlock and override. ",-1)),he.value?(r(),n("span",A0,"Loading...")):I("",!0),w(Zt,{modelValue:j.value,"onUpdate:modelValue":te[25]||(te[25]=Te=>j.value=Te),inherited:$.value,"allow-custom":!0,disabled:u.value},null,8,["modelValue","inherited","disabled"])])]),_:1},8,["icon"])):I("",!0)])],512)])]),_:1}))]),_:1},8,["model-value","title"])}}}),ta=me({__name:"ExtractCopyToggle",props:{value:{},disabled:{type:Boolean}},emits:["update:value"],setup(t,{emit:o}){const a=o,i=l=>{a("update:value",l)};return(l,u)=>{const s=Be("FormKit");return r(),H(s,{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:i},null,8,["value","disabled"])}}}),O0={class:"font-mono text-sm"},R0={class:"flex items-center gap-2 py-1.5"},U0={class:"text-neutral-600 dark:text-neutral-400"},B0={class:"ml-auto"},ra=me({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:Oe("div",{class:"ml-4"},t.children.map((o,a)=>Oe("div",{class:"relative",key:o.uid},[a<t.children.length-1?Oe("div",{class:"absolute left-0 top-0 bottom-0 border-l border-neutral-300 dark:border-neutral-700"}):Oe("div",{class:"absolute left-0 top-0 h-3 border-l border-neutral-300 dark:border-neutral-700"}),Oe("div",{class:"absolute left-0 top-3 w-4 border-t border-neutral-300 dark:border-neutral-700"}),Oe("div",{class:"pl-5"},[Oe("div",{class:"flex items-center gap-2 py-1.5"},[Oe("span",{class:"text-neutral-600 dark:text-neutral-400"},o.name),Oe(ft,{variant:t.getTypeColor(o.type),size:"sm"},()=>o.type),t.isShared(o)?Oe("span",{class:"text-xs text-amber-600 dark:text-amber-400",title:`Used by: ${o.sharedWith.join(", ")}`},`(used in ${o.sharedWith.length} other${o.sharedWith.length>1?"s":""})`):null,o.isDuplicate?null:Oe("div",{class:"ml-auto"},[Oe(ta,{value:t.getSelection(o),disabled:t.isShared(o),"onUpdate:value":i=>t.setSelection(o,i),title:t.isShared(o)?"Cannot extract items shared with other agents":""})])]),o.children.length>0?Oe(ra,{children:o.children,getSelection:t.getSelection,setSelection:t.setSelection,isShared:t.isShared,getTypeColor:t.getTypeColor}):null])])))}}),F0=me({__name:"DependencyTree",props:{analysis:{},selections:{}},emits:["update:selection"],setup(t,{emit:o}){const a=t,i=o,l=B(()=>{const c=a.analysis,f=[];let y=0;const b=(L,R)=>{for(const K of L){const Y=`${R}:${K.name}`;f.push({...K,type:R,uid:`${Y}:${y++}`})}};b(c.constituents.agents,"agent"),b(c.constituents.prompts,"prompt"),b(c.constituents.tools,"tool"),b(c.constituents.models,"model"),b(c.constituents.hooks,"hook");const v=new Map,d=`agent:${c.agent}`;for(const L of f){const R=L.parentKey||d;`${L.type}:${L.name}`===d&&!L.parentKey||(v.has(R)||v.set(R,[]),v.get(R).push(L))}const k=new Set,g=L=>{const R=`${L.type}:${L.name}`,K=k.has(R);k.add(R);const Y=[],z=v.get(R)||[];for(const P of z)Y.push(g(P));return{name:L.name,type:L.type,filePath:L.filePath,sharedWith:L.sharedWith,discoveredVia:L.discoveredVia,children:Y,uid:L.uid,isDuplicate:K}},_=f.find(L=>L.type==="agent"&&L.name===c.agent&&!L.parentKey);return _?g(_):{name:c.agent,type:"agent",filePath:"",sharedWith:[],discoveredVia:"static",children:[],uid:"root",isDuplicate:!1}}),u=c=>`${c.type}:${c.name}`,s=c=>a.selections.get(u(c))||"extract",m=(c,f)=>{i("update:selection",u(c),f)},h=c=>c.sharedWith.length>0,x=c=>{switch(c){case"agent":return"accent";case"prompt":return"secondary";case"tool":return"success";case"model":return"warning";case"hook":return"default"}};return(c,f)=>(r(),n("div",O0,[e("div",R0,[e("span",U0,C(l.value.name),1),w(T(ft),{variant:x(l.value.type),size:"sm"},{default:D(()=>[Z(C(l.value.type),1)]),_:1},8,["variant"]),e("div",B0,[w(ta,{value:s(l.value),"onUpdate:value":f[0]||(f[0]=y=>m(l.value,y))},null,8,["value"])])]),(r(),H(Ue(T(ra)),{children:l.value.children,"get-selection":s,"set-selection":m,"is-shared":h,"get-type-color":x},null,8,["children"]))]))}}),N0={key:0,class:"flex items-center justify-center py-12"},q0={key:1,class:"py-4"},H0={key:2,class:"py-4 space-y-4"},W0={class:"space-y-2"},K0={class:"text-sm opacity-80"},J0={class:"text-sm opacity-80"},Y0={key:3,class:"space-y-6"},G0={class:"space-y-4"},Z0={class:"grid grid-cols-2 gap-4"},X0={class:"col-span-2"},Q0=["value"],ep={class:"col-span-2"},tp={class:"col-span-2"},rp={key:0,class:"mt-3 space-y-3"},ap={class:"flex gap-2 border-b border-neutral-200 dark:border-neutral-700"},op={key:0},np=["innerHTML"],lp={class:"space-y-4"},sp={class:"list-disc list-inside space-y-1"},ip={class:"border border-neutral-200 dark:border-neutral-700 rounded-lg p-4 bg-neutral-50 dark:bg-neutral-900/50"},up={class:"flex justify-between"},dp=me({__name:"PackModal",props:{modelValue:{type:Boolean},agent:{}},emits:["update:modelValue","packed"],setup(t,{emit:o}){Vt.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"}],i=t,l=o,u=B({get:()=>i.modelValue,set:q=>l("update:modelValue",q)}),s=p(null),m=p(!1),h=p(!1),x=p(null),c=p(null),f=p(""),y=p("1.0.0"),b=p("MIT"),v=p(""),d=p(""),k=p("edit"),g=p(!1),_=p(null),L=p(null),R=B(()=>d.value?Vt(d.value):""),K=p(new Map);ge(()=>i.modelValue,async q=>{q&&i.agent?await Promise.all([z(),P()]):Y()});const Y=()=>{s.value=null,x.value=null,c.value=null,K.value=new Map,f.value="",y.value="1.0.0",b.value="MIT",v.value="",d.value="",k.value="edit",g.value=!1,_.value=null,L.value=null},z=async()=>{if(i.agent){m.value=!0,x.value=null;try{const q=await fetch(fe(`/api/pack/${i.agent.id}/analyze`)),N=await q.json();if(!q.ok){x.value=N.error||"Failed to analyze agent";return}if(s.value=N,N.generatedReadme)d.value=N.generatedReadme;else{const J=G(i.agent?.id||"agent");d.value=ee(J,i.agent?.id||"agent",N.agentDescription)}de(N)}catch(q){x.value=q instanceof Error?q.message:"Failed to analyze agent"}finally{m.value=!1}}},P=async()=>{if(i.agent)try{const q=await fetch(fe(`/api/pack/${i.agent.id}/metadata`));if(q.ok){const N=await q.json();f.value=N.packageName,y.value=se(N.version),b.value=N.license||"MIT",v.value=N.licenseOwner||""}else f.value=G(i.agent.id),y.value="1.0.0",b.value="MIT",v.value=""}catch{f.value=G(i.agent?.id||"agent"),y.value="1.0.0",b.value="MIT",v.value=""}},G=q=>`standardagent-${q.toLowerCase().replace(/_/g,"-")}`,ee=(q,N,J)=>`# ${q}
6
6
 
7
7
  ${J||"A Standard Agent package."}
8
8