groove-dev 0.26.6 → 0.26.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/node_modules/@groove-dev/daemon/src/api.js +3 -3
- package/node_modules/@groove-dev/gui/dist/assets/{index-BdRue2C0.js → index-PPbrScja.js} +1 -1
- package/node_modules/@groove-dev/gui/dist/index.html +1 -1
- package/node_modules/@groove-dev/gui/src/views/models.jsx +2 -2
- package/package.json +1 -1
- package/packages/daemon/src/api.js +3 -3
- package/packages/gui/dist/assets/{index-BdRue2C0.js → index-PPbrScja.js} +1 -1
- package/packages/gui/dist/index.html +1 -1
- package/packages/gui/src/views/models.jsx +2 -2
|
@@ -301,10 +301,10 @@ export function createApi(app, daemon) {
|
|
|
301
301
|
app.get('/api/models/recommended', (req, res) => {
|
|
302
302
|
const hardware = OllamaProvider.getSystemHardware();
|
|
303
303
|
const catalog = OllamaProvider.catalog;
|
|
304
|
-
// Filter to models that fit in RAM
|
|
305
|
-
|
|
304
|
+
// Filter to models that fit in RAM — same threshold as hardware recommendation
|
|
305
|
+
// Apple Silicon unified memory handles these well, no aggressive headroom needed
|
|
306
306
|
const recommended = catalog
|
|
307
|
-
.filter((m) => m.ramGb <=
|
|
307
|
+
.filter((m) => m.ramGb <= hardware.totalRamGb)
|
|
308
308
|
.sort((a, b) => b.ramGb - a.ramGb) // Biggest that fits = best quality
|
|
309
309
|
.slice(0, 12);
|
|
310
310
|
res.json({ models: recommended, hardware });
|
|
@@ -624,7 +624,7 @@ Error generating stack: `+c.message+`
|
|
|
624
624
|
|
|
625
625
|
If you want to hide the \`${n.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
626
626
|
|
|
627
|
-
For more information, see https://radix-ui.com/primitives/docs/components/${n.docsSlug}`;return y.useEffect(()=>{t&&(document.getElementById(t)||console.error(s))},[s,t]),null},U_="DialogDescriptionWarning",G_=({contentRef:t,descriptionId:n})=>{const l=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${XS(U_).contentName}}.`;return y.useEffect(()=>{var u;const o=(u=t.current)==null?void 0:u.getAttribute("aria-describedby");n&&o&&(document.getElementById(n)||console.warn(l))},[l,t,n]),null},_S=yS,ZS=jS,AS=wS,ES=kS,qS=TS,MS=PS,YS=RS;function VS({children:t,...n}){return i.jsx(_S,{...n,children:t})}function US({children:t,className:n,title:s,description:l,...o}){return i.jsxs(ZS,{children:[i.jsx(AS,{className:"fixed inset-0 z-50 bg-black/50 backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0"}),i.jsxs(ES,{className:se("fixed left-1/2 top-1/2 z-50 -translate-x-1/2 -translate-y-1/2","w-full max-w-lg max-h-[85vh] overflow-y-auto","bg-surface-1 border border-border rounded-lg shadow-2xl","data-[state=open]:animate-in data-[state=closed]:animate-out","data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0","data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95",n),...o,children:[s&&i.jsxs("div",{className:"flex items-center justify-between px-5 py-4 border-b border-border-subtle",children:[i.jsx(qS,{className:"text-base font-semibold text-text-0 font-sans",children:s}),i.jsx(YS,{className:"p-1 rounded-md text-text-3 hover:text-text-0 hover:bg-surface-5 transition-colors",children:i.jsx(jt,{size:16})})]}),l&&i.jsx(MS,{className:"sr-only",children:l}),t]})]})}var b0={};function L_({path:t,onNavigate:n}){const s=t.split("/").filter(Boolean);return i.jsxs("div",{className:"flex items-center gap-0.5 min-w-0 overflow-x-auto py-1.5 scrollbar-none",children:[i.jsx("button",{onClick:()=>n("/"),className:"flex-shrink-0 p-1 rounded hover:bg-surface-5 cursor-pointer text-text-3 hover:text-text-0 transition-colors",children:i.jsx(Ff,{size:13})}),s.map((l,o)=>{const u="/"+s.slice(0,o+1).join("/"),d=o===s.length-1;return i.jsxs("div",{className:"flex items-center gap-0.5 flex-shrink-0",children:[i.jsx(Gl,{size:11,className:"text-text-4"}),i.jsx("button",{onClick:()=>n(u),className:se("px-1.5 py-0.5 rounded text-xs font-mono cursor-pointer transition-colors",d?"text-text-0 bg-surface-4 font-medium":"text-text-3 hover:text-text-0 hover:bg-surface-5"),children:l})]},o)})]})}function GS({open:t,onOpenChange:n,currentPath:s,onSelect:l}){const[o,u]=y.useState(s||b0.HOME||"/"),[d,O]=y.useState([]),[m,p]=y.useState(!1),[g,x]=y.useState(null);y.useEffect(()=>{t&&b(s||"/")},[t]);async function b(T){p(!0),x(null);try{const k=await ee.get(`/browse-system?path=${encodeURIComponent(T)}`);u(k.current||T),O(k.dirs||[])}catch(k){x(k.message),O([])}p(!1)}function v(){const T=o==="/"?"/":o.split("/").slice(0,-1).join("/")||"/";b(T)}function Q(){b(b0.HOME||"/Users")}function w(){l(o),n(!1)}return i.jsx(VS,{open:t,onOpenChange:n,children:i.jsx(US,{title:"Select Working Directory",description:"Choose a directory for this agent to work in",className:"max-w-[520px]",children:i.jsxs("div",{className:"px-5 py-4 space-y-3",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("button",{onClick:v,disabled:o==="/",className:"p-1.5 rounded-md bg-surface-4 border border-border text-text-2 hover:text-text-0 hover:bg-surface-5 transition-colors cursor-pointer disabled:opacity-30 disabled:cursor-not-allowed",children:i.jsx(y5,{size:14})}),i.jsx("button",{onClick:Q,className:"p-1.5 rounded-md bg-surface-4 border border-border text-text-2 hover:text-text-0 hover:bg-surface-5 transition-colors cursor-pointer",children:i.jsx(vT,{size:14})}),i.jsx("div",{className:"flex-1 min-w-0 bg-surface-0 rounded-md border border-border-subtle px-2",children:i.jsx(L_,{path:o,onNavigate:b})})]}),i.jsx("div",{className:"bg-surface-0 rounded-lg border border-border-subtle overflow-hidden",children:i.jsxs("div",{className:"max-h-[340px] overflow-y-auto",children:[m&&i.jsx("div",{className:"flex items-center justify-center py-8",children:i.jsx(Kn,{size:18,className:"text-text-3 animate-spin"})}),g&&i.jsx("div",{className:"px-4 py-6 text-center",children:i.jsx("p",{className:"text-xs text-danger font-sans",children:g})}),!m&&!g&&d.length===0&&i.jsx("div",{className:"px-4 py-6 text-center",children:i.jsx("p",{className:"text-xs text-text-3 font-sans",children:"No subdirectories"})}),!m&&!g&&d.map(T=>i.jsxs("button",{onClick:()=>b(T.path),className:se("w-full flex items-center gap-2.5 px-3.5 py-2 text-left cursor-pointer","hover:bg-surface-4 transition-colors border-b border-border-subtle last:border-0"),children:[T.hasChildren?i.jsx(oT,{size:15,className:"text-warning flex-shrink-0"}):i.jsx(ai,{size:15,className:"text-text-3 flex-shrink-0"}),i.jsx("span",{className:"text-sm text-text-0 font-sans truncate flex-1",children:T.name}),T.hasChildren&&i.jsx(Gl,{size:12,className:"text-text-4 flex-shrink-0"})]},T.path))]})}),i.jsxs("div",{className:"flex items-center gap-3 bg-surface-4/50 rounded-lg px-3.5 py-2.5 border border-border-subtle",children:[i.jsx(ai,{size:16,className:"text-accent flex-shrink-0"}),i.jsx("span",{className:"text-xs font-mono text-text-1 truncate flex-1",children:o})]}),i.jsxs("div",{className:"flex justify-end gap-2",children:[i.jsx(be,{variant:"ghost",size:"md",onClick:()=>n(!1),children:"Cancel"}),i.jsxs(be,{variant:"primary",size:"md",onClick:w,className:"gap-1.5",children:[i.jsx(ia,{size:14})," Select Folder"]})]})]})})})}function LS({children:t,...n}){return i.jsx(_S,{...n,children:t})}function DS({children:t,className:n,title:s,side:l="right",width:o=400,...u}){return i.jsxs(ZS,{children:[i.jsx(AS,{className:"fixed inset-0 z-40 bg-black/30"}),i.jsxs(ES,{className:se("fixed top-0 z-50 h-full overflow-y-auto","bg-surface-1 border-l border-border shadow-2xl","data-[state=open]:animate-in data-[state=closed]:animate-out",l==="right"&&"right-0 data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right",l==="left"&&"left-0 data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left",n),style:{width:o},...u,children:[s&&i.jsxs("div",{className:"flex items-center justify-between px-5 py-4 border-b border-border-subtle sticky top-0 bg-surface-1 z-10",children:[i.jsx(qS,{className:"text-base font-semibold text-text-0 font-sans",children:s}),i.jsx(YS,{className:"p-1 rounded-md text-text-3 hover:text-text-0 hover:bg-surface-5 transition-colors cursor-pointer",children:i.jsx(jt,{size:16})})]}),i.jsx(MS,{className:"sr-only",children:"Panel"}),t]})]})}function D_({value:t,onChange:n}){return i.jsx("button",{onClick:()=>n(!t),className:se("w-9 h-5 rounded-full p-0.5 transition-colors cursor-pointer",t?"bg-accent":"bg-surface-5"),children:i.jsx("div",{className:se("w-4 h-4 rounded-full bg-white shadow-sm transition-transform",t?"translate-x-4":"translate-x-0")})})}function W_({user:t}){const[n,s]=y.useState(!1),l=(t==null?void 0:t.avatar)||(t==null?void 0:t.picture)||(t==null?void 0:t.photoURL)||(t==null?void 0:t.photo);return l&&!n?i.jsx("img",{src:l,alt:"",className:"w-6 h-6 rounded-full",referrerPolicy:"no-referrer",crossOrigin:"anonymous",onError:()=>s(!0)}):i.jsx("div",{className:"w-6 h-6 rounded-full bg-accent/10 flex items-center justify-center",children:i.jsx(Hb,{size:12,className:"text-accent"})})}function B_({provider:t,onKeyChange:n}){var T,k,z;const[s,l]=y.useState(!1),[o,u]=y.useState(""),[d,O]=y.useState(!1),[m,p]=y.useState(!1),g=D($=>$.addToast),x=t.authType==="local",b=t.authType==="subscription",v=x||b?t.installed:t.hasKey;async function Q(){if(o.trim())try{await ee.post(`/credentials/${t.id}`,{key:o.trim()}),g("success",`API key set for ${t.name}`),u(""),l(!1),n&&n()}catch($){g("error","Failed to set key",$.message)}}async function w(){try{await ee.delete(`/credentials/${t.id}`),g("info",`Removed ${t.name} key`),n&&n()}catch($){g("error","Remove failed",$.message)}}if(x){const $=((k=(T=t.models)==null?void 0:T.filter(G=>!G.disabled))==null?void 0:k.length)||0,C=()=>D.getState().setActiveView("models");return i.jsxs("div",{className:"flex flex-col rounded-lg border border-border-subtle bg-surface-1 overflow-hidden min-w-[220px]",children:[i.jsxs("div",{className:"flex items-center gap-2.5 px-4 py-3 border-b border-border-subtle",children:[i.jsx($s,{status:v&&$>0?"running":"crashed",size:"sm"}),i.jsx("span",{className:"text-[13px] font-semibold text-text-0 font-sans",children:t.name}),i.jsx("div",{className:"flex-1"}),v&&$>0?i.jsxs(Ze,{variant:"success",className:"text-2xs gap-1",children:[i.jsx(ia,{size:8})," ",$," models"]}):v?i.jsx(Ze,{variant:"warning",className:"text-2xs",children:"No models pulled"}):i.jsx(Ze,{variant:"default",className:"text-2xs",children:"Not set up"})]}),i.jsx("div",{className:"flex-1",children:m?i.jsxs(i.Fragment,{children:[i.jsx(oS,{isInstalled:v,onModelChange:n}),i.jsxs("div",{className:"px-4 py-2 border-t border-border-subtle flex gap-2",children:[i.jsx(be,{variant:"ghost",size:"sm",onClick:()=>p(!1),className:"flex-1 h-7 text-2xs",children:"Back"}),i.jsx(be,{variant:"secondary",size:"sm",onClick:()=>{p(!1),C()},className:"flex-1 h-7 text-2xs gap-1",children:"Models Tab"})]})]}):i.jsxs("div",{className:"px-4 py-3 flex flex-col h-full",children:[i.jsx("div",{className:"text-xs text-text-3 font-sans flex-1",children:v&&$>0?"Full agentic runtime — tool calling, context rotation, zero cloud cost":v?"Ollama is running. Pull a model to start using local agents.":"Run any open-source model locally — free, private, fully offline. Requires Ollama."}),i.jsxs("div",{className:"flex gap-2 mt-3",children:[v?i.jsxs(be,{variant:"primary",size:"sm",onClick:()=>p(!0),className:"flex-1 h-7 text-2xs gap-1.5",children:[i.jsx(Zl,{size:11})," ",$>0?"Manage":"Pull Models"]}):i.jsxs(be,{variant:"primary",size:"sm",onClick:()=>p(!0),className:"flex-1 h-7 text-2xs gap-1.5",children:[i.jsx(Zl,{size:11})," Set Up Ollama"]}),i.jsx(be,{variant:"secondary",size:"sm",onClick:C,className:"flex-1 h-7 text-2xs gap-1.5",children:"Models Tab"})]})]})})]})}return i.jsxs("div",{className:"flex flex-col rounded-lg border border-border-subtle bg-surface-1 overflow-hidden min-w-[220px]",children:[i.jsxs("div",{className:"flex items-center gap-2.5 px-4 py-3 border-b border-border-subtle",children:[i.jsx($s,{status:v?"running":"crashed",size:"sm"}),i.jsx("span",{className:"text-[13px] font-semibold text-text-0 font-sans",children:t.name}),i.jsx("div",{className:"flex-1"}),v?i.jsxs(Ze,{variant:"success",className:"text-2xs gap-1",children:[i.jsx(ia,{size:8})," Ready"]}):i.jsx(Ze,{variant:"default",className:"text-2xs",children:b?"Not installed":"No key"})]}),i.jsxs("div",{className:"flex-1 flex flex-col px-4 py-3 min-h-[120px]",children:[((z=t.models)==null?void 0:z.length)>0&&i.jsx("div",{className:"flex flex-wrap gap-1 mb-3",children:t.models.map($=>i.jsx("span",{className:"px-1.5 py-0.5 rounded bg-surface-4 text-2xs font-mono text-text-3",children:$.name||$.id},$.id))}),b&&v&&!t.hasKey&&!s&&i.jsxs("div",{className:"flex items-center gap-1.5 h-8 px-2.5 bg-accent/8 border border-accent/20 rounded-md text-2xs font-sans text-accent mb-3",children:[i.jsx(ia,{size:10})," Subscription active"]}),t.hasKey&&!s&&i.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[i.jsxs("div",{className:"flex-1 flex items-center gap-1.5 h-8 px-2.5 bg-success/8 border border-success/20 rounded-md text-2xs font-sans text-success",children:[i.jsx(ia,{size:10})," API Connected"]}),i.jsx("button",{onClick:()=>{l(!0),O(!1),u("")},className:"text-2xs text-text-4 hover:text-accent cursor-pointer font-sans",children:"Edit"}),i.jsx("button",{onClick:w,className:"text-2xs text-text-4 hover:text-danger cursor-pointer font-sans",children:"Remove"})]}),i.jsx("div",{className:"flex-1"}),s&&i.jsxs("div",{className:"space-y-2.5 pt-1",children:[i.jsxs("div",{children:[i.jsx("label",{className:"text-2xs font-semibold text-text-2 font-sans mb-1.5 block",children:t.hasKey?"Update API Key":`${t.name} API Key`}),i.jsxs("div",{className:"relative",children:[i.jsx("input",{value:o,onChange:$=>u($.target.value),onKeyDown:$=>$.key==="Enter"&&Q(),type:d?"text":"password",placeholder:"sk-...",className:"w-full h-9 px-3 pr-9 text-xs bg-surface-0 border border-border rounded-md text-text-0 font-mono placeholder:text-text-4 focus:outline-none focus:ring-1 focus:ring-accent",autoFocus:!0}),i.jsx("button",{onClick:()=>O(!d),className:"absolute right-2.5 top-1/2 -translate-y-1/2 text-text-4 hover:text-text-2 cursor-pointer",children:d?i.jsx(If,{size:12}):i.jsx(mi,{size:12})})]})]}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx(be,{variant:"primary",size:"sm",onClick:Q,disabled:!o.trim(),className:"flex-1 h-8 text-xs",children:"Save Key"}),i.jsx(be,{variant:"ghost",size:"sm",onClick:()=>{l(!1),u("")},className:"h-8 text-xs px-3",children:"Cancel"})]})]}),!s&&!t.hasKey&&i.jsxs(be,{variant:b?"secondary":"primary",size:"sm",onClick:()=>{l(!0),O(!1),u("")},className:"w-full h-8 text-2xs gap-1.5 mt-2",children:[i.jsx(vc,{size:11}),b?"Add API key for headless mode":"Add API Key"]})]})]})}function Ql({icon:t,label:n,description:s,children:l}){return i.jsxs("div",{className:"rounded-lg border border-border-subtle bg-surface-1 px-4 py-3.5 flex flex-col gap-2",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("div",{className:"w-6 h-6 rounded bg-accent/8 flex items-center justify-center flex-shrink-0",children:i.jsx(t,{size:12,className:"text-accent"})}),i.jsx("div",{className:"text-[13px] font-medium text-text-0 font-sans leading-tight",children:n})]}),i.jsx("div",{className:"text-2xs text-text-4 font-sans leading-relaxed",children:s}),i.jsx("div",{className:"mt-auto pt-1",children:l})]})}const WS={telegram:th,discord:pi,slack:qb},js={telegram:"Telegram",discord:"Discord",slack:"Slack"},H_={telegram:"Bot token from @BotFather",discord:"Bot token from Developer Portal",slack:"Bot token (xoxb-...)"},I_=["critical","lifecycle","all"];function F_({type:t,open:n,onOpenChange:s}){if(!t)return null;const o={telegram:{title:"Set Up Telegram",icon:th,intro:"Create a Telegram bot and connect it to Groove in under 2 minutes. No dependencies required.",sections:[{title:"Create Your Bot",steps:[{text:"Open Telegram on any device and search for",link:"https://t.me/BotFather",linkText:"@BotFather"},{text:"Send /newbot to start the setup"},{text:"Choose a display name — we suggest GroovePilot"},{text:'Choose a username (must end in "bot") — e.g. GroovePilot_bot'},{text:"BotFather will reply with your bot token — copy it"}]},{title:"Connect to Groove",steps:[{text:"In Groove Settings > Gateways, click Set Token on the Telegram card"},{text:"Paste your bot token and click Save"},{text:"The gateway will connect automatically"}]},{title:"Link a Chat",steps:[{text:"Open a chat with your new bot in Telegram"},{text:'Send any message (e.g. "hello") — Groove captures the chat ID automatically'},{text:"Click Test in the gateway card to verify"}]},{title:"Commands",note:"All commands use / prefix in Telegram:",commands:["/instruct <team> <msg>","/query <team> <question>","/plan <description>","/log <team>","/brief","/tokens","/status","/agents","/help"]}]},discord:{title:"Set Up Discord",icon:pi,intro:"Create a Discord bot and add it to your server. Requires discord.js (installed automatically with Groove).",sections:[{title:"Create the Application",steps:[{text:"Go to the",link:"https://discord.com/developers/applications",linkText:"Discord Developer Portal"},{text:"Click New Application and name it GroovePilot"},{text:"Go to the Bot tab in the left sidebar"},{text:"Click Reset Token and copy the bot token"}]},{title:"Set Permissions & Invite",steps:[{text:"Go to OAuth2 > URL Generator"},{text:"Under Scopes, check bot"},{text:"Under Bot Permissions, check:"}],scopes:["Send Messages","Read Message History","Embed Links","Use External Emojis"],after:[{text:"Copy the generated URL at the bottom and open it in your browser"},{text:"Select your server and click Authorize"}]},{title:"Enable Message Content Intent",steps:[{text:"Go back to the Bot tab in the Developer Portal"},{text:"Scroll to Privileged Gateway Intents"},{text:"Enable Message Content Intent — required for the bot to read commands"},{text:"Click Save Changes"}]},{title:"Connect to Groove",steps:[{text:"In Groove Settings > Gateways, click Set Token on the Discord card"},{text:"Paste your bot token and click Save"},{text:"Send a message in any channel where the bot is — Groove captures the channel automatically"}]},{title:"Commands",note:"All commands use / prefix in Discord:",commands:["/instruct <team> <msg>","/query <team> <question>","/plan <description>","/log <team>","/brief","/tokens","/status","/agents","/help"]}]},slack:{title:"Set Up Slack",icon:qb,intro:"Create a Slack app with Socket Mode — no public URL needed. Requires @slack/bolt (installed automatically with Groove).",sections:[{title:"Create the App",steps:[{text:"Go to",link:"https://api.slack.com/apps",linkText:"api.slack.com/apps"},{text:"Click Create New App > From scratch"},{text:"Name it GroovePilot and select your workspace"}]},{title:"Enable Socket Mode",steps:[{text:"In the left sidebar, go to Settings > Socket Mode"},{text:"Toggle Enable Socket Mode to on"},{text:"It will ask you to create an App-Level Token"},{text:'Name it "groove", add the connections:write scope'},{text:"Click Generate — copy the xapp-... token (this is your App Token)"}],important:"Save this token now — you can't view it again after closing the dialog."},{title:"Set Bot Token Scopes",steps:[{text:"Go to Features > OAuth & Permissions"},{text:"Scroll to Bot Token Scopes and add all of these:"}],scopes:["chat:write","channels:read","channels:history","groups:read","groups:history","im:history","app_mentions:read"],after:[{text:"Scroll up and click Install to Workspace"},{text:"Click Allow to grant permissions"},{text:"Copy the Bot User OAuth Token (xoxb-...) — this is your Bot Token"}]},{title:"Enable Events",steps:[{text:"Go to Features > Event Subscriptions"},{text:"Toggle Enable Events to on"},{text:"Under Subscribe to bot events, add:"}],scopes:["message.channels","message.im","app_mention"],after:[{text:"Click Save Changes at the bottom"}]},{title:"Connect to Groove",steps:[{text:"In Groove Settings > Gateways, click Set Token on the Slack card"},{text:"Paste your Bot Token (xoxb-...) in the first field"},{text:"Paste your App Token (xapp-...) in the second field"},{text:"Click Save — Groove will auto-connect"}]},{title:"Link a Channel",steps:[{text:"Invite the bot to a channel: /invite @GroovePilot"},{text:"Select the channel from the dropdown in the gateway card"},{text:"Or @mention the bot — it will auto-capture the channel"},{text:"Click Test to verify"}],important:"For private channels, make sure you added the groups:read scope."},{title:"Commands",note:"In Slack, use plain text commands (no / prefix) or @mention the bot:",commands:["instruct <team> <msg>","query <team> <question>","plan <description>","log <team>","brief","tokens","status","agents","help","@GroovePilot status"]}]}}[t];if(!o)return null;const u=o.icon;return i.jsx(LS,{open:n,onOpenChange:s,children:i.jsx(DS,{title:o.title,width:480,children:i.jsxs("div",{className:"px-5 py-4 space-y-5",children:[i.jsxs("div",{className:"flex items-start gap-3 p-3 bg-accent/5 border border-accent/15 rounded-lg",children:[i.jsx("div",{className:"w-8 h-8 rounded-lg bg-accent/10 flex items-center justify-center flex-shrink-0 mt-0.5",children:i.jsx(u,{size:16,className:"text-accent"})}),i.jsx("p",{className:"text-xs text-text-2 font-sans leading-relaxed",children:o.intro})]}),o.sections.map((d,O)=>{var m;return i.jsxs("div",{children:[i.jsxs("h3",{className:"text-xs font-semibold text-text-0 font-sans mb-2.5 flex items-center gap-2",children:[i.jsx("span",{className:"w-5 h-5 rounded-full bg-accent/10 flex items-center justify-center text-2xs font-bold text-accent",children:O+1}),d.title]}),d.note&&i.jsx("p",{className:"text-2xs text-text-3 font-sans mb-2",children:d.note}),d.steps&&i.jsx("ol",{className:"space-y-2 mb-2",children:d.steps.map((p,g)=>i.jsxs("li",{className:"flex gap-2 text-2xs text-text-2 font-sans leading-relaxed",children:[i.jsxs("span",{className:"text-text-4 font-mono w-4 flex-shrink-0 pt-px",children:[g+1,"."]}),i.jsxs("span",{children:[p.text,p.link&&i.jsxs(i.Fragment,{children:[" ",i.jsxs("a",{href:p.link,target:"_blank",rel:"noopener noreferrer",className:"text-accent hover:underline inline-flex items-center gap-0.5 font-medium",children:[p.linkText,i.jsx(bc,{size:9})]})]})]})]},g))}),d.scopes&&i.jsx("div",{className:"flex flex-wrap gap-1.5 mb-2 ml-6",children:d.scopes.map(p=>i.jsx("code",{className:"px-2 py-0.5 rounded bg-surface-4 text-2xs font-mono text-accent",children:p},p))}),d.after&&i.jsx("ol",{className:"space-y-2 mb-2",start:(((m=d.steps)==null?void 0:m.length)||0)+1,children:d.after.map((p,g)=>{var x;return i.jsxs("li",{className:"flex gap-2 text-2xs text-text-2 font-sans leading-relaxed",children:[i.jsxs("span",{className:"text-text-4 font-mono w-4 flex-shrink-0 pt-px",children:[(((x=d.steps)==null?void 0:x.length)||0)+g+1,"."]}),i.jsx("span",{children:p.text})]},g)})}),d.important&&i.jsx("div",{className:"ml-6 p-2 bg-warning/8 border border-warning/20 rounded-md text-2xs text-warning font-sans",children:d.important}),d.commands&&i.jsx("div",{className:"ml-6 p-2.5 bg-surface-0 border border-border-subtle rounded-md space-y-1",children:d.commands.map(p=>i.jsx("code",{className:"block text-2xs font-mono text-text-1",children:p},p))})]},O)}),i.jsxs("a",{href:"https://docs.groovedev.ai/guide/gateways",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 text-2xs text-accent hover:text-accent/80 font-sans font-medium mt-2",children:[i.jsx(bc,{size:10}),"Full documentation at docs.groovedev.ai"]})]})})})}function K_({gateway:t,onRefresh:n}){var ce,re;const[s,l]=y.useState(!1),[o,u]=y.useState(""),[d,O]=y.useState(""),[m,p]=y.useState(!1),[g,x]=y.useState(!1),[b,v]=y.useState(!1),[Q,w]=y.useState([]),[T,k]=y.useState(!1),z=D(F=>F.addToast);y.useEffect(()=>{t.connected&&!t.chatId&&t.type==="slack"&&ee.get(`/gateways/${t.id}/channels`).then(F=>w(Array.isArray(F)?F:[])).catch(()=>{})},[t.connected,t.chatId,t.id,t.type]);const $=WS[t.type]||eh,C=t.type==="slack";async function G(){if(o.trim())try{await ee.post(`/gateways/${t.id}/credentials`,{key:"bot_token",value:o.trim()}),C&&d.trim()&&await ee.post(`/gateways/${t.id}/credentials`,{key:"app_token",value:d.trim()}),z("success","Token saved — connecting..."),u(""),O(""),l(!1);try{await ee.post(`/gateways/${t.id}/connect`),z("success",`${js[t.type]} connected!`)}catch(F){z("error","Token saved but connect failed",F.message)}n()}catch(F){z("error","Failed to save token",F.message)}}async function X(){x(!0);try{await ee.post(`/gateways/${t.id}/test`),z("success","Test message sent!")}catch(F){z("error","Test failed",F.message)}x(!1)}async function _(){v(!0);try{t.connected?(await ee.post(`/gateways/${t.id}/disconnect`),z("info",`${js[t.type]} disconnected`)):(await ee.post(`/gateways/${t.id}/connect`),z("success",`${js[t.type]} connected!`)),n()}catch(F){z("error",t.connected?"Disconnect failed":"Connect failed",F.message)}v(!1)}async function N(F){try{await ee.patch(`/gateways/${t.id}`,{enabled:F}),n()}catch(P){z("error","Update failed",P.message)}}async function E(F){try{await ee.patch(`/gateways/${t.id}`,{notifications:{preset:F}}),n()}catch(P){z("error","Update failed",P.message)}}async function Y(F){try{await ee.patch(`/gateways/${t.id}`,{commandPermission:F}),n()}catch(P){z("error","Update failed",P.message)}}async function ne(){try{await ee.delete(`/gateways/${t.id}`),z("info",`${js[t.type]} gateway removed`),n()}catch(F){z("error","Delete failed",F.message)}}const oe=((ce=t.notifications)==null?void 0:ce.preset)||"critical";return i.jsxs("div",{className:"flex flex-col rounded-lg border border-border-subtle bg-surface-1 overflow-hidden min-w-[220px]",children:[i.jsxs("div",{className:"flex items-center gap-2.5 px-4 py-3 border-b border-border-subtle",children:[i.jsx($s,{status:t.connected?"running":"crashed",size:"sm"}),i.jsx($,{size:13,className:"text-text-2"}),i.jsx("span",{className:"text-[13px] font-semibold text-text-0 font-sans",children:js[t.type]}),i.jsx("div",{className:"flex-1"}),t.connected?i.jsxs(Ze,{variant:"success",className:"text-2xs gap-1",children:[i.jsx(a1,{size:8})," Connected"]}):t.enabled?i.jsx(Ze,{variant:"warning",className:"text-2xs",children:"Disconnected"}):i.jsx(Ze,{variant:"default",className:"text-2xs",children:"Disabled"})]}),i.jsxs("div",{className:"flex-1 flex flex-col px-4 py-3 min-h-[140px]",children:[t.connected&&!s&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"flex items-center gap-1.5 h-8 px-2.5 bg-success/8 border border-success/20 rounded-md text-2xs font-sans text-success mb-3",children:[i.jsx(ia,{size:10})," Gateway active",t.botUsername&&i.jsxs("span",{className:"text-text-4 ml-1",children:["@",t.botUsername]}),t.botTag&&i.jsx("span",{className:"text-text-4 ml-1",children:t.botTag})]}),i.jsxs("div",{className:"mb-3",children:[i.jsx("label",{className:"text-2xs font-semibold text-text-3 font-sans mb-1.5 block",children:t.type==="slack"?"Channel":"Chat ID"}),t.chatId?i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("code",{className:"flex-1 flex items-center h-7 px-2 bg-surface-0 border border-border-subtle rounded-md text-2xs font-mono text-text-2",children:t.type==="slack"&&Q.length>0?`#${((re=Q.find(F=>F.id===t.chatId))==null?void 0:re.name)||t.chatId}`:t.chatId}),i.jsx("button",{onClick:async()=>{try{await ee.patch(`/gateways/${t.id}`,{chatId:null}),n()}catch(F){z("error","Failed",F.message)}},className:"text-2xs text-text-4 hover:text-text-1 cursor-pointer font-sans",children:"Change"})]}):t.type==="slack"&&Q.length>0?i.jsxs("select",{onChange:async F=>{if(F.target.value)try{await ee.patch(`/gateways/${t.id}`,{chatId:F.target.value}),n()}catch(P){z("error","Failed to set channel",P.message)}},className:"w-full h-7 px-2 text-2xs bg-surface-0 border border-border-subtle rounded-md text-text-0 font-sans focus:outline-none focus:ring-1 focus:ring-accent cursor-pointer",defaultValue:"",children:[i.jsx("option",{value:"",disabled:!0,children:"Select a channel..."}),Q.map(F=>i.jsxs("option",{value:F.id,children:["#",F.name]},F.id))]}):i.jsxs("div",{className:"text-2xs text-warning font-sans",children:[t.type==="slack"?"No channels found — invite the bot to a channel first.":"Send a message to the bot to auto-capture, or enter manually:",i.jsx("input",{placeholder:t.type==="slack"?"C0123456789":"Chat ID",className:"mt-1 w-full h-7 px-2 text-2xs bg-surface-0 border border-border rounded-md text-text-0 font-mono placeholder:text-text-4 focus:outline-none focus:ring-1 focus:ring-accent",onKeyDown:async F=>{if(F.key==="Enter"&&F.target.value.trim())try{await ee.patch(`/gateways/${t.id}`,{chatId:F.target.value.trim()}),n()}catch(P){z("error","Failed to set channel",P.message)}}})]})]}),i.jsxs("div",{className:"mb-3",children:[i.jsx("label",{className:"text-2xs font-semibold text-text-3 font-sans mb-1.5 block",children:"Notifications"}),i.jsx("div",{className:"flex bg-surface-0 rounded-md p-0.5 border border-border-subtle",children:I_.map(F=>i.jsx("button",{onClick:()=>E(F),className:se("flex-1 px-2 py-1.5 text-2xs font-semibold font-sans rounded transition-all cursor-pointer capitalize",oe===F?"bg-accent/15 text-accent shadow-sm":"text-text-3 hover:text-text-1"),children:F},F))})]}),i.jsxs("div",{className:"mb-3",children:[i.jsx("label",{className:"text-2xs font-semibold text-text-3 font-sans mb-1.5 block",children:"Commands"}),i.jsx("div",{className:"flex bg-surface-0 rounded-md p-0.5 border border-border-subtle",children:["full","read-only"].map(F=>i.jsx("button",{onClick:()=>Y(F),className:se("flex-1 px-2 py-1.5 text-2xs font-semibold font-sans rounded transition-all cursor-pointer capitalize",(t.commandPermission||"full")===F?"bg-accent/15 text-accent shadow-sm":"text-text-3 hover:text-text-1"),children:F==="full"?"Full Access":"Read Only"},F))})]})]}),!t.connected&&!s&&i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"text-xs text-text-3 font-sans mb-2",children:t.enabled?t.hasCredentials?"Tokens saved — click Connect.":"Configure bot token to connect.":"Gateway is disabled."}),!t.hasCredentials&&i.jsxs("button",{onClick:()=>k(!0),className:"flex items-center gap-1.5 text-2xs text-accent hover:text-accent/80 font-sans font-medium cursor-pointer mb-2",children:[i.jsx(gc,{size:11}),"How to set up",i.jsx(bc,{size:9})]})]}),i.jsx(F_,{type:t.type,open:T,onOpenChange:k}),i.jsx("div",{className:"flex-1"}),s&&i.jsxs("div",{className:"space-y-2.5 pt-1",children:[i.jsxs("button",{onClick:()=>k(!0),className:"flex items-center gap-1.5 text-2xs text-accent hover:text-accent/80 font-sans font-medium cursor-pointer",children:[i.jsx(gc,{size:11}),"Where do I get these?"]}),i.jsxs("div",{children:[i.jsx("label",{className:"text-2xs font-semibold text-text-2 font-sans mb-1.5 block",children:"Bot Token"}),i.jsxs("div",{className:"relative",children:[i.jsx("input",{value:o,onChange:F=>u(F.target.value),onKeyDown:F=>F.key==="Enter"&&!C&&G(),type:m?"text":"password",placeholder:H_[t.type],className:"w-full h-9 px-3 pr-9 text-xs bg-surface-0 border border-border rounded-md text-text-0 font-mono placeholder:text-text-4 focus:outline-none focus:ring-1 focus:ring-accent",autoFocus:!0}),i.jsx("button",{onClick:()=>p(!m),className:"absolute right-2.5 top-1/2 -translate-y-1/2 text-text-4 hover:text-text-2 cursor-pointer",children:m?i.jsx(If,{size:12}):i.jsx(mi,{size:12})})]})]}),C&&i.jsxs("div",{children:[i.jsx("label",{className:"text-2xs font-semibold text-text-2 font-sans mb-1.5 block",children:"App Token (Socket Mode)"}),i.jsx("input",{value:d,onChange:F=>O(F.target.value),onKeyDown:F=>F.key==="Enter"&&G(),type:m?"text":"password",placeholder:"xapp-...",className:"w-full h-9 px-3 text-xs bg-surface-0 border border-border rounded-md text-text-0 font-mono placeholder:text-text-4 focus:outline-none focus:ring-1 focus:ring-accent"})]}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx(be,{variant:"primary",size:"sm",onClick:G,disabled:!o.trim(),className:"flex-1 h-8 text-xs",children:"Save Token"}),i.jsx(be,{variant:"ghost",size:"sm",onClick:()=>{l(!1),u(""),O("")},className:"h-8 text-xs px-3",children:"Cancel"})]})]}),!s&&i.jsxs("div",{className:"flex gap-2 mt-2",children:[!t.connected&&i.jsxs(be,{variant:"primary",size:"sm",onClick:()=>l(!0),className:"flex-1 h-7 text-2xs gap-1.5",children:[i.jsx(vc,{size:11}),t.enabled?"Set Token":"Configure"]}),t.connected&&i.jsxs(i.Fragment,{children:[i.jsxs(be,{variant:"secondary",size:"sm",onClick:X,disabled:g,className:"flex-1 h-7 text-2xs gap-1.5",children:[i.jsx(nh,{size:11}),g?"Sending...":"Test"]}),i.jsx(be,{variant:"secondary",size:"sm",onClick:()=>l(!0),className:"h-7 text-2xs px-2.5",children:i.jsx(vc,{size:11})})]}),i.jsx(be,{variant:"ghost",size:"sm",onClick:_,disabled:b,className:"h-7 text-2xs px-2.5",title:t.connected?"Disconnect":"Connect",children:t.connected?i.jsx(Vb,{size:11}):i.jsx(a1,{size:11})}),i.jsx(D_,{value:t.enabled,onChange:N}),i.jsx("button",{onClick:ne,className:"text-text-4 hover:text-danger cursor-pointer p-1",title:"Remove gateway",children:i.jsx(Dl,{size:11})})]})]})]})}function J_({existingTypes:t,onAdd:n}){const[s,l]=y.useState(!1),o=["telegram","discord","slack"].filter(u=>!t.includes(u));return o.length===0?null:s?i.jsxs("div",{className:"flex flex-col rounded-lg border border-accent/30 bg-surface-1 overflow-hidden min-w-[220px]",children:[i.jsxs("div",{className:"flex items-center gap-2.5 px-4 py-3 border-b border-border-subtle",children:[i.jsx(eh,{size:13,className:"text-accent"}),i.jsx("span",{className:"text-[13px] font-semibold text-text-0 font-sans",children:"Add Gateway"}),i.jsx("div",{className:"flex-1"}),i.jsx("button",{onClick:()=>l(!1),className:"text-text-4 hover:text-text-1 cursor-pointer",children:i.jsx(jt,{size:12})})]}),i.jsx("div",{className:"p-3 space-y-2",children:o.map(u=>{const d=WS[u];return i.jsxs("button",{onClick:()=>{n(u),l(!1)},className:"w-full flex items-center gap-3 px-3 py-2.5 rounded-md bg-surface-0 hover:bg-accent/8 border border-border-subtle hover:border-accent/20 cursor-pointer transition-all group",children:[i.jsx(d,{size:14,className:"text-text-3 group-hover:text-accent"}),i.jsx("span",{className:"text-xs font-medium text-text-1 group-hover:text-accent font-sans",children:js[u]})]},u)})})]}):i.jsxs("button",{onClick:()=>l(!0),className:"flex flex-col items-center justify-center rounded-lg border border-dashed border-border-subtle bg-surface-1/50 hover:bg-surface-1 hover:border-accent/30 min-h-[140px] min-w-[220px] cursor-pointer transition-all group",children:[i.jsx("div",{className:"w-8 h-8 rounded-full bg-accent/8 group-hover:bg-accent/15 flex items-center justify-center mb-2 transition-colors",children:i.jsx(Jn,{size:14,className:"text-accent"})}),i.jsx("span",{className:"text-2xs font-semibold text-text-3 group-hover:text-text-1 font-sans transition-colors",children:"Add Gateway"})]})}function eZ(){const[t,n]=y.useState([]),[s,l]=y.useState(null),[o,u]=y.useState(null),[d,O]=y.useState([]),[m,p]=y.useState(!0),[g,x]=y.useState(!1),b=D(_=>_.addToast),v=D(_=>_.marketplaceUser),Q=D(_=>_.marketplaceAuthenticated),w=D(_=>_.marketplaceLogin),T=D(_=>_.marketplaceLogout);function k(){ee.get("/providers").then(_=>n(Array.isArray(_)?_:[])).catch(()=>{})}function z(){ee.get("/gateways").then(_=>O(Array.isArray(_)?_:[])).catch(()=>{})}y.useEffect(()=>{Promise.all([ee.get("/providers"),ee.get("/config"),ee.get("/status"),ee.get("/gateways")]).then(([_,N,E,Y])=>{n(Array.isArray(_)?_:[]),l(N),u(E),O(Array.isArray(Y)?Y:[]),p(!1)}).catch(()=>p(!1))},[]);async function $(_){try{await ee.post("/gateways",{type:_}),b("success",`${js[_]} gateway added`),z()}catch(N){b("error","Failed to add gateway",N.message)}}async function C(_,N){try{const E=await ee.patch("/config",{[_]:N});l(E)}catch(E){b("error","Update failed",E.message)}}if(m)return i.jsxs("div",{className:"flex flex-col h-full",children:[i.jsx("div",{className:"h-12 bg-surface-1 border-b border-border"}),i.jsxs("div",{className:"flex-1 p-4 space-y-4",children:[i.jsx("div",{className:"grid grid-cols-4 gap-3",children:[...Array(4)].map((_,N)=>i.jsx(ra,{className:"h-40 rounded-lg"},N))}),i.jsx("div",{className:"grid grid-cols-3 gap-3",children:[...Array(6)].map((_,N)=>i.jsx(ra,{className:"h-28 rounded-lg"},N))})]})]});const G=t.filter(_=>_.authType==="local"||_.authType==="subscription"?_.installed:_.hasKey).length,X=(s==null?void 0:s.rotationThreshold)||0;return i.jsxs("div",{className:"flex flex-col h-full",children:[i.jsxs("div",{className:"flex items-center gap-4 px-4 py-2.5 bg-surface-1 border-b border-border flex-shrink-0",children:[i.jsx("h2",{className:"text-sm font-semibold text-text-0 font-sans",children:"Settings"}),i.jsx("div",{className:"flex-1"}),i.jsxs("div",{className:"flex items-center gap-4 text-2xs text-text-3 font-sans",children:[(o==null?void 0:o.version)&&i.jsxs("span",{children:["v",o.version]}),(o==null?void 0:o.port)&&i.jsxs("span",{children:[":",o.port]}),(o==null?void 0:o.uptime)>0&&i.jsxs("span",{children:["Up ",Dc(o.uptime)]})]}),i.jsx("div",{className:"w-px h-4 bg-border-subtle"}),Q?i.jsxs("div",{className:"flex items-center gap-2.5",children:[i.jsx(W_,{user:v}),i.jsx("span",{className:"text-xs font-medium text-text-0 font-sans",children:(v==null?void 0:v.displayName)||"User"}),i.jsxs("button",{onClick:T,className:"text-2xs text-text-4 hover:text-text-1 cursor-pointer font-sans flex items-center gap-1",children:[i.jsx(Eb,{size:10})," Sign out"]})]}):i.jsxs(be,{variant:"ghost",size:"sm",onClick:w,className:"h-7 text-2xs gap-1.5 text-text-3",children:[i.jsx(Kf,{size:11})," Sign in"]}),i.jsx($s,{status:"running",size:"sm"})]}),i.jsx(fn,{className:"flex-1",children:i.jsxs("div",{className:"p-4 space-y-4",children:[i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center gap-2 mb-2.5 px-0.5",children:[i.jsx("span",{className:"text-2xs font-semibold text-text-3 font-sans uppercase tracking-wider",children:"Providers"}),i.jsx("div",{className:"flex-1 h-px bg-border-subtle"}),i.jsxs("span",{className:"text-2xs text-text-4 font-sans",children:[G,"/",t.length," connected"]})]}),i.jsx("div",{className:"grid grid-cols-4 gap-3",children:t.map(_=>i.jsx(B_,{provider:_,onKeyChange:k},_.id))})]}),i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center gap-2 mb-2.5 px-0.5",children:[i.jsx("span",{className:"text-2xs font-semibold text-text-3 font-sans uppercase tracking-wider",children:"Gateways"}),i.jsx("div",{className:"flex-1 h-px bg-border-subtle"}),i.jsxs("span",{className:"text-2xs text-text-4 font-sans",children:[d.filter(_=>_.connected).length,"/",d.length," connected"]})]}),i.jsxs("div",{className:"grid grid-cols-4 gap-3",children:[d.map(_=>i.jsx(K_,{gateway:_,onRefresh:z},_.id)),i.jsx(J_,{existingTypes:d.map(_=>_.type),onAdd:$})]})]}),s&&i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center gap-2 mb-2.5 px-0.5",children:[i.jsx("span",{className:"text-2xs font-semibold text-text-3 font-sans uppercase tracking-wider",children:"Configuration"}),i.jsx("div",{className:"flex-1 h-px bg-border-subtle"}),i.jsx("span",{className:"text-2xs text-text-4 font-sans",children:"Auto-saves"})]}),i.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[i.jsx(Ql,{icon:Zl,label:"Default Provider",description:"Provider used when spawning new agents.",children:i.jsx("select",{value:s.defaultProvider||"claude-code",onChange:_=>C("defaultProvider",_.target.value),className:"w-full h-8 px-2.5 text-xs bg-surface-0 border border-border-subtle rounded-md text-text-0 font-mono focus:outline-none focus:ring-1 focus:ring-accent cursor-pointer",children:t.filter(_=>_.installed||_.hasKey).map(_=>i.jsx("option",{value:_.id,children:_.name},_.id))})}),i.jsx(Ql,{icon:ai,label:"Working Directory",description:"Default root directory for new agents.",children:i.jsxs("div",{className:"flex items-center gap-1.5",children:[i.jsx("code",{className:"flex-1 h-8 px-2 flex items-center bg-surface-0 border border-border-subtle rounded-md text-2xs font-mono text-text-2 truncate min-w-0",children:s.defaultWorkingDir||"Project root"}),i.jsx(be,{variant:"secondary",size:"sm",onClick:()=>x(!0),className:"h-8 px-2 flex-shrink-0",children:i.jsx(Xb,{size:12})})]})}),i.jsx(Ql,{icon:Zb,label:"Rotation Threshold",description:"Context usage that triggers auto-rotation.",children:i.jsx("div",{className:"flex bg-surface-0 rounded-md p-0.5 border border-border-subtle",children:["auto","50%","65%","75%","85%"].map(_=>{const N=_==="auto"?0:parseInt(_,10)/100,E=X===N;return i.jsx("button",{onClick:()=>C("rotationThreshold",N),className:se("flex-1 px-2 py-1.5 text-2xs font-semibold font-sans rounded transition-all cursor-pointer",E?"bg-accent/15 text-accent shadow-sm":"text-text-3 hover:text-text-1"),children:_==="auto"?"Auto":_},_)})})}),i.jsx(Ql,{icon:Wb,label:"QC Threshold",description:"Running agents count that triggers auto-QC.",children:i.jsx("div",{className:"flex bg-surface-0 rounded-md p-0.5 border border-border-subtle",children:[2,3,4,6,8].map(_=>{const N=(s.qcThreshold||2)===_;return i.jsx("button",{onClick:()=>C("qcThreshold",_),className:se("flex-1 px-2 py-1.5 text-2xs font-semibold font-sans rounded transition-all cursor-pointer",N?"bg-accent/15 text-accent shadow-sm":"text-text-3 hover:text-text-1"),children:_},_)})})}),i.jsx(Ql,{icon:bi,label:"Max Agents",description:"Concurrent agent limit. 0 = unlimited.",children:i.jsx("div",{className:"flex bg-surface-0 rounded-md p-0.5 border border-border-subtle",children:[0,4,8,12,20].map(_=>{const N=(s.maxAgents||0)===_;return i.jsx("button",{onClick:()=>C("maxAgents",_),className:se("flex-1 px-2 py-1.5 text-2xs font-semibold font-sans rounded transition-all cursor-pointer",N?"bg-accent/15 text-accent shadow-sm":"text-text-3 hover:text-text-1"),children:_===0?"∞":_},_)})})}),i.jsx(Ql,{icon:ni,label:"Journalist Interval",description:"Seconds between synthesis cycles.",children:i.jsx("div",{className:"flex bg-surface-0 rounded-md p-0.5 border border-border-subtle",children:[60,120,300,600].map(_=>{const N=(s.journalistInterval||120)===_,E=_<60?`${_}s`:`${_/60}m`;return i.jsx("button",{onClick:()=>C("journalistInterval",_),className:se("flex-1 px-2 py-1.5 text-2xs font-semibold font-sans rounded transition-all cursor-pointer",N?"bg-accent/15 text-accent shadow-sm":"text-text-3 hover:text-text-1"),children:E},_)})})})]})]})]})}),i.jsx(GS,{open:g,onOpenChange:x,currentPath:(s==null?void 0:s.defaultWorkingDir)||"/",onSelect:_=>C("defaultWorkingDir",_)})]})}const zf=y.forwardRef(({className:t,label:n,error:s,mono:l,...o},u)=>i.jsxs("div",{className:"flex flex-col gap-1",children:[n&&i.jsx("label",{className:"text-xs font-medium text-text-2 font-sans",children:n}),i.jsx("input",{ref:u,className:se("h-8 w-full rounded-md px-3 text-sm","bg-surface-1 border border-border text-text-0","placeholder:text-text-4","focus:outline-none focus:ring-1 focus:ring-accent focus:border-accent","disabled:opacity-40 disabled:cursor-not-allowed","transition-colors duration-100",l?"font-mono":"font-sans",s&&"border-danger focus:ring-danger",t),...o}),s&&i.jsx("span",{className:"text-2xs text-danger font-sans",children:s})]}));zf.displayName="Input";const tZ=y.forwardRef(({className:t,label:n,error:s,mono:l,...o},u)=>i.jsxs("div",{className:"flex flex-col gap-1",children:[n&&i.jsx("label",{className:"text-xs font-medium text-text-2 font-sans",children:n}),i.jsx("textarea",{ref:u,className:se("w-full rounded-md px-3 py-2 text-sm resize-none","bg-surface-1 border border-border text-text-0","placeholder:text-text-4","focus:outline-none focus:ring-1 focus:ring-accent focus:border-accent","disabled:opacity-40 disabled:cursor-not-allowed","transition-colors duration-100",l?"font-mono":"font-sans",s&&"border-danger focus:ring-danger",t),...o}),s&&i.jsx("span",{className:"text-2xs text-danger font-sans",children:s})]}));tZ.displayName="Textarea";function Cc(t){return t?t<1024*1024?`${(t/1024).toFixed(0)} KB`:t<1024*1024*1024?`${(t/(1024*1024)).toFixed(1)} MB`:`${(t/(1024*1024*1024)).toFixed(2)} GB`:"—"}function aZ(t){return t?t<1024*1024?`${(t/1024).toFixed(0)} KB/s`:`${(t/(1024*1024)).toFixed(1)} MB/s`:""}function nZ({hardware:t}){var n;return t?i.jsxs("div",{className:"flex items-center gap-4 px-4 py-2.5 bg-surface-1 border border-border-subtle rounded-lg text-xs font-sans text-text-2",children:[i.jsxs("div",{className:"flex items-center gap-1.5",children:[i.jsx(ZT,{size:14,className:"text-text-3"}),i.jsxs("span",{children:[t.totalRamGb," GB RAM"]})]}),i.jsxs("div",{className:"flex items-center gap-1.5",children:[i.jsx(Zl,{size:14,className:"text-text-3"}),i.jsxs("span",{children:[t.cores," cores"]})]}),t.gpu&&i.jsxs("div",{className:"flex items-center gap-1.5",children:[i.jsx(Ff,{size:14,className:"text-text-3"}),i.jsxs("span",{children:[t.gpu.name,t.gpu.vram?` (${t.gpu.vram} GB)`:""]})]}),((n=t.recommended)==null?void 0:n.code)&&i.jsxs("div",{className:"ml-auto text-accent",children:["Recommended: ",t.recommended.code]})]}):null}function sZ({download:t}){const n=Math.round((t.percent||0)*100);return i.jsxs("div",{className:"space-y-1",children:[i.jsxs("div",{className:"flex items-center justify-between text-2xs font-sans text-text-3",children:[i.jsx("span",{children:t.filename}),i.jsxs("span",{children:[n,"% ",aZ(t.speed)]})]}),i.jsx("div",{className:"h-1.5 bg-surface-3 rounded-full overflow-hidden",children:i.jsx("div",{className:"h-full bg-accent rounded-full transition-all",style:{width:`${n}%`}})}),i.jsxs("div",{className:"text-2xs text-text-4",children:[Cc(t.downloaded)," / ",Cc(t.totalBytes)]})]})}function lZ({model:t,onDelete:n}){const[s,l]=y.useState(!1),o={light:"text-green-400",medium:"text-blue-400",heavy:"text-orange-400"};return i.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 bg-surface-1 border border-border-subtle rounded-lg",children:[i.jsx(Hf,{size:18,className:"text-accent flex-shrink-0"}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-sm font-mono font-bold text-text-0 truncate",children:t.id}),t.quantization&&i.jsx(Ze,{variant:"subtle",className:"text-2xs",children:t.quantization}),t.parameters&&i.jsx(Ze,{variant:"subtle",className:"text-2xs",children:t.parameters}),i.jsx("span",{className:se("text-2xs font-medium capitalize",o[t.tier]||"text-text-3"),children:t.tier})]}),i.jsxs("div",{className:"text-2xs text-text-3 font-sans mt-0.5",children:[Cc(t.sizeBytes)," · ctx ",(t.contextWindow||0).toLocaleString()," · ",t.category,t.repoId&&i.jsxs("span",{className:"text-text-4",children:[" · ",t.repoId]})]})]}),i.jsx("button",{onClick:async()=>{l(!0),await n(t.id),l(!1)},disabled:s,className:"p-1.5 rounded-md text-text-4 hover:text-red-400 hover:bg-red-400/10 transition-colors",children:s?i.jsx(Kn,{size:14,className:"animate-spin"}):i.jsx(Dl,{size:14})})]})}function rZ({result:t,onExpand:n,expanded:s}){var l;return i.jsxs("button",{onClick:()=>n(s?null:t.id),className:"w-full text-left px-4 py-3 bg-surface-1 border border-border-subtle rounded-lg hover:border-accent/30 transition-colors cursor-pointer",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-sm font-mono font-bold text-text-0 truncate flex-1",children:t.name}),i.jsx("span",{className:"text-2xs text-text-4 font-sans",children:t.author}),s?i.jsx(on,{size:14,className:"text-text-3"}):i.jsx(Gl,{size:14,className:"text-text-3"})]}),i.jsxs("div",{className:"text-2xs text-text-3 font-sans mt-0.5 flex gap-3",children:[i.jsxs("span",{children:[(l=t.downloads)==null?void 0:l.toLocaleString()," downloads"]}),i.jsxs("span",{children:[t.likes," likes"]})]})]})}function iZ({repoId:t,onDownload:n,systemRamGb:s}){const[l,o]=y.useState(null),[u,d]=y.useState(!0),[O,m]=y.useState(null),p=Wl();y.useEffect(()=>{d(!0),ee.get(`/models/${t}/files`).then(x=>o(x.files||[])).catch(()=>p.error("Failed to load model files")).finally(()=>d(!1))},[t]);async function g(x){m(x.filename);try{await ee.post("/models/download",{repoId:t,filename:x.filename}),p.success(`Downloading ${x.filename}`),n==null||n(x.filename)}catch(b){p.error(b.message)}m(null)}return u?i.jsx("div",{className:"py-3 px-4 text-2xs text-text-4 font-sans",children:"Loading quantization variants..."}):l!=null&&l.length?i.jsx("div",{className:"pl-6 pr-4 pb-2 space-y-1.5",children:l.map(x=>{const b=!x.estimatedRamGb||!s||x.estimatedRamGb<=s*.85,v=x.estimatedRamGb&&s&&x.estimatedRamGb>s*.7&&b;return i.jsxs("div",{className:se("flex items-center gap-2 py-1.5 px-3 rounded-md text-xs font-sans",b?"bg-surface-2":"bg-red-500/5 border border-red-500/15"),children:[i.jsx("span",{className:"font-mono text-text-1 truncate flex-1",children:x.filename}),x.quantization&&i.jsx(Ze,{variant:"subtle",className:"text-2xs",children:x.quantization}),i.jsx("span",{className:"text-text-2 text-2xs w-16 text-right",children:Cc(x.size)}),x.estimatedRamGb&&i.jsxs("span",{className:se("text-2xs w-20 text-right font-medium",b?v?"text-yellow-400":"text-green-400":"text-red-400"),children:["~",x.estimatedRamGb," GB RAM"]}),!b&&i.jsx("span",{className:"text-2xs text-red-400 font-medium",children:"too large"}),i.jsx("button",{onClick:()=>g(x),disabled:O===x.filename||!b,className:se("p-1 rounded transition-colors",b?"text-accent hover:bg-accent/10":"text-text-4 cursor-not-allowed","disabled:opacity-40"),children:O===x.filename?i.jsx(Kn,{size:13,className:"animate-spin"}):i.jsx(hi,{size:13})})]},x.filename)})}):i.jsx("div",{className:"py-3 px-4 text-2xs text-text-4 font-sans",children:"No GGUF files found in this repo."})}function oZ({model:t,systemRamGb:n,onPull:s,pulling:l}){const o={light:"text-green-400",medium:"text-blue-400",heavy:"text-orange-400"},u={code:"{}",general:"AI"},d=n?Math.round((1-t.ramGb/n)*100):null;return i.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 bg-surface-1 border border-border-subtle rounded-lg hover:border-accent/20 transition-colors",children:[i.jsx("div",{className:"w-9 h-9 rounded-lg bg-surface-3 flex items-center justify-center text-xs font-mono text-text-2 flex-shrink-0",children:u[t.category]||"AI"}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-sm font-mono font-bold text-text-0 truncate",children:t.name}),i.jsx("span",{className:se("text-2xs font-semibold capitalize",o[t.tier]),children:t.tier})]}),i.jsx("div",{className:"text-2xs text-text-3 font-sans mt-0.5",children:t.description}),i.jsxs("div",{className:"flex items-center gap-3 mt-1 text-2xs font-sans",children:[i.jsxs("span",{className:"text-text-2",children:[t.sizeGb," GB download"]}),i.jsxs("span",{className:"text-green-400 font-medium",children:[t.ramGb," GB RAM"]}),d!==null&&i.jsxs("span",{className:"text-text-4",children:[d,"% headroom"]})]})]}),i.jsxs("button",{onClick:()=>s(t.id),disabled:l===t.id,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-md text-xs font-sans font-medium bg-accent/10 text-accent hover:bg-accent/20 transition-colors cursor-pointer disabled:opacity-40",children:[l===t.id?i.jsx(Kn,{size:12,className:"animate-spin"}):i.jsx(hi,{size:12}),"Pull"]})]})}function cZ(){const[t,n]=y.useState("recommended"),[s,l]=y.useState(""),[o,u]=y.useState([]),[d,O]=y.useState(!1),[m,p]=y.useState([]),[g,x]=y.useState([]),[b,v]=y.useState([]),[Q,w]=y.useState(null),[T,k]=y.useState(null),[z,$]=y.useState(null),C=Wl(),G=y.useCallback(()=>{ee.get("/models/installed").then(E=>{p(E.models||[])}).catch(()=>{})},[]);y.useEffect(()=>{ee.get("/providers/ollama/hardware").then(w).catch(()=>{}),ee.get("/models/recommended").then(E=>{x(E.models||[]),!Q&&E.hardware&&w(E.hardware)}).catch(()=>{}),G()},[G]);async function X(E){$(E);try{await ee.post("/providers/ollama/pull",{model:E}),C.success(`${E} pulled successfully`),G()}catch(Y){C.error(`Pull failed: ${Y.message}`)}$(null)}y.useEffect(()=>{const E=D.subscribe((ne,oe)=>{}),Y=setInterval(()=>{ee.get("/models/downloads").then(v).catch(()=>{})},2e3);return()=>{E(),clearInterval(Y)}},[]),y.useEffect(()=>{function E(ne){try{const oe=JSON.parse(ne.data);oe.type==="model:download:progress"&&v(ce=>{const re=ce.findIndex(F=>F.filename===oe.data.filename);if(re>=0){const F=[...ce];return F[re]=oe.data,F}return[...ce,oe.data]}),oe.type==="model:download:complete"&&(v(ce=>ce.filter(re=>re.filename!==oe.data.filename)),G(),C.success(`${oe.data.filename} downloaded`)),oe.type==="model:download:error"&&(v(ce=>ce.filter(re=>re.filename!==oe.data.filename)),C.error(`Download failed: ${oe.data.error}`))}catch{}}const Y=D.getState()._ws;return Y&&Y.addEventListener("message",E),()=>{Y&&Y.removeEventListener("message",E)}},[G,C]);async function _(){if(s.trim()){O(!0),n("search");try{const E=await ee.get(`/models/search?q=${encodeURIComponent(s.trim())}`);u(E)}catch(E){C.error(E.message)}O(!1)}}async function N(E){try{await ee.delete(`/models/${E}`),p(Y=>Y.filter(ne=>ne.id!==E)),C.success("Model deleted")}catch(Y){C.error(Y.message)}}return i.jsxs("div",{className:"h-full flex flex-col bg-surface-0",children:[i.jsxs("div",{className:"flex-shrink-0 px-5 pt-4 pb-3 border-b border-border space-y-3",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("h1",{className:"text-base font-bold font-sans text-text-0",children:"Local Models"}),i.jsxs(Ze,{variant:"subtle",className:"text-2xs",children:[m.length," installed"]})]}),i.jsx(nZ,{hardware:Q}),i.jsxs("div",{className:"flex gap-2",children:[i.jsxs("div",{className:"relative flex-1",children:[i.jsx(un,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-text-4"}),i.jsx("input",{value:s,onChange:E=>l(E.target.value),onKeyDown:E=>E.key==="Enter"&&_(),placeholder:"Search HuggingFace for GGUF models...",className:"w-full h-8 pl-9 pr-3 text-sm rounded-md bg-surface-1 border border-border text-text-0 font-sans placeholder:text-text-4 focus:outline-none focus:ring-1 focus:ring-accent"})]}),i.jsx(be,{onClick:_,disabled:d,size:"sm",variant:"accent",children:d?i.jsx(Kn,{size:14,className:"animate-spin"}):"Search"})]}),i.jsx("div",{className:"flex gap-1",children:[{id:"recommended",label:`Recommended (${g.length})`},{id:"installed",label:`Installed (${m.length})`},{id:"search",label:`Search (${o.length})`}].map(E=>i.jsx("button",{onClick:()=>n(E.id),className:se("px-3 py-1 rounded-md text-xs font-sans font-medium transition-colors cursor-pointer",t===E.id?"bg-accent/12 text-accent":"text-text-3 hover:text-text-1 hover:bg-surface-3"),children:E.label},E.id))})]}),b.length>0&&i.jsxs("div",{className:"px-5 py-3 border-b border-border space-y-2",children:[i.jsx("div",{className:"text-xs font-sans font-semibold text-text-2",children:"Downloading"}),b.map(E=>i.jsx(sZ,{download:E},E.filename))]}),i.jsx(fn,{className:"flex-1",children:i.jsxs("div",{className:"px-5 py-4 space-y-2",children:[t==="recommended"&&i.jsx(i.Fragment,{children:g.length===0?i.jsxs("div",{className:"text-center py-12",children:[i.jsx(Zl,{size:40,className:"mx-auto text-text-4 mb-3"}),i.jsx("p",{className:"text-sm text-text-2 font-sans font-medium",children:"Detecting hardware..."}),i.jsx("p",{className:"text-xs text-text-3 font-sans mt-1",children:"Make sure Ollama is installed so we can check your system."})]}):i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"text-xs text-text-3 font-sans mb-2",children:["Top models for your system (",(Q==null?void 0:Q.totalRamGb)||"?"," GB RAM). Click Pull to download via Ollama."]}),g.map(E=>i.jsx(oZ,{model:E,systemRamGb:Q==null?void 0:Q.totalRamGb,onPull:X,pulling:z},E.id))]})}),t==="installed"&&i.jsx(i.Fragment,{children:m.length===0?i.jsxs("div",{className:"text-center py-12",children:[i.jsx(Hf,{size:40,className:"mx-auto text-text-4 mb-3"}),i.jsx("p",{className:"text-sm text-text-2 font-sans font-medium",children:"No local models yet"}),i.jsx("p",{className:"text-xs text-text-3 font-sans mt-1",children:"Search HuggingFace to download GGUF models, or pull models via Ollama."})]}):m.map(E=>i.jsx(lZ,{model:E,onDelete:N},E.id))}),t==="search"&&i.jsx(i.Fragment,{children:d?i.jsxs("div",{className:"text-center py-12",children:[i.jsx(Kn,{size:24,className:"mx-auto text-accent animate-spin mb-3"}),i.jsx("p",{className:"text-sm text-text-3 font-sans",children:"Searching HuggingFace..."})]}):o.length===0?i.jsxs("div",{className:"text-center py-12",children:[i.jsx(un,{size:40,className:"mx-auto text-text-4 mb-3"}),i.jsx("p",{className:"text-sm text-text-2 font-sans font-medium",children:"Search for GGUF models"}),i.jsx("p",{className:"text-xs text-text-3 font-sans mt-1",children:'Try "qwen coder", "deepseek", "codestral", "llama"'})]}):o.map(E=>i.jsxs("div",{className:"space-y-1",children:[i.jsx(rZ,{result:E,expanded:T===E.id,onExpand:k}),T===E.id&&i.jsx(iZ,{repoId:E.id,onDownload:()=>G(),systemRamGb:Q==null?void 0:Q.totalRamGb})]},E.id))})]})})]})}const Rf=[];function BS(t){const n=(t||"").toLowerCase();return n.includes("reading")||n.includes("read ")?{icon:mi,color:"text-info",label:"Reading"}:n.includes("editing")||n.includes("wrote")||n.includes("writing")||n.includes("edit ")?{icon:Cb,color:"text-warning",label:"Editing"}:n.includes("searching")||n.includes("search")||n.includes("grep")||n.includes("glob")?{icon:un,color:"text-purple",label:"Searching"}:n.includes("running")||n.includes("bash")||n.includes("command")||n.includes("exec")?{icon:xi,color:"text-orange",label:"Running"}:n.includes("test")||n.includes("pass")?{icon:mf,color:"text-success",label:"Testing"}:n.includes("error")||n.includes("fail")||n.includes("crash")?{icon:cn,color:"text-danger",label:"Error"}:n.includes("rotat")?{icon:Ll,color:"text-accent",label:"Rotating"}:n.includes("spawn")||n.includes("start")?{icon:Pa,color:"text-success",label:"Spawned"}:n.includes("tool")||n.includes("function")?{icon:qN,color:"text-text-2",label:"Tool"}:n.includes("complet")||n.includes("done")||n.includes("finish")?{icon:mf,color:"text-success",label:"Done"}:{icon:On,color:"text-text-3",label:"Activity"}}function wl({text:t}){return t?t.split(/(\*\*[^*]+\*\*|`[^`]+`)/g).map((n,s)=>n.startsWith("**")&&n.endsWith("**")?i.jsx("strong",{className:"font-semibold text-text-0",children:n.slice(2,-2)},s):n.startsWith("`")&&n.endsWith("`")?i.jsx("code",{className:"px-1 py-px rounded bg-accent/8 text-[11px] font-mono text-accent",children:n.slice(1,-1)},s):i.jsx("span",{children:n},s)):null}function uZ({text:t}){if(!t)return null;const n=[],s=t.split(`
|
|
627
|
+
For more information, see https://radix-ui.com/primitives/docs/components/${n.docsSlug}`;return y.useEffect(()=>{t&&(document.getElementById(t)||console.error(s))},[s,t]),null},U_="DialogDescriptionWarning",G_=({contentRef:t,descriptionId:n})=>{const l=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${XS(U_).contentName}}.`;return y.useEffect(()=>{var u;const o=(u=t.current)==null?void 0:u.getAttribute("aria-describedby");n&&o&&(document.getElementById(n)||console.warn(l))},[l,t,n]),null},_S=yS,ZS=jS,AS=wS,ES=kS,qS=TS,MS=PS,YS=RS;function VS({children:t,...n}){return i.jsx(_S,{...n,children:t})}function US({children:t,className:n,title:s,description:l,...o}){return i.jsxs(ZS,{children:[i.jsx(AS,{className:"fixed inset-0 z-50 bg-black/50 backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0"}),i.jsxs(ES,{className:se("fixed left-1/2 top-1/2 z-50 -translate-x-1/2 -translate-y-1/2","w-full max-w-lg max-h-[85vh] overflow-y-auto","bg-surface-1 border border-border rounded-lg shadow-2xl","data-[state=open]:animate-in data-[state=closed]:animate-out","data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0","data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95",n),...o,children:[s&&i.jsxs("div",{className:"flex items-center justify-between px-5 py-4 border-b border-border-subtle",children:[i.jsx(qS,{className:"text-base font-semibold text-text-0 font-sans",children:s}),i.jsx(YS,{className:"p-1 rounded-md text-text-3 hover:text-text-0 hover:bg-surface-5 transition-colors",children:i.jsx(jt,{size:16})})]}),l&&i.jsx(MS,{className:"sr-only",children:l}),t]})]})}var b0={};function L_({path:t,onNavigate:n}){const s=t.split("/").filter(Boolean);return i.jsxs("div",{className:"flex items-center gap-0.5 min-w-0 overflow-x-auto py-1.5 scrollbar-none",children:[i.jsx("button",{onClick:()=>n("/"),className:"flex-shrink-0 p-1 rounded hover:bg-surface-5 cursor-pointer text-text-3 hover:text-text-0 transition-colors",children:i.jsx(Ff,{size:13})}),s.map((l,o)=>{const u="/"+s.slice(0,o+1).join("/"),d=o===s.length-1;return i.jsxs("div",{className:"flex items-center gap-0.5 flex-shrink-0",children:[i.jsx(Gl,{size:11,className:"text-text-4"}),i.jsx("button",{onClick:()=>n(u),className:se("px-1.5 py-0.5 rounded text-xs font-mono cursor-pointer transition-colors",d?"text-text-0 bg-surface-4 font-medium":"text-text-3 hover:text-text-0 hover:bg-surface-5"),children:l})]},o)})]})}function GS({open:t,onOpenChange:n,currentPath:s,onSelect:l}){const[o,u]=y.useState(s||b0.HOME||"/"),[d,O]=y.useState([]),[m,p]=y.useState(!1),[g,x]=y.useState(null);y.useEffect(()=>{t&&b(s||"/")},[t]);async function b(T){p(!0),x(null);try{const k=await ee.get(`/browse-system?path=${encodeURIComponent(T)}`);u(k.current||T),O(k.dirs||[])}catch(k){x(k.message),O([])}p(!1)}function v(){const T=o==="/"?"/":o.split("/").slice(0,-1).join("/")||"/";b(T)}function Q(){b(b0.HOME||"/Users")}function w(){l(o),n(!1)}return i.jsx(VS,{open:t,onOpenChange:n,children:i.jsx(US,{title:"Select Working Directory",description:"Choose a directory for this agent to work in",className:"max-w-[520px]",children:i.jsxs("div",{className:"px-5 py-4 space-y-3",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("button",{onClick:v,disabled:o==="/",className:"p-1.5 rounded-md bg-surface-4 border border-border text-text-2 hover:text-text-0 hover:bg-surface-5 transition-colors cursor-pointer disabled:opacity-30 disabled:cursor-not-allowed",children:i.jsx(y5,{size:14})}),i.jsx("button",{onClick:Q,className:"p-1.5 rounded-md bg-surface-4 border border-border text-text-2 hover:text-text-0 hover:bg-surface-5 transition-colors cursor-pointer",children:i.jsx(vT,{size:14})}),i.jsx("div",{className:"flex-1 min-w-0 bg-surface-0 rounded-md border border-border-subtle px-2",children:i.jsx(L_,{path:o,onNavigate:b})})]}),i.jsx("div",{className:"bg-surface-0 rounded-lg border border-border-subtle overflow-hidden",children:i.jsxs("div",{className:"max-h-[340px] overflow-y-auto",children:[m&&i.jsx("div",{className:"flex items-center justify-center py-8",children:i.jsx(Kn,{size:18,className:"text-text-3 animate-spin"})}),g&&i.jsx("div",{className:"px-4 py-6 text-center",children:i.jsx("p",{className:"text-xs text-danger font-sans",children:g})}),!m&&!g&&d.length===0&&i.jsx("div",{className:"px-4 py-6 text-center",children:i.jsx("p",{className:"text-xs text-text-3 font-sans",children:"No subdirectories"})}),!m&&!g&&d.map(T=>i.jsxs("button",{onClick:()=>b(T.path),className:se("w-full flex items-center gap-2.5 px-3.5 py-2 text-left cursor-pointer","hover:bg-surface-4 transition-colors border-b border-border-subtle last:border-0"),children:[T.hasChildren?i.jsx(oT,{size:15,className:"text-warning flex-shrink-0"}):i.jsx(ai,{size:15,className:"text-text-3 flex-shrink-0"}),i.jsx("span",{className:"text-sm text-text-0 font-sans truncate flex-1",children:T.name}),T.hasChildren&&i.jsx(Gl,{size:12,className:"text-text-4 flex-shrink-0"})]},T.path))]})}),i.jsxs("div",{className:"flex items-center gap-3 bg-surface-4/50 rounded-lg px-3.5 py-2.5 border border-border-subtle",children:[i.jsx(ai,{size:16,className:"text-accent flex-shrink-0"}),i.jsx("span",{className:"text-xs font-mono text-text-1 truncate flex-1",children:o})]}),i.jsxs("div",{className:"flex justify-end gap-2",children:[i.jsx(be,{variant:"ghost",size:"md",onClick:()=>n(!1),children:"Cancel"}),i.jsxs(be,{variant:"primary",size:"md",onClick:w,className:"gap-1.5",children:[i.jsx(ia,{size:14})," Select Folder"]})]})]})})})}function LS({children:t,...n}){return i.jsx(_S,{...n,children:t})}function DS({children:t,className:n,title:s,side:l="right",width:o=400,...u}){return i.jsxs(ZS,{children:[i.jsx(AS,{className:"fixed inset-0 z-40 bg-black/30"}),i.jsxs(ES,{className:se("fixed top-0 z-50 h-full overflow-y-auto","bg-surface-1 border-l border-border shadow-2xl","data-[state=open]:animate-in data-[state=closed]:animate-out",l==="right"&&"right-0 data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right",l==="left"&&"left-0 data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left",n),style:{width:o},...u,children:[s&&i.jsxs("div",{className:"flex items-center justify-between px-5 py-4 border-b border-border-subtle sticky top-0 bg-surface-1 z-10",children:[i.jsx(qS,{className:"text-base font-semibold text-text-0 font-sans",children:s}),i.jsx(YS,{className:"p-1 rounded-md text-text-3 hover:text-text-0 hover:bg-surface-5 transition-colors cursor-pointer",children:i.jsx(jt,{size:16})})]}),i.jsx(MS,{className:"sr-only",children:"Panel"}),t]})]})}function D_({value:t,onChange:n}){return i.jsx("button",{onClick:()=>n(!t),className:se("w-9 h-5 rounded-full p-0.5 transition-colors cursor-pointer",t?"bg-accent":"bg-surface-5"),children:i.jsx("div",{className:se("w-4 h-4 rounded-full bg-white shadow-sm transition-transform",t?"translate-x-4":"translate-x-0")})})}function W_({user:t}){const[n,s]=y.useState(!1),l=(t==null?void 0:t.avatar)||(t==null?void 0:t.picture)||(t==null?void 0:t.photoURL)||(t==null?void 0:t.photo);return l&&!n?i.jsx("img",{src:l,alt:"",className:"w-6 h-6 rounded-full",referrerPolicy:"no-referrer",crossOrigin:"anonymous",onError:()=>s(!0)}):i.jsx("div",{className:"w-6 h-6 rounded-full bg-accent/10 flex items-center justify-center",children:i.jsx(Hb,{size:12,className:"text-accent"})})}function B_({provider:t,onKeyChange:n}){var T,k,z;const[s,l]=y.useState(!1),[o,u]=y.useState(""),[d,O]=y.useState(!1),[m,p]=y.useState(!1),g=D($=>$.addToast),x=t.authType==="local",b=t.authType==="subscription",v=x||b?t.installed:t.hasKey;async function Q(){if(o.trim())try{await ee.post(`/credentials/${t.id}`,{key:o.trim()}),g("success",`API key set for ${t.name}`),u(""),l(!1),n&&n()}catch($){g("error","Failed to set key",$.message)}}async function w(){try{await ee.delete(`/credentials/${t.id}`),g("info",`Removed ${t.name} key`),n&&n()}catch($){g("error","Remove failed",$.message)}}if(x){const $=((k=(T=t.models)==null?void 0:T.filter(G=>!G.disabled))==null?void 0:k.length)||0,C=()=>D.getState().setActiveView("models");return i.jsxs("div",{className:"flex flex-col rounded-lg border border-border-subtle bg-surface-1 overflow-hidden min-w-[220px]",children:[i.jsxs("div",{className:"flex items-center gap-2.5 px-4 py-3 border-b border-border-subtle",children:[i.jsx($s,{status:v&&$>0?"running":"crashed",size:"sm"}),i.jsx("span",{className:"text-[13px] font-semibold text-text-0 font-sans",children:t.name}),i.jsx("div",{className:"flex-1"}),v&&$>0?i.jsxs(Ze,{variant:"success",className:"text-2xs gap-1",children:[i.jsx(ia,{size:8})," ",$," models"]}):v?i.jsx(Ze,{variant:"warning",className:"text-2xs",children:"No models pulled"}):i.jsx(Ze,{variant:"default",className:"text-2xs",children:"Not set up"})]}),i.jsx("div",{className:"flex-1",children:m?i.jsxs(i.Fragment,{children:[i.jsx(oS,{isInstalled:v,onModelChange:n}),i.jsxs("div",{className:"px-4 py-2 border-t border-border-subtle flex gap-2",children:[i.jsx(be,{variant:"ghost",size:"sm",onClick:()=>p(!1),className:"flex-1 h-7 text-2xs",children:"Back"}),i.jsx(be,{variant:"secondary",size:"sm",onClick:()=>{p(!1),C()},className:"flex-1 h-7 text-2xs gap-1",children:"Models Tab"})]})]}):i.jsxs("div",{className:"px-4 py-3 flex flex-col h-full",children:[i.jsx("div",{className:"text-xs text-text-3 font-sans flex-1",children:v&&$>0?"Full agentic runtime — tool calling, context rotation, zero cloud cost":v?"Ollama is running. Pull a model to start using local agents.":"Run any open-source model locally — free, private, fully offline. Requires Ollama."}),i.jsxs("div",{className:"flex gap-2 mt-3",children:[v?i.jsxs(be,{variant:"primary",size:"sm",onClick:()=>p(!0),className:"flex-1 h-7 text-2xs gap-1.5",children:[i.jsx(Zl,{size:11})," ",$>0?"Manage":"Pull Models"]}):i.jsxs(be,{variant:"primary",size:"sm",onClick:()=>p(!0),className:"flex-1 h-7 text-2xs gap-1.5",children:[i.jsx(Zl,{size:11})," Set Up Ollama"]}),i.jsx(be,{variant:"secondary",size:"sm",onClick:C,className:"flex-1 h-7 text-2xs gap-1.5",children:"Models Tab"})]})]})})]})}return i.jsxs("div",{className:"flex flex-col rounded-lg border border-border-subtle bg-surface-1 overflow-hidden min-w-[220px]",children:[i.jsxs("div",{className:"flex items-center gap-2.5 px-4 py-3 border-b border-border-subtle",children:[i.jsx($s,{status:v?"running":"crashed",size:"sm"}),i.jsx("span",{className:"text-[13px] font-semibold text-text-0 font-sans",children:t.name}),i.jsx("div",{className:"flex-1"}),v?i.jsxs(Ze,{variant:"success",className:"text-2xs gap-1",children:[i.jsx(ia,{size:8})," Ready"]}):i.jsx(Ze,{variant:"default",className:"text-2xs",children:b?"Not installed":"No key"})]}),i.jsxs("div",{className:"flex-1 flex flex-col px-4 py-3 min-h-[120px]",children:[((z=t.models)==null?void 0:z.length)>0&&i.jsx("div",{className:"flex flex-wrap gap-1 mb-3",children:t.models.map($=>i.jsx("span",{className:"px-1.5 py-0.5 rounded bg-surface-4 text-2xs font-mono text-text-3",children:$.name||$.id},$.id))}),b&&v&&!t.hasKey&&!s&&i.jsxs("div",{className:"flex items-center gap-1.5 h-8 px-2.5 bg-accent/8 border border-accent/20 rounded-md text-2xs font-sans text-accent mb-3",children:[i.jsx(ia,{size:10})," Subscription active"]}),t.hasKey&&!s&&i.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[i.jsxs("div",{className:"flex-1 flex items-center gap-1.5 h-8 px-2.5 bg-success/8 border border-success/20 rounded-md text-2xs font-sans text-success",children:[i.jsx(ia,{size:10})," API Connected"]}),i.jsx("button",{onClick:()=>{l(!0),O(!1),u("")},className:"text-2xs text-text-4 hover:text-accent cursor-pointer font-sans",children:"Edit"}),i.jsx("button",{onClick:w,className:"text-2xs text-text-4 hover:text-danger cursor-pointer font-sans",children:"Remove"})]}),i.jsx("div",{className:"flex-1"}),s&&i.jsxs("div",{className:"space-y-2.5 pt-1",children:[i.jsxs("div",{children:[i.jsx("label",{className:"text-2xs font-semibold text-text-2 font-sans mb-1.5 block",children:t.hasKey?"Update API Key":`${t.name} API Key`}),i.jsxs("div",{className:"relative",children:[i.jsx("input",{value:o,onChange:$=>u($.target.value),onKeyDown:$=>$.key==="Enter"&&Q(),type:d?"text":"password",placeholder:"sk-...",className:"w-full h-9 px-3 pr-9 text-xs bg-surface-0 border border-border rounded-md text-text-0 font-mono placeholder:text-text-4 focus:outline-none focus:ring-1 focus:ring-accent",autoFocus:!0}),i.jsx("button",{onClick:()=>O(!d),className:"absolute right-2.5 top-1/2 -translate-y-1/2 text-text-4 hover:text-text-2 cursor-pointer",children:d?i.jsx(If,{size:12}):i.jsx(mi,{size:12})})]})]}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx(be,{variant:"primary",size:"sm",onClick:Q,disabled:!o.trim(),className:"flex-1 h-8 text-xs",children:"Save Key"}),i.jsx(be,{variant:"ghost",size:"sm",onClick:()=>{l(!1),u("")},className:"h-8 text-xs px-3",children:"Cancel"})]})]}),!s&&!t.hasKey&&i.jsxs(be,{variant:b?"secondary":"primary",size:"sm",onClick:()=>{l(!0),O(!1),u("")},className:"w-full h-8 text-2xs gap-1.5 mt-2",children:[i.jsx(vc,{size:11}),b?"Add API key for headless mode":"Add API Key"]})]})]})}function Ql({icon:t,label:n,description:s,children:l}){return i.jsxs("div",{className:"rounded-lg border border-border-subtle bg-surface-1 px-4 py-3.5 flex flex-col gap-2",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("div",{className:"w-6 h-6 rounded bg-accent/8 flex items-center justify-center flex-shrink-0",children:i.jsx(t,{size:12,className:"text-accent"})}),i.jsx("div",{className:"text-[13px] font-medium text-text-0 font-sans leading-tight",children:n})]}),i.jsx("div",{className:"text-2xs text-text-4 font-sans leading-relaxed",children:s}),i.jsx("div",{className:"mt-auto pt-1",children:l})]})}const WS={telegram:th,discord:pi,slack:qb},js={telegram:"Telegram",discord:"Discord",slack:"Slack"},H_={telegram:"Bot token from @BotFather",discord:"Bot token from Developer Portal",slack:"Bot token (xoxb-...)"},I_=["critical","lifecycle","all"];function F_({type:t,open:n,onOpenChange:s}){if(!t)return null;const o={telegram:{title:"Set Up Telegram",icon:th,intro:"Create a Telegram bot and connect it to Groove in under 2 minutes. No dependencies required.",sections:[{title:"Create Your Bot",steps:[{text:"Open Telegram on any device and search for",link:"https://t.me/BotFather",linkText:"@BotFather"},{text:"Send /newbot to start the setup"},{text:"Choose a display name — we suggest GroovePilot"},{text:'Choose a username (must end in "bot") — e.g. GroovePilot_bot'},{text:"BotFather will reply with your bot token — copy it"}]},{title:"Connect to Groove",steps:[{text:"In Groove Settings > Gateways, click Set Token on the Telegram card"},{text:"Paste your bot token and click Save"},{text:"The gateway will connect automatically"}]},{title:"Link a Chat",steps:[{text:"Open a chat with your new bot in Telegram"},{text:'Send any message (e.g. "hello") — Groove captures the chat ID automatically'},{text:"Click Test in the gateway card to verify"}]},{title:"Commands",note:"All commands use / prefix in Telegram:",commands:["/instruct <team> <msg>","/query <team> <question>","/plan <description>","/log <team>","/brief","/tokens","/status","/agents","/help"]}]},discord:{title:"Set Up Discord",icon:pi,intro:"Create a Discord bot and add it to your server. Requires discord.js (installed automatically with Groove).",sections:[{title:"Create the Application",steps:[{text:"Go to the",link:"https://discord.com/developers/applications",linkText:"Discord Developer Portal"},{text:"Click New Application and name it GroovePilot"},{text:"Go to the Bot tab in the left sidebar"},{text:"Click Reset Token and copy the bot token"}]},{title:"Set Permissions & Invite",steps:[{text:"Go to OAuth2 > URL Generator"},{text:"Under Scopes, check bot"},{text:"Under Bot Permissions, check:"}],scopes:["Send Messages","Read Message History","Embed Links","Use External Emojis"],after:[{text:"Copy the generated URL at the bottom and open it in your browser"},{text:"Select your server and click Authorize"}]},{title:"Enable Message Content Intent",steps:[{text:"Go back to the Bot tab in the Developer Portal"},{text:"Scroll to Privileged Gateway Intents"},{text:"Enable Message Content Intent — required for the bot to read commands"},{text:"Click Save Changes"}]},{title:"Connect to Groove",steps:[{text:"In Groove Settings > Gateways, click Set Token on the Discord card"},{text:"Paste your bot token and click Save"},{text:"Send a message in any channel where the bot is — Groove captures the channel automatically"}]},{title:"Commands",note:"All commands use / prefix in Discord:",commands:["/instruct <team> <msg>","/query <team> <question>","/plan <description>","/log <team>","/brief","/tokens","/status","/agents","/help"]}]},slack:{title:"Set Up Slack",icon:qb,intro:"Create a Slack app with Socket Mode — no public URL needed. Requires @slack/bolt (installed automatically with Groove).",sections:[{title:"Create the App",steps:[{text:"Go to",link:"https://api.slack.com/apps",linkText:"api.slack.com/apps"},{text:"Click Create New App > From scratch"},{text:"Name it GroovePilot and select your workspace"}]},{title:"Enable Socket Mode",steps:[{text:"In the left sidebar, go to Settings > Socket Mode"},{text:"Toggle Enable Socket Mode to on"},{text:"It will ask you to create an App-Level Token"},{text:'Name it "groove", add the connections:write scope'},{text:"Click Generate — copy the xapp-... token (this is your App Token)"}],important:"Save this token now — you can't view it again after closing the dialog."},{title:"Set Bot Token Scopes",steps:[{text:"Go to Features > OAuth & Permissions"},{text:"Scroll to Bot Token Scopes and add all of these:"}],scopes:["chat:write","channels:read","channels:history","groups:read","groups:history","im:history","app_mentions:read"],after:[{text:"Scroll up and click Install to Workspace"},{text:"Click Allow to grant permissions"},{text:"Copy the Bot User OAuth Token (xoxb-...) — this is your Bot Token"}]},{title:"Enable Events",steps:[{text:"Go to Features > Event Subscriptions"},{text:"Toggle Enable Events to on"},{text:"Under Subscribe to bot events, add:"}],scopes:["message.channels","message.im","app_mention"],after:[{text:"Click Save Changes at the bottom"}]},{title:"Connect to Groove",steps:[{text:"In Groove Settings > Gateways, click Set Token on the Slack card"},{text:"Paste your Bot Token (xoxb-...) in the first field"},{text:"Paste your App Token (xapp-...) in the second field"},{text:"Click Save — Groove will auto-connect"}]},{title:"Link a Channel",steps:[{text:"Invite the bot to a channel: /invite @GroovePilot"},{text:"Select the channel from the dropdown in the gateway card"},{text:"Or @mention the bot — it will auto-capture the channel"},{text:"Click Test to verify"}],important:"For private channels, make sure you added the groups:read scope."},{title:"Commands",note:"In Slack, use plain text commands (no / prefix) or @mention the bot:",commands:["instruct <team> <msg>","query <team> <question>","plan <description>","log <team>","brief","tokens","status","agents","help","@GroovePilot status"]}]}}[t];if(!o)return null;const u=o.icon;return i.jsx(LS,{open:n,onOpenChange:s,children:i.jsx(DS,{title:o.title,width:480,children:i.jsxs("div",{className:"px-5 py-4 space-y-5",children:[i.jsxs("div",{className:"flex items-start gap-3 p-3 bg-accent/5 border border-accent/15 rounded-lg",children:[i.jsx("div",{className:"w-8 h-8 rounded-lg bg-accent/10 flex items-center justify-center flex-shrink-0 mt-0.5",children:i.jsx(u,{size:16,className:"text-accent"})}),i.jsx("p",{className:"text-xs text-text-2 font-sans leading-relaxed",children:o.intro})]}),o.sections.map((d,O)=>{var m;return i.jsxs("div",{children:[i.jsxs("h3",{className:"text-xs font-semibold text-text-0 font-sans mb-2.5 flex items-center gap-2",children:[i.jsx("span",{className:"w-5 h-5 rounded-full bg-accent/10 flex items-center justify-center text-2xs font-bold text-accent",children:O+1}),d.title]}),d.note&&i.jsx("p",{className:"text-2xs text-text-3 font-sans mb-2",children:d.note}),d.steps&&i.jsx("ol",{className:"space-y-2 mb-2",children:d.steps.map((p,g)=>i.jsxs("li",{className:"flex gap-2 text-2xs text-text-2 font-sans leading-relaxed",children:[i.jsxs("span",{className:"text-text-4 font-mono w-4 flex-shrink-0 pt-px",children:[g+1,"."]}),i.jsxs("span",{children:[p.text,p.link&&i.jsxs(i.Fragment,{children:[" ",i.jsxs("a",{href:p.link,target:"_blank",rel:"noopener noreferrer",className:"text-accent hover:underline inline-flex items-center gap-0.5 font-medium",children:[p.linkText,i.jsx(bc,{size:9})]})]})]})]},g))}),d.scopes&&i.jsx("div",{className:"flex flex-wrap gap-1.5 mb-2 ml-6",children:d.scopes.map(p=>i.jsx("code",{className:"px-2 py-0.5 rounded bg-surface-4 text-2xs font-mono text-accent",children:p},p))}),d.after&&i.jsx("ol",{className:"space-y-2 mb-2",start:(((m=d.steps)==null?void 0:m.length)||0)+1,children:d.after.map((p,g)=>{var x;return i.jsxs("li",{className:"flex gap-2 text-2xs text-text-2 font-sans leading-relaxed",children:[i.jsxs("span",{className:"text-text-4 font-mono w-4 flex-shrink-0 pt-px",children:[(((x=d.steps)==null?void 0:x.length)||0)+g+1,"."]}),i.jsx("span",{children:p.text})]},g)})}),d.important&&i.jsx("div",{className:"ml-6 p-2 bg-warning/8 border border-warning/20 rounded-md text-2xs text-warning font-sans",children:d.important}),d.commands&&i.jsx("div",{className:"ml-6 p-2.5 bg-surface-0 border border-border-subtle rounded-md space-y-1",children:d.commands.map(p=>i.jsx("code",{className:"block text-2xs font-mono text-text-1",children:p},p))})]},O)}),i.jsxs("a",{href:"https://docs.groovedev.ai/guide/gateways",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 text-2xs text-accent hover:text-accent/80 font-sans font-medium mt-2",children:[i.jsx(bc,{size:10}),"Full documentation at docs.groovedev.ai"]})]})})})}function K_({gateway:t,onRefresh:n}){var ce,re;const[s,l]=y.useState(!1),[o,u]=y.useState(""),[d,O]=y.useState(""),[m,p]=y.useState(!1),[g,x]=y.useState(!1),[b,v]=y.useState(!1),[Q,w]=y.useState([]),[T,k]=y.useState(!1),z=D(F=>F.addToast);y.useEffect(()=>{t.connected&&!t.chatId&&t.type==="slack"&&ee.get(`/gateways/${t.id}/channels`).then(F=>w(Array.isArray(F)?F:[])).catch(()=>{})},[t.connected,t.chatId,t.id,t.type]);const $=WS[t.type]||eh,C=t.type==="slack";async function G(){if(o.trim())try{await ee.post(`/gateways/${t.id}/credentials`,{key:"bot_token",value:o.trim()}),C&&d.trim()&&await ee.post(`/gateways/${t.id}/credentials`,{key:"app_token",value:d.trim()}),z("success","Token saved — connecting..."),u(""),O(""),l(!1);try{await ee.post(`/gateways/${t.id}/connect`),z("success",`${js[t.type]} connected!`)}catch(F){z("error","Token saved but connect failed",F.message)}n()}catch(F){z("error","Failed to save token",F.message)}}async function X(){x(!0);try{await ee.post(`/gateways/${t.id}/test`),z("success","Test message sent!")}catch(F){z("error","Test failed",F.message)}x(!1)}async function _(){v(!0);try{t.connected?(await ee.post(`/gateways/${t.id}/disconnect`),z("info",`${js[t.type]} disconnected`)):(await ee.post(`/gateways/${t.id}/connect`),z("success",`${js[t.type]} connected!`)),n()}catch(F){z("error",t.connected?"Disconnect failed":"Connect failed",F.message)}v(!1)}async function N(F){try{await ee.patch(`/gateways/${t.id}`,{enabled:F}),n()}catch(P){z("error","Update failed",P.message)}}async function E(F){try{await ee.patch(`/gateways/${t.id}`,{notifications:{preset:F}}),n()}catch(P){z("error","Update failed",P.message)}}async function Y(F){try{await ee.patch(`/gateways/${t.id}`,{commandPermission:F}),n()}catch(P){z("error","Update failed",P.message)}}async function ne(){try{await ee.delete(`/gateways/${t.id}`),z("info",`${js[t.type]} gateway removed`),n()}catch(F){z("error","Delete failed",F.message)}}const oe=((ce=t.notifications)==null?void 0:ce.preset)||"critical";return i.jsxs("div",{className:"flex flex-col rounded-lg border border-border-subtle bg-surface-1 overflow-hidden min-w-[220px]",children:[i.jsxs("div",{className:"flex items-center gap-2.5 px-4 py-3 border-b border-border-subtle",children:[i.jsx($s,{status:t.connected?"running":"crashed",size:"sm"}),i.jsx($,{size:13,className:"text-text-2"}),i.jsx("span",{className:"text-[13px] font-semibold text-text-0 font-sans",children:js[t.type]}),i.jsx("div",{className:"flex-1"}),t.connected?i.jsxs(Ze,{variant:"success",className:"text-2xs gap-1",children:[i.jsx(a1,{size:8})," Connected"]}):t.enabled?i.jsx(Ze,{variant:"warning",className:"text-2xs",children:"Disconnected"}):i.jsx(Ze,{variant:"default",className:"text-2xs",children:"Disabled"})]}),i.jsxs("div",{className:"flex-1 flex flex-col px-4 py-3 min-h-[140px]",children:[t.connected&&!s&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"flex items-center gap-1.5 h-8 px-2.5 bg-success/8 border border-success/20 rounded-md text-2xs font-sans text-success mb-3",children:[i.jsx(ia,{size:10})," Gateway active",t.botUsername&&i.jsxs("span",{className:"text-text-4 ml-1",children:["@",t.botUsername]}),t.botTag&&i.jsx("span",{className:"text-text-4 ml-1",children:t.botTag})]}),i.jsxs("div",{className:"mb-3",children:[i.jsx("label",{className:"text-2xs font-semibold text-text-3 font-sans mb-1.5 block",children:t.type==="slack"?"Channel":"Chat ID"}),t.chatId?i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("code",{className:"flex-1 flex items-center h-7 px-2 bg-surface-0 border border-border-subtle rounded-md text-2xs font-mono text-text-2",children:t.type==="slack"&&Q.length>0?`#${((re=Q.find(F=>F.id===t.chatId))==null?void 0:re.name)||t.chatId}`:t.chatId}),i.jsx("button",{onClick:async()=>{try{await ee.patch(`/gateways/${t.id}`,{chatId:null}),n()}catch(F){z("error","Failed",F.message)}},className:"text-2xs text-text-4 hover:text-text-1 cursor-pointer font-sans",children:"Change"})]}):t.type==="slack"&&Q.length>0?i.jsxs("select",{onChange:async F=>{if(F.target.value)try{await ee.patch(`/gateways/${t.id}`,{chatId:F.target.value}),n()}catch(P){z("error","Failed to set channel",P.message)}},className:"w-full h-7 px-2 text-2xs bg-surface-0 border border-border-subtle rounded-md text-text-0 font-sans focus:outline-none focus:ring-1 focus:ring-accent cursor-pointer",defaultValue:"",children:[i.jsx("option",{value:"",disabled:!0,children:"Select a channel..."}),Q.map(F=>i.jsxs("option",{value:F.id,children:["#",F.name]},F.id))]}):i.jsxs("div",{className:"text-2xs text-warning font-sans",children:[t.type==="slack"?"No channels found — invite the bot to a channel first.":"Send a message to the bot to auto-capture, or enter manually:",i.jsx("input",{placeholder:t.type==="slack"?"C0123456789":"Chat ID",className:"mt-1 w-full h-7 px-2 text-2xs bg-surface-0 border border-border rounded-md text-text-0 font-mono placeholder:text-text-4 focus:outline-none focus:ring-1 focus:ring-accent",onKeyDown:async F=>{if(F.key==="Enter"&&F.target.value.trim())try{await ee.patch(`/gateways/${t.id}`,{chatId:F.target.value.trim()}),n()}catch(P){z("error","Failed to set channel",P.message)}}})]})]}),i.jsxs("div",{className:"mb-3",children:[i.jsx("label",{className:"text-2xs font-semibold text-text-3 font-sans mb-1.5 block",children:"Notifications"}),i.jsx("div",{className:"flex bg-surface-0 rounded-md p-0.5 border border-border-subtle",children:I_.map(F=>i.jsx("button",{onClick:()=>E(F),className:se("flex-1 px-2 py-1.5 text-2xs font-semibold font-sans rounded transition-all cursor-pointer capitalize",oe===F?"bg-accent/15 text-accent shadow-sm":"text-text-3 hover:text-text-1"),children:F},F))})]}),i.jsxs("div",{className:"mb-3",children:[i.jsx("label",{className:"text-2xs font-semibold text-text-3 font-sans mb-1.5 block",children:"Commands"}),i.jsx("div",{className:"flex bg-surface-0 rounded-md p-0.5 border border-border-subtle",children:["full","read-only"].map(F=>i.jsx("button",{onClick:()=>Y(F),className:se("flex-1 px-2 py-1.5 text-2xs font-semibold font-sans rounded transition-all cursor-pointer capitalize",(t.commandPermission||"full")===F?"bg-accent/15 text-accent shadow-sm":"text-text-3 hover:text-text-1"),children:F==="full"?"Full Access":"Read Only"},F))})]})]}),!t.connected&&!s&&i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"text-xs text-text-3 font-sans mb-2",children:t.enabled?t.hasCredentials?"Tokens saved — click Connect.":"Configure bot token to connect.":"Gateway is disabled."}),!t.hasCredentials&&i.jsxs("button",{onClick:()=>k(!0),className:"flex items-center gap-1.5 text-2xs text-accent hover:text-accent/80 font-sans font-medium cursor-pointer mb-2",children:[i.jsx(gc,{size:11}),"How to set up",i.jsx(bc,{size:9})]})]}),i.jsx(F_,{type:t.type,open:T,onOpenChange:k}),i.jsx("div",{className:"flex-1"}),s&&i.jsxs("div",{className:"space-y-2.5 pt-1",children:[i.jsxs("button",{onClick:()=>k(!0),className:"flex items-center gap-1.5 text-2xs text-accent hover:text-accent/80 font-sans font-medium cursor-pointer",children:[i.jsx(gc,{size:11}),"Where do I get these?"]}),i.jsxs("div",{children:[i.jsx("label",{className:"text-2xs font-semibold text-text-2 font-sans mb-1.5 block",children:"Bot Token"}),i.jsxs("div",{className:"relative",children:[i.jsx("input",{value:o,onChange:F=>u(F.target.value),onKeyDown:F=>F.key==="Enter"&&!C&&G(),type:m?"text":"password",placeholder:H_[t.type],className:"w-full h-9 px-3 pr-9 text-xs bg-surface-0 border border-border rounded-md text-text-0 font-mono placeholder:text-text-4 focus:outline-none focus:ring-1 focus:ring-accent",autoFocus:!0}),i.jsx("button",{onClick:()=>p(!m),className:"absolute right-2.5 top-1/2 -translate-y-1/2 text-text-4 hover:text-text-2 cursor-pointer",children:m?i.jsx(If,{size:12}):i.jsx(mi,{size:12})})]})]}),C&&i.jsxs("div",{children:[i.jsx("label",{className:"text-2xs font-semibold text-text-2 font-sans mb-1.5 block",children:"App Token (Socket Mode)"}),i.jsx("input",{value:d,onChange:F=>O(F.target.value),onKeyDown:F=>F.key==="Enter"&&G(),type:m?"text":"password",placeholder:"xapp-...",className:"w-full h-9 px-3 text-xs bg-surface-0 border border-border rounded-md text-text-0 font-mono placeholder:text-text-4 focus:outline-none focus:ring-1 focus:ring-accent"})]}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx(be,{variant:"primary",size:"sm",onClick:G,disabled:!o.trim(),className:"flex-1 h-8 text-xs",children:"Save Token"}),i.jsx(be,{variant:"ghost",size:"sm",onClick:()=>{l(!1),u(""),O("")},className:"h-8 text-xs px-3",children:"Cancel"})]})]}),!s&&i.jsxs("div",{className:"flex gap-2 mt-2",children:[!t.connected&&i.jsxs(be,{variant:"primary",size:"sm",onClick:()=>l(!0),className:"flex-1 h-7 text-2xs gap-1.5",children:[i.jsx(vc,{size:11}),t.enabled?"Set Token":"Configure"]}),t.connected&&i.jsxs(i.Fragment,{children:[i.jsxs(be,{variant:"secondary",size:"sm",onClick:X,disabled:g,className:"flex-1 h-7 text-2xs gap-1.5",children:[i.jsx(nh,{size:11}),g?"Sending...":"Test"]}),i.jsx(be,{variant:"secondary",size:"sm",onClick:()=>l(!0),className:"h-7 text-2xs px-2.5",children:i.jsx(vc,{size:11})})]}),i.jsx(be,{variant:"ghost",size:"sm",onClick:_,disabled:b,className:"h-7 text-2xs px-2.5",title:t.connected?"Disconnect":"Connect",children:t.connected?i.jsx(Vb,{size:11}):i.jsx(a1,{size:11})}),i.jsx(D_,{value:t.enabled,onChange:N}),i.jsx("button",{onClick:ne,className:"text-text-4 hover:text-danger cursor-pointer p-1",title:"Remove gateway",children:i.jsx(Dl,{size:11})})]})]})]})}function J_({existingTypes:t,onAdd:n}){const[s,l]=y.useState(!1),o=["telegram","discord","slack"].filter(u=>!t.includes(u));return o.length===0?null:s?i.jsxs("div",{className:"flex flex-col rounded-lg border border-accent/30 bg-surface-1 overflow-hidden min-w-[220px]",children:[i.jsxs("div",{className:"flex items-center gap-2.5 px-4 py-3 border-b border-border-subtle",children:[i.jsx(eh,{size:13,className:"text-accent"}),i.jsx("span",{className:"text-[13px] font-semibold text-text-0 font-sans",children:"Add Gateway"}),i.jsx("div",{className:"flex-1"}),i.jsx("button",{onClick:()=>l(!1),className:"text-text-4 hover:text-text-1 cursor-pointer",children:i.jsx(jt,{size:12})})]}),i.jsx("div",{className:"p-3 space-y-2",children:o.map(u=>{const d=WS[u];return i.jsxs("button",{onClick:()=>{n(u),l(!1)},className:"w-full flex items-center gap-3 px-3 py-2.5 rounded-md bg-surface-0 hover:bg-accent/8 border border-border-subtle hover:border-accent/20 cursor-pointer transition-all group",children:[i.jsx(d,{size:14,className:"text-text-3 group-hover:text-accent"}),i.jsx("span",{className:"text-xs font-medium text-text-1 group-hover:text-accent font-sans",children:js[u]})]},u)})})]}):i.jsxs("button",{onClick:()=>l(!0),className:"flex flex-col items-center justify-center rounded-lg border border-dashed border-border-subtle bg-surface-1/50 hover:bg-surface-1 hover:border-accent/30 min-h-[140px] min-w-[220px] cursor-pointer transition-all group",children:[i.jsx("div",{className:"w-8 h-8 rounded-full bg-accent/8 group-hover:bg-accent/15 flex items-center justify-center mb-2 transition-colors",children:i.jsx(Jn,{size:14,className:"text-accent"})}),i.jsx("span",{className:"text-2xs font-semibold text-text-3 group-hover:text-text-1 font-sans transition-colors",children:"Add Gateway"})]})}function eZ(){const[t,n]=y.useState([]),[s,l]=y.useState(null),[o,u]=y.useState(null),[d,O]=y.useState([]),[m,p]=y.useState(!0),[g,x]=y.useState(!1),b=D(_=>_.addToast),v=D(_=>_.marketplaceUser),Q=D(_=>_.marketplaceAuthenticated),w=D(_=>_.marketplaceLogin),T=D(_=>_.marketplaceLogout);function k(){ee.get("/providers").then(_=>n(Array.isArray(_)?_:[])).catch(()=>{})}function z(){ee.get("/gateways").then(_=>O(Array.isArray(_)?_:[])).catch(()=>{})}y.useEffect(()=>{Promise.all([ee.get("/providers"),ee.get("/config"),ee.get("/status"),ee.get("/gateways")]).then(([_,N,E,Y])=>{n(Array.isArray(_)?_:[]),l(N),u(E),O(Array.isArray(Y)?Y:[]),p(!1)}).catch(()=>p(!1))},[]);async function $(_){try{await ee.post("/gateways",{type:_}),b("success",`${js[_]} gateway added`),z()}catch(N){b("error","Failed to add gateway",N.message)}}async function C(_,N){try{const E=await ee.patch("/config",{[_]:N});l(E)}catch(E){b("error","Update failed",E.message)}}if(m)return i.jsxs("div",{className:"flex flex-col h-full",children:[i.jsx("div",{className:"h-12 bg-surface-1 border-b border-border"}),i.jsxs("div",{className:"flex-1 p-4 space-y-4",children:[i.jsx("div",{className:"grid grid-cols-4 gap-3",children:[...Array(4)].map((_,N)=>i.jsx(ra,{className:"h-40 rounded-lg"},N))}),i.jsx("div",{className:"grid grid-cols-3 gap-3",children:[...Array(6)].map((_,N)=>i.jsx(ra,{className:"h-28 rounded-lg"},N))})]})]});const G=t.filter(_=>_.authType==="local"||_.authType==="subscription"?_.installed:_.hasKey).length,X=(s==null?void 0:s.rotationThreshold)||0;return i.jsxs("div",{className:"flex flex-col h-full",children:[i.jsxs("div",{className:"flex items-center gap-4 px-4 py-2.5 bg-surface-1 border-b border-border flex-shrink-0",children:[i.jsx("h2",{className:"text-sm font-semibold text-text-0 font-sans",children:"Settings"}),i.jsx("div",{className:"flex-1"}),i.jsxs("div",{className:"flex items-center gap-4 text-2xs text-text-3 font-sans",children:[(o==null?void 0:o.version)&&i.jsxs("span",{children:["v",o.version]}),(o==null?void 0:o.port)&&i.jsxs("span",{children:[":",o.port]}),(o==null?void 0:o.uptime)>0&&i.jsxs("span",{children:["Up ",Dc(o.uptime)]})]}),i.jsx("div",{className:"w-px h-4 bg-border-subtle"}),Q?i.jsxs("div",{className:"flex items-center gap-2.5",children:[i.jsx(W_,{user:v}),i.jsx("span",{className:"text-xs font-medium text-text-0 font-sans",children:(v==null?void 0:v.displayName)||"User"}),i.jsxs("button",{onClick:T,className:"text-2xs text-text-4 hover:text-text-1 cursor-pointer font-sans flex items-center gap-1",children:[i.jsx(Eb,{size:10})," Sign out"]})]}):i.jsxs(be,{variant:"ghost",size:"sm",onClick:w,className:"h-7 text-2xs gap-1.5 text-text-3",children:[i.jsx(Kf,{size:11})," Sign in"]}),i.jsx($s,{status:"running",size:"sm"})]}),i.jsx(fn,{className:"flex-1",children:i.jsxs("div",{className:"p-4 space-y-4",children:[i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center gap-2 mb-2.5 px-0.5",children:[i.jsx("span",{className:"text-2xs font-semibold text-text-3 font-sans uppercase tracking-wider",children:"Providers"}),i.jsx("div",{className:"flex-1 h-px bg-border-subtle"}),i.jsxs("span",{className:"text-2xs text-text-4 font-sans",children:[G,"/",t.length," connected"]})]}),i.jsx("div",{className:"grid grid-cols-4 gap-3",children:t.map(_=>i.jsx(B_,{provider:_,onKeyChange:k},_.id))})]}),i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center gap-2 mb-2.5 px-0.5",children:[i.jsx("span",{className:"text-2xs font-semibold text-text-3 font-sans uppercase tracking-wider",children:"Gateways"}),i.jsx("div",{className:"flex-1 h-px bg-border-subtle"}),i.jsxs("span",{className:"text-2xs text-text-4 font-sans",children:[d.filter(_=>_.connected).length,"/",d.length," connected"]})]}),i.jsxs("div",{className:"grid grid-cols-4 gap-3",children:[d.map(_=>i.jsx(K_,{gateway:_,onRefresh:z},_.id)),i.jsx(J_,{existingTypes:d.map(_=>_.type),onAdd:$})]})]}),s&&i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center gap-2 mb-2.5 px-0.5",children:[i.jsx("span",{className:"text-2xs font-semibold text-text-3 font-sans uppercase tracking-wider",children:"Configuration"}),i.jsx("div",{className:"flex-1 h-px bg-border-subtle"}),i.jsx("span",{className:"text-2xs text-text-4 font-sans",children:"Auto-saves"})]}),i.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[i.jsx(Ql,{icon:Zl,label:"Default Provider",description:"Provider used when spawning new agents.",children:i.jsx("select",{value:s.defaultProvider||"claude-code",onChange:_=>C("defaultProvider",_.target.value),className:"w-full h-8 px-2.5 text-xs bg-surface-0 border border-border-subtle rounded-md text-text-0 font-mono focus:outline-none focus:ring-1 focus:ring-accent cursor-pointer",children:t.filter(_=>_.installed||_.hasKey).map(_=>i.jsx("option",{value:_.id,children:_.name},_.id))})}),i.jsx(Ql,{icon:ai,label:"Working Directory",description:"Default root directory for new agents.",children:i.jsxs("div",{className:"flex items-center gap-1.5",children:[i.jsx("code",{className:"flex-1 h-8 px-2 flex items-center bg-surface-0 border border-border-subtle rounded-md text-2xs font-mono text-text-2 truncate min-w-0",children:s.defaultWorkingDir||"Project root"}),i.jsx(be,{variant:"secondary",size:"sm",onClick:()=>x(!0),className:"h-8 px-2 flex-shrink-0",children:i.jsx(Xb,{size:12})})]})}),i.jsx(Ql,{icon:Zb,label:"Rotation Threshold",description:"Context usage that triggers auto-rotation.",children:i.jsx("div",{className:"flex bg-surface-0 rounded-md p-0.5 border border-border-subtle",children:["auto","50%","65%","75%","85%"].map(_=>{const N=_==="auto"?0:parseInt(_,10)/100,E=X===N;return i.jsx("button",{onClick:()=>C("rotationThreshold",N),className:se("flex-1 px-2 py-1.5 text-2xs font-semibold font-sans rounded transition-all cursor-pointer",E?"bg-accent/15 text-accent shadow-sm":"text-text-3 hover:text-text-1"),children:_==="auto"?"Auto":_},_)})})}),i.jsx(Ql,{icon:Wb,label:"QC Threshold",description:"Running agents count that triggers auto-QC.",children:i.jsx("div",{className:"flex bg-surface-0 rounded-md p-0.5 border border-border-subtle",children:[2,3,4,6,8].map(_=>{const N=(s.qcThreshold||2)===_;return i.jsx("button",{onClick:()=>C("qcThreshold",_),className:se("flex-1 px-2 py-1.5 text-2xs font-semibold font-sans rounded transition-all cursor-pointer",N?"bg-accent/15 text-accent shadow-sm":"text-text-3 hover:text-text-1"),children:_},_)})})}),i.jsx(Ql,{icon:bi,label:"Max Agents",description:"Concurrent agent limit. 0 = unlimited.",children:i.jsx("div",{className:"flex bg-surface-0 rounded-md p-0.5 border border-border-subtle",children:[0,4,8,12,20].map(_=>{const N=(s.maxAgents||0)===_;return i.jsx("button",{onClick:()=>C("maxAgents",_),className:se("flex-1 px-2 py-1.5 text-2xs font-semibold font-sans rounded transition-all cursor-pointer",N?"bg-accent/15 text-accent shadow-sm":"text-text-3 hover:text-text-1"),children:_===0?"∞":_},_)})})}),i.jsx(Ql,{icon:ni,label:"Journalist Interval",description:"Seconds between synthesis cycles.",children:i.jsx("div",{className:"flex bg-surface-0 rounded-md p-0.5 border border-border-subtle",children:[60,120,300,600].map(_=>{const N=(s.journalistInterval||120)===_,E=_<60?`${_}s`:`${_/60}m`;return i.jsx("button",{onClick:()=>C("journalistInterval",_),className:se("flex-1 px-2 py-1.5 text-2xs font-semibold font-sans rounded transition-all cursor-pointer",N?"bg-accent/15 text-accent shadow-sm":"text-text-3 hover:text-text-1"),children:E},_)})})})]})]})]})}),i.jsx(GS,{open:g,onOpenChange:x,currentPath:(s==null?void 0:s.defaultWorkingDir)||"/",onSelect:_=>C("defaultWorkingDir",_)})]})}const zf=y.forwardRef(({className:t,label:n,error:s,mono:l,...o},u)=>i.jsxs("div",{className:"flex flex-col gap-1",children:[n&&i.jsx("label",{className:"text-xs font-medium text-text-2 font-sans",children:n}),i.jsx("input",{ref:u,className:se("h-8 w-full rounded-md px-3 text-sm","bg-surface-1 border border-border text-text-0","placeholder:text-text-4","focus:outline-none focus:ring-1 focus:ring-accent focus:border-accent","disabled:opacity-40 disabled:cursor-not-allowed","transition-colors duration-100",l?"font-mono":"font-sans",s&&"border-danger focus:ring-danger",t),...o}),s&&i.jsx("span",{className:"text-2xs text-danger font-sans",children:s})]}));zf.displayName="Input";const tZ=y.forwardRef(({className:t,label:n,error:s,mono:l,...o},u)=>i.jsxs("div",{className:"flex flex-col gap-1",children:[n&&i.jsx("label",{className:"text-xs font-medium text-text-2 font-sans",children:n}),i.jsx("textarea",{ref:u,className:se("w-full rounded-md px-3 py-2 text-sm resize-none","bg-surface-1 border border-border text-text-0","placeholder:text-text-4","focus:outline-none focus:ring-1 focus:ring-accent focus:border-accent","disabled:opacity-40 disabled:cursor-not-allowed","transition-colors duration-100",l?"font-mono":"font-sans",s&&"border-danger focus:ring-danger",t),...o}),s&&i.jsx("span",{className:"text-2xs text-danger font-sans",children:s})]}));tZ.displayName="Textarea";function Cc(t){return t?t<1024*1024?`${(t/1024).toFixed(0)} KB`:t<1024*1024*1024?`${(t/(1024*1024)).toFixed(1)} MB`:`${(t/(1024*1024*1024)).toFixed(2)} GB`:"—"}function aZ(t){return t?t<1024*1024?`${(t/1024).toFixed(0)} KB/s`:`${(t/(1024*1024)).toFixed(1)} MB/s`:""}function nZ({hardware:t}){var n;return t?i.jsxs("div",{className:"flex items-center gap-4 px-4 py-2.5 bg-surface-1 border border-border-subtle rounded-lg text-xs font-sans text-text-2",children:[i.jsxs("div",{className:"flex items-center gap-1.5",children:[i.jsx(ZT,{size:14,className:"text-text-3"}),i.jsxs("span",{children:[t.totalRamGb," GB RAM"]})]}),i.jsxs("div",{className:"flex items-center gap-1.5",children:[i.jsx(Zl,{size:14,className:"text-text-3"}),i.jsxs("span",{children:[t.cores," cores"]})]}),t.gpu&&i.jsxs("div",{className:"flex items-center gap-1.5",children:[i.jsx(Ff,{size:14,className:"text-text-3"}),i.jsxs("span",{children:[t.gpu.name,t.gpu.vram?` (${t.gpu.vram} GB)`:""]})]}),((n=t.recommended)==null?void 0:n.code)&&i.jsxs("div",{className:"ml-auto text-accent",children:["Recommended: ",t.recommended.code]})]}):null}function sZ({download:t}){const n=Math.round((t.percent||0)*100);return i.jsxs("div",{className:"space-y-1",children:[i.jsxs("div",{className:"flex items-center justify-between text-2xs font-sans text-text-3",children:[i.jsx("span",{children:t.filename}),i.jsxs("span",{children:[n,"% ",aZ(t.speed)]})]}),i.jsx("div",{className:"h-1.5 bg-surface-3 rounded-full overflow-hidden",children:i.jsx("div",{className:"h-full bg-accent rounded-full transition-all",style:{width:`${n}%`}})}),i.jsxs("div",{className:"text-2xs text-text-4",children:[Cc(t.downloaded)," / ",Cc(t.totalBytes)]})]})}function lZ({model:t,onDelete:n}){const[s,l]=y.useState(!1),o={light:"text-green-400",medium:"text-blue-400",heavy:"text-orange-400"};return i.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 bg-surface-1 border border-border-subtle rounded-lg",children:[i.jsx(Hf,{size:18,className:"text-accent flex-shrink-0"}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-sm font-mono font-bold text-text-0 truncate",children:t.id}),t.quantization&&i.jsx(Ze,{variant:"subtle",className:"text-2xs",children:t.quantization}),t.parameters&&i.jsx(Ze,{variant:"subtle",className:"text-2xs",children:t.parameters}),i.jsx("span",{className:se("text-2xs font-medium capitalize",o[t.tier]||"text-text-3"),children:t.tier})]}),i.jsxs("div",{className:"text-2xs text-text-3 font-sans mt-0.5",children:[Cc(t.sizeBytes)," · ctx ",(t.contextWindow||0).toLocaleString()," · ",t.category,t.repoId&&i.jsxs("span",{className:"text-text-4",children:[" · ",t.repoId]})]})]}),i.jsx("button",{onClick:async()=>{l(!0),await n(t.id),l(!1)},disabled:s,className:"p-1.5 rounded-md text-text-4 hover:text-red-400 hover:bg-red-400/10 transition-colors",children:s?i.jsx(Kn,{size:14,className:"animate-spin"}):i.jsx(Dl,{size:14})})]})}function rZ({result:t,onExpand:n,expanded:s}){var l;return i.jsxs("button",{onClick:()=>n(s?null:t.id),className:"w-full text-left px-4 py-3 bg-surface-1 border border-border-subtle rounded-lg hover:border-accent/30 transition-colors cursor-pointer",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-sm font-mono font-bold text-text-0 truncate flex-1",children:t.name}),i.jsx("span",{className:"text-2xs text-text-4 font-sans",children:t.author}),s?i.jsx(on,{size:14,className:"text-text-3"}):i.jsx(Gl,{size:14,className:"text-text-3"})]}),i.jsxs("div",{className:"text-2xs text-text-3 font-sans mt-0.5 flex gap-3",children:[i.jsxs("span",{children:[(l=t.downloads)==null?void 0:l.toLocaleString()," downloads"]}),i.jsxs("span",{children:[t.likes," likes"]})]})]})}function iZ({repoId:t,onDownload:n,systemRamGb:s}){const[l,o]=y.useState(null),[u,d]=y.useState(!0),[O,m]=y.useState(null),p=Wl();y.useEffect(()=>{d(!0),ee.get(`/models/${t}/files`).then(x=>o(x.files||[])).catch(()=>p.error("Failed to load model files")).finally(()=>d(!1))},[t]);async function g(x){m(x.filename);try{await ee.post("/models/download",{repoId:t,filename:x.filename}),p.success(`Downloading ${x.filename}`),n==null||n(x.filename)}catch(b){p.error(b.message)}m(null)}return u?i.jsx("div",{className:"py-3 px-4 text-2xs text-text-4 font-sans",children:"Loading quantization variants..."}):l!=null&&l.length?i.jsx("div",{className:"pl-6 pr-4 pb-2 space-y-1.5",children:l.map(x=>{const b=!x.estimatedRamGb||!s||x.estimatedRamGb<=s,v=x.estimatedRamGb&&s&&x.estimatedRamGb>s*.8&&b;return i.jsxs("div",{className:se("flex items-center gap-2 py-1.5 px-3 rounded-md text-xs font-sans",b?"bg-surface-2":"bg-red-500/5 border border-red-500/15"),children:[i.jsx("span",{className:"font-mono text-text-1 truncate flex-1",children:x.filename}),x.quantization&&i.jsx(Ze,{variant:"subtle",className:"text-2xs",children:x.quantization}),i.jsx("span",{className:"text-text-2 text-2xs w-16 text-right",children:Cc(x.size)}),x.estimatedRamGb&&i.jsxs("span",{className:se("text-2xs w-20 text-right font-medium",b?v?"text-yellow-400":"text-green-400":"text-red-400"),children:["~",x.estimatedRamGb," GB RAM"]}),!b&&i.jsx("span",{className:"text-2xs text-red-400 font-medium",children:"too large"}),i.jsx("button",{onClick:()=>g(x),disabled:O===x.filename||!b,className:se("p-1 rounded transition-colors",b?"text-accent hover:bg-accent/10":"text-text-4 cursor-not-allowed","disabled:opacity-40"),children:O===x.filename?i.jsx(Kn,{size:13,className:"animate-spin"}):i.jsx(hi,{size:13})})]},x.filename)})}):i.jsx("div",{className:"py-3 px-4 text-2xs text-text-4 font-sans",children:"No GGUF files found in this repo."})}function oZ({model:t,systemRamGb:n,onPull:s,pulling:l}){const o={light:"text-green-400",medium:"text-blue-400",heavy:"text-orange-400"},u={code:"{}",general:"AI"},d=n?Math.round((1-t.ramGb/n)*100):null;return i.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 bg-surface-1 border border-border-subtle rounded-lg hover:border-accent/20 transition-colors",children:[i.jsx("div",{className:"w-9 h-9 rounded-lg bg-surface-3 flex items-center justify-center text-xs font-mono text-text-2 flex-shrink-0",children:u[t.category]||"AI"}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-sm font-mono font-bold text-text-0 truncate",children:t.name}),i.jsx("span",{className:se("text-2xs font-semibold capitalize",o[t.tier]),children:t.tier})]}),i.jsx("div",{className:"text-2xs text-text-3 font-sans mt-0.5",children:t.description}),i.jsxs("div",{className:"flex items-center gap-3 mt-1 text-2xs font-sans",children:[i.jsxs("span",{className:"text-text-2",children:[t.sizeGb," GB download"]}),i.jsxs("span",{className:"text-green-400 font-medium",children:[t.ramGb," GB RAM"]}),d!==null&&i.jsxs("span",{className:"text-text-4",children:[d,"% headroom"]})]})]}),i.jsxs("button",{onClick:()=>s(t.id),disabled:l===t.id,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-md text-xs font-sans font-medium bg-accent/10 text-accent hover:bg-accent/20 transition-colors cursor-pointer disabled:opacity-40",children:[l===t.id?i.jsx(Kn,{size:12,className:"animate-spin"}):i.jsx(hi,{size:12}),"Pull"]})]})}function cZ(){const[t,n]=y.useState("recommended"),[s,l]=y.useState(""),[o,u]=y.useState([]),[d,O]=y.useState(!1),[m,p]=y.useState([]),[g,x]=y.useState([]),[b,v]=y.useState([]),[Q,w]=y.useState(null),[T,k]=y.useState(null),[z,$]=y.useState(null),C=Wl(),G=y.useCallback(()=>{ee.get("/models/installed").then(E=>{p(E.models||[])}).catch(()=>{})},[]);y.useEffect(()=>{ee.get("/providers/ollama/hardware").then(w).catch(()=>{}),ee.get("/models/recommended").then(E=>{x(E.models||[]),!Q&&E.hardware&&w(E.hardware)}).catch(()=>{}),G()},[G]);async function X(E){$(E);try{await ee.post("/providers/ollama/pull",{model:E}),C.success(`${E} pulled successfully`),G()}catch(Y){C.error(`Pull failed: ${Y.message}`)}$(null)}y.useEffect(()=>{const E=D.subscribe((ne,oe)=>{}),Y=setInterval(()=>{ee.get("/models/downloads").then(v).catch(()=>{})},2e3);return()=>{E(),clearInterval(Y)}},[]),y.useEffect(()=>{function E(ne){try{const oe=JSON.parse(ne.data);oe.type==="model:download:progress"&&v(ce=>{const re=ce.findIndex(F=>F.filename===oe.data.filename);if(re>=0){const F=[...ce];return F[re]=oe.data,F}return[...ce,oe.data]}),oe.type==="model:download:complete"&&(v(ce=>ce.filter(re=>re.filename!==oe.data.filename)),G(),C.success(`${oe.data.filename} downloaded`)),oe.type==="model:download:error"&&(v(ce=>ce.filter(re=>re.filename!==oe.data.filename)),C.error(`Download failed: ${oe.data.error}`))}catch{}}const Y=D.getState()._ws;return Y&&Y.addEventListener("message",E),()=>{Y&&Y.removeEventListener("message",E)}},[G,C]);async function _(){if(s.trim()){O(!0),n("search");try{const E=await ee.get(`/models/search?q=${encodeURIComponent(s.trim())}`);u(E)}catch(E){C.error(E.message)}O(!1)}}async function N(E){try{await ee.delete(`/models/${E}`),p(Y=>Y.filter(ne=>ne.id!==E)),C.success("Model deleted")}catch(Y){C.error(Y.message)}}return i.jsxs("div",{className:"h-full flex flex-col bg-surface-0",children:[i.jsxs("div",{className:"flex-shrink-0 px-5 pt-4 pb-3 border-b border-border space-y-3",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("h1",{className:"text-base font-bold font-sans text-text-0",children:"Local Models"}),i.jsxs(Ze,{variant:"subtle",className:"text-2xs",children:[m.length," installed"]})]}),i.jsx(nZ,{hardware:Q}),i.jsxs("div",{className:"flex gap-2",children:[i.jsxs("div",{className:"relative flex-1",children:[i.jsx(un,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-text-4"}),i.jsx("input",{value:s,onChange:E=>l(E.target.value),onKeyDown:E=>E.key==="Enter"&&_(),placeholder:"Search HuggingFace for GGUF models...",className:"w-full h-8 pl-9 pr-3 text-sm rounded-md bg-surface-1 border border-border text-text-0 font-sans placeholder:text-text-4 focus:outline-none focus:ring-1 focus:ring-accent"})]}),i.jsx(be,{onClick:_,disabled:d,size:"sm",variant:"accent",children:d?i.jsx(Kn,{size:14,className:"animate-spin"}):"Search"})]}),i.jsx("div",{className:"flex gap-1",children:[{id:"recommended",label:`Recommended (${g.length})`},{id:"installed",label:`Installed (${m.length})`},{id:"search",label:`Search (${o.length})`}].map(E=>i.jsx("button",{onClick:()=>n(E.id),className:se("px-3 py-1 rounded-md text-xs font-sans font-medium transition-colors cursor-pointer",t===E.id?"bg-accent/12 text-accent":"text-text-3 hover:text-text-1 hover:bg-surface-3"),children:E.label},E.id))})]}),b.length>0&&i.jsxs("div",{className:"px-5 py-3 border-b border-border space-y-2",children:[i.jsx("div",{className:"text-xs font-sans font-semibold text-text-2",children:"Downloading"}),b.map(E=>i.jsx(sZ,{download:E},E.filename))]}),i.jsx(fn,{className:"flex-1",children:i.jsxs("div",{className:"px-5 py-4 space-y-2",children:[t==="recommended"&&i.jsx(i.Fragment,{children:g.length===0?i.jsxs("div",{className:"text-center py-12",children:[i.jsx(Zl,{size:40,className:"mx-auto text-text-4 mb-3"}),i.jsx("p",{className:"text-sm text-text-2 font-sans font-medium",children:"Detecting hardware..."}),i.jsx("p",{className:"text-xs text-text-3 font-sans mt-1",children:"Make sure Ollama is installed so we can check your system."})]}):i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"text-xs text-text-3 font-sans mb-2",children:["Top models for your system (",(Q==null?void 0:Q.totalRamGb)||"?"," GB RAM). Click Pull to download via Ollama."]}),g.map(E=>i.jsx(oZ,{model:E,systemRamGb:Q==null?void 0:Q.totalRamGb,onPull:X,pulling:z},E.id))]})}),t==="installed"&&i.jsx(i.Fragment,{children:m.length===0?i.jsxs("div",{className:"text-center py-12",children:[i.jsx(Hf,{size:40,className:"mx-auto text-text-4 mb-3"}),i.jsx("p",{className:"text-sm text-text-2 font-sans font-medium",children:"No local models yet"}),i.jsx("p",{className:"text-xs text-text-3 font-sans mt-1",children:"Search HuggingFace to download GGUF models, or pull models via Ollama."})]}):m.map(E=>i.jsx(lZ,{model:E,onDelete:N},E.id))}),t==="search"&&i.jsx(i.Fragment,{children:d?i.jsxs("div",{className:"text-center py-12",children:[i.jsx(Kn,{size:24,className:"mx-auto text-accent animate-spin mb-3"}),i.jsx("p",{className:"text-sm text-text-3 font-sans",children:"Searching HuggingFace..."})]}):o.length===0?i.jsxs("div",{className:"text-center py-12",children:[i.jsx(un,{size:40,className:"mx-auto text-text-4 mb-3"}),i.jsx("p",{className:"text-sm text-text-2 font-sans font-medium",children:"Search for GGUF models"}),i.jsx("p",{className:"text-xs text-text-3 font-sans mt-1",children:'Try "qwen coder", "deepseek", "codestral", "llama"'})]}):o.map(E=>i.jsxs("div",{className:"space-y-1",children:[i.jsx(rZ,{result:E,expanded:T===E.id,onExpand:k}),T===E.id&&i.jsx(iZ,{repoId:E.id,onDownload:()=>G(),systemRamGb:Q==null?void 0:Q.totalRamGb})]},E.id))})]})})]})}const Rf=[];function BS(t){const n=(t||"").toLowerCase();return n.includes("reading")||n.includes("read ")?{icon:mi,color:"text-info",label:"Reading"}:n.includes("editing")||n.includes("wrote")||n.includes("writing")||n.includes("edit ")?{icon:Cb,color:"text-warning",label:"Editing"}:n.includes("searching")||n.includes("search")||n.includes("grep")||n.includes("glob")?{icon:un,color:"text-purple",label:"Searching"}:n.includes("running")||n.includes("bash")||n.includes("command")||n.includes("exec")?{icon:xi,color:"text-orange",label:"Running"}:n.includes("test")||n.includes("pass")?{icon:mf,color:"text-success",label:"Testing"}:n.includes("error")||n.includes("fail")||n.includes("crash")?{icon:cn,color:"text-danger",label:"Error"}:n.includes("rotat")?{icon:Ll,color:"text-accent",label:"Rotating"}:n.includes("spawn")||n.includes("start")?{icon:Pa,color:"text-success",label:"Spawned"}:n.includes("tool")||n.includes("function")?{icon:qN,color:"text-text-2",label:"Tool"}:n.includes("complet")||n.includes("done")||n.includes("finish")?{icon:mf,color:"text-success",label:"Done"}:{icon:On,color:"text-text-3",label:"Activity"}}function wl({text:t}){return t?t.split(/(\*\*[^*]+\*\*|`[^`]+`)/g).map((n,s)=>n.startsWith("**")&&n.endsWith("**")?i.jsx("strong",{className:"font-semibold text-text-0",children:n.slice(2,-2)},s):n.startsWith("`")&&n.endsWith("`")?i.jsx("code",{className:"px-1 py-px rounded bg-accent/8 text-[11px] font-mono text-accent",children:n.slice(1,-1)},s):i.jsx("span",{children:n},s)):null}function uZ({text:t}){if(!t)return null;const n=[],s=t.split(`
|
|
628
628
|
`);let l=0;for(;l<s.length;){const o=s[l];if(o.trimStart().startsWith("```")){const d=[],O=o.trim().slice(3);for(l++;l<s.length&&!s[l].trimStart().startsWith("```");)d.push(s[l]),l++;l++,n.push({type:"code",content:d.join(`
|
|
629
629
|
`),lang:O});continue}if(/^#{1,3}\s/.test(o)||/^\*\*[^*]+:\*\*\s*$/.test(o.trim())){const d=o.replace(/^#+\s*/,"").replace(/^\*\*/,"").replace(/:\*\*\s*$/,":").trim();n.push({type:"heading",content:d}),l++;continue}if(/^\s*[-*]\s/.test(o)){const d=[];for(;l<s.length&&/^\s*[-*]\s/.test(s[l]);)d.push(s[l].replace(/^\s*[-*]\s+/,"").trim()),l++;n.push({type:"list",items:d});continue}if(/^\s*\d+[\.)]\s/.test(o)){const d=[];for(;l<s.length&&/^\s*\d+[\.)]\s/.test(s[l]);)d.push(s[l].replace(/^\s*\d+[\.)]\s+/,"").trim()),l++;n.push({type:"numbered",items:d});continue}if(!o.trim()){l++;continue}if(/^(Note|Warning|Important|IMPORTANT|TODO):/i.test(o.trim())){n.push({type:"note",content:o.trim()}),l++;continue}const u=[];for(;l<s.length&&s[l].trim()&&!/^#{1,3}\s/.test(s[l])&&!/^\s*[-*]\s/.test(s[l])&&!/^\s*\d+[\.)]\s/.test(s[l])&&!s[l].trimStart().startsWith("```");)u.push(s[l].trim()),l++;u.length>0&&n.push({type:"para",content:u.join(" ")})}return i.jsx("div",{className:"space-y-2",children:n.map((o,u)=>{switch(o.type){case"heading":return i.jsxs("div",{className:"flex items-center gap-1.5 pt-1.5 first:pt-0",children:[i.jsx("div",{className:"w-1 h-3.5 rounded-full bg-accent/40 flex-shrink-0"}),i.jsx("span",{className:"text-[12px] font-semibold text-text-0 font-sans",children:i.jsx(wl,{text:o.content})})]},u);case"list":return i.jsx("div",{className:"space-y-1 pl-2",children:o.items.map((d,O)=>i.jsxs("div",{className:"flex gap-2 text-[12px] text-text-0 font-sans leading-relaxed",children:[i.jsx("span",{className:"text-accent/50 mt-0.5 flex-shrink-0",children:"-"}),i.jsx("span",{className:"min-w-0",children:i.jsx(wl,{text:d})})]},O))},u);case"numbered":return i.jsx("div",{className:"space-y-1 pl-2",children:o.items.map((d,O)=>i.jsxs("div",{className:"flex gap-2 text-[12px] text-text-0 font-sans leading-relaxed",children:[i.jsxs("span",{className:"text-text-4 font-mono w-4 text-right flex-shrink-0",children:[O+1,"."]}),i.jsx("span",{className:"min-w-0",children:i.jsx(wl,{text:d})})]},O))},u);case"code":return i.jsx("pre",{className:"p-2.5 rounded-md bg-[#0d1117] text-[11px] font-mono text-[#c9d1d9] overflow-x-auto whitespace-pre-wrap border border-white/[0.06] leading-relaxed",children:o.content},u);case"note":return i.jsxs("div",{className:"flex items-start gap-1.5 px-2.5 py-1.5 rounded-md bg-warning/6 border border-warning/12",children:[i.jsx(cn,{size:10,className:"text-warning mt-0.5 flex-shrink-0"}),i.jsx("span",{className:"text-[11px] text-warning/80 font-sans",children:i.jsx(wl,{text:o.content})})]},u);case"para":default:return i.jsx("p",{className:"text-[12px] text-text-0 font-sans leading-relaxed",children:i.jsx(wl,{text:o.content})},u)}})})}function dZ({text:t}){if(!t)return null;const n=t.split(/(```[\s\S]*?```)/g);return i.jsx("span",{children:n.map((s,l)=>{if(s.startsWith("```")&&s.endsWith("```")){const o=s.slice(3,-3).replace(/^\w+\n/,"");return i.jsx("pre",{className:"my-1.5 p-2 rounded-md bg-[#0d1117] text-[11px] font-mono text-[#c9d1d9] overflow-x-auto whitespace-pre-wrap border border-white/[0.06]",children:o},l)}return i.jsx("span",{children:i.jsx(wl,{text:s})},l)})})}function OZ({msg:t}){const n=t.isQuery;return i.jsx("div",{className:"flex justify-end pl-8",children:i.jsxs("div",{className:"max-w-[90%]",children:[n&&i.jsxs("div",{className:"flex items-center justify-end gap-1 mb-1",children:[i.jsx(gc,{size:9,className:"text-info"}),i.jsx("span",{className:"text-2xs text-info font-sans font-medium",children:"Query"})]}),i.jsx("div",{className:se("px-3.5 py-2.5 rounded-lg border","bg-info/10 border-info/25"),children:i.jsx("div",{className:"text-[12px] font-sans whitespace-pre-wrap break-words leading-relaxed text-text-0",children:i.jsx(dZ,{text:t.text})})}),i.jsx("div",{className:"text-[10px] text-text-4 font-sans mt-1 text-right",children:vt(t.timestamp)})]})})}function fZ({msg:t,agent:n}){var u,d;const[s,l]=y.useState(((u=t.text)==null?void 0:u.length)>600),o=((d=t.text)==null?void 0:d.length)>600;return i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[i.jsx("span",{className:"text-2xs font-semibold text-text-1 font-sans",children:(n==null?void 0:n.name)||"Agent"}),i.jsx("span",{className:"text-2xs text-text-4 font-sans",children:n==null?void 0:n.role}),i.jsx("span",{className:"text-[10px] text-text-4 font-sans ml-auto",children:vt(t.timestamp)})]}),i.jsx("div",{className:"border-l border-accent pl-3.5 py-1",children:i.jsx(uZ,{text:s?t.text.slice(0,600)+"...":t.text})}),s&&i.jsxs("button",{onClick:()=>l(!1),className:"ml-3.5 mt-1.5 flex items-center gap-1.5 text-[11px] text-accent/70 hover:text-accent font-sans font-medium cursor-pointer transition-colors",children:[i.jsx(on,{size:11}),"Show full response"]}),o&&!s&&i.jsxs("button",{onClick:()=>l(!0),className:"ml-3.5 mt-1.5 flex items-center gap-1.5 text-[11px] text-accent/70 hover:text-accent font-sans font-medium cursor-pointer transition-colors",children:[i.jsx(on,{size:11,className:"rotate-180"}),"Collapse"]})]})}function hZ({msg:t}){return i.jsxs("div",{className:"flex items-center gap-3 py-2",children:[i.jsx("div",{className:"flex-1 h-px bg-border-subtle"}),i.jsx("span",{className:"text-[10px] text-text-4 font-sans flex-shrink-0 uppercase tracking-wide",children:t.text}),i.jsx("div",{className:"flex-1 h-px bg-border-subtle"})]})}function mZ({entries:t,isLive:n}){var d;const[s,l]=y.useState(0);if(y.useEffect(()=>{if(!n||t.length<=1)return;const O=setInterval(()=>l(m=>(m+1)%t.length),1500);return()=>clearInterval(O)},[t.length,n]),!n){const O=t[t.length-1],p=BS(O.text).icon;return i.jsxs("div",{className:"ml-7 flex items-center gap-2 px-3 py-1 text-[10px] text-text-4 font-mono",children:[i.jsx(p,{size:10,className:"opacity-50"}),i.jsxs("span",{className:"truncate",children:[t.length," tool call",t.length!==1?"s":""]})]})}const o=t[Math.min(s,t.length-1)],u=((d=o.text)==null?void 0:d.length)>60?o.text.slice(0,60)+"...":o.text;return i.jsxs("div",{className:"ml-7 flex items-center gap-2 px-3 py-2 rounded-md bg-surface-3/50 border border-border-subtle/30",children:[i.jsx(Kn,{size:11,className:"text-accent animate-spin flex-shrink-0"}),i.jsx("span",{className:"text-[11px] text-text-2 font-mono truncate flex-1 min-w-0 transition-opacity duration-300",children:u}),t.length>1&&i.jsx("span",{className:"text-[10px] text-text-4 font-mono flex-shrink-0",children:t.length})]})}function pZ({agent:t}){const n=D(m=>m.activityLog[t.id])||Rf,s=n[n.length-1],l=s?BS(s.text):null,o=(l==null?void 0:l.icon)||On,u=s&&Date.now()-s.timestamp<1e4,d=u&&s.text?s.text.length>60?s.text.slice(0,60)+"...":s.text:null,O=Math.round((t.contextUsage||0)*100);return i.jsxs("div",{className:"flex items-center gap-3 px-4 h-8 border-b border-border-subtle bg-surface-1/80 flex-shrink-0",children:[i.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[i.jsxs("div",{className:"relative flex items-center justify-center w-4 h-4",children:[i.jsx("span",{className:"absolute inset-0 rounded-full bg-accent/15 animate-ping",style:{animationDuration:"2s"}}),i.jsx("span",{className:"relative w-1.5 h-1.5 rounded-full bg-accent"})]}),u?i.jsxs(i.Fragment,{children:[i.jsx(o,{size:10,className:se(l.color,"flex-shrink-0")}),i.jsx("span",{className:"text-[11px] text-text-2 font-sans truncate",children:d})]}):i.jsx("span",{className:"text-[11px] text-text-3 font-sans",children:"Working..."})]}),i.jsxs("div",{className:"flex items-center gap-3 flex-shrink-0",children:[i.jsx("span",{className:"text-[10px] text-text-4 font-mono",children:xZ(t.tokensUsed)}),i.jsxs("div",{className:"flex items-center gap-1.5",children:[i.jsx("div",{className:"w-14 h-1 rounded-full bg-surface-4 overflow-hidden",children:i.jsx("div",{className:"h-full rounded-full transition-all duration-500",style:{width:`${O}%`,background:O>=75?"var(--color-danger)":O>=50?"var(--color-warning)":"var(--color-accent)"}})}),i.jsxs("span",{className:"text-[10px] text-text-4 font-mono w-7 text-right",children:[O,"%"]})]})]})]})}function xZ(t){return t?t>=1e6?(t/1e6).toFixed(1)+"M":t>=1e3?(t/1e3).toFixed(1)+"K":String(t):"0"}function gZ({agent:t}){const[n,s]=y.useState([]),l=[{text:`Initializing ${t.name}`,delay:0},{text:`Role: ${t.role}`,delay:400},{text:`Provider: ${t.provider||"claude-code"}`,delay:700},{text:"Loading workspace context",delay:1e3},{text:"Scanning project structure",delay:1400},{text:"Session active",delay:1900}];return y.useEffect(()=>{const o=l.map((u,d)=>setTimeout(()=>s(O=>[...O,d]),u.delay));return()=>o.forEach(clearTimeout)},[]),i.jsxs("div",{className:"flex flex-col px-4 pt-6",children:[i.jsxs("div",{className:"flex items-center gap-3 mb-5",children:[i.jsxs("div",{className:"relative w-9 h-9",children:[i.jsx("span",{className:"absolute inset-0 rounded-full border-2 border-accent/20 animate-ping",style:{animationDuration:"2s"}}),i.jsx("span",{className:"absolute inset-0 rounded-full border-2 border-transparent border-t-accent animate-spin",style:{animationDuration:"1s"}}),i.jsx("span",{className:"absolute inset-[5px] rounded-full bg-accent/8"})]}),i.jsxs("div",{children:[i.jsx("p",{className:"text-sm font-bold text-text-0 font-sans",children:t.name}),i.jsx("p",{className:"text-2xs text-accent font-mono",children:"starting up"})]})]}),i.jsx("div",{className:"space-y-2 pl-3 border-l border-accent/15",children:l.map((o,u)=>{const d=n.includes(u),O=u===l.length-1;return i.jsxs("div",{className:se("flex items-center gap-2.5 transition-all duration-300",d?"opacity-100 translate-x-0":"opacity-0 -translate-x-2"),children:[i.jsx("span",{className:se("w-1 h-1 rounded-full flex-shrink-0",O&&d?"bg-accent":d?"bg-text-3":"bg-transparent")}),i.jsx("span",{className:se("text-[11px] font-mono",O&&d?"text-accent":"text-text-3"),children:o.text}),O&&d&&i.jsxs("span",{className:"flex gap-0.5 ml-1",children:[i.jsx("span",{className:"w-1 h-1 rounded-full bg-accent animate-pulse",style:{animationDelay:"0ms"}}),i.jsx("span",{className:"w-1 h-1 rounded-full bg-accent animate-pulse",style:{animationDelay:"200ms"}}),i.jsx("span",{className:"w-1 h-1 rounded-full bg-accent animate-pulse",style:{animationDelay:"400ms"}})]})]},u)})})]})}function bZ({agent:t}){const n=D($=>$.chatHistory[t.id])||Rf,s=D($=>$.activityLog[t.id])||Rf,l=D($=>$.instructAgent),o=D($=>$.queryAgent),[u,d]=y.useState(""),[O,m]=y.useState("instruct"),[p,g]=y.useState(!1),x=y.useRef(null),b=y.useRef(null),v=y.useRef(null),Q=y.useMemo(()=>{var E;const $=[],C=new Set;for(const Y of n){const ne=`${Y.from}:${(E=Y.text)==null?void 0:E.slice(0,100)}`;$.find(ce=>{var re;return ce.kind==="chat"&&`${ce.from}:${(re=ce.text)==null?void 0:re.slice(0,100)}`===ne&&Math.abs(ce.ts-Y.timestamp)<5e3})||($.push({...Y,kind:"chat",ts:Y.timestamp}),C.add(Y.text))}const G=C,X=s.slice(-30);for(const Y of X)(Y.text||"").trim()&&!G.has(Y.text)&&$.push({...Y,kind:"activity",ts:Y.timestamp});$.sort((Y,ne)=>Y.ts-ne.ts);const _=[];let N=[];for(const Y of $)Y.kind==="activity"?N.push(Y):(N.length>0&&(_.push({kind:"activity-group",entries:N}),N=[]),_.push(Y));return N.length>0&&_.push({kind:"activity-group",entries:N}),_},[n,s]);y.useEffect(()=>{x.current&&requestAnimationFrame(()=>{x.current&&(x.current.scrollTop=x.current.scrollHeight)})},[Q.length]);async function w($){var _;const C=Array.from($.target.files||[]);if(C.length===0)return;const G=D.getState().addToast,X=[];for(const N of C)try{const E=await new Promise((Y,ne)=>{const oe=new FileReader;oe.onload=()=>Y(oe.result.split(",")[1]),oe.onerror=ne,oe.readAsDataURL(N)});await ee.post(`/agents/${t.id}/upload`,{filename:N.name,content:E}),X.push(N.name)}catch(E){G("error",`Upload failed: ${N.name}`,E.message)}if(X.length>0){const N=X.join(", ");d(E=>(E?E+`
|
|
630
630
|
`:"")+`[Uploaded: ${N}] — I've uploaded these files to your working directory. Read them and use their content.`),G("success",`Uploaded ${X.length} file${X.length>1?"s":""}`)}$.target.value="",(_=b.current)==null||_.focus()}async function T(){var C;const $=u.trim();if(!(!$||p)){if($==="/rotate"){const G=D.getState().rotateAgent;d("");try{await G(t.id)}catch{}return}d(""),g(!0);try{O==="query"?await o(t.id,$):await l(t.id,$)}catch{}g(!1),(C=b.current)==null||C.focus()}}function k($){$.key==="Enter"&&!$.shiftKey&&($.preventDefault(),T())}const z=t.status==="running"||t.status==="starting";return i.jsxs("div",{className:"flex flex-col h-full min-h-0",children:[z&&i.jsx(pZ,{agent:t}),i.jsxs("div",{ref:x,className:"flex-1 overflow-y-auto px-4 py-4 space-y-4",children:[!Q.some($=>$.from==="agent"||$.kind==="activity-group")&&(z?i.jsx(gZ,{agent:t}):i.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-center py-8",children:[i.jsx("div",{className:"w-10 h-10 rounded-xl bg-surface-3 flex items-center justify-center mb-3",children:i.jsx(pi,{size:18,className:"text-text-4"})}),i.jsx("p",{className:"text-sm font-semibold text-text-0 font-sans",children:t.name}),i.jsx("p",{className:"text-xs text-text-3 font-sans mt-1",children:"Session complete — send a message to continue"})]})),Q.map(($,C)=>{if($.kind==="activity-group"){const G=!Q.slice(C+1).some(X=>X.kind==="activity-group"||X.from==="agent");return i.jsx(mZ,{entries:$.entries,isLive:z&&G},`grp-${C}`)}return $.from==="user"?i.jsx(OZ,{msg:$},`msg-${C}`):$.from==="system"?i.jsx(hZ,{msg:$},`msg-${C}`):i.jsx(fZ,{msg:$,agent:t},`msg-${C}`)}),p&&i.jsxs("div",{className:"flex items-center gap-2 ml-7 py-2",children:[i.jsx("div",{className:"w-5 h-5 rounded-md bg-accent/12 flex items-center justify-center",children:i.jsx(On,{size:10,className:"text-accent"})}),i.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-2 rounded-2xl bg-surface-2/60 border border-border-subtle",children:[i.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-accent/60 animate-pulse",style:{animationDelay:"0ms"}}),i.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-accent/60 animate-pulse",style:{animationDelay:"200ms"}}),i.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-accent/60 animate-pulse",style:{animationDelay:"400ms"}})]})]})]}),i.jsxs("div",{className:"border-t border-border px-4 py-3 bg-surface-1/50 flex-shrink-0",children:[i.jsxs("div",{className:"flex items-center gap-1 mb-2",children:[i.jsxs("button",{onClick:()=>m("instruct"),className:se("flex items-center gap-1.5 px-2.5 py-1 rounded-md text-[11px] font-sans font-medium transition-colors cursor-pointer",O==="instruct"?"bg-accent/12 text-accent border border-accent/20":"text-text-3 hover:text-text-1 hover:bg-surface-3"),children:[i.jsx(Gc,{size:10}),"Instruct"]}),i.jsxs("button",{onClick:()=>m("query"),className:se("flex items-center gap-1.5 px-2.5 py-1 rounded-md text-[11px] font-sans font-medium transition-colors cursor-pointer",O==="query"?"bg-info/12 text-info border border-info/20":"text-text-3 hover:text-text-1 hover:bg-surface-3"),children:[i.jsx(gc,{size:10}),"Query"]}),i.jsx("span",{className:"text-[10px] text-text-4 font-sans ml-auto",children:O==="query"?"Read-only — agent keeps working":z?"Directs the agent":"Continues the session"})]}),i.jsxs("div",{className:se("flex items-end gap-1 rounded-xl border bg-surface-0 p-1 transition-colors",O==="query"?"border-info/20 focus-within:border-info/40":"border-border-subtle focus-within:border-accent/30"),children:[i.jsx("input",{ref:v,type:"file",multiple:!0,accept:".pdf,.png,.jpg,.jpeg,.gif,.svg,.csv,.txt,.md,.json,.yaml,.yml,.docx,.pptx,.xlsx",onChange:w,className:"hidden"}),i.jsx("button",{onClick:()=>{var $;return($=v.current)==null?void 0:$.click()},className:"w-9 h-9 flex items-center justify-center rounded-lg text-text-4 hover:text-text-1 hover:bg-surface-3 transition-colors cursor-pointer flex-shrink-0 mb-px",title:"Attach file",children:i.jsx(BT,{size:14})}),i.jsx("textarea",{ref:b,value:u,onChange:$=>d($.target.value),onKeyDown:k,placeholder:O==="query"?"Ask about this agent's work...":z?"Send an instruction...":"Continue this session...",rows:1,className:se("flex-1 resize-none px-3 py-2 text-[13px]","bg-transparent text-text-0 font-sans","placeholder:text-text-4","focus:outline-none","max-h-[120px] min-h-[36px]"),style:{height:Math.min(Math.max(36,u.split(`
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
6
|
<link rel="icon" type="image/png" href="/favicon.png" />
|
|
7
7
|
<title>Groove GUI</title>
|
|
8
|
-
<script type="module" crossorigin src="/assets/index-
|
|
8
|
+
<script type="module" crossorigin src="/assets/index-PPbrScja.js"></script>
|
|
9
9
|
<link rel="modulepreload" crossorigin href="/assets/vendor-C0HXlhrU.js">
|
|
10
10
|
<link rel="modulepreload" crossorigin href="/assets/reactflow-BQPfi37R.js">
|
|
11
11
|
<link rel="modulepreload" crossorigin href="/assets/codemirror-BBL3i_JW.js">
|
|
@@ -162,8 +162,8 @@ function FilePicker({ repoId, onDownload, systemRamGb }) {
|
|
|
162
162
|
return (
|
|
163
163
|
<div className="pl-6 pr-4 pb-2 space-y-1.5">
|
|
164
164
|
{files.map((f) => {
|
|
165
|
-
const canRun = !f.estimatedRamGb || !systemRamGb || f.estimatedRamGb <= systemRamGb
|
|
166
|
-
const tight = f.estimatedRamGb && systemRamGb && f.estimatedRamGb > systemRamGb * 0.
|
|
165
|
+
const canRun = !f.estimatedRamGb || !systemRamGb || f.estimatedRamGb <= systemRamGb;
|
|
166
|
+
const tight = f.estimatedRamGb && systemRamGb && f.estimatedRamGb > systemRamGb * 0.8 && canRun;
|
|
167
167
|
return (
|
|
168
168
|
<div key={f.filename} className={cn(
|
|
169
169
|
'flex items-center gap-2 py-1.5 px-3 rounded-md text-xs font-sans',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "groove-dev",
|
|
3
|
-
"version": "0.26.
|
|
3
|
+
"version": "0.26.7",
|
|
4
4
|
"description": "Open-source agent orchestration layer — the AI company OS. Local model agent engine (GGUF/Ollama/llama-server), HuggingFace model browser, MCP integrations (Slack, Gmail, Stripe, 15+), agent scheduling (cron), business roles (CMO, CFO, EA). GUI dashboard, multi-agent coordination, zero cold-start, infinite sessions. Works with Claude Code, Codex, Gemini CLI, Ollama, any local model.",
|
|
5
5
|
"license": "FSL-1.1-Apache-2.0",
|
|
6
6
|
"author": "Groove Dev <hello@groovedev.ai> (https://groovedev.ai)",
|
|
@@ -301,10 +301,10 @@ export function createApi(app, daemon) {
|
|
|
301
301
|
app.get('/api/models/recommended', (req, res) => {
|
|
302
302
|
const hardware = OllamaProvider.getSystemHardware();
|
|
303
303
|
const catalog = OllamaProvider.catalog;
|
|
304
|
-
// Filter to models that fit in RAM
|
|
305
|
-
|
|
304
|
+
// Filter to models that fit in RAM — same threshold as hardware recommendation
|
|
305
|
+
// Apple Silicon unified memory handles these well, no aggressive headroom needed
|
|
306
306
|
const recommended = catalog
|
|
307
|
-
.filter((m) => m.ramGb <=
|
|
307
|
+
.filter((m) => m.ramGb <= hardware.totalRamGb)
|
|
308
308
|
.sort((a, b) => b.ramGb - a.ramGb) // Biggest that fits = best quality
|
|
309
309
|
.slice(0, 12);
|
|
310
310
|
res.json({ models: recommended, hardware });
|
|
@@ -624,7 +624,7 @@ Error generating stack: `+c.message+`
|
|
|
624
624
|
|
|
625
625
|
If you want to hide the \`${n.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
626
626
|
|
|
627
|
-
For more information, see https://radix-ui.com/primitives/docs/components/${n.docsSlug}`;return y.useEffect(()=>{t&&(document.getElementById(t)||console.error(s))},[s,t]),null},U_="DialogDescriptionWarning",G_=({contentRef:t,descriptionId:n})=>{const l=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${XS(U_).contentName}}.`;return y.useEffect(()=>{var u;const o=(u=t.current)==null?void 0:u.getAttribute("aria-describedby");n&&o&&(document.getElementById(n)||console.warn(l))},[l,t,n]),null},_S=yS,ZS=jS,AS=wS,ES=kS,qS=TS,MS=PS,YS=RS;function VS({children:t,...n}){return i.jsx(_S,{...n,children:t})}function US({children:t,className:n,title:s,description:l,...o}){return i.jsxs(ZS,{children:[i.jsx(AS,{className:"fixed inset-0 z-50 bg-black/50 backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0"}),i.jsxs(ES,{className:se("fixed left-1/2 top-1/2 z-50 -translate-x-1/2 -translate-y-1/2","w-full max-w-lg max-h-[85vh] overflow-y-auto","bg-surface-1 border border-border rounded-lg shadow-2xl","data-[state=open]:animate-in data-[state=closed]:animate-out","data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0","data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95",n),...o,children:[s&&i.jsxs("div",{className:"flex items-center justify-between px-5 py-4 border-b border-border-subtle",children:[i.jsx(qS,{className:"text-base font-semibold text-text-0 font-sans",children:s}),i.jsx(YS,{className:"p-1 rounded-md text-text-3 hover:text-text-0 hover:bg-surface-5 transition-colors",children:i.jsx(jt,{size:16})})]}),l&&i.jsx(MS,{className:"sr-only",children:l}),t]})]})}var b0={};function L_({path:t,onNavigate:n}){const s=t.split("/").filter(Boolean);return i.jsxs("div",{className:"flex items-center gap-0.5 min-w-0 overflow-x-auto py-1.5 scrollbar-none",children:[i.jsx("button",{onClick:()=>n("/"),className:"flex-shrink-0 p-1 rounded hover:bg-surface-5 cursor-pointer text-text-3 hover:text-text-0 transition-colors",children:i.jsx(Ff,{size:13})}),s.map((l,o)=>{const u="/"+s.slice(0,o+1).join("/"),d=o===s.length-1;return i.jsxs("div",{className:"flex items-center gap-0.5 flex-shrink-0",children:[i.jsx(Gl,{size:11,className:"text-text-4"}),i.jsx("button",{onClick:()=>n(u),className:se("px-1.5 py-0.5 rounded text-xs font-mono cursor-pointer transition-colors",d?"text-text-0 bg-surface-4 font-medium":"text-text-3 hover:text-text-0 hover:bg-surface-5"),children:l})]},o)})]})}function GS({open:t,onOpenChange:n,currentPath:s,onSelect:l}){const[o,u]=y.useState(s||b0.HOME||"/"),[d,O]=y.useState([]),[m,p]=y.useState(!1),[g,x]=y.useState(null);y.useEffect(()=>{t&&b(s||"/")},[t]);async function b(T){p(!0),x(null);try{const k=await ee.get(`/browse-system?path=${encodeURIComponent(T)}`);u(k.current||T),O(k.dirs||[])}catch(k){x(k.message),O([])}p(!1)}function v(){const T=o==="/"?"/":o.split("/").slice(0,-1).join("/")||"/";b(T)}function Q(){b(b0.HOME||"/Users")}function w(){l(o),n(!1)}return i.jsx(VS,{open:t,onOpenChange:n,children:i.jsx(US,{title:"Select Working Directory",description:"Choose a directory for this agent to work in",className:"max-w-[520px]",children:i.jsxs("div",{className:"px-5 py-4 space-y-3",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("button",{onClick:v,disabled:o==="/",className:"p-1.5 rounded-md bg-surface-4 border border-border text-text-2 hover:text-text-0 hover:bg-surface-5 transition-colors cursor-pointer disabled:opacity-30 disabled:cursor-not-allowed",children:i.jsx(y5,{size:14})}),i.jsx("button",{onClick:Q,className:"p-1.5 rounded-md bg-surface-4 border border-border text-text-2 hover:text-text-0 hover:bg-surface-5 transition-colors cursor-pointer",children:i.jsx(vT,{size:14})}),i.jsx("div",{className:"flex-1 min-w-0 bg-surface-0 rounded-md border border-border-subtle px-2",children:i.jsx(L_,{path:o,onNavigate:b})})]}),i.jsx("div",{className:"bg-surface-0 rounded-lg border border-border-subtle overflow-hidden",children:i.jsxs("div",{className:"max-h-[340px] overflow-y-auto",children:[m&&i.jsx("div",{className:"flex items-center justify-center py-8",children:i.jsx(Kn,{size:18,className:"text-text-3 animate-spin"})}),g&&i.jsx("div",{className:"px-4 py-6 text-center",children:i.jsx("p",{className:"text-xs text-danger font-sans",children:g})}),!m&&!g&&d.length===0&&i.jsx("div",{className:"px-4 py-6 text-center",children:i.jsx("p",{className:"text-xs text-text-3 font-sans",children:"No subdirectories"})}),!m&&!g&&d.map(T=>i.jsxs("button",{onClick:()=>b(T.path),className:se("w-full flex items-center gap-2.5 px-3.5 py-2 text-left cursor-pointer","hover:bg-surface-4 transition-colors border-b border-border-subtle last:border-0"),children:[T.hasChildren?i.jsx(oT,{size:15,className:"text-warning flex-shrink-0"}):i.jsx(ai,{size:15,className:"text-text-3 flex-shrink-0"}),i.jsx("span",{className:"text-sm text-text-0 font-sans truncate flex-1",children:T.name}),T.hasChildren&&i.jsx(Gl,{size:12,className:"text-text-4 flex-shrink-0"})]},T.path))]})}),i.jsxs("div",{className:"flex items-center gap-3 bg-surface-4/50 rounded-lg px-3.5 py-2.5 border border-border-subtle",children:[i.jsx(ai,{size:16,className:"text-accent flex-shrink-0"}),i.jsx("span",{className:"text-xs font-mono text-text-1 truncate flex-1",children:o})]}),i.jsxs("div",{className:"flex justify-end gap-2",children:[i.jsx(be,{variant:"ghost",size:"md",onClick:()=>n(!1),children:"Cancel"}),i.jsxs(be,{variant:"primary",size:"md",onClick:w,className:"gap-1.5",children:[i.jsx(ia,{size:14})," Select Folder"]})]})]})})})}function LS({children:t,...n}){return i.jsx(_S,{...n,children:t})}function DS({children:t,className:n,title:s,side:l="right",width:o=400,...u}){return i.jsxs(ZS,{children:[i.jsx(AS,{className:"fixed inset-0 z-40 bg-black/30"}),i.jsxs(ES,{className:se("fixed top-0 z-50 h-full overflow-y-auto","bg-surface-1 border-l border-border shadow-2xl","data-[state=open]:animate-in data-[state=closed]:animate-out",l==="right"&&"right-0 data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right",l==="left"&&"left-0 data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left",n),style:{width:o},...u,children:[s&&i.jsxs("div",{className:"flex items-center justify-between px-5 py-4 border-b border-border-subtle sticky top-0 bg-surface-1 z-10",children:[i.jsx(qS,{className:"text-base font-semibold text-text-0 font-sans",children:s}),i.jsx(YS,{className:"p-1 rounded-md text-text-3 hover:text-text-0 hover:bg-surface-5 transition-colors cursor-pointer",children:i.jsx(jt,{size:16})})]}),i.jsx(MS,{className:"sr-only",children:"Panel"}),t]})]})}function D_({value:t,onChange:n}){return i.jsx("button",{onClick:()=>n(!t),className:se("w-9 h-5 rounded-full p-0.5 transition-colors cursor-pointer",t?"bg-accent":"bg-surface-5"),children:i.jsx("div",{className:se("w-4 h-4 rounded-full bg-white shadow-sm transition-transform",t?"translate-x-4":"translate-x-0")})})}function W_({user:t}){const[n,s]=y.useState(!1),l=(t==null?void 0:t.avatar)||(t==null?void 0:t.picture)||(t==null?void 0:t.photoURL)||(t==null?void 0:t.photo);return l&&!n?i.jsx("img",{src:l,alt:"",className:"w-6 h-6 rounded-full",referrerPolicy:"no-referrer",crossOrigin:"anonymous",onError:()=>s(!0)}):i.jsx("div",{className:"w-6 h-6 rounded-full bg-accent/10 flex items-center justify-center",children:i.jsx(Hb,{size:12,className:"text-accent"})})}function B_({provider:t,onKeyChange:n}){var T,k,z;const[s,l]=y.useState(!1),[o,u]=y.useState(""),[d,O]=y.useState(!1),[m,p]=y.useState(!1),g=D($=>$.addToast),x=t.authType==="local",b=t.authType==="subscription",v=x||b?t.installed:t.hasKey;async function Q(){if(o.trim())try{await ee.post(`/credentials/${t.id}`,{key:o.trim()}),g("success",`API key set for ${t.name}`),u(""),l(!1),n&&n()}catch($){g("error","Failed to set key",$.message)}}async function w(){try{await ee.delete(`/credentials/${t.id}`),g("info",`Removed ${t.name} key`),n&&n()}catch($){g("error","Remove failed",$.message)}}if(x){const $=((k=(T=t.models)==null?void 0:T.filter(G=>!G.disabled))==null?void 0:k.length)||0,C=()=>D.getState().setActiveView("models");return i.jsxs("div",{className:"flex flex-col rounded-lg border border-border-subtle bg-surface-1 overflow-hidden min-w-[220px]",children:[i.jsxs("div",{className:"flex items-center gap-2.5 px-4 py-3 border-b border-border-subtle",children:[i.jsx($s,{status:v&&$>0?"running":"crashed",size:"sm"}),i.jsx("span",{className:"text-[13px] font-semibold text-text-0 font-sans",children:t.name}),i.jsx("div",{className:"flex-1"}),v&&$>0?i.jsxs(Ze,{variant:"success",className:"text-2xs gap-1",children:[i.jsx(ia,{size:8})," ",$," models"]}):v?i.jsx(Ze,{variant:"warning",className:"text-2xs",children:"No models pulled"}):i.jsx(Ze,{variant:"default",className:"text-2xs",children:"Not set up"})]}),i.jsx("div",{className:"flex-1",children:m?i.jsxs(i.Fragment,{children:[i.jsx(oS,{isInstalled:v,onModelChange:n}),i.jsxs("div",{className:"px-4 py-2 border-t border-border-subtle flex gap-2",children:[i.jsx(be,{variant:"ghost",size:"sm",onClick:()=>p(!1),className:"flex-1 h-7 text-2xs",children:"Back"}),i.jsx(be,{variant:"secondary",size:"sm",onClick:()=>{p(!1),C()},className:"flex-1 h-7 text-2xs gap-1",children:"Models Tab"})]})]}):i.jsxs("div",{className:"px-4 py-3 flex flex-col h-full",children:[i.jsx("div",{className:"text-xs text-text-3 font-sans flex-1",children:v&&$>0?"Full agentic runtime — tool calling, context rotation, zero cloud cost":v?"Ollama is running. Pull a model to start using local agents.":"Run any open-source model locally — free, private, fully offline. Requires Ollama."}),i.jsxs("div",{className:"flex gap-2 mt-3",children:[v?i.jsxs(be,{variant:"primary",size:"sm",onClick:()=>p(!0),className:"flex-1 h-7 text-2xs gap-1.5",children:[i.jsx(Zl,{size:11})," ",$>0?"Manage":"Pull Models"]}):i.jsxs(be,{variant:"primary",size:"sm",onClick:()=>p(!0),className:"flex-1 h-7 text-2xs gap-1.5",children:[i.jsx(Zl,{size:11})," Set Up Ollama"]}),i.jsx(be,{variant:"secondary",size:"sm",onClick:C,className:"flex-1 h-7 text-2xs gap-1.5",children:"Models Tab"})]})]})})]})}return i.jsxs("div",{className:"flex flex-col rounded-lg border border-border-subtle bg-surface-1 overflow-hidden min-w-[220px]",children:[i.jsxs("div",{className:"flex items-center gap-2.5 px-4 py-3 border-b border-border-subtle",children:[i.jsx($s,{status:v?"running":"crashed",size:"sm"}),i.jsx("span",{className:"text-[13px] font-semibold text-text-0 font-sans",children:t.name}),i.jsx("div",{className:"flex-1"}),v?i.jsxs(Ze,{variant:"success",className:"text-2xs gap-1",children:[i.jsx(ia,{size:8})," Ready"]}):i.jsx(Ze,{variant:"default",className:"text-2xs",children:b?"Not installed":"No key"})]}),i.jsxs("div",{className:"flex-1 flex flex-col px-4 py-3 min-h-[120px]",children:[((z=t.models)==null?void 0:z.length)>0&&i.jsx("div",{className:"flex flex-wrap gap-1 mb-3",children:t.models.map($=>i.jsx("span",{className:"px-1.5 py-0.5 rounded bg-surface-4 text-2xs font-mono text-text-3",children:$.name||$.id},$.id))}),b&&v&&!t.hasKey&&!s&&i.jsxs("div",{className:"flex items-center gap-1.5 h-8 px-2.5 bg-accent/8 border border-accent/20 rounded-md text-2xs font-sans text-accent mb-3",children:[i.jsx(ia,{size:10})," Subscription active"]}),t.hasKey&&!s&&i.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[i.jsxs("div",{className:"flex-1 flex items-center gap-1.5 h-8 px-2.5 bg-success/8 border border-success/20 rounded-md text-2xs font-sans text-success",children:[i.jsx(ia,{size:10})," API Connected"]}),i.jsx("button",{onClick:()=>{l(!0),O(!1),u("")},className:"text-2xs text-text-4 hover:text-accent cursor-pointer font-sans",children:"Edit"}),i.jsx("button",{onClick:w,className:"text-2xs text-text-4 hover:text-danger cursor-pointer font-sans",children:"Remove"})]}),i.jsx("div",{className:"flex-1"}),s&&i.jsxs("div",{className:"space-y-2.5 pt-1",children:[i.jsxs("div",{children:[i.jsx("label",{className:"text-2xs font-semibold text-text-2 font-sans mb-1.5 block",children:t.hasKey?"Update API Key":`${t.name} API Key`}),i.jsxs("div",{className:"relative",children:[i.jsx("input",{value:o,onChange:$=>u($.target.value),onKeyDown:$=>$.key==="Enter"&&Q(),type:d?"text":"password",placeholder:"sk-...",className:"w-full h-9 px-3 pr-9 text-xs bg-surface-0 border border-border rounded-md text-text-0 font-mono placeholder:text-text-4 focus:outline-none focus:ring-1 focus:ring-accent",autoFocus:!0}),i.jsx("button",{onClick:()=>O(!d),className:"absolute right-2.5 top-1/2 -translate-y-1/2 text-text-4 hover:text-text-2 cursor-pointer",children:d?i.jsx(If,{size:12}):i.jsx(mi,{size:12})})]})]}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx(be,{variant:"primary",size:"sm",onClick:Q,disabled:!o.trim(),className:"flex-1 h-8 text-xs",children:"Save Key"}),i.jsx(be,{variant:"ghost",size:"sm",onClick:()=>{l(!1),u("")},className:"h-8 text-xs px-3",children:"Cancel"})]})]}),!s&&!t.hasKey&&i.jsxs(be,{variant:b?"secondary":"primary",size:"sm",onClick:()=>{l(!0),O(!1),u("")},className:"w-full h-8 text-2xs gap-1.5 mt-2",children:[i.jsx(vc,{size:11}),b?"Add API key for headless mode":"Add API Key"]})]})]})}function Ql({icon:t,label:n,description:s,children:l}){return i.jsxs("div",{className:"rounded-lg border border-border-subtle bg-surface-1 px-4 py-3.5 flex flex-col gap-2",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("div",{className:"w-6 h-6 rounded bg-accent/8 flex items-center justify-center flex-shrink-0",children:i.jsx(t,{size:12,className:"text-accent"})}),i.jsx("div",{className:"text-[13px] font-medium text-text-0 font-sans leading-tight",children:n})]}),i.jsx("div",{className:"text-2xs text-text-4 font-sans leading-relaxed",children:s}),i.jsx("div",{className:"mt-auto pt-1",children:l})]})}const WS={telegram:th,discord:pi,slack:qb},js={telegram:"Telegram",discord:"Discord",slack:"Slack"},H_={telegram:"Bot token from @BotFather",discord:"Bot token from Developer Portal",slack:"Bot token (xoxb-...)"},I_=["critical","lifecycle","all"];function F_({type:t,open:n,onOpenChange:s}){if(!t)return null;const o={telegram:{title:"Set Up Telegram",icon:th,intro:"Create a Telegram bot and connect it to Groove in under 2 minutes. No dependencies required.",sections:[{title:"Create Your Bot",steps:[{text:"Open Telegram on any device and search for",link:"https://t.me/BotFather",linkText:"@BotFather"},{text:"Send /newbot to start the setup"},{text:"Choose a display name — we suggest GroovePilot"},{text:'Choose a username (must end in "bot") — e.g. GroovePilot_bot'},{text:"BotFather will reply with your bot token — copy it"}]},{title:"Connect to Groove",steps:[{text:"In Groove Settings > Gateways, click Set Token on the Telegram card"},{text:"Paste your bot token and click Save"},{text:"The gateway will connect automatically"}]},{title:"Link a Chat",steps:[{text:"Open a chat with your new bot in Telegram"},{text:'Send any message (e.g. "hello") — Groove captures the chat ID automatically'},{text:"Click Test in the gateway card to verify"}]},{title:"Commands",note:"All commands use / prefix in Telegram:",commands:["/instruct <team> <msg>","/query <team> <question>","/plan <description>","/log <team>","/brief","/tokens","/status","/agents","/help"]}]},discord:{title:"Set Up Discord",icon:pi,intro:"Create a Discord bot and add it to your server. Requires discord.js (installed automatically with Groove).",sections:[{title:"Create the Application",steps:[{text:"Go to the",link:"https://discord.com/developers/applications",linkText:"Discord Developer Portal"},{text:"Click New Application and name it GroovePilot"},{text:"Go to the Bot tab in the left sidebar"},{text:"Click Reset Token and copy the bot token"}]},{title:"Set Permissions & Invite",steps:[{text:"Go to OAuth2 > URL Generator"},{text:"Under Scopes, check bot"},{text:"Under Bot Permissions, check:"}],scopes:["Send Messages","Read Message History","Embed Links","Use External Emojis"],after:[{text:"Copy the generated URL at the bottom and open it in your browser"},{text:"Select your server and click Authorize"}]},{title:"Enable Message Content Intent",steps:[{text:"Go back to the Bot tab in the Developer Portal"},{text:"Scroll to Privileged Gateway Intents"},{text:"Enable Message Content Intent — required for the bot to read commands"},{text:"Click Save Changes"}]},{title:"Connect to Groove",steps:[{text:"In Groove Settings > Gateways, click Set Token on the Discord card"},{text:"Paste your bot token and click Save"},{text:"Send a message in any channel where the bot is — Groove captures the channel automatically"}]},{title:"Commands",note:"All commands use / prefix in Discord:",commands:["/instruct <team> <msg>","/query <team> <question>","/plan <description>","/log <team>","/brief","/tokens","/status","/agents","/help"]}]},slack:{title:"Set Up Slack",icon:qb,intro:"Create a Slack app with Socket Mode — no public URL needed. Requires @slack/bolt (installed automatically with Groove).",sections:[{title:"Create the App",steps:[{text:"Go to",link:"https://api.slack.com/apps",linkText:"api.slack.com/apps"},{text:"Click Create New App > From scratch"},{text:"Name it GroovePilot and select your workspace"}]},{title:"Enable Socket Mode",steps:[{text:"In the left sidebar, go to Settings > Socket Mode"},{text:"Toggle Enable Socket Mode to on"},{text:"It will ask you to create an App-Level Token"},{text:'Name it "groove", add the connections:write scope'},{text:"Click Generate — copy the xapp-... token (this is your App Token)"}],important:"Save this token now — you can't view it again after closing the dialog."},{title:"Set Bot Token Scopes",steps:[{text:"Go to Features > OAuth & Permissions"},{text:"Scroll to Bot Token Scopes and add all of these:"}],scopes:["chat:write","channels:read","channels:history","groups:read","groups:history","im:history","app_mentions:read"],after:[{text:"Scroll up and click Install to Workspace"},{text:"Click Allow to grant permissions"},{text:"Copy the Bot User OAuth Token (xoxb-...) — this is your Bot Token"}]},{title:"Enable Events",steps:[{text:"Go to Features > Event Subscriptions"},{text:"Toggle Enable Events to on"},{text:"Under Subscribe to bot events, add:"}],scopes:["message.channels","message.im","app_mention"],after:[{text:"Click Save Changes at the bottom"}]},{title:"Connect to Groove",steps:[{text:"In Groove Settings > Gateways, click Set Token on the Slack card"},{text:"Paste your Bot Token (xoxb-...) in the first field"},{text:"Paste your App Token (xapp-...) in the second field"},{text:"Click Save — Groove will auto-connect"}]},{title:"Link a Channel",steps:[{text:"Invite the bot to a channel: /invite @GroovePilot"},{text:"Select the channel from the dropdown in the gateway card"},{text:"Or @mention the bot — it will auto-capture the channel"},{text:"Click Test to verify"}],important:"For private channels, make sure you added the groups:read scope."},{title:"Commands",note:"In Slack, use plain text commands (no / prefix) or @mention the bot:",commands:["instruct <team> <msg>","query <team> <question>","plan <description>","log <team>","brief","tokens","status","agents","help","@GroovePilot status"]}]}}[t];if(!o)return null;const u=o.icon;return i.jsx(LS,{open:n,onOpenChange:s,children:i.jsx(DS,{title:o.title,width:480,children:i.jsxs("div",{className:"px-5 py-4 space-y-5",children:[i.jsxs("div",{className:"flex items-start gap-3 p-3 bg-accent/5 border border-accent/15 rounded-lg",children:[i.jsx("div",{className:"w-8 h-8 rounded-lg bg-accent/10 flex items-center justify-center flex-shrink-0 mt-0.5",children:i.jsx(u,{size:16,className:"text-accent"})}),i.jsx("p",{className:"text-xs text-text-2 font-sans leading-relaxed",children:o.intro})]}),o.sections.map((d,O)=>{var m;return i.jsxs("div",{children:[i.jsxs("h3",{className:"text-xs font-semibold text-text-0 font-sans mb-2.5 flex items-center gap-2",children:[i.jsx("span",{className:"w-5 h-5 rounded-full bg-accent/10 flex items-center justify-center text-2xs font-bold text-accent",children:O+1}),d.title]}),d.note&&i.jsx("p",{className:"text-2xs text-text-3 font-sans mb-2",children:d.note}),d.steps&&i.jsx("ol",{className:"space-y-2 mb-2",children:d.steps.map((p,g)=>i.jsxs("li",{className:"flex gap-2 text-2xs text-text-2 font-sans leading-relaxed",children:[i.jsxs("span",{className:"text-text-4 font-mono w-4 flex-shrink-0 pt-px",children:[g+1,"."]}),i.jsxs("span",{children:[p.text,p.link&&i.jsxs(i.Fragment,{children:[" ",i.jsxs("a",{href:p.link,target:"_blank",rel:"noopener noreferrer",className:"text-accent hover:underline inline-flex items-center gap-0.5 font-medium",children:[p.linkText,i.jsx(bc,{size:9})]})]})]})]},g))}),d.scopes&&i.jsx("div",{className:"flex flex-wrap gap-1.5 mb-2 ml-6",children:d.scopes.map(p=>i.jsx("code",{className:"px-2 py-0.5 rounded bg-surface-4 text-2xs font-mono text-accent",children:p},p))}),d.after&&i.jsx("ol",{className:"space-y-2 mb-2",start:(((m=d.steps)==null?void 0:m.length)||0)+1,children:d.after.map((p,g)=>{var x;return i.jsxs("li",{className:"flex gap-2 text-2xs text-text-2 font-sans leading-relaxed",children:[i.jsxs("span",{className:"text-text-4 font-mono w-4 flex-shrink-0 pt-px",children:[(((x=d.steps)==null?void 0:x.length)||0)+g+1,"."]}),i.jsx("span",{children:p.text})]},g)})}),d.important&&i.jsx("div",{className:"ml-6 p-2 bg-warning/8 border border-warning/20 rounded-md text-2xs text-warning font-sans",children:d.important}),d.commands&&i.jsx("div",{className:"ml-6 p-2.5 bg-surface-0 border border-border-subtle rounded-md space-y-1",children:d.commands.map(p=>i.jsx("code",{className:"block text-2xs font-mono text-text-1",children:p},p))})]},O)}),i.jsxs("a",{href:"https://docs.groovedev.ai/guide/gateways",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 text-2xs text-accent hover:text-accent/80 font-sans font-medium mt-2",children:[i.jsx(bc,{size:10}),"Full documentation at docs.groovedev.ai"]})]})})})}function K_({gateway:t,onRefresh:n}){var ce,re;const[s,l]=y.useState(!1),[o,u]=y.useState(""),[d,O]=y.useState(""),[m,p]=y.useState(!1),[g,x]=y.useState(!1),[b,v]=y.useState(!1),[Q,w]=y.useState([]),[T,k]=y.useState(!1),z=D(F=>F.addToast);y.useEffect(()=>{t.connected&&!t.chatId&&t.type==="slack"&&ee.get(`/gateways/${t.id}/channels`).then(F=>w(Array.isArray(F)?F:[])).catch(()=>{})},[t.connected,t.chatId,t.id,t.type]);const $=WS[t.type]||eh,C=t.type==="slack";async function G(){if(o.trim())try{await ee.post(`/gateways/${t.id}/credentials`,{key:"bot_token",value:o.trim()}),C&&d.trim()&&await ee.post(`/gateways/${t.id}/credentials`,{key:"app_token",value:d.trim()}),z("success","Token saved — connecting..."),u(""),O(""),l(!1);try{await ee.post(`/gateways/${t.id}/connect`),z("success",`${js[t.type]} connected!`)}catch(F){z("error","Token saved but connect failed",F.message)}n()}catch(F){z("error","Failed to save token",F.message)}}async function X(){x(!0);try{await ee.post(`/gateways/${t.id}/test`),z("success","Test message sent!")}catch(F){z("error","Test failed",F.message)}x(!1)}async function _(){v(!0);try{t.connected?(await ee.post(`/gateways/${t.id}/disconnect`),z("info",`${js[t.type]} disconnected`)):(await ee.post(`/gateways/${t.id}/connect`),z("success",`${js[t.type]} connected!`)),n()}catch(F){z("error",t.connected?"Disconnect failed":"Connect failed",F.message)}v(!1)}async function N(F){try{await ee.patch(`/gateways/${t.id}`,{enabled:F}),n()}catch(P){z("error","Update failed",P.message)}}async function E(F){try{await ee.patch(`/gateways/${t.id}`,{notifications:{preset:F}}),n()}catch(P){z("error","Update failed",P.message)}}async function Y(F){try{await ee.patch(`/gateways/${t.id}`,{commandPermission:F}),n()}catch(P){z("error","Update failed",P.message)}}async function ne(){try{await ee.delete(`/gateways/${t.id}`),z("info",`${js[t.type]} gateway removed`),n()}catch(F){z("error","Delete failed",F.message)}}const oe=((ce=t.notifications)==null?void 0:ce.preset)||"critical";return i.jsxs("div",{className:"flex flex-col rounded-lg border border-border-subtle bg-surface-1 overflow-hidden min-w-[220px]",children:[i.jsxs("div",{className:"flex items-center gap-2.5 px-4 py-3 border-b border-border-subtle",children:[i.jsx($s,{status:t.connected?"running":"crashed",size:"sm"}),i.jsx($,{size:13,className:"text-text-2"}),i.jsx("span",{className:"text-[13px] font-semibold text-text-0 font-sans",children:js[t.type]}),i.jsx("div",{className:"flex-1"}),t.connected?i.jsxs(Ze,{variant:"success",className:"text-2xs gap-1",children:[i.jsx(a1,{size:8})," Connected"]}):t.enabled?i.jsx(Ze,{variant:"warning",className:"text-2xs",children:"Disconnected"}):i.jsx(Ze,{variant:"default",className:"text-2xs",children:"Disabled"})]}),i.jsxs("div",{className:"flex-1 flex flex-col px-4 py-3 min-h-[140px]",children:[t.connected&&!s&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"flex items-center gap-1.5 h-8 px-2.5 bg-success/8 border border-success/20 rounded-md text-2xs font-sans text-success mb-3",children:[i.jsx(ia,{size:10})," Gateway active",t.botUsername&&i.jsxs("span",{className:"text-text-4 ml-1",children:["@",t.botUsername]}),t.botTag&&i.jsx("span",{className:"text-text-4 ml-1",children:t.botTag})]}),i.jsxs("div",{className:"mb-3",children:[i.jsx("label",{className:"text-2xs font-semibold text-text-3 font-sans mb-1.5 block",children:t.type==="slack"?"Channel":"Chat ID"}),t.chatId?i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("code",{className:"flex-1 flex items-center h-7 px-2 bg-surface-0 border border-border-subtle rounded-md text-2xs font-mono text-text-2",children:t.type==="slack"&&Q.length>0?`#${((re=Q.find(F=>F.id===t.chatId))==null?void 0:re.name)||t.chatId}`:t.chatId}),i.jsx("button",{onClick:async()=>{try{await ee.patch(`/gateways/${t.id}`,{chatId:null}),n()}catch(F){z("error","Failed",F.message)}},className:"text-2xs text-text-4 hover:text-text-1 cursor-pointer font-sans",children:"Change"})]}):t.type==="slack"&&Q.length>0?i.jsxs("select",{onChange:async F=>{if(F.target.value)try{await ee.patch(`/gateways/${t.id}`,{chatId:F.target.value}),n()}catch(P){z("error","Failed to set channel",P.message)}},className:"w-full h-7 px-2 text-2xs bg-surface-0 border border-border-subtle rounded-md text-text-0 font-sans focus:outline-none focus:ring-1 focus:ring-accent cursor-pointer",defaultValue:"",children:[i.jsx("option",{value:"",disabled:!0,children:"Select a channel..."}),Q.map(F=>i.jsxs("option",{value:F.id,children:["#",F.name]},F.id))]}):i.jsxs("div",{className:"text-2xs text-warning font-sans",children:[t.type==="slack"?"No channels found — invite the bot to a channel first.":"Send a message to the bot to auto-capture, or enter manually:",i.jsx("input",{placeholder:t.type==="slack"?"C0123456789":"Chat ID",className:"mt-1 w-full h-7 px-2 text-2xs bg-surface-0 border border-border rounded-md text-text-0 font-mono placeholder:text-text-4 focus:outline-none focus:ring-1 focus:ring-accent",onKeyDown:async F=>{if(F.key==="Enter"&&F.target.value.trim())try{await ee.patch(`/gateways/${t.id}`,{chatId:F.target.value.trim()}),n()}catch(P){z("error","Failed to set channel",P.message)}}})]})]}),i.jsxs("div",{className:"mb-3",children:[i.jsx("label",{className:"text-2xs font-semibold text-text-3 font-sans mb-1.5 block",children:"Notifications"}),i.jsx("div",{className:"flex bg-surface-0 rounded-md p-0.5 border border-border-subtle",children:I_.map(F=>i.jsx("button",{onClick:()=>E(F),className:se("flex-1 px-2 py-1.5 text-2xs font-semibold font-sans rounded transition-all cursor-pointer capitalize",oe===F?"bg-accent/15 text-accent shadow-sm":"text-text-3 hover:text-text-1"),children:F},F))})]}),i.jsxs("div",{className:"mb-3",children:[i.jsx("label",{className:"text-2xs font-semibold text-text-3 font-sans mb-1.5 block",children:"Commands"}),i.jsx("div",{className:"flex bg-surface-0 rounded-md p-0.5 border border-border-subtle",children:["full","read-only"].map(F=>i.jsx("button",{onClick:()=>Y(F),className:se("flex-1 px-2 py-1.5 text-2xs font-semibold font-sans rounded transition-all cursor-pointer capitalize",(t.commandPermission||"full")===F?"bg-accent/15 text-accent shadow-sm":"text-text-3 hover:text-text-1"),children:F==="full"?"Full Access":"Read Only"},F))})]})]}),!t.connected&&!s&&i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"text-xs text-text-3 font-sans mb-2",children:t.enabled?t.hasCredentials?"Tokens saved — click Connect.":"Configure bot token to connect.":"Gateway is disabled."}),!t.hasCredentials&&i.jsxs("button",{onClick:()=>k(!0),className:"flex items-center gap-1.5 text-2xs text-accent hover:text-accent/80 font-sans font-medium cursor-pointer mb-2",children:[i.jsx(gc,{size:11}),"How to set up",i.jsx(bc,{size:9})]})]}),i.jsx(F_,{type:t.type,open:T,onOpenChange:k}),i.jsx("div",{className:"flex-1"}),s&&i.jsxs("div",{className:"space-y-2.5 pt-1",children:[i.jsxs("button",{onClick:()=>k(!0),className:"flex items-center gap-1.5 text-2xs text-accent hover:text-accent/80 font-sans font-medium cursor-pointer",children:[i.jsx(gc,{size:11}),"Where do I get these?"]}),i.jsxs("div",{children:[i.jsx("label",{className:"text-2xs font-semibold text-text-2 font-sans mb-1.5 block",children:"Bot Token"}),i.jsxs("div",{className:"relative",children:[i.jsx("input",{value:o,onChange:F=>u(F.target.value),onKeyDown:F=>F.key==="Enter"&&!C&&G(),type:m?"text":"password",placeholder:H_[t.type],className:"w-full h-9 px-3 pr-9 text-xs bg-surface-0 border border-border rounded-md text-text-0 font-mono placeholder:text-text-4 focus:outline-none focus:ring-1 focus:ring-accent",autoFocus:!0}),i.jsx("button",{onClick:()=>p(!m),className:"absolute right-2.5 top-1/2 -translate-y-1/2 text-text-4 hover:text-text-2 cursor-pointer",children:m?i.jsx(If,{size:12}):i.jsx(mi,{size:12})})]})]}),C&&i.jsxs("div",{children:[i.jsx("label",{className:"text-2xs font-semibold text-text-2 font-sans mb-1.5 block",children:"App Token (Socket Mode)"}),i.jsx("input",{value:d,onChange:F=>O(F.target.value),onKeyDown:F=>F.key==="Enter"&&G(),type:m?"text":"password",placeholder:"xapp-...",className:"w-full h-9 px-3 text-xs bg-surface-0 border border-border rounded-md text-text-0 font-mono placeholder:text-text-4 focus:outline-none focus:ring-1 focus:ring-accent"})]}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx(be,{variant:"primary",size:"sm",onClick:G,disabled:!o.trim(),className:"flex-1 h-8 text-xs",children:"Save Token"}),i.jsx(be,{variant:"ghost",size:"sm",onClick:()=>{l(!1),u(""),O("")},className:"h-8 text-xs px-3",children:"Cancel"})]})]}),!s&&i.jsxs("div",{className:"flex gap-2 mt-2",children:[!t.connected&&i.jsxs(be,{variant:"primary",size:"sm",onClick:()=>l(!0),className:"flex-1 h-7 text-2xs gap-1.5",children:[i.jsx(vc,{size:11}),t.enabled?"Set Token":"Configure"]}),t.connected&&i.jsxs(i.Fragment,{children:[i.jsxs(be,{variant:"secondary",size:"sm",onClick:X,disabled:g,className:"flex-1 h-7 text-2xs gap-1.5",children:[i.jsx(nh,{size:11}),g?"Sending...":"Test"]}),i.jsx(be,{variant:"secondary",size:"sm",onClick:()=>l(!0),className:"h-7 text-2xs px-2.5",children:i.jsx(vc,{size:11})})]}),i.jsx(be,{variant:"ghost",size:"sm",onClick:_,disabled:b,className:"h-7 text-2xs px-2.5",title:t.connected?"Disconnect":"Connect",children:t.connected?i.jsx(Vb,{size:11}):i.jsx(a1,{size:11})}),i.jsx(D_,{value:t.enabled,onChange:N}),i.jsx("button",{onClick:ne,className:"text-text-4 hover:text-danger cursor-pointer p-1",title:"Remove gateway",children:i.jsx(Dl,{size:11})})]})]})]})}function J_({existingTypes:t,onAdd:n}){const[s,l]=y.useState(!1),o=["telegram","discord","slack"].filter(u=>!t.includes(u));return o.length===0?null:s?i.jsxs("div",{className:"flex flex-col rounded-lg border border-accent/30 bg-surface-1 overflow-hidden min-w-[220px]",children:[i.jsxs("div",{className:"flex items-center gap-2.5 px-4 py-3 border-b border-border-subtle",children:[i.jsx(eh,{size:13,className:"text-accent"}),i.jsx("span",{className:"text-[13px] font-semibold text-text-0 font-sans",children:"Add Gateway"}),i.jsx("div",{className:"flex-1"}),i.jsx("button",{onClick:()=>l(!1),className:"text-text-4 hover:text-text-1 cursor-pointer",children:i.jsx(jt,{size:12})})]}),i.jsx("div",{className:"p-3 space-y-2",children:o.map(u=>{const d=WS[u];return i.jsxs("button",{onClick:()=>{n(u),l(!1)},className:"w-full flex items-center gap-3 px-3 py-2.5 rounded-md bg-surface-0 hover:bg-accent/8 border border-border-subtle hover:border-accent/20 cursor-pointer transition-all group",children:[i.jsx(d,{size:14,className:"text-text-3 group-hover:text-accent"}),i.jsx("span",{className:"text-xs font-medium text-text-1 group-hover:text-accent font-sans",children:js[u]})]},u)})})]}):i.jsxs("button",{onClick:()=>l(!0),className:"flex flex-col items-center justify-center rounded-lg border border-dashed border-border-subtle bg-surface-1/50 hover:bg-surface-1 hover:border-accent/30 min-h-[140px] min-w-[220px] cursor-pointer transition-all group",children:[i.jsx("div",{className:"w-8 h-8 rounded-full bg-accent/8 group-hover:bg-accent/15 flex items-center justify-center mb-2 transition-colors",children:i.jsx(Jn,{size:14,className:"text-accent"})}),i.jsx("span",{className:"text-2xs font-semibold text-text-3 group-hover:text-text-1 font-sans transition-colors",children:"Add Gateway"})]})}function eZ(){const[t,n]=y.useState([]),[s,l]=y.useState(null),[o,u]=y.useState(null),[d,O]=y.useState([]),[m,p]=y.useState(!0),[g,x]=y.useState(!1),b=D(_=>_.addToast),v=D(_=>_.marketplaceUser),Q=D(_=>_.marketplaceAuthenticated),w=D(_=>_.marketplaceLogin),T=D(_=>_.marketplaceLogout);function k(){ee.get("/providers").then(_=>n(Array.isArray(_)?_:[])).catch(()=>{})}function z(){ee.get("/gateways").then(_=>O(Array.isArray(_)?_:[])).catch(()=>{})}y.useEffect(()=>{Promise.all([ee.get("/providers"),ee.get("/config"),ee.get("/status"),ee.get("/gateways")]).then(([_,N,E,Y])=>{n(Array.isArray(_)?_:[]),l(N),u(E),O(Array.isArray(Y)?Y:[]),p(!1)}).catch(()=>p(!1))},[]);async function $(_){try{await ee.post("/gateways",{type:_}),b("success",`${js[_]} gateway added`),z()}catch(N){b("error","Failed to add gateway",N.message)}}async function C(_,N){try{const E=await ee.patch("/config",{[_]:N});l(E)}catch(E){b("error","Update failed",E.message)}}if(m)return i.jsxs("div",{className:"flex flex-col h-full",children:[i.jsx("div",{className:"h-12 bg-surface-1 border-b border-border"}),i.jsxs("div",{className:"flex-1 p-4 space-y-4",children:[i.jsx("div",{className:"grid grid-cols-4 gap-3",children:[...Array(4)].map((_,N)=>i.jsx(ra,{className:"h-40 rounded-lg"},N))}),i.jsx("div",{className:"grid grid-cols-3 gap-3",children:[...Array(6)].map((_,N)=>i.jsx(ra,{className:"h-28 rounded-lg"},N))})]})]});const G=t.filter(_=>_.authType==="local"||_.authType==="subscription"?_.installed:_.hasKey).length,X=(s==null?void 0:s.rotationThreshold)||0;return i.jsxs("div",{className:"flex flex-col h-full",children:[i.jsxs("div",{className:"flex items-center gap-4 px-4 py-2.5 bg-surface-1 border-b border-border flex-shrink-0",children:[i.jsx("h2",{className:"text-sm font-semibold text-text-0 font-sans",children:"Settings"}),i.jsx("div",{className:"flex-1"}),i.jsxs("div",{className:"flex items-center gap-4 text-2xs text-text-3 font-sans",children:[(o==null?void 0:o.version)&&i.jsxs("span",{children:["v",o.version]}),(o==null?void 0:o.port)&&i.jsxs("span",{children:[":",o.port]}),(o==null?void 0:o.uptime)>0&&i.jsxs("span",{children:["Up ",Dc(o.uptime)]})]}),i.jsx("div",{className:"w-px h-4 bg-border-subtle"}),Q?i.jsxs("div",{className:"flex items-center gap-2.5",children:[i.jsx(W_,{user:v}),i.jsx("span",{className:"text-xs font-medium text-text-0 font-sans",children:(v==null?void 0:v.displayName)||"User"}),i.jsxs("button",{onClick:T,className:"text-2xs text-text-4 hover:text-text-1 cursor-pointer font-sans flex items-center gap-1",children:[i.jsx(Eb,{size:10})," Sign out"]})]}):i.jsxs(be,{variant:"ghost",size:"sm",onClick:w,className:"h-7 text-2xs gap-1.5 text-text-3",children:[i.jsx(Kf,{size:11})," Sign in"]}),i.jsx($s,{status:"running",size:"sm"})]}),i.jsx(fn,{className:"flex-1",children:i.jsxs("div",{className:"p-4 space-y-4",children:[i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center gap-2 mb-2.5 px-0.5",children:[i.jsx("span",{className:"text-2xs font-semibold text-text-3 font-sans uppercase tracking-wider",children:"Providers"}),i.jsx("div",{className:"flex-1 h-px bg-border-subtle"}),i.jsxs("span",{className:"text-2xs text-text-4 font-sans",children:[G,"/",t.length," connected"]})]}),i.jsx("div",{className:"grid grid-cols-4 gap-3",children:t.map(_=>i.jsx(B_,{provider:_,onKeyChange:k},_.id))})]}),i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center gap-2 mb-2.5 px-0.5",children:[i.jsx("span",{className:"text-2xs font-semibold text-text-3 font-sans uppercase tracking-wider",children:"Gateways"}),i.jsx("div",{className:"flex-1 h-px bg-border-subtle"}),i.jsxs("span",{className:"text-2xs text-text-4 font-sans",children:[d.filter(_=>_.connected).length,"/",d.length," connected"]})]}),i.jsxs("div",{className:"grid grid-cols-4 gap-3",children:[d.map(_=>i.jsx(K_,{gateway:_,onRefresh:z},_.id)),i.jsx(J_,{existingTypes:d.map(_=>_.type),onAdd:$})]})]}),s&&i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center gap-2 mb-2.5 px-0.5",children:[i.jsx("span",{className:"text-2xs font-semibold text-text-3 font-sans uppercase tracking-wider",children:"Configuration"}),i.jsx("div",{className:"flex-1 h-px bg-border-subtle"}),i.jsx("span",{className:"text-2xs text-text-4 font-sans",children:"Auto-saves"})]}),i.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[i.jsx(Ql,{icon:Zl,label:"Default Provider",description:"Provider used when spawning new agents.",children:i.jsx("select",{value:s.defaultProvider||"claude-code",onChange:_=>C("defaultProvider",_.target.value),className:"w-full h-8 px-2.5 text-xs bg-surface-0 border border-border-subtle rounded-md text-text-0 font-mono focus:outline-none focus:ring-1 focus:ring-accent cursor-pointer",children:t.filter(_=>_.installed||_.hasKey).map(_=>i.jsx("option",{value:_.id,children:_.name},_.id))})}),i.jsx(Ql,{icon:ai,label:"Working Directory",description:"Default root directory for new agents.",children:i.jsxs("div",{className:"flex items-center gap-1.5",children:[i.jsx("code",{className:"flex-1 h-8 px-2 flex items-center bg-surface-0 border border-border-subtle rounded-md text-2xs font-mono text-text-2 truncate min-w-0",children:s.defaultWorkingDir||"Project root"}),i.jsx(be,{variant:"secondary",size:"sm",onClick:()=>x(!0),className:"h-8 px-2 flex-shrink-0",children:i.jsx(Xb,{size:12})})]})}),i.jsx(Ql,{icon:Zb,label:"Rotation Threshold",description:"Context usage that triggers auto-rotation.",children:i.jsx("div",{className:"flex bg-surface-0 rounded-md p-0.5 border border-border-subtle",children:["auto","50%","65%","75%","85%"].map(_=>{const N=_==="auto"?0:parseInt(_,10)/100,E=X===N;return i.jsx("button",{onClick:()=>C("rotationThreshold",N),className:se("flex-1 px-2 py-1.5 text-2xs font-semibold font-sans rounded transition-all cursor-pointer",E?"bg-accent/15 text-accent shadow-sm":"text-text-3 hover:text-text-1"),children:_==="auto"?"Auto":_},_)})})}),i.jsx(Ql,{icon:Wb,label:"QC Threshold",description:"Running agents count that triggers auto-QC.",children:i.jsx("div",{className:"flex bg-surface-0 rounded-md p-0.5 border border-border-subtle",children:[2,3,4,6,8].map(_=>{const N=(s.qcThreshold||2)===_;return i.jsx("button",{onClick:()=>C("qcThreshold",_),className:se("flex-1 px-2 py-1.5 text-2xs font-semibold font-sans rounded transition-all cursor-pointer",N?"bg-accent/15 text-accent shadow-sm":"text-text-3 hover:text-text-1"),children:_},_)})})}),i.jsx(Ql,{icon:bi,label:"Max Agents",description:"Concurrent agent limit. 0 = unlimited.",children:i.jsx("div",{className:"flex bg-surface-0 rounded-md p-0.5 border border-border-subtle",children:[0,4,8,12,20].map(_=>{const N=(s.maxAgents||0)===_;return i.jsx("button",{onClick:()=>C("maxAgents",_),className:se("flex-1 px-2 py-1.5 text-2xs font-semibold font-sans rounded transition-all cursor-pointer",N?"bg-accent/15 text-accent shadow-sm":"text-text-3 hover:text-text-1"),children:_===0?"∞":_},_)})})}),i.jsx(Ql,{icon:ni,label:"Journalist Interval",description:"Seconds between synthesis cycles.",children:i.jsx("div",{className:"flex bg-surface-0 rounded-md p-0.5 border border-border-subtle",children:[60,120,300,600].map(_=>{const N=(s.journalistInterval||120)===_,E=_<60?`${_}s`:`${_/60}m`;return i.jsx("button",{onClick:()=>C("journalistInterval",_),className:se("flex-1 px-2 py-1.5 text-2xs font-semibold font-sans rounded transition-all cursor-pointer",N?"bg-accent/15 text-accent shadow-sm":"text-text-3 hover:text-text-1"),children:E},_)})})})]})]})]})}),i.jsx(GS,{open:g,onOpenChange:x,currentPath:(s==null?void 0:s.defaultWorkingDir)||"/",onSelect:_=>C("defaultWorkingDir",_)})]})}const zf=y.forwardRef(({className:t,label:n,error:s,mono:l,...o},u)=>i.jsxs("div",{className:"flex flex-col gap-1",children:[n&&i.jsx("label",{className:"text-xs font-medium text-text-2 font-sans",children:n}),i.jsx("input",{ref:u,className:se("h-8 w-full rounded-md px-3 text-sm","bg-surface-1 border border-border text-text-0","placeholder:text-text-4","focus:outline-none focus:ring-1 focus:ring-accent focus:border-accent","disabled:opacity-40 disabled:cursor-not-allowed","transition-colors duration-100",l?"font-mono":"font-sans",s&&"border-danger focus:ring-danger",t),...o}),s&&i.jsx("span",{className:"text-2xs text-danger font-sans",children:s})]}));zf.displayName="Input";const tZ=y.forwardRef(({className:t,label:n,error:s,mono:l,...o},u)=>i.jsxs("div",{className:"flex flex-col gap-1",children:[n&&i.jsx("label",{className:"text-xs font-medium text-text-2 font-sans",children:n}),i.jsx("textarea",{ref:u,className:se("w-full rounded-md px-3 py-2 text-sm resize-none","bg-surface-1 border border-border text-text-0","placeholder:text-text-4","focus:outline-none focus:ring-1 focus:ring-accent focus:border-accent","disabled:opacity-40 disabled:cursor-not-allowed","transition-colors duration-100",l?"font-mono":"font-sans",s&&"border-danger focus:ring-danger",t),...o}),s&&i.jsx("span",{className:"text-2xs text-danger font-sans",children:s})]}));tZ.displayName="Textarea";function Cc(t){return t?t<1024*1024?`${(t/1024).toFixed(0)} KB`:t<1024*1024*1024?`${(t/(1024*1024)).toFixed(1)} MB`:`${(t/(1024*1024*1024)).toFixed(2)} GB`:"—"}function aZ(t){return t?t<1024*1024?`${(t/1024).toFixed(0)} KB/s`:`${(t/(1024*1024)).toFixed(1)} MB/s`:""}function nZ({hardware:t}){var n;return t?i.jsxs("div",{className:"flex items-center gap-4 px-4 py-2.5 bg-surface-1 border border-border-subtle rounded-lg text-xs font-sans text-text-2",children:[i.jsxs("div",{className:"flex items-center gap-1.5",children:[i.jsx(ZT,{size:14,className:"text-text-3"}),i.jsxs("span",{children:[t.totalRamGb," GB RAM"]})]}),i.jsxs("div",{className:"flex items-center gap-1.5",children:[i.jsx(Zl,{size:14,className:"text-text-3"}),i.jsxs("span",{children:[t.cores," cores"]})]}),t.gpu&&i.jsxs("div",{className:"flex items-center gap-1.5",children:[i.jsx(Ff,{size:14,className:"text-text-3"}),i.jsxs("span",{children:[t.gpu.name,t.gpu.vram?` (${t.gpu.vram} GB)`:""]})]}),((n=t.recommended)==null?void 0:n.code)&&i.jsxs("div",{className:"ml-auto text-accent",children:["Recommended: ",t.recommended.code]})]}):null}function sZ({download:t}){const n=Math.round((t.percent||0)*100);return i.jsxs("div",{className:"space-y-1",children:[i.jsxs("div",{className:"flex items-center justify-between text-2xs font-sans text-text-3",children:[i.jsx("span",{children:t.filename}),i.jsxs("span",{children:[n,"% ",aZ(t.speed)]})]}),i.jsx("div",{className:"h-1.5 bg-surface-3 rounded-full overflow-hidden",children:i.jsx("div",{className:"h-full bg-accent rounded-full transition-all",style:{width:`${n}%`}})}),i.jsxs("div",{className:"text-2xs text-text-4",children:[Cc(t.downloaded)," / ",Cc(t.totalBytes)]})]})}function lZ({model:t,onDelete:n}){const[s,l]=y.useState(!1),o={light:"text-green-400",medium:"text-blue-400",heavy:"text-orange-400"};return i.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 bg-surface-1 border border-border-subtle rounded-lg",children:[i.jsx(Hf,{size:18,className:"text-accent flex-shrink-0"}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-sm font-mono font-bold text-text-0 truncate",children:t.id}),t.quantization&&i.jsx(Ze,{variant:"subtle",className:"text-2xs",children:t.quantization}),t.parameters&&i.jsx(Ze,{variant:"subtle",className:"text-2xs",children:t.parameters}),i.jsx("span",{className:se("text-2xs font-medium capitalize",o[t.tier]||"text-text-3"),children:t.tier})]}),i.jsxs("div",{className:"text-2xs text-text-3 font-sans mt-0.5",children:[Cc(t.sizeBytes)," · ctx ",(t.contextWindow||0).toLocaleString()," · ",t.category,t.repoId&&i.jsxs("span",{className:"text-text-4",children:[" · ",t.repoId]})]})]}),i.jsx("button",{onClick:async()=>{l(!0),await n(t.id),l(!1)},disabled:s,className:"p-1.5 rounded-md text-text-4 hover:text-red-400 hover:bg-red-400/10 transition-colors",children:s?i.jsx(Kn,{size:14,className:"animate-spin"}):i.jsx(Dl,{size:14})})]})}function rZ({result:t,onExpand:n,expanded:s}){var l;return i.jsxs("button",{onClick:()=>n(s?null:t.id),className:"w-full text-left px-4 py-3 bg-surface-1 border border-border-subtle rounded-lg hover:border-accent/30 transition-colors cursor-pointer",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-sm font-mono font-bold text-text-0 truncate flex-1",children:t.name}),i.jsx("span",{className:"text-2xs text-text-4 font-sans",children:t.author}),s?i.jsx(on,{size:14,className:"text-text-3"}):i.jsx(Gl,{size:14,className:"text-text-3"})]}),i.jsxs("div",{className:"text-2xs text-text-3 font-sans mt-0.5 flex gap-3",children:[i.jsxs("span",{children:[(l=t.downloads)==null?void 0:l.toLocaleString()," downloads"]}),i.jsxs("span",{children:[t.likes," likes"]})]})]})}function iZ({repoId:t,onDownload:n,systemRamGb:s}){const[l,o]=y.useState(null),[u,d]=y.useState(!0),[O,m]=y.useState(null),p=Wl();y.useEffect(()=>{d(!0),ee.get(`/models/${t}/files`).then(x=>o(x.files||[])).catch(()=>p.error("Failed to load model files")).finally(()=>d(!1))},[t]);async function g(x){m(x.filename);try{await ee.post("/models/download",{repoId:t,filename:x.filename}),p.success(`Downloading ${x.filename}`),n==null||n(x.filename)}catch(b){p.error(b.message)}m(null)}return u?i.jsx("div",{className:"py-3 px-4 text-2xs text-text-4 font-sans",children:"Loading quantization variants..."}):l!=null&&l.length?i.jsx("div",{className:"pl-6 pr-4 pb-2 space-y-1.5",children:l.map(x=>{const b=!x.estimatedRamGb||!s||x.estimatedRamGb<=s*.85,v=x.estimatedRamGb&&s&&x.estimatedRamGb>s*.7&&b;return i.jsxs("div",{className:se("flex items-center gap-2 py-1.5 px-3 rounded-md text-xs font-sans",b?"bg-surface-2":"bg-red-500/5 border border-red-500/15"),children:[i.jsx("span",{className:"font-mono text-text-1 truncate flex-1",children:x.filename}),x.quantization&&i.jsx(Ze,{variant:"subtle",className:"text-2xs",children:x.quantization}),i.jsx("span",{className:"text-text-2 text-2xs w-16 text-right",children:Cc(x.size)}),x.estimatedRamGb&&i.jsxs("span",{className:se("text-2xs w-20 text-right font-medium",b?v?"text-yellow-400":"text-green-400":"text-red-400"),children:["~",x.estimatedRamGb," GB RAM"]}),!b&&i.jsx("span",{className:"text-2xs text-red-400 font-medium",children:"too large"}),i.jsx("button",{onClick:()=>g(x),disabled:O===x.filename||!b,className:se("p-1 rounded transition-colors",b?"text-accent hover:bg-accent/10":"text-text-4 cursor-not-allowed","disabled:opacity-40"),children:O===x.filename?i.jsx(Kn,{size:13,className:"animate-spin"}):i.jsx(hi,{size:13})})]},x.filename)})}):i.jsx("div",{className:"py-3 px-4 text-2xs text-text-4 font-sans",children:"No GGUF files found in this repo."})}function oZ({model:t,systemRamGb:n,onPull:s,pulling:l}){const o={light:"text-green-400",medium:"text-blue-400",heavy:"text-orange-400"},u={code:"{}",general:"AI"},d=n?Math.round((1-t.ramGb/n)*100):null;return i.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 bg-surface-1 border border-border-subtle rounded-lg hover:border-accent/20 transition-colors",children:[i.jsx("div",{className:"w-9 h-9 rounded-lg bg-surface-3 flex items-center justify-center text-xs font-mono text-text-2 flex-shrink-0",children:u[t.category]||"AI"}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-sm font-mono font-bold text-text-0 truncate",children:t.name}),i.jsx("span",{className:se("text-2xs font-semibold capitalize",o[t.tier]),children:t.tier})]}),i.jsx("div",{className:"text-2xs text-text-3 font-sans mt-0.5",children:t.description}),i.jsxs("div",{className:"flex items-center gap-3 mt-1 text-2xs font-sans",children:[i.jsxs("span",{className:"text-text-2",children:[t.sizeGb," GB download"]}),i.jsxs("span",{className:"text-green-400 font-medium",children:[t.ramGb," GB RAM"]}),d!==null&&i.jsxs("span",{className:"text-text-4",children:[d,"% headroom"]})]})]}),i.jsxs("button",{onClick:()=>s(t.id),disabled:l===t.id,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-md text-xs font-sans font-medium bg-accent/10 text-accent hover:bg-accent/20 transition-colors cursor-pointer disabled:opacity-40",children:[l===t.id?i.jsx(Kn,{size:12,className:"animate-spin"}):i.jsx(hi,{size:12}),"Pull"]})]})}function cZ(){const[t,n]=y.useState("recommended"),[s,l]=y.useState(""),[o,u]=y.useState([]),[d,O]=y.useState(!1),[m,p]=y.useState([]),[g,x]=y.useState([]),[b,v]=y.useState([]),[Q,w]=y.useState(null),[T,k]=y.useState(null),[z,$]=y.useState(null),C=Wl(),G=y.useCallback(()=>{ee.get("/models/installed").then(E=>{p(E.models||[])}).catch(()=>{})},[]);y.useEffect(()=>{ee.get("/providers/ollama/hardware").then(w).catch(()=>{}),ee.get("/models/recommended").then(E=>{x(E.models||[]),!Q&&E.hardware&&w(E.hardware)}).catch(()=>{}),G()},[G]);async function X(E){$(E);try{await ee.post("/providers/ollama/pull",{model:E}),C.success(`${E} pulled successfully`),G()}catch(Y){C.error(`Pull failed: ${Y.message}`)}$(null)}y.useEffect(()=>{const E=D.subscribe((ne,oe)=>{}),Y=setInterval(()=>{ee.get("/models/downloads").then(v).catch(()=>{})},2e3);return()=>{E(),clearInterval(Y)}},[]),y.useEffect(()=>{function E(ne){try{const oe=JSON.parse(ne.data);oe.type==="model:download:progress"&&v(ce=>{const re=ce.findIndex(F=>F.filename===oe.data.filename);if(re>=0){const F=[...ce];return F[re]=oe.data,F}return[...ce,oe.data]}),oe.type==="model:download:complete"&&(v(ce=>ce.filter(re=>re.filename!==oe.data.filename)),G(),C.success(`${oe.data.filename} downloaded`)),oe.type==="model:download:error"&&(v(ce=>ce.filter(re=>re.filename!==oe.data.filename)),C.error(`Download failed: ${oe.data.error}`))}catch{}}const Y=D.getState()._ws;return Y&&Y.addEventListener("message",E),()=>{Y&&Y.removeEventListener("message",E)}},[G,C]);async function _(){if(s.trim()){O(!0),n("search");try{const E=await ee.get(`/models/search?q=${encodeURIComponent(s.trim())}`);u(E)}catch(E){C.error(E.message)}O(!1)}}async function N(E){try{await ee.delete(`/models/${E}`),p(Y=>Y.filter(ne=>ne.id!==E)),C.success("Model deleted")}catch(Y){C.error(Y.message)}}return i.jsxs("div",{className:"h-full flex flex-col bg-surface-0",children:[i.jsxs("div",{className:"flex-shrink-0 px-5 pt-4 pb-3 border-b border-border space-y-3",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("h1",{className:"text-base font-bold font-sans text-text-0",children:"Local Models"}),i.jsxs(Ze,{variant:"subtle",className:"text-2xs",children:[m.length," installed"]})]}),i.jsx(nZ,{hardware:Q}),i.jsxs("div",{className:"flex gap-2",children:[i.jsxs("div",{className:"relative flex-1",children:[i.jsx(un,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-text-4"}),i.jsx("input",{value:s,onChange:E=>l(E.target.value),onKeyDown:E=>E.key==="Enter"&&_(),placeholder:"Search HuggingFace for GGUF models...",className:"w-full h-8 pl-9 pr-3 text-sm rounded-md bg-surface-1 border border-border text-text-0 font-sans placeholder:text-text-4 focus:outline-none focus:ring-1 focus:ring-accent"})]}),i.jsx(be,{onClick:_,disabled:d,size:"sm",variant:"accent",children:d?i.jsx(Kn,{size:14,className:"animate-spin"}):"Search"})]}),i.jsx("div",{className:"flex gap-1",children:[{id:"recommended",label:`Recommended (${g.length})`},{id:"installed",label:`Installed (${m.length})`},{id:"search",label:`Search (${o.length})`}].map(E=>i.jsx("button",{onClick:()=>n(E.id),className:se("px-3 py-1 rounded-md text-xs font-sans font-medium transition-colors cursor-pointer",t===E.id?"bg-accent/12 text-accent":"text-text-3 hover:text-text-1 hover:bg-surface-3"),children:E.label},E.id))})]}),b.length>0&&i.jsxs("div",{className:"px-5 py-3 border-b border-border space-y-2",children:[i.jsx("div",{className:"text-xs font-sans font-semibold text-text-2",children:"Downloading"}),b.map(E=>i.jsx(sZ,{download:E},E.filename))]}),i.jsx(fn,{className:"flex-1",children:i.jsxs("div",{className:"px-5 py-4 space-y-2",children:[t==="recommended"&&i.jsx(i.Fragment,{children:g.length===0?i.jsxs("div",{className:"text-center py-12",children:[i.jsx(Zl,{size:40,className:"mx-auto text-text-4 mb-3"}),i.jsx("p",{className:"text-sm text-text-2 font-sans font-medium",children:"Detecting hardware..."}),i.jsx("p",{className:"text-xs text-text-3 font-sans mt-1",children:"Make sure Ollama is installed so we can check your system."})]}):i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"text-xs text-text-3 font-sans mb-2",children:["Top models for your system (",(Q==null?void 0:Q.totalRamGb)||"?"," GB RAM). Click Pull to download via Ollama."]}),g.map(E=>i.jsx(oZ,{model:E,systemRamGb:Q==null?void 0:Q.totalRamGb,onPull:X,pulling:z},E.id))]})}),t==="installed"&&i.jsx(i.Fragment,{children:m.length===0?i.jsxs("div",{className:"text-center py-12",children:[i.jsx(Hf,{size:40,className:"mx-auto text-text-4 mb-3"}),i.jsx("p",{className:"text-sm text-text-2 font-sans font-medium",children:"No local models yet"}),i.jsx("p",{className:"text-xs text-text-3 font-sans mt-1",children:"Search HuggingFace to download GGUF models, or pull models via Ollama."})]}):m.map(E=>i.jsx(lZ,{model:E,onDelete:N},E.id))}),t==="search"&&i.jsx(i.Fragment,{children:d?i.jsxs("div",{className:"text-center py-12",children:[i.jsx(Kn,{size:24,className:"mx-auto text-accent animate-spin mb-3"}),i.jsx("p",{className:"text-sm text-text-3 font-sans",children:"Searching HuggingFace..."})]}):o.length===0?i.jsxs("div",{className:"text-center py-12",children:[i.jsx(un,{size:40,className:"mx-auto text-text-4 mb-3"}),i.jsx("p",{className:"text-sm text-text-2 font-sans font-medium",children:"Search for GGUF models"}),i.jsx("p",{className:"text-xs text-text-3 font-sans mt-1",children:'Try "qwen coder", "deepseek", "codestral", "llama"'})]}):o.map(E=>i.jsxs("div",{className:"space-y-1",children:[i.jsx(rZ,{result:E,expanded:T===E.id,onExpand:k}),T===E.id&&i.jsx(iZ,{repoId:E.id,onDownload:()=>G(),systemRamGb:Q==null?void 0:Q.totalRamGb})]},E.id))})]})})]})}const Rf=[];function BS(t){const n=(t||"").toLowerCase();return n.includes("reading")||n.includes("read ")?{icon:mi,color:"text-info",label:"Reading"}:n.includes("editing")||n.includes("wrote")||n.includes("writing")||n.includes("edit ")?{icon:Cb,color:"text-warning",label:"Editing"}:n.includes("searching")||n.includes("search")||n.includes("grep")||n.includes("glob")?{icon:un,color:"text-purple",label:"Searching"}:n.includes("running")||n.includes("bash")||n.includes("command")||n.includes("exec")?{icon:xi,color:"text-orange",label:"Running"}:n.includes("test")||n.includes("pass")?{icon:mf,color:"text-success",label:"Testing"}:n.includes("error")||n.includes("fail")||n.includes("crash")?{icon:cn,color:"text-danger",label:"Error"}:n.includes("rotat")?{icon:Ll,color:"text-accent",label:"Rotating"}:n.includes("spawn")||n.includes("start")?{icon:Pa,color:"text-success",label:"Spawned"}:n.includes("tool")||n.includes("function")?{icon:qN,color:"text-text-2",label:"Tool"}:n.includes("complet")||n.includes("done")||n.includes("finish")?{icon:mf,color:"text-success",label:"Done"}:{icon:On,color:"text-text-3",label:"Activity"}}function wl({text:t}){return t?t.split(/(\*\*[^*]+\*\*|`[^`]+`)/g).map((n,s)=>n.startsWith("**")&&n.endsWith("**")?i.jsx("strong",{className:"font-semibold text-text-0",children:n.slice(2,-2)},s):n.startsWith("`")&&n.endsWith("`")?i.jsx("code",{className:"px-1 py-px rounded bg-accent/8 text-[11px] font-mono text-accent",children:n.slice(1,-1)},s):i.jsx("span",{children:n},s)):null}function uZ({text:t}){if(!t)return null;const n=[],s=t.split(`
|
|
627
|
+
For more information, see https://radix-ui.com/primitives/docs/components/${n.docsSlug}`;return y.useEffect(()=>{t&&(document.getElementById(t)||console.error(s))},[s,t]),null},U_="DialogDescriptionWarning",G_=({contentRef:t,descriptionId:n})=>{const l=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${XS(U_).contentName}}.`;return y.useEffect(()=>{var u;const o=(u=t.current)==null?void 0:u.getAttribute("aria-describedby");n&&o&&(document.getElementById(n)||console.warn(l))},[l,t,n]),null},_S=yS,ZS=jS,AS=wS,ES=kS,qS=TS,MS=PS,YS=RS;function VS({children:t,...n}){return i.jsx(_S,{...n,children:t})}function US({children:t,className:n,title:s,description:l,...o}){return i.jsxs(ZS,{children:[i.jsx(AS,{className:"fixed inset-0 z-50 bg-black/50 backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0"}),i.jsxs(ES,{className:se("fixed left-1/2 top-1/2 z-50 -translate-x-1/2 -translate-y-1/2","w-full max-w-lg max-h-[85vh] overflow-y-auto","bg-surface-1 border border-border rounded-lg shadow-2xl","data-[state=open]:animate-in data-[state=closed]:animate-out","data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0","data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95",n),...o,children:[s&&i.jsxs("div",{className:"flex items-center justify-between px-5 py-4 border-b border-border-subtle",children:[i.jsx(qS,{className:"text-base font-semibold text-text-0 font-sans",children:s}),i.jsx(YS,{className:"p-1 rounded-md text-text-3 hover:text-text-0 hover:bg-surface-5 transition-colors",children:i.jsx(jt,{size:16})})]}),l&&i.jsx(MS,{className:"sr-only",children:l}),t]})]})}var b0={};function L_({path:t,onNavigate:n}){const s=t.split("/").filter(Boolean);return i.jsxs("div",{className:"flex items-center gap-0.5 min-w-0 overflow-x-auto py-1.5 scrollbar-none",children:[i.jsx("button",{onClick:()=>n("/"),className:"flex-shrink-0 p-1 rounded hover:bg-surface-5 cursor-pointer text-text-3 hover:text-text-0 transition-colors",children:i.jsx(Ff,{size:13})}),s.map((l,o)=>{const u="/"+s.slice(0,o+1).join("/"),d=o===s.length-1;return i.jsxs("div",{className:"flex items-center gap-0.5 flex-shrink-0",children:[i.jsx(Gl,{size:11,className:"text-text-4"}),i.jsx("button",{onClick:()=>n(u),className:se("px-1.5 py-0.5 rounded text-xs font-mono cursor-pointer transition-colors",d?"text-text-0 bg-surface-4 font-medium":"text-text-3 hover:text-text-0 hover:bg-surface-5"),children:l})]},o)})]})}function GS({open:t,onOpenChange:n,currentPath:s,onSelect:l}){const[o,u]=y.useState(s||b0.HOME||"/"),[d,O]=y.useState([]),[m,p]=y.useState(!1),[g,x]=y.useState(null);y.useEffect(()=>{t&&b(s||"/")},[t]);async function b(T){p(!0),x(null);try{const k=await ee.get(`/browse-system?path=${encodeURIComponent(T)}`);u(k.current||T),O(k.dirs||[])}catch(k){x(k.message),O([])}p(!1)}function v(){const T=o==="/"?"/":o.split("/").slice(0,-1).join("/")||"/";b(T)}function Q(){b(b0.HOME||"/Users")}function w(){l(o),n(!1)}return i.jsx(VS,{open:t,onOpenChange:n,children:i.jsx(US,{title:"Select Working Directory",description:"Choose a directory for this agent to work in",className:"max-w-[520px]",children:i.jsxs("div",{className:"px-5 py-4 space-y-3",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("button",{onClick:v,disabled:o==="/",className:"p-1.5 rounded-md bg-surface-4 border border-border text-text-2 hover:text-text-0 hover:bg-surface-5 transition-colors cursor-pointer disabled:opacity-30 disabled:cursor-not-allowed",children:i.jsx(y5,{size:14})}),i.jsx("button",{onClick:Q,className:"p-1.5 rounded-md bg-surface-4 border border-border text-text-2 hover:text-text-0 hover:bg-surface-5 transition-colors cursor-pointer",children:i.jsx(vT,{size:14})}),i.jsx("div",{className:"flex-1 min-w-0 bg-surface-0 rounded-md border border-border-subtle px-2",children:i.jsx(L_,{path:o,onNavigate:b})})]}),i.jsx("div",{className:"bg-surface-0 rounded-lg border border-border-subtle overflow-hidden",children:i.jsxs("div",{className:"max-h-[340px] overflow-y-auto",children:[m&&i.jsx("div",{className:"flex items-center justify-center py-8",children:i.jsx(Kn,{size:18,className:"text-text-3 animate-spin"})}),g&&i.jsx("div",{className:"px-4 py-6 text-center",children:i.jsx("p",{className:"text-xs text-danger font-sans",children:g})}),!m&&!g&&d.length===0&&i.jsx("div",{className:"px-4 py-6 text-center",children:i.jsx("p",{className:"text-xs text-text-3 font-sans",children:"No subdirectories"})}),!m&&!g&&d.map(T=>i.jsxs("button",{onClick:()=>b(T.path),className:se("w-full flex items-center gap-2.5 px-3.5 py-2 text-left cursor-pointer","hover:bg-surface-4 transition-colors border-b border-border-subtle last:border-0"),children:[T.hasChildren?i.jsx(oT,{size:15,className:"text-warning flex-shrink-0"}):i.jsx(ai,{size:15,className:"text-text-3 flex-shrink-0"}),i.jsx("span",{className:"text-sm text-text-0 font-sans truncate flex-1",children:T.name}),T.hasChildren&&i.jsx(Gl,{size:12,className:"text-text-4 flex-shrink-0"})]},T.path))]})}),i.jsxs("div",{className:"flex items-center gap-3 bg-surface-4/50 rounded-lg px-3.5 py-2.5 border border-border-subtle",children:[i.jsx(ai,{size:16,className:"text-accent flex-shrink-0"}),i.jsx("span",{className:"text-xs font-mono text-text-1 truncate flex-1",children:o})]}),i.jsxs("div",{className:"flex justify-end gap-2",children:[i.jsx(be,{variant:"ghost",size:"md",onClick:()=>n(!1),children:"Cancel"}),i.jsxs(be,{variant:"primary",size:"md",onClick:w,className:"gap-1.5",children:[i.jsx(ia,{size:14})," Select Folder"]})]})]})})})}function LS({children:t,...n}){return i.jsx(_S,{...n,children:t})}function DS({children:t,className:n,title:s,side:l="right",width:o=400,...u}){return i.jsxs(ZS,{children:[i.jsx(AS,{className:"fixed inset-0 z-40 bg-black/30"}),i.jsxs(ES,{className:se("fixed top-0 z-50 h-full overflow-y-auto","bg-surface-1 border-l border-border shadow-2xl","data-[state=open]:animate-in data-[state=closed]:animate-out",l==="right"&&"right-0 data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right",l==="left"&&"left-0 data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left",n),style:{width:o},...u,children:[s&&i.jsxs("div",{className:"flex items-center justify-between px-5 py-4 border-b border-border-subtle sticky top-0 bg-surface-1 z-10",children:[i.jsx(qS,{className:"text-base font-semibold text-text-0 font-sans",children:s}),i.jsx(YS,{className:"p-1 rounded-md text-text-3 hover:text-text-0 hover:bg-surface-5 transition-colors cursor-pointer",children:i.jsx(jt,{size:16})})]}),i.jsx(MS,{className:"sr-only",children:"Panel"}),t]})]})}function D_({value:t,onChange:n}){return i.jsx("button",{onClick:()=>n(!t),className:se("w-9 h-5 rounded-full p-0.5 transition-colors cursor-pointer",t?"bg-accent":"bg-surface-5"),children:i.jsx("div",{className:se("w-4 h-4 rounded-full bg-white shadow-sm transition-transform",t?"translate-x-4":"translate-x-0")})})}function W_({user:t}){const[n,s]=y.useState(!1),l=(t==null?void 0:t.avatar)||(t==null?void 0:t.picture)||(t==null?void 0:t.photoURL)||(t==null?void 0:t.photo);return l&&!n?i.jsx("img",{src:l,alt:"",className:"w-6 h-6 rounded-full",referrerPolicy:"no-referrer",crossOrigin:"anonymous",onError:()=>s(!0)}):i.jsx("div",{className:"w-6 h-6 rounded-full bg-accent/10 flex items-center justify-center",children:i.jsx(Hb,{size:12,className:"text-accent"})})}function B_({provider:t,onKeyChange:n}){var T,k,z;const[s,l]=y.useState(!1),[o,u]=y.useState(""),[d,O]=y.useState(!1),[m,p]=y.useState(!1),g=D($=>$.addToast),x=t.authType==="local",b=t.authType==="subscription",v=x||b?t.installed:t.hasKey;async function Q(){if(o.trim())try{await ee.post(`/credentials/${t.id}`,{key:o.trim()}),g("success",`API key set for ${t.name}`),u(""),l(!1),n&&n()}catch($){g("error","Failed to set key",$.message)}}async function w(){try{await ee.delete(`/credentials/${t.id}`),g("info",`Removed ${t.name} key`),n&&n()}catch($){g("error","Remove failed",$.message)}}if(x){const $=((k=(T=t.models)==null?void 0:T.filter(G=>!G.disabled))==null?void 0:k.length)||0,C=()=>D.getState().setActiveView("models");return i.jsxs("div",{className:"flex flex-col rounded-lg border border-border-subtle bg-surface-1 overflow-hidden min-w-[220px]",children:[i.jsxs("div",{className:"flex items-center gap-2.5 px-4 py-3 border-b border-border-subtle",children:[i.jsx($s,{status:v&&$>0?"running":"crashed",size:"sm"}),i.jsx("span",{className:"text-[13px] font-semibold text-text-0 font-sans",children:t.name}),i.jsx("div",{className:"flex-1"}),v&&$>0?i.jsxs(Ze,{variant:"success",className:"text-2xs gap-1",children:[i.jsx(ia,{size:8})," ",$," models"]}):v?i.jsx(Ze,{variant:"warning",className:"text-2xs",children:"No models pulled"}):i.jsx(Ze,{variant:"default",className:"text-2xs",children:"Not set up"})]}),i.jsx("div",{className:"flex-1",children:m?i.jsxs(i.Fragment,{children:[i.jsx(oS,{isInstalled:v,onModelChange:n}),i.jsxs("div",{className:"px-4 py-2 border-t border-border-subtle flex gap-2",children:[i.jsx(be,{variant:"ghost",size:"sm",onClick:()=>p(!1),className:"flex-1 h-7 text-2xs",children:"Back"}),i.jsx(be,{variant:"secondary",size:"sm",onClick:()=>{p(!1),C()},className:"flex-1 h-7 text-2xs gap-1",children:"Models Tab"})]})]}):i.jsxs("div",{className:"px-4 py-3 flex flex-col h-full",children:[i.jsx("div",{className:"text-xs text-text-3 font-sans flex-1",children:v&&$>0?"Full agentic runtime — tool calling, context rotation, zero cloud cost":v?"Ollama is running. Pull a model to start using local agents.":"Run any open-source model locally — free, private, fully offline. Requires Ollama."}),i.jsxs("div",{className:"flex gap-2 mt-3",children:[v?i.jsxs(be,{variant:"primary",size:"sm",onClick:()=>p(!0),className:"flex-1 h-7 text-2xs gap-1.5",children:[i.jsx(Zl,{size:11})," ",$>0?"Manage":"Pull Models"]}):i.jsxs(be,{variant:"primary",size:"sm",onClick:()=>p(!0),className:"flex-1 h-7 text-2xs gap-1.5",children:[i.jsx(Zl,{size:11})," Set Up Ollama"]}),i.jsx(be,{variant:"secondary",size:"sm",onClick:C,className:"flex-1 h-7 text-2xs gap-1.5",children:"Models Tab"})]})]})})]})}return i.jsxs("div",{className:"flex flex-col rounded-lg border border-border-subtle bg-surface-1 overflow-hidden min-w-[220px]",children:[i.jsxs("div",{className:"flex items-center gap-2.5 px-4 py-3 border-b border-border-subtle",children:[i.jsx($s,{status:v?"running":"crashed",size:"sm"}),i.jsx("span",{className:"text-[13px] font-semibold text-text-0 font-sans",children:t.name}),i.jsx("div",{className:"flex-1"}),v?i.jsxs(Ze,{variant:"success",className:"text-2xs gap-1",children:[i.jsx(ia,{size:8})," Ready"]}):i.jsx(Ze,{variant:"default",className:"text-2xs",children:b?"Not installed":"No key"})]}),i.jsxs("div",{className:"flex-1 flex flex-col px-4 py-3 min-h-[120px]",children:[((z=t.models)==null?void 0:z.length)>0&&i.jsx("div",{className:"flex flex-wrap gap-1 mb-3",children:t.models.map($=>i.jsx("span",{className:"px-1.5 py-0.5 rounded bg-surface-4 text-2xs font-mono text-text-3",children:$.name||$.id},$.id))}),b&&v&&!t.hasKey&&!s&&i.jsxs("div",{className:"flex items-center gap-1.5 h-8 px-2.5 bg-accent/8 border border-accent/20 rounded-md text-2xs font-sans text-accent mb-3",children:[i.jsx(ia,{size:10})," Subscription active"]}),t.hasKey&&!s&&i.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[i.jsxs("div",{className:"flex-1 flex items-center gap-1.5 h-8 px-2.5 bg-success/8 border border-success/20 rounded-md text-2xs font-sans text-success",children:[i.jsx(ia,{size:10})," API Connected"]}),i.jsx("button",{onClick:()=>{l(!0),O(!1),u("")},className:"text-2xs text-text-4 hover:text-accent cursor-pointer font-sans",children:"Edit"}),i.jsx("button",{onClick:w,className:"text-2xs text-text-4 hover:text-danger cursor-pointer font-sans",children:"Remove"})]}),i.jsx("div",{className:"flex-1"}),s&&i.jsxs("div",{className:"space-y-2.5 pt-1",children:[i.jsxs("div",{children:[i.jsx("label",{className:"text-2xs font-semibold text-text-2 font-sans mb-1.5 block",children:t.hasKey?"Update API Key":`${t.name} API Key`}),i.jsxs("div",{className:"relative",children:[i.jsx("input",{value:o,onChange:$=>u($.target.value),onKeyDown:$=>$.key==="Enter"&&Q(),type:d?"text":"password",placeholder:"sk-...",className:"w-full h-9 px-3 pr-9 text-xs bg-surface-0 border border-border rounded-md text-text-0 font-mono placeholder:text-text-4 focus:outline-none focus:ring-1 focus:ring-accent",autoFocus:!0}),i.jsx("button",{onClick:()=>O(!d),className:"absolute right-2.5 top-1/2 -translate-y-1/2 text-text-4 hover:text-text-2 cursor-pointer",children:d?i.jsx(If,{size:12}):i.jsx(mi,{size:12})})]})]}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx(be,{variant:"primary",size:"sm",onClick:Q,disabled:!o.trim(),className:"flex-1 h-8 text-xs",children:"Save Key"}),i.jsx(be,{variant:"ghost",size:"sm",onClick:()=>{l(!1),u("")},className:"h-8 text-xs px-3",children:"Cancel"})]})]}),!s&&!t.hasKey&&i.jsxs(be,{variant:b?"secondary":"primary",size:"sm",onClick:()=>{l(!0),O(!1),u("")},className:"w-full h-8 text-2xs gap-1.5 mt-2",children:[i.jsx(vc,{size:11}),b?"Add API key for headless mode":"Add API Key"]})]})]})}function Ql({icon:t,label:n,description:s,children:l}){return i.jsxs("div",{className:"rounded-lg border border-border-subtle bg-surface-1 px-4 py-3.5 flex flex-col gap-2",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("div",{className:"w-6 h-6 rounded bg-accent/8 flex items-center justify-center flex-shrink-0",children:i.jsx(t,{size:12,className:"text-accent"})}),i.jsx("div",{className:"text-[13px] font-medium text-text-0 font-sans leading-tight",children:n})]}),i.jsx("div",{className:"text-2xs text-text-4 font-sans leading-relaxed",children:s}),i.jsx("div",{className:"mt-auto pt-1",children:l})]})}const WS={telegram:th,discord:pi,slack:qb},js={telegram:"Telegram",discord:"Discord",slack:"Slack"},H_={telegram:"Bot token from @BotFather",discord:"Bot token from Developer Portal",slack:"Bot token (xoxb-...)"},I_=["critical","lifecycle","all"];function F_({type:t,open:n,onOpenChange:s}){if(!t)return null;const o={telegram:{title:"Set Up Telegram",icon:th,intro:"Create a Telegram bot and connect it to Groove in under 2 minutes. No dependencies required.",sections:[{title:"Create Your Bot",steps:[{text:"Open Telegram on any device and search for",link:"https://t.me/BotFather",linkText:"@BotFather"},{text:"Send /newbot to start the setup"},{text:"Choose a display name — we suggest GroovePilot"},{text:'Choose a username (must end in "bot") — e.g. GroovePilot_bot'},{text:"BotFather will reply with your bot token — copy it"}]},{title:"Connect to Groove",steps:[{text:"In Groove Settings > Gateways, click Set Token on the Telegram card"},{text:"Paste your bot token and click Save"},{text:"The gateway will connect automatically"}]},{title:"Link a Chat",steps:[{text:"Open a chat with your new bot in Telegram"},{text:'Send any message (e.g. "hello") — Groove captures the chat ID automatically'},{text:"Click Test in the gateway card to verify"}]},{title:"Commands",note:"All commands use / prefix in Telegram:",commands:["/instruct <team> <msg>","/query <team> <question>","/plan <description>","/log <team>","/brief","/tokens","/status","/agents","/help"]}]},discord:{title:"Set Up Discord",icon:pi,intro:"Create a Discord bot and add it to your server. Requires discord.js (installed automatically with Groove).",sections:[{title:"Create the Application",steps:[{text:"Go to the",link:"https://discord.com/developers/applications",linkText:"Discord Developer Portal"},{text:"Click New Application and name it GroovePilot"},{text:"Go to the Bot tab in the left sidebar"},{text:"Click Reset Token and copy the bot token"}]},{title:"Set Permissions & Invite",steps:[{text:"Go to OAuth2 > URL Generator"},{text:"Under Scopes, check bot"},{text:"Under Bot Permissions, check:"}],scopes:["Send Messages","Read Message History","Embed Links","Use External Emojis"],after:[{text:"Copy the generated URL at the bottom and open it in your browser"},{text:"Select your server and click Authorize"}]},{title:"Enable Message Content Intent",steps:[{text:"Go back to the Bot tab in the Developer Portal"},{text:"Scroll to Privileged Gateway Intents"},{text:"Enable Message Content Intent — required for the bot to read commands"},{text:"Click Save Changes"}]},{title:"Connect to Groove",steps:[{text:"In Groove Settings > Gateways, click Set Token on the Discord card"},{text:"Paste your bot token and click Save"},{text:"Send a message in any channel where the bot is — Groove captures the channel automatically"}]},{title:"Commands",note:"All commands use / prefix in Discord:",commands:["/instruct <team> <msg>","/query <team> <question>","/plan <description>","/log <team>","/brief","/tokens","/status","/agents","/help"]}]},slack:{title:"Set Up Slack",icon:qb,intro:"Create a Slack app with Socket Mode — no public URL needed. Requires @slack/bolt (installed automatically with Groove).",sections:[{title:"Create the App",steps:[{text:"Go to",link:"https://api.slack.com/apps",linkText:"api.slack.com/apps"},{text:"Click Create New App > From scratch"},{text:"Name it GroovePilot and select your workspace"}]},{title:"Enable Socket Mode",steps:[{text:"In the left sidebar, go to Settings > Socket Mode"},{text:"Toggle Enable Socket Mode to on"},{text:"It will ask you to create an App-Level Token"},{text:'Name it "groove", add the connections:write scope'},{text:"Click Generate — copy the xapp-... token (this is your App Token)"}],important:"Save this token now — you can't view it again after closing the dialog."},{title:"Set Bot Token Scopes",steps:[{text:"Go to Features > OAuth & Permissions"},{text:"Scroll to Bot Token Scopes and add all of these:"}],scopes:["chat:write","channels:read","channels:history","groups:read","groups:history","im:history","app_mentions:read"],after:[{text:"Scroll up and click Install to Workspace"},{text:"Click Allow to grant permissions"},{text:"Copy the Bot User OAuth Token (xoxb-...) — this is your Bot Token"}]},{title:"Enable Events",steps:[{text:"Go to Features > Event Subscriptions"},{text:"Toggle Enable Events to on"},{text:"Under Subscribe to bot events, add:"}],scopes:["message.channels","message.im","app_mention"],after:[{text:"Click Save Changes at the bottom"}]},{title:"Connect to Groove",steps:[{text:"In Groove Settings > Gateways, click Set Token on the Slack card"},{text:"Paste your Bot Token (xoxb-...) in the first field"},{text:"Paste your App Token (xapp-...) in the second field"},{text:"Click Save — Groove will auto-connect"}]},{title:"Link a Channel",steps:[{text:"Invite the bot to a channel: /invite @GroovePilot"},{text:"Select the channel from the dropdown in the gateway card"},{text:"Or @mention the bot — it will auto-capture the channel"},{text:"Click Test to verify"}],important:"For private channels, make sure you added the groups:read scope."},{title:"Commands",note:"In Slack, use plain text commands (no / prefix) or @mention the bot:",commands:["instruct <team> <msg>","query <team> <question>","plan <description>","log <team>","brief","tokens","status","agents","help","@GroovePilot status"]}]}}[t];if(!o)return null;const u=o.icon;return i.jsx(LS,{open:n,onOpenChange:s,children:i.jsx(DS,{title:o.title,width:480,children:i.jsxs("div",{className:"px-5 py-4 space-y-5",children:[i.jsxs("div",{className:"flex items-start gap-3 p-3 bg-accent/5 border border-accent/15 rounded-lg",children:[i.jsx("div",{className:"w-8 h-8 rounded-lg bg-accent/10 flex items-center justify-center flex-shrink-0 mt-0.5",children:i.jsx(u,{size:16,className:"text-accent"})}),i.jsx("p",{className:"text-xs text-text-2 font-sans leading-relaxed",children:o.intro})]}),o.sections.map((d,O)=>{var m;return i.jsxs("div",{children:[i.jsxs("h3",{className:"text-xs font-semibold text-text-0 font-sans mb-2.5 flex items-center gap-2",children:[i.jsx("span",{className:"w-5 h-5 rounded-full bg-accent/10 flex items-center justify-center text-2xs font-bold text-accent",children:O+1}),d.title]}),d.note&&i.jsx("p",{className:"text-2xs text-text-3 font-sans mb-2",children:d.note}),d.steps&&i.jsx("ol",{className:"space-y-2 mb-2",children:d.steps.map((p,g)=>i.jsxs("li",{className:"flex gap-2 text-2xs text-text-2 font-sans leading-relaxed",children:[i.jsxs("span",{className:"text-text-4 font-mono w-4 flex-shrink-0 pt-px",children:[g+1,"."]}),i.jsxs("span",{children:[p.text,p.link&&i.jsxs(i.Fragment,{children:[" ",i.jsxs("a",{href:p.link,target:"_blank",rel:"noopener noreferrer",className:"text-accent hover:underline inline-flex items-center gap-0.5 font-medium",children:[p.linkText,i.jsx(bc,{size:9})]})]})]})]},g))}),d.scopes&&i.jsx("div",{className:"flex flex-wrap gap-1.5 mb-2 ml-6",children:d.scopes.map(p=>i.jsx("code",{className:"px-2 py-0.5 rounded bg-surface-4 text-2xs font-mono text-accent",children:p},p))}),d.after&&i.jsx("ol",{className:"space-y-2 mb-2",start:(((m=d.steps)==null?void 0:m.length)||0)+1,children:d.after.map((p,g)=>{var x;return i.jsxs("li",{className:"flex gap-2 text-2xs text-text-2 font-sans leading-relaxed",children:[i.jsxs("span",{className:"text-text-4 font-mono w-4 flex-shrink-0 pt-px",children:[(((x=d.steps)==null?void 0:x.length)||0)+g+1,"."]}),i.jsx("span",{children:p.text})]},g)})}),d.important&&i.jsx("div",{className:"ml-6 p-2 bg-warning/8 border border-warning/20 rounded-md text-2xs text-warning font-sans",children:d.important}),d.commands&&i.jsx("div",{className:"ml-6 p-2.5 bg-surface-0 border border-border-subtle rounded-md space-y-1",children:d.commands.map(p=>i.jsx("code",{className:"block text-2xs font-mono text-text-1",children:p},p))})]},O)}),i.jsxs("a",{href:"https://docs.groovedev.ai/guide/gateways",target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 text-2xs text-accent hover:text-accent/80 font-sans font-medium mt-2",children:[i.jsx(bc,{size:10}),"Full documentation at docs.groovedev.ai"]})]})})})}function K_({gateway:t,onRefresh:n}){var ce,re;const[s,l]=y.useState(!1),[o,u]=y.useState(""),[d,O]=y.useState(""),[m,p]=y.useState(!1),[g,x]=y.useState(!1),[b,v]=y.useState(!1),[Q,w]=y.useState([]),[T,k]=y.useState(!1),z=D(F=>F.addToast);y.useEffect(()=>{t.connected&&!t.chatId&&t.type==="slack"&&ee.get(`/gateways/${t.id}/channels`).then(F=>w(Array.isArray(F)?F:[])).catch(()=>{})},[t.connected,t.chatId,t.id,t.type]);const $=WS[t.type]||eh,C=t.type==="slack";async function G(){if(o.trim())try{await ee.post(`/gateways/${t.id}/credentials`,{key:"bot_token",value:o.trim()}),C&&d.trim()&&await ee.post(`/gateways/${t.id}/credentials`,{key:"app_token",value:d.trim()}),z("success","Token saved — connecting..."),u(""),O(""),l(!1);try{await ee.post(`/gateways/${t.id}/connect`),z("success",`${js[t.type]} connected!`)}catch(F){z("error","Token saved but connect failed",F.message)}n()}catch(F){z("error","Failed to save token",F.message)}}async function X(){x(!0);try{await ee.post(`/gateways/${t.id}/test`),z("success","Test message sent!")}catch(F){z("error","Test failed",F.message)}x(!1)}async function _(){v(!0);try{t.connected?(await ee.post(`/gateways/${t.id}/disconnect`),z("info",`${js[t.type]} disconnected`)):(await ee.post(`/gateways/${t.id}/connect`),z("success",`${js[t.type]} connected!`)),n()}catch(F){z("error",t.connected?"Disconnect failed":"Connect failed",F.message)}v(!1)}async function N(F){try{await ee.patch(`/gateways/${t.id}`,{enabled:F}),n()}catch(P){z("error","Update failed",P.message)}}async function E(F){try{await ee.patch(`/gateways/${t.id}`,{notifications:{preset:F}}),n()}catch(P){z("error","Update failed",P.message)}}async function Y(F){try{await ee.patch(`/gateways/${t.id}`,{commandPermission:F}),n()}catch(P){z("error","Update failed",P.message)}}async function ne(){try{await ee.delete(`/gateways/${t.id}`),z("info",`${js[t.type]} gateway removed`),n()}catch(F){z("error","Delete failed",F.message)}}const oe=((ce=t.notifications)==null?void 0:ce.preset)||"critical";return i.jsxs("div",{className:"flex flex-col rounded-lg border border-border-subtle bg-surface-1 overflow-hidden min-w-[220px]",children:[i.jsxs("div",{className:"flex items-center gap-2.5 px-4 py-3 border-b border-border-subtle",children:[i.jsx($s,{status:t.connected?"running":"crashed",size:"sm"}),i.jsx($,{size:13,className:"text-text-2"}),i.jsx("span",{className:"text-[13px] font-semibold text-text-0 font-sans",children:js[t.type]}),i.jsx("div",{className:"flex-1"}),t.connected?i.jsxs(Ze,{variant:"success",className:"text-2xs gap-1",children:[i.jsx(a1,{size:8})," Connected"]}):t.enabled?i.jsx(Ze,{variant:"warning",className:"text-2xs",children:"Disconnected"}):i.jsx(Ze,{variant:"default",className:"text-2xs",children:"Disabled"})]}),i.jsxs("div",{className:"flex-1 flex flex-col px-4 py-3 min-h-[140px]",children:[t.connected&&!s&&i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"flex items-center gap-1.5 h-8 px-2.5 bg-success/8 border border-success/20 rounded-md text-2xs font-sans text-success mb-3",children:[i.jsx(ia,{size:10})," Gateway active",t.botUsername&&i.jsxs("span",{className:"text-text-4 ml-1",children:["@",t.botUsername]}),t.botTag&&i.jsx("span",{className:"text-text-4 ml-1",children:t.botTag})]}),i.jsxs("div",{className:"mb-3",children:[i.jsx("label",{className:"text-2xs font-semibold text-text-3 font-sans mb-1.5 block",children:t.type==="slack"?"Channel":"Chat ID"}),t.chatId?i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("code",{className:"flex-1 flex items-center h-7 px-2 bg-surface-0 border border-border-subtle rounded-md text-2xs font-mono text-text-2",children:t.type==="slack"&&Q.length>0?`#${((re=Q.find(F=>F.id===t.chatId))==null?void 0:re.name)||t.chatId}`:t.chatId}),i.jsx("button",{onClick:async()=>{try{await ee.patch(`/gateways/${t.id}`,{chatId:null}),n()}catch(F){z("error","Failed",F.message)}},className:"text-2xs text-text-4 hover:text-text-1 cursor-pointer font-sans",children:"Change"})]}):t.type==="slack"&&Q.length>0?i.jsxs("select",{onChange:async F=>{if(F.target.value)try{await ee.patch(`/gateways/${t.id}`,{chatId:F.target.value}),n()}catch(P){z("error","Failed to set channel",P.message)}},className:"w-full h-7 px-2 text-2xs bg-surface-0 border border-border-subtle rounded-md text-text-0 font-sans focus:outline-none focus:ring-1 focus:ring-accent cursor-pointer",defaultValue:"",children:[i.jsx("option",{value:"",disabled:!0,children:"Select a channel..."}),Q.map(F=>i.jsxs("option",{value:F.id,children:["#",F.name]},F.id))]}):i.jsxs("div",{className:"text-2xs text-warning font-sans",children:[t.type==="slack"?"No channels found — invite the bot to a channel first.":"Send a message to the bot to auto-capture, or enter manually:",i.jsx("input",{placeholder:t.type==="slack"?"C0123456789":"Chat ID",className:"mt-1 w-full h-7 px-2 text-2xs bg-surface-0 border border-border rounded-md text-text-0 font-mono placeholder:text-text-4 focus:outline-none focus:ring-1 focus:ring-accent",onKeyDown:async F=>{if(F.key==="Enter"&&F.target.value.trim())try{await ee.patch(`/gateways/${t.id}`,{chatId:F.target.value.trim()}),n()}catch(P){z("error","Failed to set channel",P.message)}}})]})]}),i.jsxs("div",{className:"mb-3",children:[i.jsx("label",{className:"text-2xs font-semibold text-text-3 font-sans mb-1.5 block",children:"Notifications"}),i.jsx("div",{className:"flex bg-surface-0 rounded-md p-0.5 border border-border-subtle",children:I_.map(F=>i.jsx("button",{onClick:()=>E(F),className:se("flex-1 px-2 py-1.5 text-2xs font-semibold font-sans rounded transition-all cursor-pointer capitalize",oe===F?"bg-accent/15 text-accent shadow-sm":"text-text-3 hover:text-text-1"),children:F},F))})]}),i.jsxs("div",{className:"mb-3",children:[i.jsx("label",{className:"text-2xs font-semibold text-text-3 font-sans mb-1.5 block",children:"Commands"}),i.jsx("div",{className:"flex bg-surface-0 rounded-md p-0.5 border border-border-subtle",children:["full","read-only"].map(F=>i.jsx("button",{onClick:()=>Y(F),className:se("flex-1 px-2 py-1.5 text-2xs font-semibold font-sans rounded transition-all cursor-pointer capitalize",(t.commandPermission||"full")===F?"bg-accent/15 text-accent shadow-sm":"text-text-3 hover:text-text-1"),children:F==="full"?"Full Access":"Read Only"},F))})]})]}),!t.connected&&!s&&i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"text-xs text-text-3 font-sans mb-2",children:t.enabled?t.hasCredentials?"Tokens saved — click Connect.":"Configure bot token to connect.":"Gateway is disabled."}),!t.hasCredentials&&i.jsxs("button",{onClick:()=>k(!0),className:"flex items-center gap-1.5 text-2xs text-accent hover:text-accent/80 font-sans font-medium cursor-pointer mb-2",children:[i.jsx(gc,{size:11}),"How to set up",i.jsx(bc,{size:9})]})]}),i.jsx(F_,{type:t.type,open:T,onOpenChange:k}),i.jsx("div",{className:"flex-1"}),s&&i.jsxs("div",{className:"space-y-2.5 pt-1",children:[i.jsxs("button",{onClick:()=>k(!0),className:"flex items-center gap-1.5 text-2xs text-accent hover:text-accent/80 font-sans font-medium cursor-pointer",children:[i.jsx(gc,{size:11}),"Where do I get these?"]}),i.jsxs("div",{children:[i.jsx("label",{className:"text-2xs font-semibold text-text-2 font-sans mb-1.5 block",children:"Bot Token"}),i.jsxs("div",{className:"relative",children:[i.jsx("input",{value:o,onChange:F=>u(F.target.value),onKeyDown:F=>F.key==="Enter"&&!C&&G(),type:m?"text":"password",placeholder:H_[t.type],className:"w-full h-9 px-3 pr-9 text-xs bg-surface-0 border border-border rounded-md text-text-0 font-mono placeholder:text-text-4 focus:outline-none focus:ring-1 focus:ring-accent",autoFocus:!0}),i.jsx("button",{onClick:()=>p(!m),className:"absolute right-2.5 top-1/2 -translate-y-1/2 text-text-4 hover:text-text-2 cursor-pointer",children:m?i.jsx(If,{size:12}):i.jsx(mi,{size:12})})]})]}),C&&i.jsxs("div",{children:[i.jsx("label",{className:"text-2xs font-semibold text-text-2 font-sans mb-1.5 block",children:"App Token (Socket Mode)"}),i.jsx("input",{value:d,onChange:F=>O(F.target.value),onKeyDown:F=>F.key==="Enter"&&G(),type:m?"text":"password",placeholder:"xapp-...",className:"w-full h-9 px-3 text-xs bg-surface-0 border border-border rounded-md text-text-0 font-mono placeholder:text-text-4 focus:outline-none focus:ring-1 focus:ring-accent"})]}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx(be,{variant:"primary",size:"sm",onClick:G,disabled:!o.trim(),className:"flex-1 h-8 text-xs",children:"Save Token"}),i.jsx(be,{variant:"ghost",size:"sm",onClick:()=>{l(!1),u(""),O("")},className:"h-8 text-xs px-3",children:"Cancel"})]})]}),!s&&i.jsxs("div",{className:"flex gap-2 mt-2",children:[!t.connected&&i.jsxs(be,{variant:"primary",size:"sm",onClick:()=>l(!0),className:"flex-1 h-7 text-2xs gap-1.5",children:[i.jsx(vc,{size:11}),t.enabled?"Set Token":"Configure"]}),t.connected&&i.jsxs(i.Fragment,{children:[i.jsxs(be,{variant:"secondary",size:"sm",onClick:X,disabled:g,className:"flex-1 h-7 text-2xs gap-1.5",children:[i.jsx(nh,{size:11}),g?"Sending...":"Test"]}),i.jsx(be,{variant:"secondary",size:"sm",onClick:()=>l(!0),className:"h-7 text-2xs px-2.5",children:i.jsx(vc,{size:11})})]}),i.jsx(be,{variant:"ghost",size:"sm",onClick:_,disabled:b,className:"h-7 text-2xs px-2.5",title:t.connected?"Disconnect":"Connect",children:t.connected?i.jsx(Vb,{size:11}):i.jsx(a1,{size:11})}),i.jsx(D_,{value:t.enabled,onChange:N}),i.jsx("button",{onClick:ne,className:"text-text-4 hover:text-danger cursor-pointer p-1",title:"Remove gateway",children:i.jsx(Dl,{size:11})})]})]})]})}function J_({existingTypes:t,onAdd:n}){const[s,l]=y.useState(!1),o=["telegram","discord","slack"].filter(u=>!t.includes(u));return o.length===0?null:s?i.jsxs("div",{className:"flex flex-col rounded-lg border border-accent/30 bg-surface-1 overflow-hidden min-w-[220px]",children:[i.jsxs("div",{className:"flex items-center gap-2.5 px-4 py-3 border-b border-border-subtle",children:[i.jsx(eh,{size:13,className:"text-accent"}),i.jsx("span",{className:"text-[13px] font-semibold text-text-0 font-sans",children:"Add Gateway"}),i.jsx("div",{className:"flex-1"}),i.jsx("button",{onClick:()=>l(!1),className:"text-text-4 hover:text-text-1 cursor-pointer",children:i.jsx(jt,{size:12})})]}),i.jsx("div",{className:"p-3 space-y-2",children:o.map(u=>{const d=WS[u];return i.jsxs("button",{onClick:()=>{n(u),l(!1)},className:"w-full flex items-center gap-3 px-3 py-2.5 rounded-md bg-surface-0 hover:bg-accent/8 border border-border-subtle hover:border-accent/20 cursor-pointer transition-all group",children:[i.jsx(d,{size:14,className:"text-text-3 group-hover:text-accent"}),i.jsx("span",{className:"text-xs font-medium text-text-1 group-hover:text-accent font-sans",children:js[u]})]},u)})})]}):i.jsxs("button",{onClick:()=>l(!0),className:"flex flex-col items-center justify-center rounded-lg border border-dashed border-border-subtle bg-surface-1/50 hover:bg-surface-1 hover:border-accent/30 min-h-[140px] min-w-[220px] cursor-pointer transition-all group",children:[i.jsx("div",{className:"w-8 h-8 rounded-full bg-accent/8 group-hover:bg-accent/15 flex items-center justify-center mb-2 transition-colors",children:i.jsx(Jn,{size:14,className:"text-accent"})}),i.jsx("span",{className:"text-2xs font-semibold text-text-3 group-hover:text-text-1 font-sans transition-colors",children:"Add Gateway"})]})}function eZ(){const[t,n]=y.useState([]),[s,l]=y.useState(null),[o,u]=y.useState(null),[d,O]=y.useState([]),[m,p]=y.useState(!0),[g,x]=y.useState(!1),b=D(_=>_.addToast),v=D(_=>_.marketplaceUser),Q=D(_=>_.marketplaceAuthenticated),w=D(_=>_.marketplaceLogin),T=D(_=>_.marketplaceLogout);function k(){ee.get("/providers").then(_=>n(Array.isArray(_)?_:[])).catch(()=>{})}function z(){ee.get("/gateways").then(_=>O(Array.isArray(_)?_:[])).catch(()=>{})}y.useEffect(()=>{Promise.all([ee.get("/providers"),ee.get("/config"),ee.get("/status"),ee.get("/gateways")]).then(([_,N,E,Y])=>{n(Array.isArray(_)?_:[]),l(N),u(E),O(Array.isArray(Y)?Y:[]),p(!1)}).catch(()=>p(!1))},[]);async function $(_){try{await ee.post("/gateways",{type:_}),b("success",`${js[_]} gateway added`),z()}catch(N){b("error","Failed to add gateway",N.message)}}async function C(_,N){try{const E=await ee.patch("/config",{[_]:N});l(E)}catch(E){b("error","Update failed",E.message)}}if(m)return i.jsxs("div",{className:"flex flex-col h-full",children:[i.jsx("div",{className:"h-12 bg-surface-1 border-b border-border"}),i.jsxs("div",{className:"flex-1 p-4 space-y-4",children:[i.jsx("div",{className:"grid grid-cols-4 gap-3",children:[...Array(4)].map((_,N)=>i.jsx(ra,{className:"h-40 rounded-lg"},N))}),i.jsx("div",{className:"grid grid-cols-3 gap-3",children:[...Array(6)].map((_,N)=>i.jsx(ra,{className:"h-28 rounded-lg"},N))})]})]});const G=t.filter(_=>_.authType==="local"||_.authType==="subscription"?_.installed:_.hasKey).length,X=(s==null?void 0:s.rotationThreshold)||0;return i.jsxs("div",{className:"flex flex-col h-full",children:[i.jsxs("div",{className:"flex items-center gap-4 px-4 py-2.5 bg-surface-1 border-b border-border flex-shrink-0",children:[i.jsx("h2",{className:"text-sm font-semibold text-text-0 font-sans",children:"Settings"}),i.jsx("div",{className:"flex-1"}),i.jsxs("div",{className:"flex items-center gap-4 text-2xs text-text-3 font-sans",children:[(o==null?void 0:o.version)&&i.jsxs("span",{children:["v",o.version]}),(o==null?void 0:o.port)&&i.jsxs("span",{children:[":",o.port]}),(o==null?void 0:o.uptime)>0&&i.jsxs("span",{children:["Up ",Dc(o.uptime)]})]}),i.jsx("div",{className:"w-px h-4 bg-border-subtle"}),Q?i.jsxs("div",{className:"flex items-center gap-2.5",children:[i.jsx(W_,{user:v}),i.jsx("span",{className:"text-xs font-medium text-text-0 font-sans",children:(v==null?void 0:v.displayName)||"User"}),i.jsxs("button",{onClick:T,className:"text-2xs text-text-4 hover:text-text-1 cursor-pointer font-sans flex items-center gap-1",children:[i.jsx(Eb,{size:10})," Sign out"]})]}):i.jsxs(be,{variant:"ghost",size:"sm",onClick:w,className:"h-7 text-2xs gap-1.5 text-text-3",children:[i.jsx(Kf,{size:11})," Sign in"]}),i.jsx($s,{status:"running",size:"sm"})]}),i.jsx(fn,{className:"flex-1",children:i.jsxs("div",{className:"p-4 space-y-4",children:[i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center gap-2 mb-2.5 px-0.5",children:[i.jsx("span",{className:"text-2xs font-semibold text-text-3 font-sans uppercase tracking-wider",children:"Providers"}),i.jsx("div",{className:"flex-1 h-px bg-border-subtle"}),i.jsxs("span",{className:"text-2xs text-text-4 font-sans",children:[G,"/",t.length," connected"]})]}),i.jsx("div",{className:"grid grid-cols-4 gap-3",children:t.map(_=>i.jsx(B_,{provider:_,onKeyChange:k},_.id))})]}),i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center gap-2 mb-2.5 px-0.5",children:[i.jsx("span",{className:"text-2xs font-semibold text-text-3 font-sans uppercase tracking-wider",children:"Gateways"}),i.jsx("div",{className:"flex-1 h-px bg-border-subtle"}),i.jsxs("span",{className:"text-2xs text-text-4 font-sans",children:[d.filter(_=>_.connected).length,"/",d.length," connected"]})]}),i.jsxs("div",{className:"grid grid-cols-4 gap-3",children:[d.map(_=>i.jsx(K_,{gateway:_,onRefresh:z},_.id)),i.jsx(J_,{existingTypes:d.map(_=>_.type),onAdd:$})]})]}),s&&i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center gap-2 mb-2.5 px-0.5",children:[i.jsx("span",{className:"text-2xs font-semibold text-text-3 font-sans uppercase tracking-wider",children:"Configuration"}),i.jsx("div",{className:"flex-1 h-px bg-border-subtle"}),i.jsx("span",{className:"text-2xs text-text-4 font-sans",children:"Auto-saves"})]}),i.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[i.jsx(Ql,{icon:Zl,label:"Default Provider",description:"Provider used when spawning new agents.",children:i.jsx("select",{value:s.defaultProvider||"claude-code",onChange:_=>C("defaultProvider",_.target.value),className:"w-full h-8 px-2.5 text-xs bg-surface-0 border border-border-subtle rounded-md text-text-0 font-mono focus:outline-none focus:ring-1 focus:ring-accent cursor-pointer",children:t.filter(_=>_.installed||_.hasKey).map(_=>i.jsx("option",{value:_.id,children:_.name},_.id))})}),i.jsx(Ql,{icon:ai,label:"Working Directory",description:"Default root directory for new agents.",children:i.jsxs("div",{className:"flex items-center gap-1.5",children:[i.jsx("code",{className:"flex-1 h-8 px-2 flex items-center bg-surface-0 border border-border-subtle rounded-md text-2xs font-mono text-text-2 truncate min-w-0",children:s.defaultWorkingDir||"Project root"}),i.jsx(be,{variant:"secondary",size:"sm",onClick:()=>x(!0),className:"h-8 px-2 flex-shrink-0",children:i.jsx(Xb,{size:12})})]})}),i.jsx(Ql,{icon:Zb,label:"Rotation Threshold",description:"Context usage that triggers auto-rotation.",children:i.jsx("div",{className:"flex bg-surface-0 rounded-md p-0.5 border border-border-subtle",children:["auto","50%","65%","75%","85%"].map(_=>{const N=_==="auto"?0:parseInt(_,10)/100,E=X===N;return i.jsx("button",{onClick:()=>C("rotationThreshold",N),className:se("flex-1 px-2 py-1.5 text-2xs font-semibold font-sans rounded transition-all cursor-pointer",E?"bg-accent/15 text-accent shadow-sm":"text-text-3 hover:text-text-1"),children:_==="auto"?"Auto":_},_)})})}),i.jsx(Ql,{icon:Wb,label:"QC Threshold",description:"Running agents count that triggers auto-QC.",children:i.jsx("div",{className:"flex bg-surface-0 rounded-md p-0.5 border border-border-subtle",children:[2,3,4,6,8].map(_=>{const N=(s.qcThreshold||2)===_;return i.jsx("button",{onClick:()=>C("qcThreshold",_),className:se("flex-1 px-2 py-1.5 text-2xs font-semibold font-sans rounded transition-all cursor-pointer",N?"bg-accent/15 text-accent shadow-sm":"text-text-3 hover:text-text-1"),children:_},_)})})}),i.jsx(Ql,{icon:bi,label:"Max Agents",description:"Concurrent agent limit. 0 = unlimited.",children:i.jsx("div",{className:"flex bg-surface-0 rounded-md p-0.5 border border-border-subtle",children:[0,4,8,12,20].map(_=>{const N=(s.maxAgents||0)===_;return i.jsx("button",{onClick:()=>C("maxAgents",_),className:se("flex-1 px-2 py-1.5 text-2xs font-semibold font-sans rounded transition-all cursor-pointer",N?"bg-accent/15 text-accent shadow-sm":"text-text-3 hover:text-text-1"),children:_===0?"∞":_},_)})})}),i.jsx(Ql,{icon:ni,label:"Journalist Interval",description:"Seconds between synthesis cycles.",children:i.jsx("div",{className:"flex bg-surface-0 rounded-md p-0.5 border border-border-subtle",children:[60,120,300,600].map(_=>{const N=(s.journalistInterval||120)===_,E=_<60?`${_}s`:`${_/60}m`;return i.jsx("button",{onClick:()=>C("journalistInterval",_),className:se("flex-1 px-2 py-1.5 text-2xs font-semibold font-sans rounded transition-all cursor-pointer",N?"bg-accent/15 text-accent shadow-sm":"text-text-3 hover:text-text-1"),children:E},_)})})})]})]})]})}),i.jsx(GS,{open:g,onOpenChange:x,currentPath:(s==null?void 0:s.defaultWorkingDir)||"/",onSelect:_=>C("defaultWorkingDir",_)})]})}const zf=y.forwardRef(({className:t,label:n,error:s,mono:l,...o},u)=>i.jsxs("div",{className:"flex flex-col gap-1",children:[n&&i.jsx("label",{className:"text-xs font-medium text-text-2 font-sans",children:n}),i.jsx("input",{ref:u,className:se("h-8 w-full rounded-md px-3 text-sm","bg-surface-1 border border-border text-text-0","placeholder:text-text-4","focus:outline-none focus:ring-1 focus:ring-accent focus:border-accent","disabled:opacity-40 disabled:cursor-not-allowed","transition-colors duration-100",l?"font-mono":"font-sans",s&&"border-danger focus:ring-danger",t),...o}),s&&i.jsx("span",{className:"text-2xs text-danger font-sans",children:s})]}));zf.displayName="Input";const tZ=y.forwardRef(({className:t,label:n,error:s,mono:l,...o},u)=>i.jsxs("div",{className:"flex flex-col gap-1",children:[n&&i.jsx("label",{className:"text-xs font-medium text-text-2 font-sans",children:n}),i.jsx("textarea",{ref:u,className:se("w-full rounded-md px-3 py-2 text-sm resize-none","bg-surface-1 border border-border text-text-0","placeholder:text-text-4","focus:outline-none focus:ring-1 focus:ring-accent focus:border-accent","disabled:opacity-40 disabled:cursor-not-allowed","transition-colors duration-100",l?"font-mono":"font-sans",s&&"border-danger focus:ring-danger",t),...o}),s&&i.jsx("span",{className:"text-2xs text-danger font-sans",children:s})]}));tZ.displayName="Textarea";function Cc(t){return t?t<1024*1024?`${(t/1024).toFixed(0)} KB`:t<1024*1024*1024?`${(t/(1024*1024)).toFixed(1)} MB`:`${(t/(1024*1024*1024)).toFixed(2)} GB`:"—"}function aZ(t){return t?t<1024*1024?`${(t/1024).toFixed(0)} KB/s`:`${(t/(1024*1024)).toFixed(1)} MB/s`:""}function nZ({hardware:t}){var n;return t?i.jsxs("div",{className:"flex items-center gap-4 px-4 py-2.5 bg-surface-1 border border-border-subtle rounded-lg text-xs font-sans text-text-2",children:[i.jsxs("div",{className:"flex items-center gap-1.5",children:[i.jsx(ZT,{size:14,className:"text-text-3"}),i.jsxs("span",{children:[t.totalRamGb," GB RAM"]})]}),i.jsxs("div",{className:"flex items-center gap-1.5",children:[i.jsx(Zl,{size:14,className:"text-text-3"}),i.jsxs("span",{children:[t.cores," cores"]})]}),t.gpu&&i.jsxs("div",{className:"flex items-center gap-1.5",children:[i.jsx(Ff,{size:14,className:"text-text-3"}),i.jsxs("span",{children:[t.gpu.name,t.gpu.vram?` (${t.gpu.vram} GB)`:""]})]}),((n=t.recommended)==null?void 0:n.code)&&i.jsxs("div",{className:"ml-auto text-accent",children:["Recommended: ",t.recommended.code]})]}):null}function sZ({download:t}){const n=Math.round((t.percent||0)*100);return i.jsxs("div",{className:"space-y-1",children:[i.jsxs("div",{className:"flex items-center justify-between text-2xs font-sans text-text-3",children:[i.jsx("span",{children:t.filename}),i.jsxs("span",{children:[n,"% ",aZ(t.speed)]})]}),i.jsx("div",{className:"h-1.5 bg-surface-3 rounded-full overflow-hidden",children:i.jsx("div",{className:"h-full bg-accent rounded-full transition-all",style:{width:`${n}%`}})}),i.jsxs("div",{className:"text-2xs text-text-4",children:[Cc(t.downloaded)," / ",Cc(t.totalBytes)]})]})}function lZ({model:t,onDelete:n}){const[s,l]=y.useState(!1),o={light:"text-green-400",medium:"text-blue-400",heavy:"text-orange-400"};return i.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 bg-surface-1 border border-border-subtle rounded-lg",children:[i.jsx(Hf,{size:18,className:"text-accent flex-shrink-0"}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-sm font-mono font-bold text-text-0 truncate",children:t.id}),t.quantization&&i.jsx(Ze,{variant:"subtle",className:"text-2xs",children:t.quantization}),t.parameters&&i.jsx(Ze,{variant:"subtle",className:"text-2xs",children:t.parameters}),i.jsx("span",{className:se("text-2xs font-medium capitalize",o[t.tier]||"text-text-3"),children:t.tier})]}),i.jsxs("div",{className:"text-2xs text-text-3 font-sans mt-0.5",children:[Cc(t.sizeBytes)," · ctx ",(t.contextWindow||0).toLocaleString()," · ",t.category,t.repoId&&i.jsxs("span",{className:"text-text-4",children:[" · ",t.repoId]})]})]}),i.jsx("button",{onClick:async()=>{l(!0),await n(t.id),l(!1)},disabled:s,className:"p-1.5 rounded-md text-text-4 hover:text-red-400 hover:bg-red-400/10 transition-colors",children:s?i.jsx(Kn,{size:14,className:"animate-spin"}):i.jsx(Dl,{size:14})})]})}function rZ({result:t,onExpand:n,expanded:s}){var l;return i.jsxs("button",{onClick:()=>n(s?null:t.id),className:"w-full text-left px-4 py-3 bg-surface-1 border border-border-subtle rounded-lg hover:border-accent/30 transition-colors cursor-pointer",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-sm font-mono font-bold text-text-0 truncate flex-1",children:t.name}),i.jsx("span",{className:"text-2xs text-text-4 font-sans",children:t.author}),s?i.jsx(on,{size:14,className:"text-text-3"}):i.jsx(Gl,{size:14,className:"text-text-3"})]}),i.jsxs("div",{className:"text-2xs text-text-3 font-sans mt-0.5 flex gap-3",children:[i.jsxs("span",{children:[(l=t.downloads)==null?void 0:l.toLocaleString()," downloads"]}),i.jsxs("span",{children:[t.likes," likes"]})]})]})}function iZ({repoId:t,onDownload:n,systemRamGb:s}){const[l,o]=y.useState(null),[u,d]=y.useState(!0),[O,m]=y.useState(null),p=Wl();y.useEffect(()=>{d(!0),ee.get(`/models/${t}/files`).then(x=>o(x.files||[])).catch(()=>p.error("Failed to load model files")).finally(()=>d(!1))},[t]);async function g(x){m(x.filename);try{await ee.post("/models/download",{repoId:t,filename:x.filename}),p.success(`Downloading ${x.filename}`),n==null||n(x.filename)}catch(b){p.error(b.message)}m(null)}return u?i.jsx("div",{className:"py-3 px-4 text-2xs text-text-4 font-sans",children:"Loading quantization variants..."}):l!=null&&l.length?i.jsx("div",{className:"pl-6 pr-4 pb-2 space-y-1.5",children:l.map(x=>{const b=!x.estimatedRamGb||!s||x.estimatedRamGb<=s,v=x.estimatedRamGb&&s&&x.estimatedRamGb>s*.8&&b;return i.jsxs("div",{className:se("flex items-center gap-2 py-1.5 px-3 rounded-md text-xs font-sans",b?"bg-surface-2":"bg-red-500/5 border border-red-500/15"),children:[i.jsx("span",{className:"font-mono text-text-1 truncate flex-1",children:x.filename}),x.quantization&&i.jsx(Ze,{variant:"subtle",className:"text-2xs",children:x.quantization}),i.jsx("span",{className:"text-text-2 text-2xs w-16 text-right",children:Cc(x.size)}),x.estimatedRamGb&&i.jsxs("span",{className:se("text-2xs w-20 text-right font-medium",b?v?"text-yellow-400":"text-green-400":"text-red-400"),children:["~",x.estimatedRamGb," GB RAM"]}),!b&&i.jsx("span",{className:"text-2xs text-red-400 font-medium",children:"too large"}),i.jsx("button",{onClick:()=>g(x),disabled:O===x.filename||!b,className:se("p-1 rounded transition-colors",b?"text-accent hover:bg-accent/10":"text-text-4 cursor-not-allowed","disabled:opacity-40"),children:O===x.filename?i.jsx(Kn,{size:13,className:"animate-spin"}):i.jsx(hi,{size:13})})]},x.filename)})}):i.jsx("div",{className:"py-3 px-4 text-2xs text-text-4 font-sans",children:"No GGUF files found in this repo."})}function oZ({model:t,systemRamGb:n,onPull:s,pulling:l}){const o={light:"text-green-400",medium:"text-blue-400",heavy:"text-orange-400"},u={code:"{}",general:"AI"},d=n?Math.round((1-t.ramGb/n)*100):null;return i.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 bg-surface-1 border border-border-subtle rounded-lg hover:border-accent/20 transition-colors",children:[i.jsx("div",{className:"w-9 h-9 rounded-lg bg-surface-3 flex items-center justify-center text-xs font-mono text-text-2 flex-shrink-0",children:u[t.category]||"AI"}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-sm font-mono font-bold text-text-0 truncate",children:t.name}),i.jsx("span",{className:se("text-2xs font-semibold capitalize",o[t.tier]),children:t.tier})]}),i.jsx("div",{className:"text-2xs text-text-3 font-sans mt-0.5",children:t.description}),i.jsxs("div",{className:"flex items-center gap-3 mt-1 text-2xs font-sans",children:[i.jsxs("span",{className:"text-text-2",children:[t.sizeGb," GB download"]}),i.jsxs("span",{className:"text-green-400 font-medium",children:[t.ramGb," GB RAM"]}),d!==null&&i.jsxs("span",{className:"text-text-4",children:[d,"% headroom"]})]})]}),i.jsxs("button",{onClick:()=>s(t.id),disabled:l===t.id,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-md text-xs font-sans font-medium bg-accent/10 text-accent hover:bg-accent/20 transition-colors cursor-pointer disabled:opacity-40",children:[l===t.id?i.jsx(Kn,{size:12,className:"animate-spin"}):i.jsx(hi,{size:12}),"Pull"]})]})}function cZ(){const[t,n]=y.useState("recommended"),[s,l]=y.useState(""),[o,u]=y.useState([]),[d,O]=y.useState(!1),[m,p]=y.useState([]),[g,x]=y.useState([]),[b,v]=y.useState([]),[Q,w]=y.useState(null),[T,k]=y.useState(null),[z,$]=y.useState(null),C=Wl(),G=y.useCallback(()=>{ee.get("/models/installed").then(E=>{p(E.models||[])}).catch(()=>{})},[]);y.useEffect(()=>{ee.get("/providers/ollama/hardware").then(w).catch(()=>{}),ee.get("/models/recommended").then(E=>{x(E.models||[]),!Q&&E.hardware&&w(E.hardware)}).catch(()=>{}),G()},[G]);async function X(E){$(E);try{await ee.post("/providers/ollama/pull",{model:E}),C.success(`${E} pulled successfully`),G()}catch(Y){C.error(`Pull failed: ${Y.message}`)}$(null)}y.useEffect(()=>{const E=D.subscribe((ne,oe)=>{}),Y=setInterval(()=>{ee.get("/models/downloads").then(v).catch(()=>{})},2e3);return()=>{E(),clearInterval(Y)}},[]),y.useEffect(()=>{function E(ne){try{const oe=JSON.parse(ne.data);oe.type==="model:download:progress"&&v(ce=>{const re=ce.findIndex(F=>F.filename===oe.data.filename);if(re>=0){const F=[...ce];return F[re]=oe.data,F}return[...ce,oe.data]}),oe.type==="model:download:complete"&&(v(ce=>ce.filter(re=>re.filename!==oe.data.filename)),G(),C.success(`${oe.data.filename} downloaded`)),oe.type==="model:download:error"&&(v(ce=>ce.filter(re=>re.filename!==oe.data.filename)),C.error(`Download failed: ${oe.data.error}`))}catch{}}const Y=D.getState()._ws;return Y&&Y.addEventListener("message",E),()=>{Y&&Y.removeEventListener("message",E)}},[G,C]);async function _(){if(s.trim()){O(!0),n("search");try{const E=await ee.get(`/models/search?q=${encodeURIComponent(s.trim())}`);u(E)}catch(E){C.error(E.message)}O(!1)}}async function N(E){try{await ee.delete(`/models/${E}`),p(Y=>Y.filter(ne=>ne.id!==E)),C.success("Model deleted")}catch(Y){C.error(Y.message)}}return i.jsxs("div",{className:"h-full flex flex-col bg-surface-0",children:[i.jsxs("div",{className:"flex-shrink-0 px-5 pt-4 pb-3 border-b border-border space-y-3",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("h1",{className:"text-base font-bold font-sans text-text-0",children:"Local Models"}),i.jsxs(Ze,{variant:"subtle",className:"text-2xs",children:[m.length," installed"]})]}),i.jsx(nZ,{hardware:Q}),i.jsxs("div",{className:"flex gap-2",children:[i.jsxs("div",{className:"relative flex-1",children:[i.jsx(un,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-text-4"}),i.jsx("input",{value:s,onChange:E=>l(E.target.value),onKeyDown:E=>E.key==="Enter"&&_(),placeholder:"Search HuggingFace for GGUF models...",className:"w-full h-8 pl-9 pr-3 text-sm rounded-md bg-surface-1 border border-border text-text-0 font-sans placeholder:text-text-4 focus:outline-none focus:ring-1 focus:ring-accent"})]}),i.jsx(be,{onClick:_,disabled:d,size:"sm",variant:"accent",children:d?i.jsx(Kn,{size:14,className:"animate-spin"}):"Search"})]}),i.jsx("div",{className:"flex gap-1",children:[{id:"recommended",label:`Recommended (${g.length})`},{id:"installed",label:`Installed (${m.length})`},{id:"search",label:`Search (${o.length})`}].map(E=>i.jsx("button",{onClick:()=>n(E.id),className:se("px-3 py-1 rounded-md text-xs font-sans font-medium transition-colors cursor-pointer",t===E.id?"bg-accent/12 text-accent":"text-text-3 hover:text-text-1 hover:bg-surface-3"),children:E.label},E.id))})]}),b.length>0&&i.jsxs("div",{className:"px-5 py-3 border-b border-border space-y-2",children:[i.jsx("div",{className:"text-xs font-sans font-semibold text-text-2",children:"Downloading"}),b.map(E=>i.jsx(sZ,{download:E},E.filename))]}),i.jsx(fn,{className:"flex-1",children:i.jsxs("div",{className:"px-5 py-4 space-y-2",children:[t==="recommended"&&i.jsx(i.Fragment,{children:g.length===0?i.jsxs("div",{className:"text-center py-12",children:[i.jsx(Zl,{size:40,className:"mx-auto text-text-4 mb-3"}),i.jsx("p",{className:"text-sm text-text-2 font-sans font-medium",children:"Detecting hardware..."}),i.jsx("p",{className:"text-xs text-text-3 font-sans mt-1",children:"Make sure Ollama is installed so we can check your system."})]}):i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"text-xs text-text-3 font-sans mb-2",children:["Top models for your system (",(Q==null?void 0:Q.totalRamGb)||"?"," GB RAM). Click Pull to download via Ollama."]}),g.map(E=>i.jsx(oZ,{model:E,systemRamGb:Q==null?void 0:Q.totalRamGb,onPull:X,pulling:z},E.id))]})}),t==="installed"&&i.jsx(i.Fragment,{children:m.length===0?i.jsxs("div",{className:"text-center py-12",children:[i.jsx(Hf,{size:40,className:"mx-auto text-text-4 mb-3"}),i.jsx("p",{className:"text-sm text-text-2 font-sans font-medium",children:"No local models yet"}),i.jsx("p",{className:"text-xs text-text-3 font-sans mt-1",children:"Search HuggingFace to download GGUF models, or pull models via Ollama."})]}):m.map(E=>i.jsx(lZ,{model:E,onDelete:N},E.id))}),t==="search"&&i.jsx(i.Fragment,{children:d?i.jsxs("div",{className:"text-center py-12",children:[i.jsx(Kn,{size:24,className:"mx-auto text-accent animate-spin mb-3"}),i.jsx("p",{className:"text-sm text-text-3 font-sans",children:"Searching HuggingFace..."})]}):o.length===0?i.jsxs("div",{className:"text-center py-12",children:[i.jsx(un,{size:40,className:"mx-auto text-text-4 mb-3"}),i.jsx("p",{className:"text-sm text-text-2 font-sans font-medium",children:"Search for GGUF models"}),i.jsx("p",{className:"text-xs text-text-3 font-sans mt-1",children:'Try "qwen coder", "deepseek", "codestral", "llama"'})]}):o.map(E=>i.jsxs("div",{className:"space-y-1",children:[i.jsx(rZ,{result:E,expanded:T===E.id,onExpand:k}),T===E.id&&i.jsx(iZ,{repoId:E.id,onDownload:()=>G(),systemRamGb:Q==null?void 0:Q.totalRamGb})]},E.id))})]})})]})}const Rf=[];function BS(t){const n=(t||"").toLowerCase();return n.includes("reading")||n.includes("read ")?{icon:mi,color:"text-info",label:"Reading"}:n.includes("editing")||n.includes("wrote")||n.includes("writing")||n.includes("edit ")?{icon:Cb,color:"text-warning",label:"Editing"}:n.includes("searching")||n.includes("search")||n.includes("grep")||n.includes("glob")?{icon:un,color:"text-purple",label:"Searching"}:n.includes("running")||n.includes("bash")||n.includes("command")||n.includes("exec")?{icon:xi,color:"text-orange",label:"Running"}:n.includes("test")||n.includes("pass")?{icon:mf,color:"text-success",label:"Testing"}:n.includes("error")||n.includes("fail")||n.includes("crash")?{icon:cn,color:"text-danger",label:"Error"}:n.includes("rotat")?{icon:Ll,color:"text-accent",label:"Rotating"}:n.includes("spawn")||n.includes("start")?{icon:Pa,color:"text-success",label:"Spawned"}:n.includes("tool")||n.includes("function")?{icon:qN,color:"text-text-2",label:"Tool"}:n.includes("complet")||n.includes("done")||n.includes("finish")?{icon:mf,color:"text-success",label:"Done"}:{icon:On,color:"text-text-3",label:"Activity"}}function wl({text:t}){return t?t.split(/(\*\*[^*]+\*\*|`[^`]+`)/g).map((n,s)=>n.startsWith("**")&&n.endsWith("**")?i.jsx("strong",{className:"font-semibold text-text-0",children:n.slice(2,-2)},s):n.startsWith("`")&&n.endsWith("`")?i.jsx("code",{className:"px-1 py-px rounded bg-accent/8 text-[11px] font-mono text-accent",children:n.slice(1,-1)},s):i.jsx("span",{children:n},s)):null}function uZ({text:t}){if(!t)return null;const n=[],s=t.split(`
|
|
628
628
|
`);let l=0;for(;l<s.length;){const o=s[l];if(o.trimStart().startsWith("```")){const d=[],O=o.trim().slice(3);for(l++;l<s.length&&!s[l].trimStart().startsWith("```");)d.push(s[l]),l++;l++,n.push({type:"code",content:d.join(`
|
|
629
629
|
`),lang:O});continue}if(/^#{1,3}\s/.test(o)||/^\*\*[^*]+:\*\*\s*$/.test(o.trim())){const d=o.replace(/^#+\s*/,"").replace(/^\*\*/,"").replace(/:\*\*\s*$/,":").trim();n.push({type:"heading",content:d}),l++;continue}if(/^\s*[-*]\s/.test(o)){const d=[];for(;l<s.length&&/^\s*[-*]\s/.test(s[l]);)d.push(s[l].replace(/^\s*[-*]\s+/,"").trim()),l++;n.push({type:"list",items:d});continue}if(/^\s*\d+[\.)]\s/.test(o)){const d=[];for(;l<s.length&&/^\s*\d+[\.)]\s/.test(s[l]);)d.push(s[l].replace(/^\s*\d+[\.)]\s+/,"").trim()),l++;n.push({type:"numbered",items:d});continue}if(!o.trim()){l++;continue}if(/^(Note|Warning|Important|IMPORTANT|TODO):/i.test(o.trim())){n.push({type:"note",content:o.trim()}),l++;continue}const u=[];for(;l<s.length&&s[l].trim()&&!/^#{1,3}\s/.test(s[l])&&!/^\s*[-*]\s/.test(s[l])&&!/^\s*\d+[\.)]\s/.test(s[l])&&!s[l].trimStart().startsWith("```");)u.push(s[l].trim()),l++;u.length>0&&n.push({type:"para",content:u.join(" ")})}return i.jsx("div",{className:"space-y-2",children:n.map((o,u)=>{switch(o.type){case"heading":return i.jsxs("div",{className:"flex items-center gap-1.5 pt-1.5 first:pt-0",children:[i.jsx("div",{className:"w-1 h-3.5 rounded-full bg-accent/40 flex-shrink-0"}),i.jsx("span",{className:"text-[12px] font-semibold text-text-0 font-sans",children:i.jsx(wl,{text:o.content})})]},u);case"list":return i.jsx("div",{className:"space-y-1 pl-2",children:o.items.map((d,O)=>i.jsxs("div",{className:"flex gap-2 text-[12px] text-text-0 font-sans leading-relaxed",children:[i.jsx("span",{className:"text-accent/50 mt-0.5 flex-shrink-0",children:"-"}),i.jsx("span",{className:"min-w-0",children:i.jsx(wl,{text:d})})]},O))},u);case"numbered":return i.jsx("div",{className:"space-y-1 pl-2",children:o.items.map((d,O)=>i.jsxs("div",{className:"flex gap-2 text-[12px] text-text-0 font-sans leading-relaxed",children:[i.jsxs("span",{className:"text-text-4 font-mono w-4 text-right flex-shrink-0",children:[O+1,"."]}),i.jsx("span",{className:"min-w-0",children:i.jsx(wl,{text:d})})]},O))},u);case"code":return i.jsx("pre",{className:"p-2.5 rounded-md bg-[#0d1117] text-[11px] font-mono text-[#c9d1d9] overflow-x-auto whitespace-pre-wrap border border-white/[0.06] leading-relaxed",children:o.content},u);case"note":return i.jsxs("div",{className:"flex items-start gap-1.5 px-2.5 py-1.5 rounded-md bg-warning/6 border border-warning/12",children:[i.jsx(cn,{size:10,className:"text-warning mt-0.5 flex-shrink-0"}),i.jsx("span",{className:"text-[11px] text-warning/80 font-sans",children:i.jsx(wl,{text:o.content})})]},u);case"para":default:return i.jsx("p",{className:"text-[12px] text-text-0 font-sans leading-relaxed",children:i.jsx(wl,{text:o.content})},u)}})})}function dZ({text:t}){if(!t)return null;const n=t.split(/(```[\s\S]*?```)/g);return i.jsx("span",{children:n.map((s,l)=>{if(s.startsWith("```")&&s.endsWith("```")){const o=s.slice(3,-3).replace(/^\w+\n/,"");return i.jsx("pre",{className:"my-1.5 p-2 rounded-md bg-[#0d1117] text-[11px] font-mono text-[#c9d1d9] overflow-x-auto whitespace-pre-wrap border border-white/[0.06]",children:o},l)}return i.jsx("span",{children:i.jsx(wl,{text:s})},l)})})}function OZ({msg:t}){const n=t.isQuery;return i.jsx("div",{className:"flex justify-end pl-8",children:i.jsxs("div",{className:"max-w-[90%]",children:[n&&i.jsxs("div",{className:"flex items-center justify-end gap-1 mb-1",children:[i.jsx(gc,{size:9,className:"text-info"}),i.jsx("span",{className:"text-2xs text-info font-sans font-medium",children:"Query"})]}),i.jsx("div",{className:se("px-3.5 py-2.5 rounded-lg border","bg-info/10 border-info/25"),children:i.jsx("div",{className:"text-[12px] font-sans whitespace-pre-wrap break-words leading-relaxed text-text-0",children:i.jsx(dZ,{text:t.text})})}),i.jsx("div",{className:"text-[10px] text-text-4 font-sans mt-1 text-right",children:vt(t.timestamp)})]})})}function fZ({msg:t,agent:n}){var u,d;const[s,l]=y.useState(((u=t.text)==null?void 0:u.length)>600),o=((d=t.text)==null?void 0:d.length)>600;return i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[i.jsx("span",{className:"text-2xs font-semibold text-text-1 font-sans",children:(n==null?void 0:n.name)||"Agent"}),i.jsx("span",{className:"text-2xs text-text-4 font-sans",children:n==null?void 0:n.role}),i.jsx("span",{className:"text-[10px] text-text-4 font-sans ml-auto",children:vt(t.timestamp)})]}),i.jsx("div",{className:"border-l border-accent pl-3.5 py-1",children:i.jsx(uZ,{text:s?t.text.slice(0,600)+"...":t.text})}),s&&i.jsxs("button",{onClick:()=>l(!1),className:"ml-3.5 mt-1.5 flex items-center gap-1.5 text-[11px] text-accent/70 hover:text-accent font-sans font-medium cursor-pointer transition-colors",children:[i.jsx(on,{size:11}),"Show full response"]}),o&&!s&&i.jsxs("button",{onClick:()=>l(!0),className:"ml-3.5 mt-1.5 flex items-center gap-1.5 text-[11px] text-accent/70 hover:text-accent font-sans font-medium cursor-pointer transition-colors",children:[i.jsx(on,{size:11,className:"rotate-180"}),"Collapse"]})]})}function hZ({msg:t}){return i.jsxs("div",{className:"flex items-center gap-3 py-2",children:[i.jsx("div",{className:"flex-1 h-px bg-border-subtle"}),i.jsx("span",{className:"text-[10px] text-text-4 font-sans flex-shrink-0 uppercase tracking-wide",children:t.text}),i.jsx("div",{className:"flex-1 h-px bg-border-subtle"})]})}function mZ({entries:t,isLive:n}){var d;const[s,l]=y.useState(0);if(y.useEffect(()=>{if(!n||t.length<=1)return;const O=setInterval(()=>l(m=>(m+1)%t.length),1500);return()=>clearInterval(O)},[t.length,n]),!n){const O=t[t.length-1],p=BS(O.text).icon;return i.jsxs("div",{className:"ml-7 flex items-center gap-2 px-3 py-1 text-[10px] text-text-4 font-mono",children:[i.jsx(p,{size:10,className:"opacity-50"}),i.jsxs("span",{className:"truncate",children:[t.length," tool call",t.length!==1?"s":""]})]})}const o=t[Math.min(s,t.length-1)],u=((d=o.text)==null?void 0:d.length)>60?o.text.slice(0,60)+"...":o.text;return i.jsxs("div",{className:"ml-7 flex items-center gap-2 px-3 py-2 rounded-md bg-surface-3/50 border border-border-subtle/30",children:[i.jsx(Kn,{size:11,className:"text-accent animate-spin flex-shrink-0"}),i.jsx("span",{className:"text-[11px] text-text-2 font-mono truncate flex-1 min-w-0 transition-opacity duration-300",children:u}),t.length>1&&i.jsx("span",{className:"text-[10px] text-text-4 font-mono flex-shrink-0",children:t.length})]})}function pZ({agent:t}){const n=D(m=>m.activityLog[t.id])||Rf,s=n[n.length-1],l=s?BS(s.text):null,o=(l==null?void 0:l.icon)||On,u=s&&Date.now()-s.timestamp<1e4,d=u&&s.text?s.text.length>60?s.text.slice(0,60)+"...":s.text:null,O=Math.round((t.contextUsage||0)*100);return i.jsxs("div",{className:"flex items-center gap-3 px-4 h-8 border-b border-border-subtle bg-surface-1/80 flex-shrink-0",children:[i.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[i.jsxs("div",{className:"relative flex items-center justify-center w-4 h-4",children:[i.jsx("span",{className:"absolute inset-0 rounded-full bg-accent/15 animate-ping",style:{animationDuration:"2s"}}),i.jsx("span",{className:"relative w-1.5 h-1.5 rounded-full bg-accent"})]}),u?i.jsxs(i.Fragment,{children:[i.jsx(o,{size:10,className:se(l.color,"flex-shrink-0")}),i.jsx("span",{className:"text-[11px] text-text-2 font-sans truncate",children:d})]}):i.jsx("span",{className:"text-[11px] text-text-3 font-sans",children:"Working..."})]}),i.jsxs("div",{className:"flex items-center gap-3 flex-shrink-0",children:[i.jsx("span",{className:"text-[10px] text-text-4 font-mono",children:xZ(t.tokensUsed)}),i.jsxs("div",{className:"flex items-center gap-1.5",children:[i.jsx("div",{className:"w-14 h-1 rounded-full bg-surface-4 overflow-hidden",children:i.jsx("div",{className:"h-full rounded-full transition-all duration-500",style:{width:`${O}%`,background:O>=75?"var(--color-danger)":O>=50?"var(--color-warning)":"var(--color-accent)"}})}),i.jsxs("span",{className:"text-[10px] text-text-4 font-mono w-7 text-right",children:[O,"%"]})]})]})]})}function xZ(t){return t?t>=1e6?(t/1e6).toFixed(1)+"M":t>=1e3?(t/1e3).toFixed(1)+"K":String(t):"0"}function gZ({agent:t}){const[n,s]=y.useState([]),l=[{text:`Initializing ${t.name}`,delay:0},{text:`Role: ${t.role}`,delay:400},{text:`Provider: ${t.provider||"claude-code"}`,delay:700},{text:"Loading workspace context",delay:1e3},{text:"Scanning project structure",delay:1400},{text:"Session active",delay:1900}];return y.useEffect(()=>{const o=l.map((u,d)=>setTimeout(()=>s(O=>[...O,d]),u.delay));return()=>o.forEach(clearTimeout)},[]),i.jsxs("div",{className:"flex flex-col px-4 pt-6",children:[i.jsxs("div",{className:"flex items-center gap-3 mb-5",children:[i.jsxs("div",{className:"relative w-9 h-9",children:[i.jsx("span",{className:"absolute inset-0 rounded-full border-2 border-accent/20 animate-ping",style:{animationDuration:"2s"}}),i.jsx("span",{className:"absolute inset-0 rounded-full border-2 border-transparent border-t-accent animate-spin",style:{animationDuration:"1s"}}),i.jsx("span",{className:"absolute inset-[5px] rounded-full bg-accent/8"})]}),i.jsxs("div",{children:[i.jsx("p",{className:"text-sm font-bold text-text-0 font-sans",children:t.name}),i.jsx("p",{className:"text-2xs text-accent font-mono",children:"starting up"})]})]}),i.jsx("div",{className:"space-y-2 pl-3 border-l border-accent/15",children:l.map((o,u)=>{const d=n.includes(u),O=u===l.length-1;return i.jsxs("div",{className:se("flex items-center gap-2.5 transition-all duration-300",d?"opacity-100 translate-x-0":"opacity-0 -translate-x-2"),children:[i.jsx("span",{className:se("w-1 h-1 rounded-full flex-shrink-0",O&&d?"bg-accent":d?"bg-text-3":"bg-transparent")}),i.jsx("span",{className:se("text-[11px] font-mono",O&&d?"text-accent":"text-text-3"),children:o.text}),O&&d&&i.jsxs("span",{className:"flex gap-0.5 ml-1",children:[i.jsx("span",{className:"w-1 h-1 rounded-full bg-accent animate-pulse",style:{animationDelay:"0ms"}}),i.jsx("span",{className:"w-1 h-1 rounded-full bg-accent animate-pulse",style:{animationDelay:"200ms"}}),i.jsx("span",{className:"w-1 h-1 rounded-full bg-accent animate-pulse",style:{animationDelay:"400ms"}})]})]},u)})})]})}function bZ({agent:t}){const n=D($=>$.chatHistory[t.id])||Rf,s=D($=>$.activityLog[t.id])||Rf,l=D($=>$.instructAgent),o=D($=>$.queryAgent),[u,d]=y.useState(""),[O,m]=y.useState("instruct"),[p,g]=y.useState(!1),x=y.useRef(null),b=y.useRef(null),v=y.useRef(null),Q=y.useMemo(()=>{var E;const $=[],C=new Set;for(const Y of n){const ne=`${Y.from}:${(E=Y.text)==null?void 0:E.slice(0,100)}`;$.find(ce=>{var re;return ce.kind==="chat"&&`${ce.from}:${(re=ce.text)==null?void 0:re.slice(0,100)}`===ne&&Math.abs(ce.ts-Y.timestamp)<5e3})||($.push({...Y,kind:"chat",ts:Y.timestamp}),C.add(Y.text))}const G=C,X=s.slice(-30);for(const Y of X)(Y.text||"").trim()&&!G.has(Y.text)&&$.push({...Y,kind:"activity",ts:Y.timestamp});$.sort((Y,ne)=>Y.ts-ne.ts);const _=[];let N=[];for(const Y of $)Y.kind==="activity"?N.push(Y):(N.length>0&&(_.push({kind:"activity-group",entries:N}),N=[]),_.push(Y));return N.length>0&&_.push({kind:"activity-group",entries:N}),_},[n,s]);y.useEffect(()=>{x.current&&requestAnimationFrame(()=>{x.current&&(x.current.scrollTop=x.current.scrollHeight)})},[Q.length]);async function w($){var _;const C=Array.from($.target.files||[]);if(C.length===0)return;const G=D.getState().addToast,X=[];for(const N of C)try{const E=await new Promise((Y,ne)=>{const oe=new FileReader;oe.onload=()=>Y(oe.result.split(",")[1]),oe.onerror=ne,oe.readAsDataURL(N)});await ee.post(`/agents/${t.id}/upload`,{filename:N.name,content:E}),X.push(N.name)}catch(E){G("error",`Upload failed: ${N.name}`,E.message)}if(X.length>0){const N=X.join(", ");d(E=>(E?E+`
|
|
630
630
|
`:"")+`[Uploaded: ${N}] — I've uploaded these files to your working directory. Read them and use their content.`),G("success",`Uploaded ${X.length} file${X.length>1?"s":""}`)}$.target.value="",(_=b.current)==null||_.focus()}async function T(){var C;const $=u.trim();if(!(!$||p)){if($==="/rotate"){const G=D.getState().rotateAgent;d("");try{await G(t.id)}catch{}return}d(""),g(!0);try{O==="query"?await o(t.id,$):await l(t.id,$)}catch{}g(!1),(C=b.current)==null||C.focus()}}function k($){$.key==="Enter"&&!$.shiftKey&&($.preventDefault(),T())}const z=t.status==="running"||t.status==="starting";return i.jsxs("div",{className:"flex flex-col h-full min-h-0",children:[z&&i.jsx(pZ,{agent:t}),i.jsxs("div",{ref:x,className:"flex-1 overflow-y-auto px-4 py-4 space-y-4",children:[!Q.some($=>$.from==="agent"||$.kind==="activity-group")&&(z?i.jsx(gZ,{agent:t}):i.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-center py-8",children:[i.jsx("div",{className:"w-10 h-10 rounded-xl bg-surface-3 flex items-center justify-center mb-3",children:i.jsx(pi,{size:18,className:"text-text-4"})}),i.jsx("p",{className:"text-sm font-semibold text-text-0 font-sans",children:t.name}),i.jsx("p",{className:"text-xs text-text-3 font-sans mt-1",children:"Session complete — send a message to continue"})]})),Q.map(($,C)=>{if($.kind==="activity-group"){const G=!Q.slice(C+1).some(X=>X.kind==="activity-group"||X.from==="agent");return i.jsx(mZ,{entries:$.entries,isLive:z&&G},`grp-${C}`)}return $.from==="user"?i.jsx(OZ,{msg:$},`msg-${C}`):$.from==="system"?i.jsx(hZ,{msg:$},`msg-${C}`):i.jsx(fZ,{msg:$,agent:t},`msg-${C}`)}),p&&i.jsxs("div",{className:"flex items-center gap-2 ml-7 py-2",children:[i.jsx("div",{className:"w-5 h-5 rounded-md bg-accent/12 flex items-center justify-center",children:i.jsx(On,{size:10,className:"text-accent"})}),i.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-2 rounded-2xl bg-surface-2/60 border border-border-subtle",children:[i.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-accent/60 animate-pulse",style:{animationDelay:"0ms"}}),i.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-accent/60 animate-pulse",style:{animationDelay:"200ms"}}),i.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-accent/60 animate-pulse",style:{animationDelay:"400ms"}})]})]})]}),i.jsxs("div",{className:"border-t border-border px-4 py-3 bg-surface-1/50 flex-shrink-0",children:[i.jsxs("div",{className:"flex items-center gap-1 mb-2",children:[i.jsxs("button",{onClick:()=>m("instruct"),className:se("flex items-center gap-1.5 px-2.5 py-1 rounded-md text-[11px] font-sans font-medium transition-colors cursor-pointer",O==="instruct"?"bg-accent/12 text-accent border border-accent/20":"text-text-3 hover:text-text-1 hover:bg-surface-3"),children:[i.jsx(Gc,{size:10}),"Instruct"]}),i.jsxs("button",{onClick:()=>m("query"),className:se("flex items-center gap-1.5 px-2.5 py-1 rounded-md text-[11px] font-sans font-medium transition-colors cursor-pointer",O==="query"?"bg-info/12 text-info border border-info/20":"text-text-3 hover:text-text-1 hover:bg-surface-3"),children:[i.jsx(gc,{size:10}),"Query"]}),i.jsx("span",{className:"text-[10px] text-text-4 font-sans ml-auto",children:O==="query"?"Read-only — agent keeps working":z?"Directs the agent":"Continues the session"})]}),i.jsxs("div",{className:se("flex items-end gap-1 rounded-xl border bg-surface-0 p-1 transition-colors",O==="query"?"border-info/20 focus-within:border-info/40":"border-border-subtle focus-within:border-accent/30"),children:[i.jsx("input",{ref:v,type:"file",multiple:!0,accept:".pdf,.png,.jpg,.jpeg,.gif,.svg,.csv,.txt,.md,.json,.yaml,.yml,.docx,.pptx,.xlsx",onChange:w,className:"hidden"}),i.jsx("button",{onClick:()=>{var $;return($=v.current)==null?void 0:$.click()},className:"w-9 h-9 flex items-center justify-center rounded-lg text-text-4 hover:text-text-1 hover:bg-surface-3 transition-colors cursor-pointer flex-shrink-0 mb-px",title:"Attach file",children:i.jsx(BT,{size:14})}),i.jsx("textarea",{ref:b,value:u,onChange:$=>d($.target.value),onKeyDown:k,placeholder:O==="query"?"Ask about this agent's work...":z?"Send an instruction...":"Continue this session...",rows:1,className:se("flex-1 resize-none px-3 py-2 text-[13px]","bg-transparent text-text-0 font-sans","placeholder:text-text-4","focus:outline-none","max-h-[120px] min-h-[36px]"),style:{height:Math.min(Math.max(36,u.split(`
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
6
|
<link rel="icon" type="image/png" href="/favicon.png" />
|
|
7
7
|
<title>Groove GUI</title>
|
|
8
|
-
<script type="module" crossorigin src="/assets/index-
|
|
8
|
+
<script type="module" crossorigin src="/assets/index-PPbrScja.js"></script>
|
|
9
9
|
<link rel="modulepreload" crossorigin href="/assets/vendor-C0HXlhrU.js">
|
|
10
10
|
<link rel="modulepreload" crossorigin href="/assets/reactflow-BQPfi37R.js">
|
|
11
11
|
<link rel="modulepreload" crossorigin href="/assets/codemirror-BBL3i_JW.js">
|
|
@@ -162,8 +162,8 @@ function FilePicker({ repoId, onDownload, systemRamGb }) {
|
|
|
162
162
|
return (
|
|
163
163
|
<div className="pl-6 pr-4 pb-2 space-y-1.5">
|
|
164
164
|
{files.map((f) => {
|
|
165
|
-
const canRun = !f.estimatedRamGb || !systemRamGb || f.estimatedRamGb <= systemRamGb
|
|
166
|
-
const tight = f.estimatedRamGb && systemRamGb && f.estimatedRamGb > systemRamGb * 0.
|
|
165
|
+
const canRun = !f.estimatedRamGb || !systemRamGb || f.estimatedRamGb <= systemRamGb;
|
|
166
|
+
const tight = f.estimatedRamGb && systemRamGb && f.estimatedRamGb > systemRamGb * 0.8 && canRun;
|
|
167
167
|
return (
|
|
168
168
|
<div key={f.filename} className={cn(
|
|
169
169
|
'flex items-center gap-2 py-1.5 px-3 rounded-md text-xs font-sans',
|