import{c as Y,a as u,f as k,t as Ee}from"./nUxvHMgL.js";import{o as zt}from"./DPMBEg2i.js";import{f as z,p as xt,c as t,s as _,u as He,g as e,d as r,r as l,e as i,ag as ct,n as _e,t as A,h as ee,a as ht}from"./CNYbWU2B.js";import{d as yt,s as C,e as Pt}from"./BWpKPX3N.js";import{l as wt,s as kt,p as ft,i as q}from"./CxfCsaSi.js";import{I as St,s as Ct,i as Lt,e as ot,r as Ot,m as Et,a as c,j as At,p as mt}from"./D9xfsXh9.js";import{b as pt,a as It,L as _t}from"./DcWGgsJS.js";import{C as Mt,I as we,S as Ye,B as U,a as Rt,b as Nt,d as Bt}from"./BQ-_QVTP.js";import{R as Ht,S as gt,P as Ut,b as jt,C as Qt}from"./1cqaUJGZ.js";import{g as Vt}from"./qoE10lYN.js";import{r as Gt}from"./CbhfpbUc.js";import{f as Yt}from"./CLON3Y_x.js";import{T as Jt,C as Kt}from"./BIZ-GM10.js";import{B as Je}from"./DrtKqSxJ.js";import"./CiMb2DjI.js";import{M as Wt}from"./Ciw8QBp0.js";import{C as Xt}from"./Nr6MLaIc.js";import{H as Zt}from"./CfIuuR-Z.js";function bt(ge,a){const be=wt(a,["children","$$slots","$$events","$$legacy"]);/**
 * @license lucide-svelte v0.469.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const te=[["path",{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"}]];St(ge,kt({name:"activity"},()=>be,{get iconNode(){return te},children:(p,L)=>{var x=Y(),S=z(x);Ct(S,a,"default",{}),u(p,x)},$$slots:{default:!0}}))}function $t(ge,a){const be=wt(a,["children","$$slots","$$events","$$legacy"]);/**
 * @license lucide-svelte v0.469.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const te=[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}],["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"}]];St(ge,kt({name:"square-pen"},()=>be,{get iconNode(){return te},children:(p,L)=>{var x=Y(),S=z(x);Ct(S,a,"default",{}),u(p,x)},$$slots:{default:!0}}))}var ea=k('<span class="text-amber-500">(long prompt may affect performance)</span>'),ta=k('<span class="text-xs text-muted-foreground ml-2"> <!></span>'),aa=k("<option>Language Model (lm)</option> <option>Multimodal (Vision)</option>",1),ra=k('<span class="text-xs text-muted-foreground">Detecting...</span>'),la=k('<span class="text-xs text-green-600 dark:text-green-400"> </span>'),ia=k("<option> </option>"),oa=k("<option> </option>"),sa=k("<option> </option>"),na=k('<div class="space-y-4 pt-4 border-t"><div class="grid grid-cols-1 md:grid-cols-2 gap-4"><div><label for="host" class="block text-sm font-medium mb-1">Host</label> <!></div> <div><label for="maxConcurrency" class="block text-sm font-medium mb-1">Max Concurrency</label> <!></div></div> <div class="grid grid-cols-1 md:grid-cols-2 gap-4"><div><label for="queueTimeout" class="block text-sm font-medium mb-1">Queue Timeout (seconds)</label> <!></div> <div><label for="queueSize" class="block text-sm font-medium mb-1">Queue Size</label> <!></div></div> <div class="pt-4 border-t"><div class="flex items-center gap-2 mb-3"><h3 class="text-sm font-medium">Model-Specific Parsers</h3> <!></div> <p class="text-xs text-muted-foreground mb-3">Required for MiniMax, Qwen3, and GLM models to enable tool calling and reasoning.</p> <div class="grid grid-cols-1 md:grid-cols-3 gap-4"><div><label for="toolCallParser" class="block text-sm font-medium mb-1">Tool Call Parser</label> <!></div> <div><label for="reasoningParser" class="block text-sm font-medium mb-1">Reasoning Parser</label> <!></div> <div><label for="messageConverter" class="block text-sm font-medium mb-1">Message Converter</label> <!></div></div></div> <div class="space-y-2"><label class="flex items-center gap-2"><input type="checkbox" class="rounded"/> <span class="text-sm">Start on Login (launchd)</span></label></div></div>'),da=k('<div class="mt-4 text-sm text-red-500 dark:text-red-400"> </div>'),ua=k(`<h2 class="text-xl font-semibold mb-6"> </h2> <div class="space-y-4"><div class="grid grid-cols-1 md:grid-cols-2 gap-4"><div><label for="name" class="block text-sm font-medium mb-1">Name *</label> <!></div> <div><label for="port" class="block text-sm font-medium mb-1">Port *</label> <!></div></div> <div><label for="description" class="block text-sm font-medium mb-1">Description</label> <textarea id="description" placeholder="Optional description" rows="2" class="flex w-full rounded-md border border-input bg-transparent px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50"></textarea></div> <div><label for="systemPrompt" class="block text-sm font-medium mb-1">System Prompt <!></label> <textarea id="systemPrompt" placeholder="e.g., You are a helpful coding assistant specializing in Python..." rows="4" class="flex w-full rounded-md border border-input bg-transparent px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50"></textarea> <p class="text-xs text-muted-foreground mt-1">Sets the model's behavior context. Appears as first message when chatting.</p></div> <div><label for="modelPath" class="block text-sm font-medium mb-1">Model Path *</label> <!></div> <div><label for="modelType" class="block text-sm font-medium mb-1">Model Type</label> <!></div> <div class="pt-4"><button type="button" class="text-sm text-primary hover:underline"> </button></div> <!></div> <!> <div class="mt-6 flex justify-end gap-3"><!> <!></div>`,1),va=k("<form><!></form>");function Na(ge,a){xt(a,!0);let be=ft(a,"nextPort",3,10240),te=ft(a,"initialModelPath",3,""),p=_(!1),L=_(null),x=_(!1),S=_(null),ae=_(""),xe=_(""),I=_(""),re=_(""),H=_("lm"),J=_(10240),K=_("127.0.0.1"),le=_(1),ie=_(300),ke=_(100),oe=_(!1),se=_(""),W=_(""),R=_(""),Se=_(!1),j=_(null),Ce=_(!0);const Ke=ee(()=>e(j)?[{value:"",label:"Default"},...e(j).tool_call_parsers.map(d=>({value:d,label:d}))]:[{value:"",label:"Loading..."}]),We=ee(()=>e(j)?[{value:"",label:"Default"},...e(j).reasoning_parsers.map(d=>({value:d,label:d}))]:[{value:"",label:"Loading..."}]),Xe=ee(()=>e(j)?[{value:"",label:"Default"},...e(j).message_converters.map(d=>({value:d,label:d}))]:[{value:"",label:"Loading..."}]);zt(async()=>{try{t(j,await Lt.parserOptions(),!0)}catch(d){console.error("Failed to load parser options:",d)}finally{t(Ce,!1)}}),He(()=>{var h,X,Q,ne,V,de,Z,De,he,Fe,ue,ve,ce,$;t(ae,((h=a.profile)==null?void 0:h.name)??"",!0),t(xe,((X=a.profile)==null?void 0:X.description)??"",!0),t(I,((Q=a.profile)==null?void 0:Q.system_prompt)??"",!0),t(re,((ne=a.profile)==null?void 0:ne.model_path)??te(),!0);const d=((V=a.profile)==null?void 0:V.model_type)??"lm";t(H,["lm","multimodal"].includes(d)?d:"lm",!0),t(J,((de=a.profile)==null?void 0:de.port)??be(),!0),t(K,((Z=a.profile)==null?void 0:Z.host)??"127.0.0.1",!0),t(le,((De=a.profile)==null?void 0:De.max_concurrency)??1,!0),t(ie,((he=a.profile)==null?void 0:he.queue_timeout)??300,!0),t(ke,((Fe=a.profile)==null?void 0:Fe.queue_size)??100,!0),t(oe,((ue=a.profile)==null?void 0:ue.auto_start)??!1,!0),t(se,((ve=a.profile)==null?void 0:ve.tool_call_parser)??"",!0),t(W,((ce=a.profile)==null?void 0:ce.reasoning_parser)??"",!0),t(R,(($=a.profile)==null?void 0:$.message_converter)??"",!0)});async function Ze(d){if(!d){t(S,null);return}t(x,!0);try{const h=await Et.detectOptions(d);t(S,h.model_family,!0),h.recommended_options&&(!e(se)&&h.recommended_options.tool_call_parser&&t(se,h.recommended_options.tool_call_parser,!0),!e(W)&&h.recommended_options.reasoning_parser&&t(W,h.recommended_options.reasoning_parser,!0),!e(R)&&h.recommended_options.message_converter&&t(R,h.recommended_options.message_converter,!0))}catch{t(S,null)}finally{t(x,!1)}}let Me=null;He(()=>{e(re)&&!a.profile&&(Me&&clearTimeout(Me),Me=setTimeout(()=>Ze(e(re)),500))});async function Ue(d){d.preventDefault(),t(p,!0),t(L,null);try{const h={name:e(ae),description:e(xe)||void 0,model_path:e(re),model_type:e(H),port:e(J),host:e(K),max_concurrency:e(le),queue_timeout:e(ie),queue_size:e(ke),auto_start:e(oe),tool_call_parser:e(se)||void 0,reasoning_parser:e(W)||void 0,message_converter:e(R)||void 0,system_prompt:e(I)||void 0};await a.onSubmit(h)}catch(h){t(L,h instanceof Error?h.message:"Failed to save profile",!0)}finally{t(p,!1)}}var Te=va(),f=r(Te);Mt(f,{class:"p-6",children:(d,h)=>{var X=ua(),Q=z(X),ne=r(Q,!0);l(Q);var V=i(Q,2),de=r(V),Z=r(de),De=i(r(Z),2);we(De,{id:"name",placeholder:"e.g., Coding Assistant",required:!0,get value(){return e(ae)},set value(o){t(ae,o,!0)}}),l(Z);var he=i(Z,2),Fe=i(r(he),2);we(Fe,{id:"port",type:"number",required:!0,get value(){return e(J)},set value(o){t(J,o,!0)}}),l(he),l(de);var ue=i(de,2),ve=i(r(ue),2);ct(ve),l(ue);var ce=i(ue,2),$=r(ce),je=i(r($));{var $e=o=>{var g=ta(),s=r(g),m=i(s);{var w=P=>{var M=ea();u(P,M)};q(m,P=>{e(I).length>2e3&&P(w)})}l(g),A(()=>C(s,`${e(I).length??""} chars `)),u(o,g)};q(je,o=>{e(I).length>0&&o($e)})}l($);var Ae=i($,2);ct(Ae),_e(2),l(ce);var qe=i(ce,2),et=i(r(qe),2);we(et,{id:"modelPath",placeholder:"e.g., mlx-community/Qwen2.5-Coder-32B-Instruct-4bit",required:!0,get value(){return e(re)},set value(o){t(re,o,!0)}}),l(qe);var Ie=i(qe,2),Qe=i(r(Ie),2);Ye(Qe,{id:"modelType",get value(){return e(H)},set value(o){t(H,o,!0)},children:(o,g)=>{var s=aa(),m=z(s);m.value=m.__value="lm";var w=i(m,2);w.value=w.__value="multimodal",u(o,s)},$$slots:{default:!0}}),l(Ie);var ze=i(Ie,2),Re=r(ze);Re.__click=()=>t(Se,!e(Se));var Ve=r(Re);l(Re),l(ze);var tt=i(ze,2);{var at=o=>{var g=na(),s=r(g),m=r(s),w=i(r(m),2);we(w,{id:"host",get value(){return e(K)},set value(b){t(K,b,!0)}}),l(m);var P=i(m,2),M=i(r(P),2);we(M,{id:"maxConcurrency",type:"number",get value(){return e(le)},set value(b){t(le,b,!0)}}),l(P),l(s);var T=i(s,2),N=r(T),F=i(r(N),2);we(F,{id:"queueTimeout",type:"number",get value(){return e(ie)},set value(b){t(ie,b,!0)}}),l(N);var Le=i(N,2),Oe=i(r(Le),2);we(Oe,{id:"queueSize",type:"number",get value(){return e(ke)},set value(b){t(ke,b,!0)}}),l(Le),l(T);var fe=i(T,2),me=r(fe),Ne=i(r(me),2);{var B=b=>{var ye=ra();u(b,ye)},Tt=b=>{var ye=Y(),G=z(ye);{var Pe=O=>{var E=la(),D=r(E);l(E),A(()=>C(D,`Detected: ${e(S)??""}`)),u(O,E)};q(G,O=>{e(S)&&O(Pe)},!0)}u(b,ye)};q(Ne,b=>{e(x)?b(B):b(Tt,!1)})}l(me);var st=i(me,4),lt=r(st),Dt=i(r(lt),2);Ye(Dt,{id:"toolCallParser",get disabled(){return e(Ce)},get value(){return e(se)},set value(b){t(se,b,!0)},children:(b,ye)=>{var G=Y(),Pe=z(G);ot(Pe,17,()=>e(Ke),O=>O.value,(O,E)=>{var D=ia(),Be=r(D,!0);l(D);var pe={};A(()=>{C(Be,e(E).label),pe!==(pe=e(E).value)&&(D.value=(D.__value=e(E).value)??"")}),u(O,D)}),u(b,G)},$$slots:{default:!0}}),l(lt);var it=i(lt,2),Ft=i(r(it),2);Ye(Ft,{id:"reasoningParser",get disabled(){return e(Ce)},get value(){return e(W)},set value(b){t(W,b,!0)},children:(b,ye)=>{var G=Y(),Pe=z(G);ot(Pe,17,()=>e(We),O=>O.value,(O,E)=>{var D=oa(),Be=r(D,!0);l(D);var pe={};A(()=>{C(Be,e(E).label),pe!==(pe=e(E).value)&&(D.value=(D.__value=e(E).value)??"")}),u(O,D)}),u(b,G)},$$slots:{default:!0}}),l(it);var nt=i(it,2),qt=i(r(nt),2);Ye(qt,{id:"messageConverter",get disabled(){return e(Ce)},get value(){return e(R)},set value(b){t(R,b,!0)},children:(b,ye)=>{var G=Y(),Pe=z(G);ot(Pe,17,()=>e(Xe),O=>O.value,(O,E)=>{var D=sa(),Be=r(D,!0);l(D);var pe={};A(()=>{C(Be,e(E).label),pe!==(pe=e(E).value)&&(D.value=(D.__value=e(E).value)??"")}),u(O,D)}),u(b,G)},$$slots:{default:!0}}),l(nt),l(st),l(fe);var dt=i(fe,2),ut=r(dt),vt=r(ut);Ot(vt),_e(2),l(ut),l(dt),l(g),It(vt,()=>e(oe),b=>t(oe,b)),u(o,g)};q(tt,o=>{e(Se)&&o(at)})}l(V);var Ge=i(V,2);{var rt=o=>{var g=da(),s=r(g,!0);l(g),A(()=>C(s,e(L))),u(o,g)};q(Ge,o=>{e(L)&&o(rt)})}var n=i(Ge,2),v=r(n);U(v,{variant:"outline",get onclick(){return a.onCancel},get disabled(){return e(p)},children:(o,g)=>{_e();var s=Ee("Cancel");u(o,s)},$$slots:{default:!0}});var y=i(v,2);U(y,{type:"submit",get disabled(){return e(p)},children:(o,g)=>{_e();var s=Ee();A(()=>C(s,e(p)?"Saving...":a.profile?"Update Profile":"Create Profile")),u(o,s)},$$slots:{default:!0}}),l(n),A(()=>{C(ne,a.profile?"Edit Profile":"Create Profile"),C(Ve,`${e(Se)?"Hide":"Show"} Advanced Options`)}),pt(ve,()=>e(xe),o=>t(xe,o)),pt(Ae,()=>e(I),o=>t(I,o)),u(d,X)},$$slots:{default:!0}}),l(Te),Pt("submit",Te,Ue),u(ge,Te),ht()}yt(["click"]);var ca=k('<p class="text-sm text-muted-foreground mt-1"> </p>'),fa=k("<!> <!> <!>",1),ma=k("<!> <!>",1),pa=k('<div class="mt-4 grid grid-cols-2 md:grid-cols-4 gap-4 text-sm"><div class="flex items-center gap-2"><!> <span class="text-muted-foreground">Port:</span> <span class="font-mono"> </span></div> <div class="flex items-center gap-2"><!> <span class="text-muted-foreground">PID:</span> <span class="font-mono"> </span></div> <div class="flex items-center gap-2"><!> <span class="text-muted-foreground">Memory:</span> <span> </span></div> <div class="flex items-center gap-2"><span class="text-muted-foreground">Uptime:</span> <span> </span></div></div>'),_a=k('<div class="mt-3 flex items-center gap-4 text-sm text-muted-foreground"><div class="flex items-center gap-2"><!> <span>Port:</span> <span class="font-mono"> </span></div> <div class="flex items-center gap-2"><span>Type:</span> <span> </span></div></div>'),ga=k('<details class="mt-2"><summary class="text-xs text-red-500 dark:text-red-400 cursor-pointer hover:underline">Show server log</summary> <div class="mt-2 relative"><button class="absolute top-2 right-2 p-1.5 rounded bg-red-200 dark:bg-red-800 hover:bg-red-300 dark:hover:bg-red-700 transition-colors" title="Copy to clipboard"><!></button> <pre class="text-xs text-red-600 dark:text-red-300 bg-red-100 dark:bg-red-900/50 p-2 pr-10 rounded overflow-x-auto max-h-48 whitespace-pre-wrap font-mono"> </pre></div></details>'),ba=k('<div class="mt-3 p-3 bg-red-50 dark:bg-red-950/50 rounded-lg border border-red-200 dark:border-red-900"><div class="flex items-start gap-2"><!> <div class="flex-1 min-w-0"><p class="text-sm text-red-600 dark:text-red-400 font-medium"> </p> <!></div></div></div>'),xa=k('<div class="flex items-start justify-between gap-4"><div class="flex-1 min-w-0"><div class="flex items-center gap-2 flex-wrap"><h3 class="font-semibold text-lg"> </h3> <!> <!></div> <!> <div class="mt-2 text-sm text-muted-foreground truncate"><span class="font-mono"> </span></div></div> <div class="flex shrink-0 gap-1"><!> <!> <!> <!></div></div> <!> <!>',1),ha=k("<!> <!>",1);function Ba(ge,a){xt(a,!0);const be=12e4,te=2e3;let p=_(!1),L=_(null),x=_(null),S=_(!1),ae=_(!1);const xe=ee(()=>c.isStarting(a.profile.id)),I=ee(()=>c.isRunning(a.profile.id)),re=ee(()=>c.isFailed(a.profile.id)),H=ee(()=>c.getFailure(a.profile.id)),J=ee(()=>a.server||c.getServer(a.profile.id));let K=_(!1),le=!1,ie=_(null);He(()=>{const f=c.getFailure(a.profile.id);f&&e(ie)!==a.profile.id?(t(ie,a.profile.id,!0),le=!0,t(K,f.detailsOpen,!0),requestAnimationFrame(()=>{le=!1})):f||(t(ie,null),t(K,!1))});function ke(){le||c.toggleDetailsOpen(a.profile.id)}let oe=_(!1);async function se(){var f;if((f=e(H))!=null&&f.details)try{await navigator.clipboard.writeText(e(H).details),t(oe,!0),setTimeout(()=>{t(oe,!1)},2e3)}catch(d){console.error("Failed to copy to clipboard:",d)}}let W=_(!1);He(()=>{e(W)||(t(W,!0),c.isStarting(a.profile.id)&&!c.isProfilePolling(a.profile.id)&&c.startProfilePolling(a.profile.id)&&(t(S,!0),t(L,Date.now(),!0),R()))}),He(()=>()=>{e(x)&&(clearTimeout(e(x)),t(x,null))});async function R(){if(!e(S)){c.stopProfilePolling(a.profile.id);return}if(e(L)&&Date.now()-e(L)>be){c.markStartupFailed(a.profile.id,"Model loading timed out after 2 minutes. Check server logs for details."),t(S,!1),t(x,null),c.stopProfilePolling(a.profile.id);return}try{const f=await At.status(a.profile.id);if(!f.running){f.failed?c.markStartupFailed(a.profile.id,"Server crashed while loading model",f.error_message||"Server process exited unexpectedly"):c.markStartupSuccess(a.profile.id),t(S,!1),t(x,null),c.stopProfilePolling(a.profile.id);return}try{const d=await fetch(`http://${a.profile.host}:${a.profile.port}/v1/models`);if(d.ok){const h=await d.json();if(h.data&&h.data.length>0){c.markStartupSuccess(a.profile.id),t(S,!1),t(x,null),c.stopProfilePolling(a.profile.id);return}}}catch{}t(x,setTimeout(R,te),!0)}catch{t(x,setTimeout(R,te),!0)}}async function Se(){if(t(p,!0),c.clearFailure(a.profile.id),t(L,Date.now(),!0),e(x)&&(clearTimeout(e(x)),t(x,null)),!c.startProfilePolling(a.profile.id)){t(p,!1);return}t(S,!0);try{await c.start(a.profile.id),R()}catch(f){const d=f instanceof Error?f.message:"Failed to start server";c.markStartupFailed(a.profile.id,d),t(L,null),t(S,!1),c.stopProfilePolling(a.profile.id)}finally{t(p,!1)}}async function j(){t(p,!0),t(L,null),t(S,!1),e(x)&&(clearTimeout(e(x)),t(x,null)),c.stopProfilePolling(a.profile.id);try{await c.stop(a.profile.id)}catch(f){const d=f instanceof Error?f.message:"Failed to stop server";c.markStartupFailed(a.profile.id,d)}finally{t(p,!1)}}async function Ce(){if(t(p,!0),c.clearFailure(a.profile.id),t(L,Date.now(),!0),e(x)&&(clearTimeout(e(x)),t(x,null)),c.stopProfilePolling(a.profile.id),!c.startProfilePolling(a.profile.id)){t(p,!1);return}t(S,!0);try{await c.restart(a.profile.id),R()}catch(f){const d=f instanceof Error?f.message:"Failed to restart server";c.markStartupFailed(a.profile.id,d),t(L,null),t(S,!1),c.stopProfilePolling(a.profile.id)}finally{t(p,!1)}}function Ke(){t(ae,!0)}async function We(){t(p,!0),c.clearFailure(a.profile.id);try{e(I)&&await c.stop(a.profile.id),await mt.delete(a.profile.id)}catch(f){const d=f instanceof Error?f.message:"Failed to delete profile";c.markStartupFailed(a.profile.id,d)}finally{t(p,!1)}}async function Xe(){const f=prompt("Enter name for the duplicate profile:",`${a.profile.name} (copy)`);if(f){t(p,!0);try{await mt.duplicate(a.profile.id,f)}catch(d){const h=d instanceof Error?d.message:"Failed to duplicate profile";alert(h)}finally{t(p,!1)}}}async function Ze(){const f=`${Gt("/chat")}?profile=${a.profile.id}`;await Vt(f)}var Me=ha(),Ue=z(Me);Mt(Ue,{class:"p-4",children:(f,d)=>{var h=xa(),X=z(h),Q=r(X),ne=r(Q),V=r(ne),de=r(V,!0);l(V);var Z=i(V,2);{var De=n=>{Je(n,{variant:"destructive",children:(v,y)=>{_e();var o=Ee("Error");u(v,o)},$$slots:{default:!0}})},he=n=>{var v=Y(),y=z(v);{var o=s=>{Je(s,{variant:"success",children:(m,w)=>{_e();var P=Ee("Running");u(m,P)},$$slots:{default:!0}})},g=s=>{var m=Y(),w=z(m);{var P=M=>{Je(M,{variant:"warning",children:(T,N)=>{_e();var F=Ee("Loading...");u(T,F)},$$slots:{default:!0}})};q(w,M=>{e(xe)&&M(P)},!0)}u(s,m)};q(y,s=>{e(I)?s(o):s(g,!1)},!0)}u(n,v)};q(Z,n=>{e(re)?n(De):n(he,!1)})}var Fe=i(Z,2);{var ue=n=>{Je(n,{variant:"outline",children:(v,y)=>{_e();var o=Ee("launchd");u(v,o)},$$slots:{default:!0}})};q(Fe,n=>{a.profile.launchd_installed&&n(ue)})}l(ne);var ve=i(ne,2);{var ce=n=>{var v=ca(),y=r(v,!0);l(v),A(()=>C(y,a.profile.description)),u(n,v)};q(ve,n=>{a.profile.description&&n(ce)})}var $=i(ve,2),je=r($),$e=r(je,!0);l(je),l($),l(Q);var Ae=i(Q,2),qe=r(Ae);{var et=n=>{var v=fa(),y=z(v);U(y,{variant:"outline",size:"sm",onclick:Ze,get disabled(){return e(p)},title:"Chat",children:(s,m)=>{Wt(s,{class:"h-4 w-4"})},$$slots:{default:!0}});var o=i(y,2);U(o,{variant:"outline",size:"sm",onclick:Ce,get disabled(){return e(p)},title:"Restart",children:(s,m)=>{Ht(s,{class:"h-4 w-4"})},$$slots:{default:!0}});var g=i(o,2);U(g,{variant:"destructive",size:"sm",onclick:j,get disabled(){return e(p)},title:"Stop",children:(s,m)=>{gt(s,{class:"h-4 w-4"})},$$slots:{default:!0}}),u(n,v)},Ie=n=>{var v=Y(),y=z(v);{var o=s=>{var m=ma(),w=z(m);U(w,{variant:"outline",size:"sm",disabled:!0,title:"Starting...",children:(M,T)=>{_t(M,{class:"h-4 w-4 animate-spin"})},$$slots:{default:!0}});var P=i(w,2);U(P,{variant:"destructive",size:"sm",onclick:j,get disabled(){return e(p)},title:"Cancel",children:(M,T)=>{gt(M,{class:"h-4 w-4"})},$$slots:{default:!0}}),u(s,m)},g=s=>{U(s,{variant:"default",size:"sm",onclick:Se,get disabled(){return e(p)},title:"Start",children:(m,w)=>{var P=Y(),M=z(P);{var T=F=>{_t(F,{class:"h-4 w-4 animate-spin"})},N=F=>{Ut(F,{class:"h-4 w-4"})};q(M,F=>{e(p)?F(T):F(N,!1)})}u(m,P)},$$slots:{default:!0}})};q(y,s=>{e(xe)?s(o):s(g,!1)},!0)}u(n,v)};q(qe,n=>{e(I)?n(et):n(Ie,!1)})}var Qe=i(qe,2);{let n=ee(()=>`/profiles/${a.profile.id}`);U(Qe,{variant:"outline",size:"sm",get href(){return e(n)},title:"Edit",children:(v,y)=>{$t(v,{class:"h-4 w-4"})},$$slots:{default:!0}})}var ze=i(Qe,2);U(ze,{variant:"outline",size:"sm",onclick:Xe,get disabled(){return e(p)},title:"Duplicate",children:(n,v)=>{Rt(n,{class:"h-4 w-4"})},$$slots:{default:!0}});var Re=i(ze,2);U(Re,{variant:"outline",size:"sm",onclick:Ke,get disabled(){return e(p)},title:"Delete",children:(n,v)=>{Jt(n,{class:"h-4 w-4"})},$$slots:{default:!0}}),l(Ae),l(X);var Ve=i(X,2);{var tt=n=>{var v=pa(),y=r(v),o=r(y);bt(o,{class:"w-4 h-4 text-muted-foreground"});var g=i(o,4),s=r(g,!0);l(g),l(y);var m=i(y,2),w=r(m);Xt(w,{class:"w-4 h-4 text-muted-foreground"});var P=i(w,4),M=r(P,!0);l(P),l(m);var T=i(m,2),N=r(T);Zt(N,{class:"w-4 h-4 text-muted-foreground"});var F=i(N,4),Le=r(F);l(F),l(T);var Oe=i(T,2),fe=i(r(Oe),2),me=r(fe,!0);l(fe),l(Oe),l(v),A((Ne,B)=>{C(s,a.profile.port),C(M,e(J).pid),C(Le,`${Ne??""} MB`),C(me,B)},[()=>e(J).memory_mb.toFixed(1),()=>Yt(e(J).uptime_seconds)]),u(n,v)},at=n=>{var v=_a(),y=r(v),o=r(y);bt(o,{class:"w-4 h-4"});var g=i(o,4),s=r(g,!0);l(g),l(y);var m=i(y,2),w=i(r(m),2),P=r(w,!0);l(w),l(m),l(v),A(()=>{C(s,a.profile.port),C(P,a.profile.model_type)}),u(n,v)};q(Ve,n=>{e(J)&&e(I)?n(tt):n(at,!1)})}var Ge=i(Ve,2);{var rt=n=>{var v=ba(),y=r(v),o=r(y);Nt(o,{class:"w-4 h-4 text-red-500 dark:text-red-400 mt-0.5 flex-shrink-0"});var g=i(o,2),s=r(g),m=r(s,!0);l(s);var w=i(s,2);{var P=M=>{var T=ga(),N=i(r(T),2),F=r(N);F.__click=se;var Le=r(F);{var Oe=B=>{Bt(B,{class:"w-3.5 h-3.5 text-green-600 dark:text-green-400"})},fe=B=>{Qt(B,{class:"w-3.5 h-3.5 text-red-600 dark:text-red-300"})};q(Le,B=>{e(oe)?B(Oe):B(fe,!1)})}l(F);var me=i(F,2),Ne=r(me,!0);l(me),l(N),l(T),A(()=>C(Ne,e(H).details)),Pt("toggle",T,ke),jt("open","toggle",T,B=>t(K,B),()=>e(K)),u(M,T)};q(w,M=>{e(H).details&&M(P)})}l(g),l(y),l(v),A(()=>C(m,e(H).error)),u(n,v)};q(Ge,n=>{e(H)&&n(rt)})}A(()=>{C(de,a.profile.name),C($e,a.profile.model_path)}),u(f,h)},$$slots:{default:!0}});var Te=i(Ue,2);Kt(Te,{title:"Delete Profile",get description(){return`Are you sure you want to delete '${a.profile.name??""}'? This action cannot be undone.`},confirmLabel:"Delete",cancelLabel:"Cancel",variant:"destructive",onConfirm:We,onCancel:()=>{},get open(){return e(ae)},set open(f){t(ae,f,!0)}}),u(ge,Me),ht()}yt(["click"]);export{Ba as P,Na as a};
