@agent-spaces/server 0.3.65 → 0.4.0
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/dist/adapters/agent-runtime.js +8 -0
- package/dist/adapters/codex-function-tool-bridge.js +152 -0
- package/dist/adapters/codex-runtime.js +23 -4
- package/dist/adapters/git.js +25 -3
- package/dist/adapters/hermes-runtime.js +813 -0
- package/dist/adapters/langchain-runtime.js +384 -21
- package/dist/adapters/oh-my-pi-runtime.js +858 -0
- package/dist/adapters/open-agent-sdk-runtime.js +202 -5
- package/dist/adapters/open-agent-sdk-runtime.test.js +35 -0
- package/dist/agents/agent-message-parts.js +52 -2
- package/dist/agents/issue-task-controller.js +71 -2
- package/dist/agents/pull-request-agent.js +115 -0
- package/dist/agents/scheduler-agent.js +1 -1
- package/dist/agents/title-generator-agent.js +120 -0
- package/dist/app.js +61 -4
- package/dist/middleware/auth.js +1 -1
- package/dist/package.json +2 -1
- package/dist/routes/agent-sse.js +70 -6
- package/dist/routes/channel.js +23 -2
- package/dist/routes/chat-run.js +191 -0
- package/dist/routes/chat.js +142 -0
- package/dist/routes/command.js +16 -0
- package/dist/routes/data.js +189 -0
- package/dist/routes/git.js +10 -1
- package/dist/routes/import.js +199 -0
- package/dist/routes/issue.js +17 -5
- package/dist/routes/notification.js +10 -0
- package/dist/routes/plugin.js +69 -0
- package/dist/routes/version.js +95 -0
- package/dist/routes/workflow-hook.js +71 -0
- package/dist/routes/workflow.js +282 -7
- package/dist/routes/workspace.js +13 -4
- package/dist/routes/worktree.js +93 -0
- package/dist/services/agent.js +123 -36
- package/dist/services/ai-text.js +185 -0
- package/dist/services/builtin-tools/index.js +1 -0
- package/dist/services/builtin-tools/workflow-editor-tools.js +509 -0
- package/dist/services/builtin-tools/workflow-exec-tools.js +320 -0
- package/dist/services/chat.js +134 -0
- package/dist/services/command-process-manager.js +16 -0
- package/dist/services/execution-manager.js +1346 -0
- package/dist/services/generated-title.js +59 -0
- package/dist/services/gitignore.js +22 -18
- package/dist/services/interaction-manager.js +114 -0
- package/dist/services/issue-retry.js +25 -0
- package/dist/services/notification-center.js +9 -0
- package/dist/services/output-style.js +8 -1
- package/dist/services/plugin.js +257 -0
- package/dist/services/prompt-template.js +8 -1
- package/dist/services/pty.js +20 -0
- package/dist/services/search.js +16 -6
- package/dist/services/skill.js +2 -0
- package/dist/services/version.js +69 -0
- package/dist/services/workflow-command-runner.js +24 -0
- package/dist/services/workflow-trigger-service.js +137 -0
- package/dist/services/workflow.js +219 -39
- package/dist/services/workspace.js +23 -1
- package/dist/services/worktree.js +207 -0
- package/dist/storage/agent-store.js +8 -0
- package/dist/storage/chat-store.js +151 -0
- package/dist/storage/database-store.js +6 -0
- package/dist/storage/json-store.js +2 -1
- package/dist/storage/kanban-store.js +6 -0
- package/dist/storage/workflow-store.js +386 -22
- package/dist/storage/worktree-store.js +33 -0
- package/dist/web/404.html +1 -1
- package/dist/web/__next.__PAGE__.txt +4 -4
- package/dist/web/__next._full.txt +21 -21
- package/dist/web/__next._head.txt +4 -4
- package/dist/web/__next._index.txt +13 -13
- package/dist/web/__next._tree.txt +2 -2
- package/dist/web/_next/static/chunks/{08x85faoz58i7.js → 0-92u-tiuy40a.js} +4 -4
- package/dist/web/_next/static/chunks/{0db14450oqzhg.js → 0-yizd8osmas2.js} +1 -1
- package/dist/web/_next/static/chunks/0.ln~3mnv8.69.js +1 -0
- package/dist/web/_next/static/chunks/{11cchuwoupmbf.js → 01y3e9pemva7b.js} +10 -10
- package/dist/web/_next/static/chunks/02l~tmzrgny.~.js +1 -0
- package/dist/web/_next/static/chunks/03f1bwuynjdmk.js +1 -0
- package/dist/web/_next/static/chunks/04cb4kc9r2pd1.js +1 -0
- package/dist/web/_next/static/chunks/04de6ha5_e3pp.js +1 -0
- package/dist/web/_next/static/chunks/09he0p79ov1rn.js +1 -0
- package/dist/web/_next/static/chunks/09vpocs4zuc8h.js +1 -0
- package/dist/web/_next/static/chunks/0_o2exgr0e_nh.js +1 -0
- package/dist/web/_next/static/chunks/{0xbaakj0dfc0..js → 0_y9nskc-xt2k.js} +1 -1
- package/dist/web/_next/static/chunks/0clnj-1fi6u8j.js +3 -0
- package/dist/web/_next/static/chunks/0gv40by0zzxs_.js +1 -0
- package/dist/web/_next/static/chunks/0iusr8y88.kjg.js +1 -0
- package/dist/web/_next/static/chunks/{0-a.-hl3wv99k.js → 0j-8418fxvkd1.js} +1 -1
- package/dist/web/_next/static/chunks/0j.wxxyoclma5.js +1 -0
- package/dist/web/_next/static/chunks/{0.6b64sy0g5.3.js → 0jq.16sozqik..js} +1 -1
- package/dist/web/_next/static/chunks/0jw8xdk_fpnp0.css +1 -0
- package/dist/web/_next/static/chunks/0l1lkd-wcotma.js +1 -0
- package/dist/web/_next/static/chunks/{0u6h-hqc_i52e.js → 0ncxf_zr4n839.js} +1 -1
- package/dist/web/_next/static/chunks/0ndo7um~v7vco.js +1 -0
- package/dist/web/_next/static/chunks/0ngk.~kan8wq_.js +1 -0
- package/dist/web/_next/static/chunks/0ppr271hz0xoq.js +1 -0
- package/dist/web/_next/static/chunks/0rt9bofnn6qvn.js +1 -0
- package/dist/web/_next/static/chunks/0t64.9jd00hio.js +3 -0
- package/dist/web/_next/static/chunks/0taui9--5n6-5.js +1 -0
- package/dist/web/_next/static/chunks/0ty39169lh~z3.js +1 -0
- package/dist/web/_next/static/chunks/0v8nof~waedlu.js +1 -0
- package/dist/web/_next/static/chunks/{0-pi.67w.ymsr.js → 0vcfoagnpf.aw.js} +1 -1
- package/dist/web/_next/static/chunks/{0vis~lx0nxgn-.js → 0wwwq.gyyz0vg.js} +3 -3
- package/dist/web/_next/static/chunks/0x5lak8yz7pm7.js +1 -0
- package/dist/web/_next/static/chunks/0xon_.4-o0_zq.js +7 -0
- package/dist/web/_next/static/chunks/0zjnrbt7inime.js +1 -0
- package/dist/web/_next/static/chunks/0zwebpitvpuv1.js +1 -0
- package/dist/web/_next/static/chunks/0~02o4g-o6n~m.js +1 -0
- package/dist/web/_next/static/chunks/{0w7.tb29958zj.js → 0~fjezp.k4qk3.js} +1 -1
- package/dist/web/_next/static/chunks/0~sh93re1-_rp.js +1 -0
- package/dist/web/_next/static/chunks/10_niiq0k6o-p.js +5 -0
- package/dist/web/_next/static/chunks/12tjr0_2ccrtq.js +2 -0
- package/dist/web/_next/static/chunks/12x5.go_x9mfk.js +1 -0
- package/dist/web/_next/static/chunks/{0l2w0qz1ea7ql.js → 12~5dk9i9d16t.js} +2 -2
- package/dist/web/_next/static/chunks/13iye4rv5p31b.js +1 -0
- package/dist/web/_next/static/chunks/{01~quun6sefgl.js → 13~y-b.b9rrw4.js} +1 -1
- package/dist/web/_next/static/chunks/151wzhb5q0lo5.js +1 -0
- package/dist/web/_not-found/__next._full.txt +19 -19
- package/dist/web/_not-found/__next._head.txt +4 -4
- package/dist/web/_not-found/__next._index.txt +13 -13
- package/dist/web/_not-found/__next._not-found.__PAGE__.txt +2 -2
- package/dist/web/_not-found/__next._not-found.txt +3 -3
- package/dist/web/_not-found/__next._tree.txt +2 -2
- package/dist/web/_not-found.html +1 -1
- package/dist/web/_not-found.txt +19 -19
- package/dist/web/index.html +1 -1
- package/dist/web/index.txt +21 -21
- package/dist/web/login/__next._full.txt +21 -21
- package/dist/web/login/__next._head.txt +4 -4
- package/dist/web/login/__next._index.txt +13 -13
- package/dist/web/login/__next._tree.txt +2 -2
- package/dist/web/login/__next.login.__PAGE__.txt +4 -4
- package/dist/web/login/__next.login.txt +3 -3
- package/dist/web/login.html +1 -1
- package/dist/web/login.txt +21 -21
- package/dist/web/settings/__next._full.txt +23 -23
- package/dist/web/settings/__next._head.txt +4 -4
- package/dist/web/settings/__next._index.txt +13 -13
- package/dist/web/settings/__next._tree.txt +2 -2
- package/dist/web/settings/__next.settings.__PAGE__.txt +4 -4
- package/dist/web/settings/__next.settings.txt +5 -5
- package/dist/web/settings/agents/__next._full.txt +23 -23
- package/dist/web/settings/agents/__next._head.txt +4 -4
- package/dist/web/settings/agents/__next._index.txt +13 -13
- package/dist/web/settings/agents/__next._tree.txt +2 -2
- package/dist/web/settings/agents/__next.settings.agents.__PAGE__.txt +4 -4
- package/dist/web/settings/agents/__next.settings.agents.txt +3 -3
- package/dist/web/settings/agents/__next.settings.txt +5 -5
- package/dist/web/settings/agents.html +1 -1
- package/dist/web/settings/agents.txt +23 -23
- package/dist/web/settings/mcps/__next._full.txt +23 -23
- package/dist/web/settings/mcps/__next._head.txt +4 -4
- package/dist/web/settings/mcps/__next._index.txt +13 -13
- package/dist/web/settings/mcps/__next._tree.txt +2 -2
- package/dist/web/settings/mcps/__next.settings.mcps.__PAGE__.txt +4 -4
- package/dist/web/settings/mcps/__next.settings.mcps.txt +3 -3
- package/dist/web/settings/mcps/__next.settings.txt +5 -5
- package/dist/web/settings/mcps.html +1 -1
- package/dist/web/settings/mcps.txt +23 -23
- package/dist/web/settings/models/__next._full.txt +23 -23
- package/dist/web/settings/models/__next._head.txt +4 -4
- package/dist/web/settings/models/__next._index.txt +13 -13
- package/dist/web/settings/models/__next._tree.txt +2 -2
- package/dist/web/settings/models/__next.settings.models.__PAGE__.txt +4 -4
- package/dist/web/settings/models/__next.settings.models.txt +3 -3
- package/dist/web/settings/models/__next.settings.txt +5 -5
- package/dist/web/settings/models.html +1 -1
- package/dist/web/settings/models.txt +23 -23
- package/dist/web/settings/output-styles/__next._full.txt +23 -23
- package/dist/web/settings/output-styles/__next._head.txt +4 -4
- package/dist/web/settings/output-styles/__next._index.txt +13 -13
- package/dist/web/settings/output-styles/__next._tree.txt +2 -2
- package/dist/web/settings/output-styles/__next.settings.output-styles.__PAGE__.txt +4 -4
- package/dist/web/settings/output-styles/__next.settings.output-styles.txt +3 -3
- package/dist/web/settings/output-styles/__next.settings.txt +5 -5
- package/dist/web/settings/output-styles.html +1 -1
- package/dist/web/settings/output-styles.txt +23 -23
- package/dist/web/settings/prompts/__next._full.txt +23 -23
- package/dist/web/settings/prompts/__next._head.txt +4 -4
- package/dist/web/settings/prompts/__next._index.txt +13 -13
- package/dist/web/settings/prompts/__next._tree.txt +2 -2
- package/dist/web/settings/prompts/__next.settings.prompts.__PAGE__.txt +4 -4
- package/dist/web/settings/prompts/__next.settings.prompts.txt +3 -3
- package/dist/web/settings/prompts/__next.settings.txt +5 -5
- package/dist/web/settings/prompts.html +1 -1
- package/dist/web/settings/prompts.txt +23 -23
- package/dist/web/settings/providers/__next._full.txt +23 -23
- package/dist/web/settings/providers/__next._head.txt +4 -4
- package/dist/web/settings/providers/__next._index.txt +13 -13
- package/dist/web/settings/providers/__next._tree.txt +2 -2
- package/dist/web/settings/providers/__next.settings.providers.__PAGE__.txt +4 -4
- package/dist/web/settings/providers/__next.settings.providers.txt +3 -3
- package/dist/web/settings/providers/__next.settings.txt +5 -5
- package/dist/web/settings/providers.html +1 -1
- package/dist/web/settings/providers.txt +23 -23
- package/dist/web/settings/skills/__next._full.txt +23 -23
- package/dist/web/settings/skills/__next._head.txt +4 -4
- package/dist/web/settings/skills/__next._index.txt +13 -13
- package/dist/web/settings/skills/__next._tree.txt +2 -2
- package/dist/web/settings/skills/__next.settings.skills.__PAGE__.txt +4 -4
- package/dist/web/settings/skills/__next.settings.skills.txt +3 -3
- package/dist/web/settings/skills/__next.settings.txt +5 -5
- package/dist/web/settings/skills.html +1 -1
- package/dist/web/settings/skills.txt +23 -23
- package/dist/web/settings/tools/__next._full.txt +23 -23
- package/dist/web/settings/tools/__next._head.txt +4 -4
- package/dist/web/settings/tools/__next._index.txt +13 -13
- package/dist/web/settings/tools/__next._tree.txt +2 -2
- package/dist/web/settings/tools/__next.settings.tools.__PAGE__.txt +4 -4
- package/dist/web/settings/tools/__next.settings.tools.txt +3 -3
- package/dist/web/settings/tools/__next.settings.txt +5 -5
- package/dist/web/settings/tools.html +1 -1
- package/dist/web/settings/tools.txt +23 -23
- package/dist/web/settings.html +1 -1
- package/dist/web/settings.txt +23 -23
- package/dist/web/workflows/__next._full.txt +22 -22
- package/dist/web/workflows/__next._head.txt +4 -4
- package/dist/web/workflows/__next._index.txt +13 -13
- package/dist/web/workflows/__next._tree.txt +2 -2
- package/dist/web/workflows/__next.workflows.__PAGE__.txt +4 -4
- package/dist/web/workflows/__next.workflows.txt +3 -3
- package/dist/web/workflows.html +1 -1
- package/dist/web/workflows.txt +22 -22
- package/dist/web/workspace/_/__next._full.txt +20 -20
- package/dist/web/workspace/_/__next._head.txt +4 -4
- package/dist/web/workspace/_/__next._index.txt +13 -13
- package/dist/web/workspace/_/__next._tree.txt +2 -2
- package/dist/web/workspace/_/__next.workspace.$d$id.__PAGE__.txt +3 -3
- package/dist/web/workspace/_/__next.workspace.$d$id.txt +3 -3
- package/dist/web/workspace/_/__next.workspace.txt +3 -3
- package/dist/web/workspace/_.html +1 -1
- package/dist/web/workspace/_.txt +20 -20
- package/dist/web/workspaces/__next._full.txt +21 -21
- package/dist/web/workspaces/__next._head.txt +4 -4
- package/dist/web/workspaces/__next._index.txt +13 -13
- package/dist/web/workspaces/__next._tree.txt +2 -2
- package/dist/web/workspaces/__next.workspaces.__PAGE__.txt +4 -4
- package/dist/web/workspaces/__next.workspaces.txt +3 -3
- package/dist/web/workspaces.html +1 -1
- package/dist/web/workspaces.txt +21 -21
- package/dist/ws/agent-prompt.js +36 -3
- package/dist/ws/agent-runner.js +30 -18
- package/dist/ws/chat-handler.js +89 -0
- package/dist/ws/connection-manager.js +49 -2
- package/dist/ws/execution-channels.js +88 -0
- package/dist/ws/handler.js +32 -5
- package/dist/ws/message-parts.js +130 -12
- package/dist/ws/terminal-handler.js +26 -0
- package/package.json +13 -1
- package/public/avatars/user.jpg +0 -0
- package/dist/web/_next/static/chunks/0-v_p6j5u3_9l.js +0 -1
- package/dist/web/_next/static/chunks/0.-x29t-8gk0r.js +0 -1
- package/dist/web/_next/static/chunks/0.l5e8~r7_0~p.js +0 -1
- package/dist/web/_next/static/chunks/0.n~yfwf4~6w-.js +0 -1
- package/dist/web/_next/static/chunks/00-syqzi-6zxr.js +0 -1
- package/dist/web/_next/static/chunks/02j4sr9psucf-.js +0 -1
- package/dist/web/_next/static/chunks/06si8l0doqe8p.js +0 -1
- package/dist/web/_next/static/chunks/08kfx8on9oty~.js +0 -1
- package/dist/web/_next/static/chunks/08ugbvzr20drp.js +0 -2
- package/dist/web/_next/static/chunks/0_cqojbge48kq.js +0 -5
- package/dist/web/_next/static/chunks/0d6~~lv0-6kex.js +0 -3
- package/dist/web/_next/static/chunks/0gdwop9cnpmtu.js +0 -1
- package/dist/web/_next/static/chunks/0ghx3j_.-gdyd.js +0 -1
- package/dist/web/_next/static/chunks/0kbvoxla7f751.js +0 -1
- package/dist/web/_next/static/chunks/0paaat8y96ayc.js +0 -7
- package/dist/web/_next/static/chunks/0pq318f8xgafg.js +0 -1
- package/dist/web/_next/static/chunks/0t6s8of0qr6nc.js +0 -1
- package/dist/web/_next/static/chunks/0xt-8wk21gs7g.js +0 -1
- package/dist/web/_next/static/chunks/0yd.m1afqg.2t.js +0 -3
- package/dist/web/_next/static/chunks/0yhbr8hl09b-5.js +0 -1
- package/dist/web/_next/static/chunks/0z~vqzbm_q371.js +0 -1
- package/dist/web/_next/static/chunks/0~~_ltu6dx_ch.js +0 -1
- package/dist/web/_next/static/chunks/12oxcgyhpaxw~.js +0 -1
- package/dist/web/_next/static/chunks/1452eibz62gs6.css +0 -1
- package/dist/web/_next/static/chunks/16zlreiems5cn.js +0 -1
- package/dist/web/_next/static/chunks/18awqjk9-o5m0.js +0 -1
- /package/dist/web/_next/static/{x4-CsKe6qUQyFDWVtfvUg → rGXyAK8rgod1NjF3bLZAY}/_buildManifest.js +0 -0
- /package/dist/web/_next/static/{x4-CsKe6qUQyFDWVtfvUg → rGXyAK8rgod1NjF3bLZAY}/_clientMiddlewareManifest.js +0 -0
- /package/dist/web/_next/static/{x4-CsKe6qUQyFDWVtfvUg → rGXyAK8rgod1NjF3bLZAY}/_ssgManifest.js +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,837121,(e,t,a)=>{"use strict";Object.defineProperty(a,"__esModule",{value:!0}),Object.defineProperty(a,"warnOnce",{enumerable:!0,get:function(){return n}});let n=e=>{}},360112,e=>{"use strict";var t=e.i(764556),a=e.i(106206);let n=Array(12).fill(0),s=({visible:e,className:a})=>t.default.createElement("div",{className:["sonner-loading-wrapper",a].filter(Boolean).join(" "),"data-visible":e},t.default.createElement("div",{className:"sonner-spinner"},n.map((e,a)=>t.default.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${a}`})))),r=t.default.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},t.default.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",clipRule:"evenodd"})),i=t.default.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},t.default.createElement("path",{fillRule:"evenodd",d:"M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z",clipRule:"evenodd"})),o=t.default.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},t.default.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",clipRule:"evenodd"})),l=t.default.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},t.default.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})),d=t.default.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},t.default.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),t.default.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),c=1,u=new class{constructor(){this.subscribe=e=>(this.subscribers.push(e),()=>{let t=this.subscribers.indexOf(e);this.subscribers.splice(t,1)}),this.publish=e=>{this.subscribers.forEach(t=>t(e))},this.addToast=e=>{this.publish(e),this.toasts=[...this.toasts,e]},this.create=e=>{var t;let{message:a,...n}=e,s="number"==typeof(null==e?void 0:e.id)||(null==(t=e.id)?void 0:t.length)>0?e.id:c++,r=this.toasts.find(e=>e.id===s),i=void 0===e.dismissible||e.dismissible;return this.dismissedToasts.has(s)&&this.dismissedToasts.delete(s),r?this.toasts=this.toasts.map(t=>t.id===s?(this.publish({...t,...e,id:s,title:a}),{...t,...e,id:s,dismissible:i,title:a}):t):this.addToast({title:a,...n,dismissible:i,id:s}),s},this.dismiss=e=>(e?(this.dismissedToasts.add(e),requestAnimationFrame(()=>this.subscribers.forEach(t=>t({id:e,dismiss:!0})))):this.toasts.forEach(e=>{this.subscribers.forEach(t=>t({id:e.id,dismiss:!0}))}),e),this.message=(e,t)=>this.create({...t,message:e}),this.error=(e,t)=>this.create({...t,message:e,type:"error"}),this.success=(e,t)=>this.create({...t,type:"success",message:e}),this.info=(e,t)=>this.create({...t,type:"info",message:e}),this.warning=(e,t)=>this.create({...t,type:"warning",message:e}),this.loading=(e,t)=>this.create({...t,type:"loading",message:e}),this.promise=(e,a)=>{let n,s;if(!a)return;void 0!==a.loading&&(s=this.create({...a,promise:e,type:"loading",message:a.loading,description:"function"!=typeof a.description?a.description:void 0}));let r=Promise.resolve(e instanceof Function?e():e),i=void 0!==s,o=r.then(async e=>{if(n=["resolve",e],t.default.isValidElement(e))i=!1,this.create({id:s,type:"default",message:e});else if(m(e)&&!e.ok){i=!1;let n="function"==typeof a.error?await a.error(`HTTP error! status: ${e.status}`):a.error,r="function"==typeof a.description?await a.description(`HTTP error! status: ${e.status}`):a.description,o="object"!=typeof n||t.default.isValidElement(n)?{message:n}:n;this.create({id:s,type:"error",description:r,...o})}else if(e instanceof Error){i=!1;let n="function"==typeof a.error?await a.error(e):a.error,r="function"==typeof a.description?await a.description(e):a.description,o="object"!=typeof n||t.default.isValidElement(n)?{message:n}:n;this.create({id:s,type:"error",description:r,...o})}else if(void 0!==a.success){i=!1;let n="function"==typeof a.success?await a.success(e):a.success,r="function"==typeof a.description?await a.description(e):a.description,o="object"!=typeof n||t.default.isValidElement(n)?{message:n}:n;this.create({id:s,type:"success",description:r,...o})}}).catch(async e=>{if(n=["reject",e],void 0!==a.error){i=!1;let n="function"==typeof a.error?await a.error(e):a.error,r="function"==typeof a.description?await a.description(e):a.description,o="object"!=typeof n||t.default.isValidElement(n)?{message:n}:n;this.create({id:s,type:"error",description:r,...o})}}).finally(()=>{i&&(this.dismiss(s),s=void 0),null==a.finally||a.finally.call(a)}),l=()=>new Promise((e,t)=>o.then(()=>"reject"===n[0]?t(n[1]):e(n[1])).catch(t));return"string"!=typeof s&&"number"!=typeof s?{unwrap:l}:Object.assign(s,{unwrap:l})},this.custom=(e,t)=>{let a=(null==t?void 0:t.id)||c++;return this.create({jsx:e(a),id:a,...t}),a},this.getActiveToasts=()=>this.toasts.filter(e=>!this.dismissedToasts.has(e.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}},m=e=>e&&"object"==typeof e&&"ok"in e&&"boolean"==typeof e.ok&&"status"in e&&"number"==typeof e.status,p=Object.assign((e,t)=>{let a=(null==t?void 0:t.id)||c++;return u.addToast({title:e,...t,id:a}),a},{success:u.success,info:u.info,warning:u.warning,error:u.error,custom:u.custom,message:u.message,promise:u.promise,dismiss:u.dismiss,loading:u.loading},{getHistory:()=>u.toasts,getToasts:()=>u.getActiveToasts()});function f(e){return void 0!==e.label}function h(...e){return e.filter(Boolean).join(" ")}!function(e){if(!e||"u"<typeof document)return;let t=document.head||document.getElementsByTagName("head")[0],a=document.createElement("style");a.type="text/css",t.appendChild(a),a.styleSheet?a.styleSheet.cssText=e:a.appendChild(document.createTextNode(e))}("[data-sonner-toaster][dir=ltr],html[dir=ltr]{--toast-icon-margin-start:-3px;--toast-icon-margin-end:4px;--toast-svg-margin-start:-1px;--toast-svg-margin-end:0px;--toast-button-margin-start:auto;--toast-button-margin-end:0;--toast-close-button-start:0;--toast-close-button-end:unset;--toast-close-button-transform:translate(-35%, -35%)}[data-sonner-toaster][dir=rtl],html[dir=rtl]{--toast-icon-margin-start:4px;--toast-icon-margin-end:-3px;--toast-svg-margin-start:0px;--toast-svg-margin-end:-1px;--toast-button-margin-start:0;--toast-button-margin-end:auto;--toast-close-button-start:unset;--toast-close-button-end:0;--toast-close-button-transform:translate(35%, -35%)}[data-sonner-toaster]{position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1:hsl(0, 0%, 99%);--gray2:hsl(0, 0%, 97.3%);--gray3:hsl(0, 0%, 95.1%);--gray4:hsl(0, 0%, 93%);--gray5:hsl(0, 0%, 90.9%);--gray6:hsl(0, 0%, 88.7%);--gray7:hsl(0, 0%, 85.8%);--gray8:hsl(0, 0%, 78%);--gray9:hsl(0, 0%, 56.1%);--gray10:hsl(0, 0%, 52.3%);--gray11:hsl(0, 0%, 43.5%);--gray12:hsl(0, 0%, 9%);--border-radius:8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:0;z-index:999999999;transition:transform .4s ease}@media (hover:none) and (pointer:coarse){[data-sonner-toaster][data-lifted=true]{transform:none}}[data-sonner-toaster][data-x-position=right]{right:var(--offset-right)}[data-sonner-toaster][data-x-position=left]{left:var(--offset-left)}[data-sonner-toaster][data-x-position=center]{left:50%;transform:translateX(-50%)}[data-sonner-toaster][data-y-position=top]{top:var(--offset-top)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--offset-bottom)}[data-sonner-toast]{--y:translateY(100%);--lift-amount:calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:0;overflow-wrap:anywhere}[data-sonner-toast][data-styled=true]{padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px rgba(0,0,0,.1);width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}[data-sonner-toast]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-y-position=top]{top:0;--y:translateY(-100%);--lift:1;--lift-amount:calc(1 * var(--gap))}[data-sonner-toast][data-y-position=bottom]{bottom:0;--y:translateY(100%);--lift:-1;--lift-amount:calc(var(--lift) * var(--gap))}[data-sonner-toast][data-styled=true] [data-description]{font-weight:400;line-height:1.4;color:#3f3f3f}[data-rich-colors=true][data-sonner-toast][data-styled=true] [data-description]{color:inherit}[data-sonner-toaster][data-sonner-theme=dark] [data-description]{color:#e8e8e8}[data-sonner-toast][data-styled=true] [data-title]{font-weight:500;line-height:1.5;color:inherit}[data-sonner-toast][data-styled=true] [data-icon]{display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}[data-sonner-toast][data-promise=true] [data-icon]>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}[data-sonner-toast][data-styled=true] [data-icon]>*{flex-shrink:0}[data-sonner-toast][data-styled=true] [data-icon] svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}[data-sonner-toast][data-styled=true] [data-content]{display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;font-weight:500;cursor:pointer;outline:0;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}[data-sonner-toast][data-styled=true] [data-button]:focus-visible{box-shadow:0 0 0 2px rgba(0,0,0,.4)}[data-sonner-toast][data-styled=true] [data-button]:first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}[data-sonner-toast][data-styled=true] [data-cancel]{color:var(--normal-text);background:rgba(0,0,0,.08)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-styled=true] [data-cancel]{background:rgba(255,255,255,.3)}[data-sonner-toast][data-styled=true] [data-close-button]{position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);background:var(--normal-bg);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast][data-styled=true] [data-close-button]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-styled=true] [data-disabled=true]{cursor:not-allowed}[data-sonner-toast][data-styled=true]:hover [data-close-button]:hover{background:var(--gray2);border-color:var(--gray5)}[data-sonner-toast][data-swiping=true]::before{content:'';position:absolute;left:-100%;right:-100%;height:100%;z-index:-1}[data-sonner-toast][data-y-position=top][data-swiping=true]::before{bottom:50%;transform:scaleY(3) translateY(50%)}[data-sonner-toast][data-y-position=bottom][data-swiping=true]::before{top:50%;transform:scaleY(3) translateY(-50%)}[data-sonner-toast][data-swiping=false][data-removed=true]::before{content:'';position:absolute;inset:0;transform:scaleY(2)}[data-sonner-toast][data-expanded=true]::after{content:'';position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}[data-sonner-toast][data-mounted=true]{--y:translateY(0);opacity:1}[data-sonner-toast][data-expanded=false][data-front=false]{--scale:var(--toasts-before) * 0.05 + 1;--y:translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}[data-sonner-toast]>*{transition:opacity .4s}[data-sonner-toast][data-x-position=right]{right:0}[data-sonner-toast][data-x-position=left]{left:0}[data-sonner-toast][data-expanded=false][data-front=false][data-styled=true]>*{opacity:0}[data-sonner-toast][data-visible=false]{opacity:0;pointer-events:none}[data-sonner-toast][data-mounted=true][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}[data-sonner-toast][data-removed=true][data-front=true][data-swipe-out=false]{--y:translateY(calc(var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=false]{--y:translateY(40%);opacity:0;transition:transform .5s,opacity .2s}[data-sonner-toast][data-removed=true][data-front=false]::before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y,0)) translateX(var(--swipe-amount-x,0));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width:600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-sonner-theme=light]{--normal-bg:#fff;--normal-border:var(--gray4);--normal-text:var(--gray12);--success-bg:hsl(143, 85%, 96%);--success-border:hsl(145, 92%, 87%);--success-text:hsl(140, 100%, 27%);--info-bg:hsl(208, 100%, 97%);--info-border:hsl(221, 91%, 93%);--info-text:hsl(210, 92%, 45%);--warning-bg:hsl(49, 100%, 97%);--warning-border:hsl(49, 91%, 84%);--warning-text:hsl(31, 92%, 45%);--error-bg:hsl(359, 100%, 97%);--error-border:hsl(359, 100%, 94%);--error-text:hsl(360, 100%, 45%)}[data-sonner-toaster][data-sonner-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg:#000;--normal-border:hsl(0, 0%, 20%);--normal-text:var(--gray1)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg:#fff;--normal-border:var(--gray3);--normal-text:var(--gray12)}[data-sonner-toaster][data-sonner-theme=dark]{--normal-bg:#000;--normal-bg-hover:hsl(0, 0%, 12%);--normal-border:hsl(0, 0%, 20%);--normal-border-hover:hsl(0, 0%, 25%);--normal-text:var(--gray1);--success-bg:hsl(150, 100%, 6%);--success-border:hsl(147, 100%, 12%);--success-text:hsl(150, 86%, 65%);--info-bg:hsl(215, 100%, 6%);--info-border:hsl(223, 43%, 17%);--info-text:hsl(216, 87%, 65%);--warning-bg:hsl(64, 100%, 6%);--warning-border:hsl(60, 100%, 9%);--warning-text:hsl(46, 87%, 65%);--error-bg:hsl(358, 76%, 10%);--error-border:hsl(357, 89%, 16%);--error-text:hsl(358, 100%, 81%)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size:16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:first-child{animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}100%{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}100%{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}100%{opacity:.15}}@media (prefers-reduced-motion){.sonner-loading-bar,[data-sonner-toast],[data-sonner-toast]>*{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}");let x=e=>{var a,n,c,u,m,p,x,g,v,y,b,j,w;let{invert:k,toast:N,unstyled:C,interacting:S,setHeights:T,visibleToasts:M,heights:P,index:E,toasts:D,expanded:z,removeToast:F,defaultRichColors:O,closeButton:R,style:I,cancelButtonStyle:A,actionButtonStyle:L,className:B="",descriptionClassName:$="",duration:H,position:U,gap:W,expandByDefault:_,classNames:V,icons:J,closeButtonAriaLabel:Y="Close toast"}=e,[q,K]=t.default.useState(null),[X,G]=t.default.useState(null),[Q,Z]=t.default.useState(!1),[ee,et]=t.default.useState(!1),[ea,en]=t.default.useState(!1),[es,er]=t.default.useState(!1),[ei,eo]=t.default.useState(!1),[el,ed]=t.default.useState(0),[ec,eu]=t.default.useState(0),em=t.default.useRef(N.duration||H||4e3),ep=t.default.useRef(null),ef=t.default.useRef(null),eh=0===E,ex=E+1<=M,eg=N.type,ev=!1!==N.dismissible,ey=N.className||"",eb=N.descriptionClassName||"",ej=t.default.useMemo(()=>P.findIndex(e=>e.toastId===N.id)||0,[P,N.id]),ew=t.default.useMemo(()=>{var e;return null!=(e=N.closeButton)?e:R},[N.closeButton,R]),ek=t.default.useMemo(()=>N.duration||H||4e3,[N.duration,H]),eN=t.default.useRef(0),eC=t.default.useRef(0),eS=t.default.useRef(0),eT=t.default.useRef(null),[eM,eP]=U.split("-"),eE=t.default.useMemo(()=>P.reduce((e,t,a)=>a>=ej?e:e+t.height,0),[P,ej]),eD=(()=>{let[e,a]=t.default.useState(document.hidden);return t.default.useEffect(()=>{let e=()=>{a(document.hidden)};return document.addEventListener("visibilitychange",e),()=>window.removeEventListener("visibilitychange",e)},[]),e})(),ez=N.invert||k,eF="loading"===eg;eC.current=t.default.useMemo(()=>ej*W+eE,[ej,eE]),t.default.useEffect(()=>{em.current=ek},[ek]),t.default.useEffect(()=>{Z(!0)},[]),t.default.useEffect(()=>{let e=ef.current;if(e){let t=e.getBoundingClientRect().height;return eu(t),T(e=>[{toastId:N.id,height:t,position:N.position},...e]),()=>T(e=>e.filter(e=>e.toastId!==N.id))}},[T,N.id]),t.default.useLayoutEffect(()=>{if(!Q)return;let e=ef.current,t=e.style.height;e.style.height="auto";let a=e.getBoundingClientRect().height;e.style.height=t,eu(a),T(e=>e.find(e=>e.toastId===N.id)?e.map(e=>e.toastId===N.id?{...e,height:a}:e):[{toastId:N.id,height:a,position:N.position},...e])},[Q,N.title,N.description,T,N.id,N.jsx,N.action,N.cancel]);let eO=t.default.useCallback(()=>{et(!0),ed(eC.current),T(e=>e.filter(e=>e.toastId!==N.id)),setTimeout(()=>{F(N)},200)},[N,F,T,eC]);t.default.useEffect(()=>{let e;if((!N.promise||"loading"!==eg)&&N.duration!==1/0&&"loading"!==N.type){if(z||S||eD){if(eS.current<eN.current){let e=new Date().getTime()-eN.current;em.current=em.current-e}eS.current=new Date().getTime()}else em.current!==1/0&&(eN.current=new Date().getTime(),e=setTimeout(()=>{null==N.onAutoClose||N.onAutoClose.call(N,N),eO()},em.current));return()=>clearTimeout(e)}},[z,S,N,eg,eD,eO]),t.default.useEffect(()=>{N.delete&&(eO(),null==N.onDismiss||N.onDismiss.call(N,N))},[eO,N.delete]);let eR=N.icon||(null==J?void 0:J[eg])||(e=>{switch(e){case"success":return r;case"info":return o;case"warning":return i;case"error":return l;default:return null}})(eg);return t.default.createElement("li",{tabIndex:0,ref:ef,className:h(B,ey,null==V?void 0:V.toast,null==N||null==(a=N.classNames)?void 0:a.toast,null==V?void 0:V.default,null==V?void 0:V[eg],null==N||null==(n=N.classNames)?void 0:n[eg]),"data-sonner-toast":"","data-rich-colors":null!=(y=N.richColors)?y:O,"data-styled":!(N.jsx||N.unstyled||C),"data-mounted":Q,"data-promise":!!N.promise,"data-swiped":ei,"data-removed":ee,"data-visible":ex,"data-y-position":eM,"data-x-position":eP,"data-index":E,"data-front":eh,"data-swiping":ea,"data-dismissible":ev,"data-type":eg,"data-invert":ez,"data-swipe-out":es,"data-swipe-direction":X,"data-expanded":!!(z||_&&Q),"data-testid":N.testId,style:{"--index":E,"--toasts-before":E,"--z-index":D.length-E,"--offset":`${ee?el:eC.current}px`,"--initial-height":_?"auto":`${ec}px`,...I,...N.style},onDragEnd:()=>{en(!1),K(null),eT.current=null},onPointerDown:e=>{2===e.button||eF||!ev||(ep.current=new Date,ed(eC.current),e.target.setPointerCapture(e.pointerId),"BUTTON"!==e.target.tagName&&(en(!0),eT.current={x:e.clientX,y:e.clientY}))},onPointerUp:()=>{var e,t,a,n,s;if(es||!ev)return;eT.current=null;let r=Number((null==(e=ef.current)?void 0:e.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),i=Number((null==(t=ef.current)?void 0:t.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),o=new Date().getTime()-(null==(a=ep.current)?void 0:a.getTime()),l="x"===q?r:i,d=Math.abs(l)/o;if(Math.abs(l)>=45||d>.11){ed(eC.current),null==N.onDismiss||N.onDismiss.call(N,N),"x"===q?G(r>0?"right":"left"):G(i>0?"down":"up"),eO(),er(!0);return}null==(n=ef.current)||n.style.setProperty("--swipe-amount-x","0px"),null==(s=ef.current)||s.style.setProperty("--swipe-amount-y","0px"),eo(!1),en(!1),K(null)},onPointerMove:t=>{var a,n,s,r;if(!eT.current||!ev||(null==(a=window.getSelection())?void 0:a.toString().length)>0)return;let i=t.clientY-eT.current.y,o=t.clientX-eT.current.x,l=null!=(r=e.swipeDirections)?r:function(e){let[t,a]=e.split("-"),n=[];return t&&n.push(t),a&&n.push(a),n}(U);!q&&(Math.abs(o)>1||Math.abs(i)>1)&&K(Math.abs(o)>Math.abs(i)?"x":"y");let d={x:0,y:0},c=e=>1/(1.5+Math.abs(e)/20);if("y"===q){if(l.includes("top")||l.includes("bottom"))if(l.includes("top")&&i<0||l.includes("bottom")&&i>0)d.y=i;else{let e=i*c(i);d.y=Math.abs(e)<Math.abs(i)?e:i}}else if("x"===q&&(l.includes("left")||l.includes("right")))if(l.includes("left")&&o<0||l.includes("right")&&o>0)d.x=o;else{let e=o*c(o);d.x=Math.abs(e)<Math.abs(o)?e:o}(Math.abs(d.x)>0||Math.abs(d.y)>0)&&eo(!0),null==(n=ef.current)||n.style.setProperty("--swipe-amount-x",`${d.x}px`),null==(s=ef.current)||s.style.setProperty("--swipe-amount-y",`${d.y}px`)}},ew&&!N.jsx&&"loading"!==eg?t.default.createElement("button",{"aria-label":Y,"data-disabled":eF,"data-close-button":!0,onClick:eF||!ev?()=>{}:()=>{eO(),null==N.onDismiss||N.onDismiss.call(N,N)},className:h(null==V?void 0:V.closeButton,null==N||null==(c=N.classNames)?void 0:c.closeButton)},null!=(b=null==J?void 0:J.close)?b:d):null,(eg||N.icon||N.promise)&&null!==N.icon&&((null==J?void 0:J[eg])!==null||N.icon)?t.default.createElement("div",{"data-icon":"",className:h(null==V?void 0:V.icon,null==N||null==(u=N.classNames)?void 0:u.icon)},N.promise||"loading"===N.type&&!N.icon?N.icon||((null==J?void 0:J.loading)?t.default.createElement("div",{className:h(null==V?void 0:V.loader,null==N||null==(w=N.classNames)?void 0:w.loader,"sonner-loader"),"data-visible":"loading"===eg},J.loading):t.default.createElement(s,{className:h(null==V?void 0:V.loader,null==N||null==(j=N.classNames)?void 0:j.loader),visible:"loading"===eg})):null,"loading"!==N.type?eR:null):null,t.default.createElement("div",{"data-content":"",className:h(null==V?void 0:V.content,null==N||null==(m=N.classNames)?void 0:m.content)},t.default.createElement("div",{"data-title":"",className:h(null==V?void 0:V.title,null==N||null==(p=N.classNames)?void 0:p.title)},N.jsx?N.jsx:"function"==typeof N.title?N.title():N.title),N.description?t.default.createElement("div",{"data-description":"",className:h($,eb,null==V?void 0:V.description,null==N||null==(x=N.classNames)?void 0:x.description)},"function"==typeof N.description?N.description():N.description):null),t.default.isValidElement(N.cancel)?N.cancel:N.cancel&&f(N.cancel)?t.default.createElement("button",{"data-button":!0,"data-cancel":!0,style:N.cancelButtonStyle||A,onClick:e=>{!f(N.cancel)||ev&&(null==N.cancel.onClick||N.cancel.onClick.call(N.cancel,e),eO())},className:h(null==V?void 0:V.cancelButton,null==N||null==(g=N.classNames)?void 0:g.cancelButton)},N.cancel.label):null,t.default.isValidElement(N.action)?N.action:N.action&&f(N.action)?t.default.createElement("button",{"data-button":!0,"data-action":!0,style:N.actionButtonStyle||L,onClick:e=>{!f(N.action)||(null==N.action.onClick||N.action.onClick.call(N.action,e),e.defaultPrevented||eO())},className:h(null==V?void 0:V.actionButton,null==N||null==(v=N.classNames)?void 0:v.actionButton)},N.action.label):null)};function g(){if("u"<typeof window||"u"<typeof document)return"ltr";let e=document.documentElement.getAttribute("dir");return"auto"!==e&&e?e:window.getComputedStyle(document.documentElement).direction}let v=t.default.forwardRef(function(e,n){let{id:s,invert:r,position:i="bottom-right",hotkey:o=["altKey","KeyT"],expand:l,closeButton:d,className:c,offset:m,mobileOffset:p,theme:f="light",richColors:h,duration:v,style:y,visibleToasts:b=3,toastOptions:j,dir:w=g(),gap:k=14,icons:N,containerAriaLabel:C="Notifications"}=e,[S,T]=t.default.useState([]),M=t.default.useMemo(()=>s?S.filter(e=>e.toasterId===s):S.filter(e=>!e.toasterId),[S,s]),P=t.default.useMemo(()=>Array.from(new Set([i].concat(M.filter(e=>e.position).map(e=>e.position)))),[M,i]),[E,D]=t.default.useState([]),[z,F]=t.default.useState(!1),[O,R]=t.default.useState(!1),[I,A]=t.default.useState("system"!==f?f:"u">typeof window&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),L=t.default.useRef(null),B=o.join("+").replace(/Key/g,"").replace(/Digit/g,""),$=t.default.useRef(null),H=t.default.useRef(!1),U=t.default.useCallback(e=>{T(t=>{var a;return(null==(a=t.find(t=>t.id===e.id))?void 0:a.delete)||u.dismiss(e.id),t.filter(({id:t})=>t!==e.id)})},[]);return t.default.useEffect(()=>u.subscribe(e=>{e.dismiss?requestAnimationFrame(()=>{T(t=>t.map(t=>t.id===e.id?{...t,delete:!0}:t))}):setTimeout(()=>{a.default.flushSync(()=>{T(t=>{let a=t.findIndex(t=>t.id===e.id);return -1!==a?[...t.slice(0,a),{...t[a],...e},...t.slice(a+1)]:[e,...t]})})})}),[S]),t.default.useEffect(()=>{if("system"!==f)return void A(f);if("system"===f&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?A("dark"):A("light")),"u"<typeof window)return;let e=window.matchMedia("(prefers-color-scheme: dark)");try{e.addEventListener("change",({matches:e})=>{e?A("dark"):A("light")})}catch(t){e.addListener(({matches:e})=>{try{e?A("dark"):A("light")}catch(e){console.error(e)}})}},[f]),t.default.useEffect(()=>{S.length<=1&&F(!1)},[S]),t.default.useEffect(()=>{let e=e=>{var t,a;o.every(t=>e[t]||e.code===t)&&(F(!0),null==(a=L.current)||a.focus()),"Escape"===e.code&&(document.activeElement===L.current||(null==(t=L.current)?void 0:t.contains(document.activeElement)))&&F(!1)};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[o]),t.default.useEffect(()=>{if(L.current)return()=>{$.current&&($.current.focus({preventScroll:!0}),$.current=null,H.current=!1)}},[L.current]),t.default.createElement("section",{ref:n,"aria-label":`${C} ${B}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},P.map((a,n)=>{var s;let i,[o,u]=a.split("-");return M.length?t.default.createElement("ol",{key:a,dir:"auto"===w?g():w,tabIndex:-1,ref:L,className:c,"data-sonner-toaster":!0,"data-sonner-theme":I,"data-y-position":o,"data-x-position":u,style:{"--front-toast-height":`${(null==(s=E[0])?void 0:s.height)||0}px`,"--width":"356px","--gap":`${k}px`,...y,...(i={},[m,p].forEach((e,t)=>{let a=1===t,n=a?"--mobile-offset":"--offset",s=a?"16px":"24px";function r(e){["top","right","bottom","left"].forEach(t=>{i[`${n}-${t}`]="number"==typeof e?`${e}px`:e})}"number"==typeof e||"string"==typeof e?r(e):"object"==typeof e?["top","right","bottom","left"].forEach(t=>{void 0===e[t]?i[`${n}-${t}`]=s:i[`${n}-${t}`]="number"==typeof e[t]?`${e[t]}px`:e[t]}):r(s)}),i)},onBlur:e=>{H.current&&!e.currentTarget.contains(e.relatedTarget)&&(H.current=!1,$.current&&($.current.focus({preventScroll:!0}),$.current=null))},onFocus:e=>{!(e.target instanceof HTMLElement&&"false"===e.target.dataset.dismissible)&&(H.current||(H.current=!0,$.current=e.relatedTarget))},onMouseEnter:()=>F(!0),onMouseMove:()=>F(!0),onMouseLeave:()=>{O||F(!1)},onDragEnd:()=>F(!1),onPointerDown:e=>{e.target instanceof HTMLElement&&"false"===e.target.dataset.dismissible||R(!0)},onPointerUp:()=>R(!1)},M.filter(e=>!e.position&&0===n||e.position===a).map((n,s)=>{var i,o;return t.default.createElement(x,{key:n.id,icons:N,index:s,toast:n,defaultRichColors:h,duration:null!=(i=null==j?void 0:j.duration)?i:v,className:null==j?void 0:j.className,descriptionClassName:null==j?void 0:j.descriptionClassName,invert:r,visibleToasts:b,closeButton:null!=(o=null==j?void 0:j.closeButton)?o:d,interacting:O,position:a,style:null==j?void 0:j.style,unstyled:null==j?void 0:j.unstyled,classNames:null==j?void 0:j.classNames,cancelButtonStyle:null==j?void 0:j.cancelButtonStyle,actionButtonStyle:null==j?void 0:j.actionButtonStyle,closeButtonAriaLabel:null==j?void 0:j.closeButtonAriaLabel,removeToast:U,toasts:M.filter(e=>e.position==n.position),heights:E.filter(e=>e.position==n.position),setHeights:D,expandByDefault:l,gap:k,expanded:z,swipeDirections:e.swipeDirections})})):null}))});e.s(["Toaster",0,v,"toast",0,p,"useSonner",0,function(){let[e,n]=t.default.useState([]);return t.default.useEffect(()=>u.subscribe(e=>{e.dismiss?setTimeout(()=>{a.default.flushSync(()=>{n(t=>t.filter(t=>t.id!==e.id))})}):setTimeout(()=>{a.default.flushSync(()=>{n(t=>{let a=t.findIndex(t=>t.id===e.id);return -1!==a?[...t.slice(0,a),{...t[a],...e},...t.slice(a+1)]:[e,...t]})})})}),[]),{toasts:e}}])},361031,e=>{"use strict";let t=(0,e.i(816709).create)(e=>({workspaces:[],setWorkspaces:t=>e({workspaces:t}),upsertWorkspace:t=>{e(e=>{let a=e.workspaces.findIndex(e=>e.id===t.id);if(-1===a)return{workspaces:[...e.workspaces,t]};let n=[...e.workspaces];return n[a]=t,{workspaces:n}})},removeWorkspace:t=>{e(e=>({workspaces:e.workspaces.filter(e=>e.id!==t)}))}}));e.s(["useWorkspaceStore",0,t])},613087,e=>{"use strict";var t=e.i(344180),a=e.i(465458);e.s(["Skeleton",0,function({className:e,...n}){return(0,t.jsx)("div",{"data-slot":"skeleton",className:(0,a.cn)("animate-pulse rounded-md bg-muted",e),...n})},"SkeletonGroup",0,function({count:e=3,children:a}){return(0,t.jsx)(t.Fragment,{children:Array.from({length:e},(e,n)=>(0,t.jsx)("div",{children:a(n)},n))})}])},210,e=>{"use strict";let t=(0,e.i(433721).default)("settings-2",[["path",{d:"M14 17H5",key:"gfn3mx"}],["path",{d:"M19 7h-9",key:"6i9tg"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]]);e.s(["Settings2",0,t],210)},226651,e=>{"use strict";let t=(0,e.i(433721).default)("ellipsis",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]]);e.s(["default",0,t])},315775,e=>{"use strict";var t=e.i(226651);e.s(["MoreHorizontal",()=>t.default])},601039,e=>{"use strict";let t=(0,e.i(433721).default)("refresh-cw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]);e.s(["RefreshCw",0,t],601039)},357301,e=>{"use strict";let t=(0,e.i(433721).default)("rotate-ccw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]);e.s(["RotateCcw",0,t],357301)},226624,e=>{"use strict";var t,a=e.i(344180);e.s([],916562),e.i(916562),e.i(8890);var n=e.i(764556),s=e.i(535270),r=e.i(29905),i=e.i(204133),o=e.i(277642),l=e.i(236706),d=e.i(863728),c=e.i(969490),u=e.i(370383),m=e.i(139236),p=e.i(931709),f=e.i(267805);let h=n.createContext(void 0);var x=e.i(438904);let g=((t={}).checked="data-checked",t.unchecked="data-unchecked",t.disabled="data-disabled",t.readonly="data-readonly",t.required="data-required",t.valid="data-valid",t.invalid="data-invalid",t.touched="data-touched",t.dirty="data-dirty",t.filled="data-filled",t.focused="data-focused",t),v={...x.fieldValidityMapping,checked:e=>e?{[g.checked]:""}:{[g.unchecked]:""}};var y=e.i(125231),b=e.i(975698),j=e.i(380414),w=e.i(443124),k=e.i(575665),N=e.i(602453),C=e.i(742665),S=e.i(638144);let T=n.forwardRef(function(e,t){let{checked:f,className:x,defaultChecked:g,"aria-labelledby":T,form:M,id:P,inputRef:E,name:D,nativeButton:z=!1,onCheckedChange:F,readOnly:O=!1,required:R=!1,disabled:I=!1,render:A,uncheckedValue:L,value:B,style:$,...H}=e,{clearErrors:U}=(0,j.useFormContext)(),{state:W,setTouched:_,setDirty:V,validityData:J,setFilled:Y,setFocused:q,shouldValidateOnChange:K,validationMode:X,disabled:G,name:Q,validation:Z}=(0,y.useFieldRootContext)(),{labelId:ee}=(0,w.useLabelableContext)(),et=G||I,ea=Q??D,en=(0,r.useStableCallback)(F),es=n.useRef(null),er=(0,i.useMergedRefs)(es,E,Z.inputRef),ei=n.useRef(null),eo=(0,m.useBaseUiId)(),el=(0,k.useLabelableId)({id:P,implicit:!1,controlRef:ei}),ed=z?void 0:el,[ec,eu]=(0,s.useControlled)({controlled:f,default:!!g,name:"Switch",state:"checked"});(0,b.useRegisterFieldControl)(ei,{id:eo,value:ec}),(0,o.useIsoLayoutEffect)(()=>{es.current&&Y(es.current.checked)},[es,Y]),(0,S.useValueChanged)(ec,()=>{U(ea),V(ec!==J.initialValue),Y(ec),K()?Z.commit(ec):Z.commit(ec,!0)});let{getButtonProps:em,buttonRef:ep}=(0,p.useButton)({disabled:et,native:z}),ef=function(e,t,a,s=!0,r){let[i,l]=n.useState(),d=(0,m.useBaseUiId)(r?`${r}-label`:void 0),c=e??t??i;return(0,o.useIsoLayoutEffect)(()=>{let n=e||t||!s?void 0:function(e,t){let a=function(e){if(!e)return;let t=e.parentElement;if(t&&"LABEL"===t.tagName)return t;let a=e.id;if(a){let t=e.nextElementSibling;if(t&&t.htmlFor===a)return t}let n=e.labels;return n&&n[0]}(e);if(a)return!a.id&&t&&(a.id=t),a.id||void 0}(a.current,d);i!==n&&l(n)}),c}(T,ee,es,!z,ed),eh=n.useMemo(()=>(0,u.mergeProps)({checked:ec,disabled:et,form:M,id:ed,name:ea,required:R,style:ea?l.visuallyHiddenInput:l.visuallyHidden,tabIndex:-1,type:"checkbox","aria-hidden":!0,ref:er,onChange(e){if(e.nativeEvent.defaultPrevented)return;if(O)return void e.preventDefault();let t=e.currentTarget.checked,a=(0,N.createChangeEventDetails)(C.REASONS.none,e.nativeEvent);en?.(t,a),a.isCanceled||eu(t)},onFocus(){ei.current?.focus()}},Z.getInputValidationProps,void 0!==B?{value:B}:d.EMPTY_OBJECT),[ec,et,M,er,ed,ea,en,O,R,eu,Z,B]),ex=n.useMemo(()=>({...W,checked:ec,disabled:et,readOnly:O,required:R}),[W,ec,et,O,R]),eg=(0,c.useRenderElement)("span",e,{state:ex,ref:[t,ei,ep],props:[{id:z?el:eo,role:"switch","aria-checked":ec,"aria-readonly":O||void 0,"aria-required":R||void 0,"aria-labelledby":ef,onFocus(){et||q(!0)},onBlur(){let e=es.current;e&&!et&&(_(!0),q(!1),"onBlur"===X&&Z.commit(e.checked))},onClick(e){O||et||(e.preventDefault(),es.current?.dispatchEvent(new PointerEvent("click",{bubbles:!0,shiftKey:e.shiftKey,ctrlKey:e.ctrlKey,altKey:e.altKey,metaKey:e.metaKey})))}},Z.getValidationProps,H,em],stateAttributesMapping:v});return(0,a.jsxs)(h.Provider,{value:ex,children:[eg,!ec&&ea&&void 0!==L&&(0,a.jsx)("input",{type:"hidden",form:M,name:ea,value:L}),(0,a.jsx)("input",{...eh,suppressHydrationWarning:!0})]})}),M=n.forwardRef(function(e,t){let{render:a,className:s,style:r,...i}=e,{state:o}=(0,y.useFieldRootContext)(),l=function(){let e=n.useContext(h);if(void 0===e)throw Error((0,f.default)(63));return e}(),d={...o,...l};return(0,c.useRenderElement)("span",e,{state:d,ref:t,stateAttributesMapping:v,props:i})});e.s(["Root",0,T,"Thumb",0,M],695728);var P=e.i(695728),P=P,E=e.i(465458);e.s(["Switch",0,function({className:e,size:t="default",...n}){return(0,a.jsx)(P.Root,{"data-slot":"switch","data-size":t,className:(0,E.cn)("peer group/switch relative inline-flex shrink-0 items-center rounded-full border border-transparent transition-all outline-none after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-[size=default]:h-[18.4px] data-[size=default]:w-[32px] data-[size=sm]:h-[14px] data-[size=sm]:w-[24px] dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:bg-primary data-unchecked:bg-input dark:data-unchecked:bg-input/80 data-disabled:cursor-not-allowed data-disabled:opacity-50",e),...n,children:(0,a.jsx)(P.Thumb,{"data-slot":"switch-thumb",className:"pointer-events-none block rounded-full bg-background ring-0 transition-transform group-data-[size=default]/switch:size-4 group-data-[size=sm]/switch:size-3 group-data-[size=default]/switch:data-checked:translate-x-[calc(100%-2px)] group-data-[size=sm]/switch:data-checked:translate-x-[calc(100%-2px)] dark:data-checked:bg-primary-foreground group-data-[size=default]/switch:data-unchecked:translate-x-0 group-data-[size=sm]/switch:data-unchecked:translate-x-0 dark:data-unchecked:bg-foreground"})})}],226624)},588591,e=>{"use strict";var t=e.i(344180),a=e.i(764556),n=e.i(244073),s=e.i(355819),r=e.i(209988),i=e.i(260218),o=e.i(917955),l=e.i(465458),d=e.i(767467),c=e.i(325443),u=e.i(650654),m=e.i(953700),p=e.i(601039),f=e.i(357301),h=e.i(511588),x=e.i(282180),g=e.i(611176),v=e.i(562918),y=e.i(226624),b=e.i(159619),j=e.i(137340);function w({agents:e,onSelect:a,onDelete:s,onToggleEnabled:r}){let o=(0,n.useTranslations)("agent");return(0,t.jsxs)("div",{className:"flex flex-col p-2",children:[e.map(e=>{let n="agent-generator"===e.id;return(0,t.jsxs)("div",{className:(0,l.cn)("group flex items-center gap-3 rounded-lg px-3 py-2.5 hover:bg-muted/50 cursor-pointer transition-colors",!e.enabled&&!n&&"opacity-50"),onClick:()=>a(e),children:[(0,t.jsx)(g.AgentIcon,{name:e.name,avatarUrl:e.avatarUrl,apiBase:e.apiBase,className:"size-8"}),(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("span",{className:"text-sm font-medium",children:e.name}),(0,t.jsx)(v.Badge,{variant:"outline",className:"text-[10px] h-4 px-1.5",children:n?"system":e.role}),(0,t.jsx)("span",{className:"text-[10px] text-muted-foreground font-mono",children:e.modelId.split("-").slice(0,2).join("-")})]}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground truncate",children:e.description||o("list.noDescription")})]}),(0,t.jsx)(i.Button,{variant:"ghost",size:"icon-xs",className:"opacity-0 group-hover:opacity-100 transition-opacity",onClick:t=>{t.stopPropagation(),navigator.clipboard.writeText(e.id)},children:(0,t.jsx)(b.Copy,{className:"size-3"})}),!n&&(0,t.jsx)(i.Button,{variant:"ghost",size:"icon-xs",className:"opacity-0 group-hover:opacity-100 transition-opacity",onClick:t=>{t.stopPropagation(),s(e.id)},children:(0,t.jsx)(j.Trash2,{className:"size-3 text-destructive"})}),(0,t.jsx)("div",{onClick:e=>e.stopPropagation(),children:(0,t.jsx)(y.Switch,{size:"sm",checked:n||e.enabled,disabled:n,onCheckedChange:()=>r?.(e.id)})})]},e.id)}),0===e.length&&(0,t.jsxs)("div",{className:"flex flex-col items-center justify-center py-12 text-muted-foreground",children:[(0,t.jsx)(c.Bot,{className:"size-10 mb-2 opacity-30"}),(0,t.jsx)("p",{className:"text-sm",children:o("list.empty")})]})]})}var k=e.i(965322);let N=new Set(["agent-generator","commit-agent"]);e.s(["AgentDialog",0,function({open:e,onOpenChange:g,roleFilter:v,initialAgentId:y,standalone:b,presetBasePath:j="/api/agents/presets",singleAgent:C=!1}){let S=(0,n.useTranslations)("agent"),T=(0,n.useTranslations)("common"),M=(0,a.useRef)(null),[P,E]=(0,a.useState)([]),[D,z]=(0,a.useState)(null),[F,O]=(0,a.useState)(!1),[R,I]=(0,a.useState)(!1),[A,L]=(0,a.useState)(!1),[B,$]=(0,a.useState)(!1),[H,U]=(0,a.useState)(null),W=v?new Set(Array.isArray(v)?v:[v]):null,_=W?P.filter(e=>N.has(e.id)||W.has(e.role)):P,V=W?x.ROLE_OPTIONS.filter(e=>W.has(e)):x.ROLE_OPTIONS;(0,a.useEffect)(()=>{if(!e)return;let t=new AbortController;return queueMicrotask(()=>{I(!0),U(null)}),fetch(j,{signal:t.signal}).then(async e=>{if(!e.ok)throw Error(await e.text());return e.json()}).then(e=>{let t=e.map(x.normalizeAgent);if(E(t),y){let e=t.find(e=>e.id===y);e&&z(e)}else C&&t[0]&&z(t[0])}).catch(e=>{"AbortError"!==e.name&&U(S("error.loadFailed"))}).finally(()=>I(!1)),()=>t.abort()},[e,y,j,C,S]);let J=()=>{z(null),O(!1)},Y=e=>{let t="empty"===e?(0,x.newEmptyAgent)():(0,x.newAgentDraft)(e);U(null),z(t)},q=async e=>{N.has(e)||(E(t=>t.map(t=>t.id===e?{...t,enabled:!t.enabled}:t)),await s.useAgentStore.getState().toggleEnabled(e))},K=async e=>{if(!N.has(e)){if(e.startsWith("draft-"))return void z(null);L(!0),U(null);try{let t=await fetch(`${j}/${e}`,{method:"DELETE"});if(!t.ok)throw Error(await t.text());E(t=>t.filter(t=>t.id!==e)),s.useAgentStore.setState(t=>({agents:t.agents.filter(t=>t.id!==e)})),D?.id===e&&z(null)}catch{U(S("error.deleteFailed"))}finally{L(!1)}}},X=async()=>{$(!0),U(null);try{let e=await fetch(`${j}/sync-workspaces`,{method:"POST"});if(!e.ok)throw Error(await e.text())}catch{U(S("error.syncFailed"))}finally{$(!1)}},G=e=>(0,t.jsxs)(o.DropdownMenu,{children:[(0,t.jsx)(o.DropdownMenuTrigger,{render:(0,t.jsxs)(i.Button,{variant:"outline",size:"sm",disabled:A,children:[(0,t.jsx)(m.Plus,{className:"size-3.5"}),!e&&S("dialog.add"),(0,t.jsx)(u.ChevronDown,{className:"size-3.5"})]})}),(0,t.jsx)(o.DropdownMenuContent,{side:"bottom",align:"end",className:"w-44",children:(0,t.jsxs)(o.DropdownMenuGroup,{children:[!W&&(0,t.jsxs)(o.DropdownMenuItem,{className:"gap-2",onClick:()=>Y("empty"),children:[(0,t.jsx)("span",{className:"size-2 rounded-full bg-muted"}),(0,t.jsx)("span",{children:S("dialog.addEmpty")})]}),x.ROLE_OPTIONS.map(e=>(0,t.jsxs)(o.DropdownMenuItem,{className:"gap-2",onClick:()=>Y(e),children:[(0,t.jsx)("span",{className:(0,l.cn)("size-2 rounded-full",x.ROLE_COLORS[e].split(" ")[0])}),(0,t.jsx)("span",{className:"capitalize",children:S(`role.${e}.name`)})]},e))]})})]}),Q=(0,t.jsxs)(t.Fragment,{children:[!b&&(0,t.jsxs)("div",{className:"flex items-center gap-3 border-b px-5 pr-12 py-4",children:[D?(0,t.jsx)(i.Button,{variant:"ghost",size:"icon-sm",onClick:C?()=>g(!1):J,children:(0,t.jsx)(d.ArrowLeft,{className:"size-4"})}):(0,t.jsx)("div",{className:"flex size-7 items-center justify-center rounded-lg bg-primary/10",children:(0,t.jsx)(c.Bot,{className:"size-4 text-primary"})}),(0,t.jsxs)(r.DialogHeader,{className:"flex-1 space-y-0",children:[(0,t.jsx)(r.DialogTitle,{className:"text-base",children:D?D.name:S("dialog.title")}),(0,t.jsx)(r.DialogDescription,{className:"text-xs",children:D?S("dialog.editDescription"):S("dialog.listDescription")})]}),D&&N.has(D.id)&&(0,t.jsxs)(i.Button,{variant:"outline",size:"sm",disabled:A,onClick:()=>M.current?.reset(),children:[(0,t.jsx)(f.RotateCcw,{className:"size-3.5"}),T("reset")]}),D&&(0,t.jsxs)(i.Button,{variant:"outline",size:"sm",onClick:()=>M.current?.openGenerate(),children:[(0,t.jsx)(h.WandSparkles,{className:"size-3.5"}),"智能创建"]}),!D&&!C&&(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsxs)(i.Button,{variant:"outline",size:"sm",onClick:X,disabled:B,children:[(0,t.jsx)(p.RefreshCw,{className:(0,l.cn)("size-3.5",B&&"animate-spin")}),S("dialog.syncTemplates")]}),(0,t.jsxs)(i.Button,{variant:"outline",size:"sm",onClick:()=>{let e=V[0]?(0,x.newAgentDraft)(V[0]):(0,x.newEmptyAgent)();U(null),z(e),O(!0)},children:[(0,t.jsx)(h.WandSparkles,{className:"size-3.5"}),"智能创建"]}),G()]})]}),b&&!D&&!C&&(0,t.jsxs)("div",{className:"flex items-center justify-end gap-2 px-5 py-3 border-b",children:[(0,t.jsxs)(i.Button,{variant:"outline",size:"sm",onClick:X,disabled:B,children:[(0,t.jsx)(p.RefreshCw,{className:(0,l.cn)("size-3.5",B&&"animate-spin")}),S("dialog.syncTemplates")]}),(0,t.jsxs)(i.Button,{variant:"outline",size:"sm",onClick:()=>{let e=V[0]?(0,x.newAgentDraft)(V[0]):(0,x.newEmptyAgent)();U(null),z(e),O(!0)},children:[(0,t.jsx)(h.WandSparkles,{className:"size-3.5"}),"智能创建"]}),G()]}),b&&D&&(0,t.jsxs)("div",{className:"flex items-center gap-3 px-5 py-3 border-b",children:[(0,t.jsx)(i.Button,{variant:"ghost",size:"icon-sm",onClick:C?()=>g(!1):J,children:(0,t.jsx)(d.ArrowLeft,{className:"size-4"})}),(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsx)("h2",{className:"text-base font-medium truncate",children:D.name}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:S("dialog.editDescription")})]}),N.has(D.id)&&(0,t.jsxs)(i.Button,{variant:"outline",size:"sm",disabled:A,onClick:()=>M.current?.reset(),children:[(0,t.jsx)(f.RotateCcw,{className:"size-3.5"}),T("reset")]}),(0,t.jsxs)(i.Button,{variant:"outline",size:"sm",onClick:()=>M.current?.openGenerate(),children:[(0,t.jsx)(h.WandSparkles,{className:"size-3.5"}),"智能创建"]})]}),H&&!D&&(0,t.jsx)("div",{className:"mx-5 mt-4 rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-xs text-destructive",children:H}),R?(0,t.jsx)("div",{className:"flex-1 flex flex-col p-2 space-y-1",children:Array.from({length:5},(e,a)=>(0,t.jsxs)("div",{className:"flex items-center gap-3 rounded-lg px-3 py-2.5",children:[(0,t.jsx)("div",{className:"size-8 rounded-full bg-muted animate-pulse"}),(0,t.jsxs)("div",{className:"flex-1 min-w-0 space-y-1.5",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("div",{className:"h-4 w-20 rounded bg-muted animate-pulse"}),(0,t.jsx)("div",{className:"h-4 w-10 rounded-full bg-muted animate-pulse"})]}),(0,t.jsx)("div",{className:"h-3 w-32 rounded bg-muted animate-pulse"})]}),(0,t.jsx)("div",{className:"h-3 w-12 rounded bg-muted animate-pulse"})]},a))}):D?(0,t.jsx)(k.AgentEditor,{ref:M,agent:D,roleOptions:V,onSaved:e=>{(E(t=>t.some(t=>t.id===e.id)?t.map(t=>t.id===e.id?e:t):[...t,e]),C)?g(!1):(z(null),O(!1))},onBack:C?()=>g(!1):J,showFooter:!0,autoOpenGenerate:F,presetBasePath:j}):(0,t.jsx)("div",{className:"flex-1 overflow-y-auto",children:(0,t.jsx)(w,{agents:_,onSelect:e=>{z(e)},onDelete:K,onToggleEnabled:q})})]});return b?(0,t.jsx)("div",{className:"h-full flex flex-col",children:Q}):(0,t.jsx)(r.Dialog,{open:e,onOpenChange:e=>{e||C||J(),g(e)},children:(0,t.jsx)(r.DialogContent,{className:"sm:max-w-2xl max-h-[85vh] flex flex-col p-0 gap-0",children:Q})})}],588591)},691223,e=>{"use strict";var t=e.i(816709);let a=new Set([".png",".jpg",".jpeg",".gif",".webp",".bmp",".ico"]),n=new Set([".mp4",".webm",".ogg",".mov"]),s=new Set([".mp3",".wav",".flac",".aac",".m4a",".opus"]),r=new Set([".svg"]),i=new Set([".md",".mdx"]);function o(e){let t="."+e.split(".").pop()?.toLowerCase();return a.has(t)?"image":n.has(t)?"video":s.has(t)?"audio":r.has(t)?"svg":i.has(t)?"markdown":null}let l="__commit_diff__:";function d(e){return e.startsWith(l)}function c(e){return e.slice(l.length)}let u=null;function m(){u&&(clearTimeout(u),u=null)}function p(e){m(),u=setTimeout(()=>{u=null,h.getState().saveEditorState(e)},500)}function f(e){return e.replace(/\r\n?/g,"\n")}let h=(0,t.create)((e,t)=>({tree:[],treeLoading:!1,loadingDirs:new Set,openFiles:[],modifiedFileContents:{},activeFilePath:null,pendingJump:null,revealPath:null,commitDiffs:{},loadTree:async t=>{e({treeLoading:!0});try{let a=await fetch(`/api/workspaces/${t}/files/tree?depth=1`),n=await a.json();e({tree:n,treeLoading:!1})}catch{e({treeLoading:!1})}},loadDirectory:async(a,n)=>{let{tree:s,loadingDirs:r}=t(),i=e=>{for(let t of e){if(t.path===n)return t;if(t.children){let e=i(t.children);if(e)return e}}};if(i(s)?.children!==void 0||r.has(n))return;let o=new Set(r);o.add(n),e({loadingDirs:o});try{let s=await fetch(`/api/workspaces/${a}/files/tree?path=${encodeURIComponent(n)}&depth=1`),r=await s.json(),i=e=>e.map(e=>e.path===n?{...e,children:r}:e.children?{...e,children:i(e.children)}:e),o=new Set(t().loadingDirs);o.delete(n),e({tree:i(t().tree),loadingDirs:o})}catch{let a=new Set(t().loadingDirs);a.delete(n),e({loadingDirs:a})}},openFile:async(a,n)=>{if(t().openFiles.find(e=>e.path===n)){e({activeFilePath:n}),p(a);return}let s=n.split("/").pop()||n,r=o(n);if(r&&"svg"!==r&&"markdown"!==r){e(e=>({openFiles:[...e.openFiles,{path:n,name:s,content:"",modified:!1,mediaType:r}],activeFilePath:n})),p(a);return}let i=await fetch(`/api/workspaces/${a}/files/content?path=${encodeURIComponent(n)}`),l=await i.json();e(e=>({openFiles:[...e.openFiles,{path:n,name:s,content:l.content,modified:!1,mediaType:r||void 0}],activeFilePath:n})),p(a)},saveFile:async(a,n)=>{let s=t().openFiles.find(e=>e.path===n);if(!s)return;let r=t().modifiedFileContents[n]??s.content;await fetch(`/api/workspaces/${a}/files/content`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:n,content:r})}),e(e=>({openFiles:e.openFiles.map(e=>e.path===n?{...e,content:r,modified:!1}:e),modifiedFileContents:Object.fromEntries(Object.entries(e.modifiedFileContents).filter(([e])=>e!==n))}))},updateContent:(t,a)=>{e(e=>({openFiles:e.openFiles.map(e=>e.path!==t?e:{...e,modified:f(e.content)!==f(a)}),modifiedFileContents:(()=>{let n=e.openFiles.find(e=>e.path===t);if(!n)return e.modifiedFileContents;let s={...e.modifiedFileContents};return f(n.content)===f(a)?delete s[t]:s[t]=a,s})()}))},refreshFile:async(a,n)=>{let s=t().openFiles.find(e=>e.path===n);if(s&&!s.modified)try{let t=await fetch(`/api/workspaces/${a}/files/content?path=${encodeURIComponent(n)}`),r=await t.json();r.content!==s.content&&e(e=>({openFiles:e.openFiles.map(e=>e.path===n?{...e,content:r.content}:e)}))}catch{}},closeFile:(t,a)=>{e(e=>{let t=e.openFiles.filter(e=>e.path!==a),n=e.activeFilePath===a?t.length>0?t[t.length-1].path:null:e.activeFilePath,s={...e.commitDiffs};d(a)&&delete s[c(a)];let r={...e.modifiedFileContents};return delete r[a],{openFiles:t,activeFilePath:n,commitDiffs:s,modifiedFileContents:r}}),p(t)},setActiveFile:(t,a)=>{e({activeFilePath:a}),p(t)},jumpToPosition:async(a,n,s,r,i,o)=>{await t().openFile(a,n),e({pendingJump:{path:n,line:s,column:r,endLine:i,endColumn:o}})},clearPendingJump:()=>e({pendingJump:null}),setRevealPath:t=>e({revealPath:t}),clearRevealPath:()=>e({revealPath:null}),resetEditorState:()=>{m(),e({tree:[],treeLoading:!1,loadingDirs:new Set,openFiles:[],modifiedFileContents:{},activeFilePath:null,pendingJump:null,revealPath:null,commitDiffs:{}})},loadEditorState:async a=>{t().resetEditorState();try{let t=await fetch(`/api/workspaces/${a}/files/editor-state`),{openFilePaths:n=[],activeFilePath:s=null,pinnedPaths:r=[]}=await t.json();if(0===n.length)return void e({openFiles:[],activeFilePath:null,modifiedFileContents:{}});let i=new Set(r),l=[];for(let e of n)try{let t=e.split("/").pop()||e,n=o(e);if(n&&"svg"!==n&&"markdown"!==n)l.push({path:e,name:t,content:"",modified:!1,mediaType:n,pinned:i.has(e)||void 0});else{let s=await fetch(`/api/workspaces/${a}/files/content?path=${encodeURIComponent(e)}`),r=await s.json();l.push({path:e,name:t,content:r.content,modified:!1,mediaType:n||void 0,pinned:i.has(e)||void 0})}}catch{}let d=s&&l.find(e=>e.path===s)?s:l.length>0?l[l.length-1].path:null;e({openFiles:l,activeFilePath:d,commitDiffs:{},modifiedFileContents:{}})}catch{e({openFiles:[],activeFilePath:null,commitDiffs:{},modifiedFileContents:{}})}},saveEditorState:async e=>{let{openFiles:a,activeFilePath:n}=t(),s=a.filter(e=>!d(e.path)),r=n&&!d(n)?n:null,i=s.filter(e=>e.pinned).map(e=>e.path);try{await fetch(`/api/workspaces/${e}/files/editor-state`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({openFilePaths:s.map(e=>e.path),activeFilePath:r,pinnedPaths:i})})}catch{}},openCommitDiff:(t,a,n,s)=>{let r=l+a;e(e=>e.openFiles.find(e=>e.path===r)?{activeFilePath:r,commitDiffs:{...e.commitDiffs,[a]:{diffs:s,message:n}}}:{openFiles:[...e.openFiles,{path:r,name:a.slice(0,7),content:"",modified:!1}],activeFilePath:r,commitDiffs:{...e.commitDiffs,[a]:{diffs:s,message:n}}})},closeCommitDiff:(e,a)=>{let n=l+a;t().closeFile(e,n)},togglePin:(t,a)=>{e(e=>{let t=e.openFiles.map(e=>e.path===a?{...e,pinned:!e.pinned}:e);return{openFiles:[...t.filter(e=>e.pinned),...t.filter(e=>!e.pinned)]}}),p(t)},reorderFiles:(t,a)=>{e({openFiles:a}),p(t)},closeOthers:(t,a)=>{e(e=>{let t=e.openFiles.filter(e=>e.path===a||e.pinned),n=new Set(t.map(e=>e.path)),s=Object.fromEntries(Object.entries(e.modifiedFileContents).filter(([e])=>n.has(e)));return{openFiles:t,activeFilePath:t.some(t=>t.path===e.activeFilePath)?e.activeFilePath:a,modifiedFileContents:s}}),p(t)},closeToLeft:(t,a)=>{e(e=>{let t=e.openFiles.findIndex(e=>e.path===a);if(t<=0)return e;let n=e.openFiles.filter((e,a)=>a>=t||e.pinned),s=new Set(n.map(e=>e.path)),r=Object.fromEntries(Object.entries(e.modifiedFileContents).filter(([e])=>s.has(e)));return{openFiles:n,activeFilePath:n.some(t=>t.path===e.activeFilePath)?e.activeFilePath:a,modifiedFileContents:r}}),p(t)},closeToRight:(t,a)=>{e(e=>{let t=e.openFiles.findIndex(e=>e.path===a);if(t<0||t>=e.openFiles.length-1)return e;let n=e.openFiles.filter((e,a)=>a<=t||e.pinned),s=new Set(n.map(e=>e.path)),r=Object.fromEntries(Object.entries(e.modifiedFileContents).filter(([e])=>s.has(e)));return{openFiles:n,activeFilePath:n.some(t=>t.path===e.activeFilePath)?e.activeFilePath:a,modifiedFileContents:r}}),p(t)}}));e.s(["getCommitHashFromPath",0,c,"getMediaType",0,o,"isCommitDiffPath",0,d,"useEditorStore",0,h])},381253,e=>{"use strict";let t=(0,e.i(433721).default)("file-code",[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 12.5 8 15l2 2.5",key:"1tg20x"}],["path",{d:"m14 12.5 2 2.5-2 2.5",key:"yinavb"}]]);e.s(["FileCode",0,t],381253)},799543,(e,t,a)=>{t.exports=e.r(233331)},767467,e=>{"use strict";let t=(0,e.i(433721).default)("arrow-left",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);e.s(["ArrowLeft",0,t],767467)},459250,e=>{"use strict";var t=e.i(764556);let a=t.createContext({register:()=>{},unregister:()=>{},subscribeMapChange:()=>()=>{},elementsRef:{current:[]},nextIndexRef:{current:0}});e.s(["CompositeListContext",0,a,"useCompositeListContext",0,function(){return t.useContext(a)}])},296615,e=>{"use strict";var t,a=e.i(764556),n=e.i(277642),s=e.i(459250);let r=((t={})[t.None=0]="None",t[t.GuessFromOrder=1]="GuessFromOrder",t);e.s(["useCompositeListItem",0,function(e={}){let{label:t,metadata:i,textRef:o,indexGuessBehavior:l,index:d}=e,{register:c,unregister:u,subscribeMapChange:m,elementsRef:p,labelsRef:f,nextIndexRef:h}=(0,s.useCompositeListContext)(),x=a.useRef(-1),[g,v]=a.useState(d??(l===r.GuessFromOrder?()=>{if(-1===x.current){let e=h.current;h.current+=1,x.current=e}return x.current}:-1)),y=a.useRef(null),b=a.useCallback(e=>{if(y.current=e,-1!==g&&null!==e&&(p.current[g]=e,f)){let a=void 0!==t;f.current[g]=a?t:o?.current?.textContent??e.textContent}},[g,p,f,t,o]);return(0,n.useIsoLayoutEffect)(()=>{if(null!=d)return;let e=y.current;if(e)return c(e,i),()=>{u(e)}},[d,c,u,i]),(0,n.useIsoLayoutEffect)(()=>{if(null==d)return m(e=>{let t=y.current?e.get(y.current)?.index:null;null!=t&&v(t)})},[d,m,v]),a.useMemo(()=>({ref:b,index:g}),[g,b])}])},756432,e=>{"use strict";var t=e.i(764556),a=e.i(549154),n=e.i(29905),s=e.i(277642),r=e.i(459250),i=e.i(344180);function o(){return new Map}function l(){return new Set}function d(e,t){let a=e.compareDocumentPosition(t);return a&Node.DOCUMENT_POSITION_FOLLOWING||a&Node.DOCUMENT_POSITION_CONTAINED_BY?-1:a&Node.DOCUMENT_POSITION_PRECEDING||a&Node.DOCUMENT_POSITION_CONTAINS?1:0}e.s(["CompositeList",0,function(e){let{children:c,elementsRef:u,labelsRef:m,onMapChange:p}=e,f=(0,n.useStableCallback)(p),h=t.useRef(0),x=(0,a.useRefWithInit)(l).current,g=(0,a.useRefWithInit)(o).current,[v,y]=t.useState(0),b=t.useRef(v),j=(0,n.useStableCallback)((e,t)=>{g.set(e,t??null),b.current+=1,y(b.current)}),w=(0,n.useStableCallback)(e=>{g.delete(e),b.current+=1,y(b.current)}),k=t.useMemo(()=>{let e=new Map;return Array.from(g.keys()).filter(e=>e.isConnected).sort(d).forEach((t,a)=>{let n=g.get(t)??{};e.set(t,{...n,index:a})}),e},[g,v]);(0,s.useIsoLayoutEffect)(()=>{if("function"!=typeof MutationObserver||0===k.size)return;let e=new MutationObserver(e=>{let t=new Set,a=e=>t.has(e)?t.delete(e):t.add(e);e.forEach(e=>{e.removedNodes.forEach(a),e.addedNodes.forEach(a)}),0===t.size&&(b.current+=1,y(b.current))});return k.forEach((t,a)=>{a.parentElement&&e.observe(a.parentElement,{childList:!0})}),()=>{e.disconnect()}},[k]),(0,s.useIsoLayoutEffect)(()=>{b.current===v&&(u.current.length!==k.size&&(u.current.length=k.size),m&&m.current.length!==k.size&&(m.current.length=k.size),h.current=k.size),f(k)},[f,k,u,m,v]),(0,s.useIsoLayoutEffect)(()=>()=>{u.current=[]},[u]),(0,s.useIsoLayoutEffect)(()=>()=>{m&&(m.current=[])},[m]);let N=(0,n.useStableCallback)(e=>(x.add(e),()=>{x.delete(e)}));(0,s.useIsoLayoutEffect)(()=>{x.forEach(e=>e(k))},[x,k]);let C=t.useMemo(()=>({register:j,unregister:w,subscribeMapChange:N,elementsRef:u,labelsRef:m,nextIndexRef:h}),[j,w,N,u,m,h]);return(0,i.jsx)(r.CompositeListContext.Provider,{value:C,children:c})}])},530909,e=>{"use strict";var t=e.i(764556),a=e.i(204133),n=e.i(352360),s=e.i(296615);e.s(["useCompositeItem",0,function(e={}){let{highlightItemOnHover:r,highlightedIndex:i,onHighlightedIndexChange:o}=(0,n.useCompositeRootContext)(),{ref:l,index:d}=(0,s.useCompositeListItem)(e),c=i===d,u=t.useRef(null),m=(0,a.useMergedRefs)(l,u);return{compositeProps:t.useMemo(()=>({tabIndex:c?0:-1,onFocus(){o(d)},onMouseMove(){let e=u.current;if(!r||!e)return;let t=e.hasAttribute("disabled")||"true"===e.ariaDisabled;c||t||e.focus()}}),[c,o,d,r]),compositeRef:m,index:d}}])},523592,e=>{"use strict";var t=e.i(8890);let a="agent-spaces-servers",n="agent-spaces-active-server",s="active-server";function r(){let e=t.default.env.NEXT_PUBLIC_SERVER_URL?.trim();if(e)return e.replace(/\/$/,"");let{hostname:a,port:n}=window.location;return("localhost"===a||"127.0.0.1"===a)&&"3000"===n?`http://${a}:3100`:window.location.origin}let i=[{id:"default",name:"Default",url:r()}];function o(){try{let e=localStorage.getItem(a);return e?JSON.parse(e).map(e=>"default"!==e.id||e.url?e:{...e,url:r()}):i}catch{return i}}function l(){return localStorage.getItem(n)||"default"}function d(){let e=o(),t=l();return e.find(e=>e.id===t)||e[0]||null}function c(){return d()?.url??null}e.s(["getActiveServer",0,d,"getActiveServerUrl",0,c,"loadActiveId",0,l,"loadServers",0,o,"resolveServerAssetUrl",0,function(e){if(!e)return"";if(/^(?:[a-z][a-z\d+\-.]*:)?\/\//i.test(e)||e.startsWith("data:")||e.startsWith("blob:"))return e;let t=c();return t?`${t.replace(/\/$/,"")}${e.startsWith("/")?"":"/"}${e}`:e},"saveActiveId",0,function(e){localStorage.setItem(n,e)},"saveServers",0,function(e){localStorage.setItem(a,JSON.stringify(e))},"setActiveServerCookie",0,function(e){e?document.cookie=`${s}=${encodeURIComponent(e)}; path=/; max-age=31536000; SameSite=Lax`:document.cookie=`${s}=; path=/; max-age=0`}])},50153,e=>{"use strict";let t=(0,e.i(433721).default)("check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);e.s(["default",0,t])},971109,e=>{"use strict";var t=e.i(267805),a=e.i(764556);let n=a.createContext(void 0);e.s(["useToolbarRootContext",0,function(e){let s=a.useContext(n);if(void 0===s&&!e)throw Error((0,t.default)(69));return s}])},122702,e=>{"use strict";var t=e.i(863728),a=e.i(969490),n=e.i(530909);e.s(["CompositeItem",0,function(e){let{render:s,className:r,style:i,state:o=t.EMPTY_OBJECT,props:l=t.EMPTY_ARRAY,refs:d=t.EMPTY_ARRAY,metadata:c,stateAttributesMapping:u,tag:m="div",...p}=e,{compositeProps:f,compositeRef:h}=(0,n.useCompositeItem)({metadata:c});return(0,a.useRenderElement)(m,e,{state:o,ref:[...d,h],props:[f,...l,p],stateAttributesMapping:u})}])},730774,e=>{"use strict";var t=e.i(641645),a=e.i(92615);e.s(["getCssDimensions",0,function(e){let n=(0,a.getComputedStyle)(e),s=parseFloat(n.width)||0,r=parseFloat(n.height)||0,i=(0,a.isHTMLElement)(e),o=i?e.offsetWidth:s,l=i?e.offsetHeight:r;return((0,t.round)(s)!==o||(0,t.round)(r)!==l)&&(s=o,r=l),{width:s,height:r}}])},972846,e=>{"use strict";var t=e.i(912248);e.s(["X",()=>t.default])},917955,e=>{"use strict";var t=e.i(344180),a=e.i(648224),n=e.i(465458);e.i(932031),e.i(299648),e.s(["DropdownMenu",0,function({...e}){return(0,t.jsx)(a.Menu.Root,{"data-slot":"dropdown-menu",...e})},"DropdownMenuContent",0,function({align:e="start",alignOffset:s=0,side:r="bottom",sideOffset:i=4,className:o,...l}){return(0,t.jsx)(a.Menu.Portal,{children:(0,t.jsx)(a.Menu.Positioner,{className:"isolate z-50 outline-none",align:e,alignOffset:s,side:r,sideOffset:i,children:(0,t.jsx)(a.Menu.Popup,{"data-slot":"dropdown-menu-content",className:(0,n.cn)("z-50 max-h-(--available-height) w-(--anchor-width) min-w-32 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover p-1 text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 outline-none data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:overflow-hidden data-closed:fade-out-0 data-closed:zoom-out-95",o),...l})})})},"DropdownMenuGroup",0,function({...e}){return(0,t.jsx)(a.Menu.Group,{"data-slot":"dropdown-menu-group",...e})},"DropdownMenuItem",0,function({className:e,inset:s,variant:r="default",...i}){return(0,t.jsx)(a.Menu.Item,{"data-slot":"dropdown-menu-item","data-inset":s,"data-variant":r,className:(0,n.cn)("group/dropdown-menu-item relative flex cursor-default items-center gap-1.5 rounded-md px-1.5 py-1 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-inset:pl-7 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 data-[variant=destructive]:*:[svg]:text-destructive",e),...i})},"DropdownMenuLabel",0,function({className:e,inset:s,...r}){return(0,t.jsx)(a.Menu.GroupLabel,{"data-slot":"dropdown-menu-label","data-inset":s,className:(0,n.cn)("px-1.5 py-1 text-xs font-medium text-muted-foreground data-inset:pl-7",e),...r})},"DropdownMenuSeparator",0,function({className:e,...s}){return(0,t.jsx)(a.Menu.Separator,{"data-slot":"dropdown-menu-separator",className:(0,n.cn)("-mx-1 my-1 h-px bg-border",e),...s})},"DropdownMenuShortcut",0,function({className:e,...a}){return(0,t.jsx)("span",{"data-slot":"dropdown-menu-shortcut",className:(0,n.cn)("ml-auto text-xs tracking-widest text-muted-foreground group-focus/dropdown-menu-item:text-accent-foreground",e),...a})},"DropdownMenuTrigger",0,function({...e}){return(0,t.jsx)(a.Menu.Trigger,{"data-slot":"dropdown-menu-trigger",...e})}])},129981,e=>{"use strict";let t=(0,e.i(433721).default)("upload",[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]]);e.s(["Upload",0,t],129981)},750012,e=>{"use strict";let t=(0,e.i(433721).default)("search",[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]);e.s(["default",0,t])},887354,e=>{"use strict";var t=e.i(750012);e.s(["Search",()=>t.default])},905724,e=>{"use strict";let t=(0,e.i(433721).default)("file-text",[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]);e.s(["default",0,t])},989484,e=>{"use strict";var t=e.i(905724);e.s(["FileText",()=>t.default])},916950,e=>{"use strict";let t="agent-spaces:store-api-base";function a(){return localStorage.getItem(t)||""}async function n(e){let t=a(),n=t?`${t.replace(/\/+$/,"")}/${e.replace(/^\/+/,"")}`:`/agents-store/${e}`,s=await fetch(n);if(!s.ok)throw Error(`fetch ${n} failed: ${s.status}`);return s.json()}e.s(["fetchStoreIndex",0,n,"getStoreApiBase",0,a,"setStoreApiBase",0,function(e){e?localStorage.setItem(t,e):localStorage.removeItem(t)}])},513501,e=>{"use strict";let t=(0,e.i(433721).default)("store",[["path",{d:"M15 21v-5a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v5",key:"slp6dd"}],["path",{d:"M17.774 10.31a1.12 1.12 0 0 0-1.549 0 2.5 2.5 0 0 1-3.451 0 1.12 1.12 0 0 0-1.548 0 2.5 2.5 0 0 1-3.452 0 1.12 1.12 0 0 0-1.549 0 2.5 2.5 0 0 1-3.77-3.248l2.889-4.184A2 2 0 0 1 7 2h10a2 2 0 0 1 1.653.873l2.895 4.192a2.5 2.5 0 0 1-3.774 3.244",key:"o0xfot"}],["path",{d:"M4 10.95V19a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8.05",key:"wn3emo"}]]);e.s(["Store",0,t],513501)},938306,e=>{"use strict";let t=(0,e.i(433721).default)("message-circle",[["path",{d:"M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719",key:"1sd12s"}]]);e.s(["MessageCircle",0,t],938306)},592039,e=>{"use strict";let t=(0,e.i(433721).default)("circle-dot",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]]);e.s(["CircleDot",0,t],592039)},327962,e=>{"use strict";let t=(0,e.i(433721).default)("git-branch",[["path",{d:"M15 6a9 9 0 0 0-9 9V3",key:"1cii5b"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}]]);e.s(["GitBranch",0,t],327962)},964970,e=>{"use strict";var t=e.i(344180),a=e.i(764556),n=e.i(244073),s=e.i(260218),r=e.i(681622),i=e.i(817854),o=e.i(360112),l=e.i(437122);e.s(["GitSettingsForm",0,function({scope:e,workspaceId:d}){let c=(0,n.useTranslations)("git.settings"),u=(0,n.useTranslations)("common"),[m,p]=(0,a.useState)(""),[f,h]=(0,a.useState)(""),[x,g]=(0,a.useState)(""),[v,y]=(0,a.useState)(""),[b,j]=(0,a.useState)(!0),[w,k]=(0,a.useState)(!1),N=(0,a.useCallback)(async()=>{j(!0);try{let t="global"===e?"/api/git-config":`/api/workspaces/${d}/git/config`,a=await fetch(t,{headers:(0,l.authHeaders)()});if(a.ok){let e=await a.json();p(e.name??""),h(e.email??""),g(e.proxy??"")}if("local"===e&&d){let e=await fetch(`/api/workspaces/${d}/git/remote-url`,{headers:(0,l.authHeaders)()});if(e.ok){let t=await e.json();y(t.url??"")}}}catch{}j(!1)},[e,d]);(0,a.useEffect)(()=>{N()},[e,d,N]);let C=async()=>{k(!0);try{let t="global"===e?"/api/git-config":`/api/workspaces/${d}/git/config`;if(!(await fetch(t,{method:"POST",headers:{"Content-Type":"application/json",...(0,l.authHeaders)()},body:JSON.stringify({name:m,email:f,proxy:x})})).ok){o.toast.error(c("saveFailed")),k(!1);return}"local"===e&&d&&v&&await fetch(`/api/workspaces/${d}/git/remotes`,{method:"POST",headers:{"Content-Type":"application/json",...(0,l.authHeaders)()},body:JSON.stringify({name:"origin",url:v})}),o.toast.success(c("saved"))}catch{o.toast.error(c("saveFailed"))}k(!1)};return b?(0,t.jsx)("div",{className:"text-xs text-muted-foreground",children:c("loading")}):(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:"global"===e?c("globalScopeDescription"):c("localScopeDescription")}),(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)(i.Label,{className:"text-xs text-muted-foreground",children:c("name")}),(0,t.jsx)(r.Input,{className:"h-7 text-xs",value:m,onChange:e=>p(e.target.value),placeholder:c("namePlaceholder")})]}),(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)(i.Label,{className:"text-xs text-muted-foreground",children:c("email")}),(0,t.jsx)(r.Input,{className:"h-7 text-xs",value:f,onChange:e=>h(e.target.value),placeholder:c("emailPlaceholder")})]}),(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)(i.Label,{className:"text-xs text-muted-foreground",children:c("proxy")}),(0,t.jsx)(r.Input,{className:"h-7 text-xs",value:x,onChange:e=>g(e.target.value),placeholder:c("proxyPlaceholder")})]}),"local"===e&&(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)(i.Label,{className:"text-xs text-muted-foreground",children:c("remoteUrl")}),(0,t.jsx)(r.Input,{className:"h-7 text-xs",value:v,onChange:e=>y(e.target.value),placeholder:c("remoteUrlPlaceholder")})]}),(0,t.jsx)(s.Button,{size:"sm",className:"text-xs",onClick:C,disabled:w,children:u(w?"loading":"save")})]})}])},506037,e=>{"use strict";var t=e.i(816709),a=e.i(437122);let n=(0,t.create)((e,t)=>({notifications:[],loaded:!1,load:async t=>{try{let n=await (0,a.fetchWithAuth)(`/api/workspaces/${t}/notifications`),s=await n.json();e({notifications:s,loaded:!0})}catch{e({loaded:!0})}},addNotification:t=>{e(e=>({notifications:[t,...e.notifications]}))},clearAll:async t=>{await (0,a.fetchWithAuth)(`/api/workspaces/${t}/notifications`,{method:"DELETE"}),e({notifications:[]})},markRead:async(t,n)=>{await (0,a.fetchWithAuth)(`/api/workspaces/${t}/notifications/${n}/read`,{method:"PUT"}),e(e=>({notifications:e.notifications.map(e=>e.id===n?{...e,read:!0}:e)}))},markAllRead:async t=>{await (0,a.fetchWithAuth)(`/api/workspaces/${t}/notifications/read-all`,{method:"PUT"}),e(e=>({notifications:e.notifications.map(e=>({...e,read:!0}))}))},reset:()=>e({notifications:[],loaded:!1})}));e.s(["useNotificationStore",0,n])},939760,e=>{"use strict";let t=(0,e.i(433721).default)("settings",[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);e.s(["Settings",0,t],939760)},651850,e=>{"use strict";let t=(0,e.i(433721).default)("panel-left",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]]);e.s(["default",0,t])},417092,e=>{"use strict";var t=e.i(344180),a=e.i(764556);function n(e,t){try{localStorage.setItem(e,JSON.stringify(t))}catch{}}let s=(0,a.forwardRef)(function({size:e=44,lsKey:s,onClick:r,children:i,className:o,style:l,visible:d=!0,snapThreshold:c=60,minimizeDelay:u=2e3,unhoverDelay:m=2e3,defaultPosition:p},f){let h=(0,a.useRef)({x:0,y:0}),[x,g]=(0,a.useState)({x:0,y:0}),[v,y]=(0,a.useState)(!1),[b,j]=(0,a.useState)(!1),w=(0,a.useRef)(!1),k=(0,a.useRef)({x:0,y:0}),N=(0,a.useRef)(!1),C=(0,a.useRef)(void 0),S=(0,a.useRef)(void 0),T=(0,a.useRef)("right"),M=(0,a.useRef)(null),P=e/2;(0,a.useEffect)(()=>{let t=function(e){try{let t=localStorage.getItem(e);return t?JSON.parse(t):null}catch{return null}}(s),a={x:p?.x??window.innerWidth-e-20,y:p?.y??window.innerHeight-e-28},n=t?{x:Math.min(t.x,window.innerWidth-e),y:Math.min(t.y,window.innerHeight-e)}:a;h.current=n,g(n),y(!0)},[s,e,p]);let E=(0,a.useCallback)(e=>{j(!0),h.current={x:"left"===e?-P:window.innerWidth-P,y:h.current.y},g(h.current)},[P]),D=(0,a.useCallback)(()=>{clearTimeout(C.current),C.current=void 0,clearTimeout(S.current),S.current=void 0},[]),z=(0,a.useCallback)(()=>{D(),j(!1);let t=window.innerWidth,a={x:h.current.x<t/2?12:t-e-12,y:h.current.y};h.current=a,g(a),n(s,a)},[D,e,s]),F=(0,a.useCallback)(()=>{b&&z(),clearTimeout(S.current),S.current=void 0},[b,z]),O=(0,a.useCallback)(()=>{M.current&&(S.current=setTimeout(()=>E(T.current),m))},[E,m]),R=(0,a.useCallback)(e=>{w.current=!0,N.current=!1,M.current=null,D(),b&&z(),k.current={x:e.clientX-h.current.x,y:e.clientY-h.current.y},e.target.setPointerCapture(e.pointerId)},[D,b,z]),I=(0,a.useCallback)(t=>{if(!w.current)return;N.current=!0;let a=Math.max(0,Math.min(window.innerWidth-e,t.clientX-k.current.x)),n=Math.max(0,Math.min(window.innerHeight-e,t.clientY-k.current.y));h.current={x:a,y:n},g({x:a,y:n})},[e]),A=(0,a.useCallback)(()=>{w.current=!1;let{x:t,y:a}=h.current,i=window.innerWidth,o=t<c,l=t>i-e-c,d=Math.max(12,Math.min(window.innerHeight-e-12,a));if(o||l){let t=o?"left":"right";T.current=t,M.current=t;let a={x:o?12:i-e-12,y:d};h.current=a,g(a),n(s,a),C.current=setTimeout(()=>E(t),u)}else M.current=null,h.current={x:t,y:d},g(h.current),n(s,{x:t,y:d});if(!N.current&&r){let e=t=>{t.stopPropagation(),t.preventDefault(),document.removeEventListener("click",e,!0)};document.addEventListener("click",e,!0),r()}},[r,E,e,c,u,s]);return((0,a.useEffect)(()=>{let t=()=>{D();let t=window.innerWidth;if(b){let a=h.current.x<t/2;h.current={x:a?-P:t-P,y:Math.min(h.current.y,window.innerHeight-e-12)}}else h.current={x:Math.min(h.current.x,t-e-12),y:Math.min(h.current.y,window.innerHeight-e-12)};g(h.current)};return window.addEventListener("resize",t),()=>window.removeEventListener("resize",t)},[D,b,P,e]),(0,a.useEffect)(()=>D,[D]),d&&v)?(0,t.jsx)("div",{ref:f,onPointerDown:R,onPointerMove:I,onPointerUp:A,onMouseEnter:F,onMouseLeave:O,className:o,style:{position:"fixed",left:x.x,top:x.y,width:e,height:e,borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",zIndex:99999,touchAction:"none",userSelect:"none",transition:w.current?"none":"left 0.3s ease-out, top 0.3s ease-out",...l},children:i}):null});e.s(["FloatingBall",0,s])},487122,511518,e=>{"use strict";let t=Symbol.for("constructDateFrom");e.s(["constructFromSymbol",0,t,"millisecondsInDay",0,864e5,"millisecondsInWeek",0,6048e5,"minutesInDay",0,1440,"minutesInMonth",0,43200],511518),e.s(["constructFrom",0,function(e,a){return"function"==typeof e?e(a):e&&"object"==typeof e&&t in e?e[t](a):e instanceof Date?new e.constructor(a):new Date(a)}],487122)},238153,244874,e=>{"use strict";var t;let a={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}};function n(e){return (t={})=>{let a=t.width?String(t.width):e.defaultWidth;return e.formats[a]||e.formats[e.defaultWidth]}}let s={date:n({formats:{full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},defaultWidth:"full"}),time:n({formats:{full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},defaultWidth:"full"}),dateTime:n({formats:{full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},defaultWidth:"full"})},r={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"};function i(e){return(t,a)=>{let n;if("formatting"===(a?.context?String(a.context):"standalone")&&e.formattingValues){let t=e.defaultFormattingWidth||e.defaultWidth,s=a?.width?String(a.width):t;n=e.formattingValues[s]||e.formattingValues[t]}else{let t=e.defaultWidth,s=a?.width?String(a.width):e.defaultWidth;n=e.values[s]||e.values[t]}return n[e.argumentCallback?e.argumentCallback(t):t]}}function o(e){return(t,a={})=>{let n,s=a.width,r=s&&e.matchPatterns[s]||e.matchPatterns[e.defaultMatchWidth],i=t.match(r);if(!i)return null;let o=i[0],l=s&&e.parsePatterns[s]||e.parsePatterns[e.defaultParseWidth],d=Array.isArray(l)?function(e,t){for(let a=0;a<e.length;a++)if(t(e[a]))return a}(l,e=>e.test(o)):function(e,t){for(let a in e)if(Object.prototype.hasOwnProperty.call(e,a)&&t(e[a]))return a}(l,e=>e.test(o));return n=e.valueCallback?e.valueCallback(d):d,{value:n=a.valueCallback?a.valueCallback(n):n,rest:t.slice(o.length)}}}let l={code:"en-US",formatDistance:(e,t,n)=>{let s,r=a[e];if(s="string"==typeof r?r:1===t?r.one:r.other.replace("{{count}}",t.toString()),n?.addSuffix)if(n.comparison&&n.comparison>0)return"in "+s;else return s+" ago";return s},formatLong:s,formatRelative:(e,t,a,n)=>r[e],localize:{ordinalNumber:(e,t)=>{let a=Number(e),n=a%100;if(n>20||n<10)switch(n%10){case 1:return a+"st";case 2:return a+"nd";case 3:return a+"rd"}return a+"th"},era:i({values:{narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},defaultWidth:"wide"}),quarter:i({values:{narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},defaultWidth:"wide",argumentCallback:e=>e-1}),month:i({values:{narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},defaultWidth:"wide"}),day:i({values:{narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},defaultWidth:"wide"}),dayPeriod:i({values:{narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},defaultWidth:"wide",formattingValues:{narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},defaultFormattingWidth:"wide"})},match:{ordinalNumber:(t={matchPattern:/^(\d+)(th|st|nd|rd)?/i,parsePattern:/\d+/i,valueCallback:e=>parseInt(e,10)},(e,a={})=>{let n=e.match(t.matchPattern);if(!n)return null;let s=n[0],r=e.match(t.parsePattern);if(!r)return null;let i=t.valueCallback?t.valueCallback(r[0]):r[0];return{value:i=a.valueCallback?a.valueCallback(i):i,rest:e.slice(s.length)}}),era:o({matchPatterns:{narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},defaultMatchWidth:"wide",parsePatterns:{any:[/^b/i,/^(a|c)/i]},defaultParseWidth:"any"}),quarter:o({matchPatterns:{narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},defaultMatchWidth:"wide",parsePatterns:{any:[/1/i,/2/i,/3/i,/4/i]},defaultParseWidth:"any",valueCallback:e=>e+1}),month:o({matchPatterns:{narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},defaultMatchWidth:"wide",parsePatterns:{narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},defaultParseWidth:"any"}),day:o({matchPatterns:{narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},defaultMatchWidth:"wide",parsePatterns:{narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},defaultParseWidth:"any"}),dayPeriod:o({matchPatterns:{narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},defaultMatchWidth:"any",parsePatterns:{any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},defaultParseWidth:"any"})},options:{weekStartsOn:0,firstWeekContainsDate:1}};e.s(["enUS",0,l],244874),e.s(["defaultLocale",0,l],238153)},492421,e=>{"use strict";let t={};e.s(["getDefaultOptions",0,function(){return t}])},632713,516467,e=>{"use strict";var t=e.i(487122);function a(e,a){return(0,t.constructFrom)(a||e,e)}e.s(["toDate",0,a],516467),e.s(["getTimezoneOffsetInMilliseconds",0,function(e){let t=a(e),n=new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()));return n.setUTCFullYear(t.getFullYear()),e-n}],632713)},539392,e=>{"use strict";var t=e.i(487122);e.s(["normalizeDates",0,function(e,...a){let n=t.constructFrom.bind(null,e||a.find(e=>"object"==typeof e));return a.map(n)}])},164202,731285,936765,e=>{"use strict";let t=(0,e.i(433721).default)("zap",[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]]);e.s(["Zap",0,t],164202);var a=e.i(539392);e.s(["differenceInCalendarMonths",0,function(e,t,n){let[s,r]=(0,a.normalizeDates)(n?.in,e,t);return 12*(s.getFullYear()-r.getFullYear())+(s.getMonth()-r.getMonth())}],731285);var n=e.i(516467);e.s(["endOfMonth",0,function(e,t){let a=(0,n.toDate)(e,t?.in),s=a.getMonth();return a.setFullYear(a.getFullYear(),s+1,0),a.setHours(23,59,59,999),a}],936765)},894920,e=>{"use strict";var t=e.i(344180),a=e.i(764556),n=e.i(209988),s=e.i(260218),r=e.i(681622),i=e.i(788010),o=e.i(344118),l=e.i(962562),d=e.i(953700),c=e.i(100559),u=e.i(137340);let m=(0,e.i(433721).default)("wifi",[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M2 8.82a15 15 0 0 1 20 0",key:"dnpr2z"}],["path",{d:"M5 12.859a10 10 0 0 1 14 0",key:"1x1e6c"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}]]);var p=e.i(244073);e.s(["ServerManagerDialog",0,function({open:e,onOpenChange:f,servers:h,activeId:x,onUpdate:g,onRemove:v,onSwitch:y}){let b=(0,p.useTranslations)("sidebar"),j=(0,p.useTranslations)("common"),[w,k]=a.useState(null),[N,C]=a.useState(""),[S,T]=a.useState(""),[M,P]=a.useState(""),[E,D]=a.useState(""),[z,F]=a.useState(""),[O,R]=a.useState(""),[I,A]=a.useState(""),[L,B]=a.useState(null),$=()=>{k(null),C(""),T(""),P("")},H=()=>{if(!N.trim()||!S.trim())return;let e=S.trim().replace(/\/$/,"");/^https?:\/\//.test(e)||(e="http://"+e),g(h.map(t=>t.id===w?{...t,name:N.trim(),url:e,secret:M.trim()||void 0}:t)),$()},U=a.useCallback(e=>{console.log(`[server-diagnostic] ${e}`),A(t=>`${t}${t?"\n":""}${e}`)},[]),W=async e=>{B(e.id),A("");let t=e.url.replace(/\/$/,""),a=`${t}/api/health`,n=new URL("/ws",t);n.protocol="https:"===n.protocol?"wss:":"ws:",n.searchParams.set("workspaceId","__diagnostic__"),n.searchParams.set("token",e.secret||"__diagnostic__"),U(`time: ${new Date().toISOString()}`),U(`window.origin: ${window.location.origin}`),U(`window.href: ${window.location.href}`),U(`navigator.onLine: ${navigator.onLine}`),U(`target: ${t}`),U(`health: ${a}`);let s=performance.now();try{let e=new AbortController,t=window.setTimeout(()=>e.abort(),1e4),n=await fetch(a,{method:"GET",cache:"no-store",mode:"cors",signal:e.signal});window.clearTimeout(t);let r=await n.text();U(`fetch /api/health: OK ${n.status} ${n.statusText} (${Math.round(performance.now()-s)}ms)`),U(`fetch response: ${r.slice(0,500)||"<empty>"}`)}catch(t){let e=t instanceof Error?t:Error(String(t));U(`fetch /api/health: FAILED ${e.name}: ${e.message} (${Math.round(performance.now()-s)}ms)`)}U(`websocket: ${n.toString()}`),await new Promise(e=>{let t=performance.now(),a=!1,s=(n,s)=>{if(!a){a=!0,U(`${n} (${Math.round(performance.now()-t)}ms)`);try{s?.close()}catch{}e()}};try{let e=new WebSocket(n.toString()),t=window.setTimeout(()=>s("websocket: TIMEOUT",e),1e4);e.onopen=()=>{window.clearTimeout(t),s("websocket: OPEN",e)},e.onerror=()=>{window.clearTimeout(t),s("websocket: ERROR",e)},e.onclose=a=>{window.clearTimeout(t),s(`websocket: CLOSE code=${a.code} reason=${a.reason||"<empty>"}`,e)}}catch(t){let e=t instanceof Error?t:Error(String(t));s(`websocket: FAILED ${e.name}: ${e.message}`)}}),B(null)};return(0,t.jsx)(n.Dialog,{open:e,onOpenChange:e=>{f(e),e||$()},children:(0,t.jsxs)(n.DialogContent,{className:"max-w-md",children:[(0,t.jsxs)(n.DialogHeader,{children:[(0,t.jsx)(n.DialogTitle,{children:b("server.manageServers")}),(0,t.jsx)(n.DialogDescription,{children:b("server.manageDescription")})]}),(0,t.jsx)("div",{className:"space-y-1",children:h.map(e=>(0,t.jsxs)("div",{className:"flex items-center gap-3 rounded-md border px-3 py-2",children:[(0,t.jsx)(c.Server,{className:"size-4 shrink-0 text-muted-foreground"}),w===e.id?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(r.Input,{className:"h-7 text-sm flex-1",value:N,onChange:e=>C(e.target.value),placeholder:"Name",autoFocus:!0}),(0,t.jsx)(r.Input,{className:"h-7 text-sm flex-[1.5]",value:S,onChange:e=>T(e.target.value),placeholder:"http://...",onKeyDown:e=>"Enter"===e.key&&e.preventDefault()}),(0,t.jsx)(s.Button,{size:"sm",variant:"ghost",onClick:H,className:"h-7 px-2",children:j("save")}),(0,t.jsx)(s.Button,{size:"sm",variant:"ghost",onClick:$,className:"h-7 px-2",children:j("cancel")})]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"flex-1 min-w-0 cursor-pointer",onClick:()=>{e.id!==x&&y(e)},children:[(0,t.jsx)("div",{className:"text-sm font-medium truncate",children:e.name}),(0,t.jsx)("div",{className:"text-xs text-muted-foreground truncate",children:e.url})]}),e.id===x?(0,t.jsx)(o.Check,{className:"size-4 shrink-0 text-primary"}):(0,t.jsx)(s.Button,{size:"sm",variant:"ghost",onClick:()=>y(e),className:"h-7 px-2 text-xs shrink-0",children:b("server.switch")}),(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(m,{className:"size-3.5 shrink-0 text-muted-foreground cursor-pointer hover:text-foreground",onClick:()=>W(e)}),(0,t.jsx)(l.Pencil,{className:"size-3.5 shrink-0 text-muted-foreground cursor-pointer hover:text-foreground",onClick:()=>{k(e.id),C(e.name),T(e.url),P(e.secret||"")}}),"default"!==e.id&&(0,t.jsx)(u.Trash2,{className:"size-3.5 shrink-0 text-muted-foreground cursor-pointer hover:text-destructive",onClick:()=>v(e.id)})]})]})]},e.id))}),null===w&&(0,t.jsxs)("div",{className:"border-t pt-3 mt-2 space-y-2",children:[(0,t.jsx)("div",{className:"text-xs font-medium text-muted-foreground mb-2",children:b("server.newServer")}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(r.Input,{className:"h-8 text-sm",value:E,onChange:e=>D(e.target.value),placeholder:"Name"}),(0,t.jsx)(s.Button,{size:"sm",onClick:()=>{if(!E.trim()||!z.trim())return;let e=z.trim().replace(/\/$/,"");/^https?:\/\//.test(e)||(e="http://"+e),g([...h,{id:Date.now().toString(),name:E.trim(),url:e,secret:O.trim()||void 0}]),D(""),F(""),R("")},disabled:!E.trim()||!z.trim(),children:(0,t.jsx)(d.Plus,{className:"size-4"})})]}),(0,t.jsx)("div",{className:"flex items-center gap-2",children:(0,t.jsx)(r.Input,{className:"h-8 text-sm flex-1",value:z,onChange:e=>F(e.target.value),placeholder:"http://..."})}),(0,t.jsx)("div",{className:"flex items-center gap-2",children:(0,t.jsx)(r.Input,{className:"h-8 text-sm flex-1",type:"password",value:O,onChange:e=>R(e.target.value),placeholder:b("server.secretOptionalPlaceholder"),onKeyDown:e=>"Enter"===e.key&&e.preventDefault()})})]}),(0,t.jsxs)("div",{className:"border-t pt-3 mt-2 space-y-2",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsx)("div",{className:"text-xs font-medium text-muted-foreground",children:"Network diagnostics"}),(0,t.jsx)(s.Button,{size:"sm",variant:"ghost",className:"h-7 px-2 text-xs",disabled:!h.find(e=>e.id===x)||null!==L,onClick:()=>{let e=h.find(e=>e.id===x);e&&W(e)},children:L?"Testing...":"Test active"})]}),(0,t.jsx)(i.Textarea,{readOnly:!0,value:I||"Tap the Wi-Fi icon next to a server, or use Test active.",className:"h-36 resize-none font-mono text-[11px]"})]})]})})}],894920)},100559,e=>{"use strict";let t=(0,e.i(433721).default)("server",[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]]);e.s(["Server",0,t],100559)},757106,e=>{"use strict";let t=(0,e.i(433721).default)("brain",[["path",{d:"M12 18V5",key:"adv99a"}],["path",{d:"M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4",key:"1e3is1"}],["path",{d:"M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5",key:"1gqd8o"}],["path",{d:"M17.997 5.125a4 4 0 0 1 2.526 5.77",key:"iwvgf7"}],["path",{d:"M18 18a4 4 0 0 0 2-7.464",key:"efp6ie"}],["path",{d:"M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517",key:"1gq6am"}],["path",{d:"M6 18a4 4 0 0 1-2-7.464",key:"k1g0md"}],["path",{d:"M6.003 5.125a4 4 0 0 0-2.526 5.77",key:"q97ue3"}]]);e.s(["default",0,t])},990336,e=>{"use strict";var t=e.i(757106);e.s(["Brain",()=>t.default])},549705,e=>{"use strict";var t=e.i(344180),a=e.i(764556),n=e.i(244073),s=e.i(209988),r=e.i(260218),i=e.i(681622),o=e.i(562918),l=e.i(767467),d=e.i(100559),c=e.i(953700),u=e.i(137340),m=e.i(990336),p=e.i(307858),f=e.i(368942);let h={vision:"bg-blue-500/10 text-blue-600 border-blue-200",reasoning:"bg-purple-500/10 text-purple-600 border-purple-200",embedding:"bg-green-500/10 text-green-600 border-green-200"};function x({providers:e,providerModels:a,onEdit:s,onDelete:i,onAddModel:l}){let c=(0,n.useTranslations)("providers");return(0,t.jsxs)("div",{className:"flex flex-col p-2",children:[e.map(e=>{let n=a.find(t=>t.id===e.id),f=n?.models??[];return(0,t.jsxs)("div",{className:"group rounded-lg px-3 py-2.5 hover:bg-muted/50 cursor-pointer transition-colors",onClick:()=>s(e),children:[(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)("div",{className:"flex size-8 items-center justify-center rounded-lg bg-primary/10",children:(0,t.jsx)(d.Server,{className:"size-4 text-primary"})}),(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsx)("span",{className:"text-sm font-medium",children:e.name}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground truncate",children:e.apiBase||c("list.noApiBase")})]}),(0,t.jsxs)(o.Badge,{variant:"outline",className:"text-[10px] h-4 px-1.5",children:[f.length," ",c("list.modelsCount")]}),(0,t.jsx)(r.Button,{variant:"ghost",size:"icon-xs",className:"opacity-0 group-hover:opacity-100 transition-opacity",onClick:t=>{t.stopPropagation(),i(e.id)},children:(0,t.jsx)(u.Trash2,{className:"size-3 text-destructive"})})]}),f.length>0&&(0,t.jsx)("div",{className:"mt-2 ml-11 flex flex-wrap gap-1",children:f.map(e=>(0,t.jsxs)("span",{className:"inline-flex items-center gap-0.5 text-[11px] text-muted-foreground",children:[(0,t.jsx)(m.Brain,{className:"size-3"}),e.name,["vision","reasoning","embedding"].map(a=>e[a]?(0,t.jsx)("span",{className:`inline-block rounded px-1 text-[9px] font-medium border ${h[a]}`,children:a[0].toUpperCase()},a):null)]},e.id))}),(0,t.jsxs)(r.Button,{variant:"ghost",size:"xs",className:"mt-1 ml-11 h-6 text-[11px] text-muted-foreground",onClick:t=>{t.stopPropagation(),l(e.name)},children:[(0,t.jsx)(p.ExternalLink,{className:"size-3"}),c("list.addModel")]})]},e.id)}),0===e.length&&(0,t.jsxs)("div",{className:"flex flex-col items-center justify-center py-12 text-muted-foreground",children:[(0,t.jsx)(d.Server,{className:"size-10 mb-2 opacity-30"}),(0,t.jsx)("p",{className:"text-sm",children:c("list.empty")})]})]})}function g({draft:e,onChange:a}){let s=(0,n.useTranslations)("providers");return(0,t.jsx)("div",{className:"flex flex-col gap-5 p-5",children:(0,t.jsxs)("div",{className:"flex flex-col gap-2.5",children:[(0,t.jsx)("div",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:s("form.connection")}),(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsx)("label",{className:"text-xs text-muted-foreground",children:s("form.name")}),(0,t.jsx)(i.Input,{value:e.name||"",onChange:e=>a("name",e.target.value),placeholder:s("form.namePlaceholder")})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsx)("label",{className:"text-xs text-muted-foreground",children:s("form.apiBase")}),(0,t.jsx)(i.Input,{value:e.apiBase||"",onChange:e=>a("apiBase",e.target.value),placeholder:s("form.apiBasePlaceholder")})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsx)("label",{className:"text-xs text-muted-foreground",children:s("form.apiKey")}),(0,t.jsx)(i.Input,{type:"password",value:e.apiKey||"",onChange:e=>a("apiKey",e.target.value),placeholder:s("form.apiKeyPlaceholder")})]})]})})}e.s(["ProvidersDialog",0,function({open:e,onOpenChange:i,onAddModel:o,standalone:d}){let u=(0,n.useTranslations)("providers"),m=(0,n.useTranslations)("common"),{models:p,providers:h,ensure:v,addProvider:y,updateProvider:b,removeProvider:j}=(0,f.useLLMStore)(),[w,k]=(0,a.useState)(null),[N,C]=(0,a.useState)(null),[S,T]=(0,a.useState)(!1),[M,P]=(0,a.useState)(!1),[E,D]=(0,a.useState)(null);(0,a.useEffect)(()=>{e&&(T(!0),D(null),v().finally(()=>T(!1)))},[e,v]);let z=()=>{k(null),C(null)},F=()=>{k(null),C({name:"",apiBase:"",apiKey:""})},O=async()=>{if(N&&N.name){P(!0),D(null);try{let e=!w,t=await fetch(e?"/api/providers":`/api/providers/${w.id}`,{method:e?"POST":"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(N)});if(!t.ok)throw Error();let a=await t.json();e?y(a):b(a),z()}catch{D(u("error.saveFailed"))}finally{P(!1)}}},R=async e=>{if(confirm(u("confirm.delete"))){P(!0);try{if(!(await fetch(`/api/providers/${e}`,{method:"DELETE"})).ok)throw Error();j(e),w?.id===e&&z()}catch{D(u("error.deleteFailed"))}finally{P(!1)}}},I=(0,t.jsxs)(t.Fragment,{children:[!d&&(0,t.jsxs)("div",{className:"flex items-center gap-3 border-b px-5 py-4",children:[N&&(0,t.jsx)(r.Button,{variant:"ghost",size:"icon-sm",onClick:z,children:(0,t.jsx)(l.ArrowLeft,{className:"size-4"})}),(0,t.jsxs)(s.DialogHeader,{className:"flex-1 space-y-0",children:[(0,t.jsx)(s.DialogTitle,{className:"text-base",children:N?w?u("dialog.editTitle"):u("dialog.addTitle"):u("dialog.title")}),(0,t.jsx)(s.DialogDescription,{className:"text-xs",children:N?u("dialog.editDescription"):u("dialog.listDescription")})]}),!N&&(0,t.jsxs)(r.Button,{variant:"outline",size:"sm",onClick:F,className:"mr-6",children:[(0,t.jsx)(c.Plus,{className:"size-3.5"}),u("dialog.add")]})]}),d&&!N&&(0,t.jsx)("div",{className:"flex items-center justify-end px-5 py-3 border-b",children:(0,t.jsxs)(r.Button,{variant:"outline",size:"sm",onClick:F,children:[(0,t.jsx)(c.Plus,{className:"size-3.5"}),u("dialog.add")]})}),d&&N&&(0,t.jsxs)("div",{className:"flex items-center gap-3 px-5 py-3 border-b",children:[(0,t.jsx)(r.Button,{variant:"ghost",size:"icon-sm",onClick:z,children:(0,t.jsx)(l.ArrowLeft,{className:"size-4"})}),(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsx)("h2",{className:"text-base font-medium truncate",children:w?u("dialog.editTitle"):u("dialog.addTitle")}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:u("dialog.editDescription")})]})]}),(0,t.jsxs)("div",{className:"flex-1 overflow-y-auto",children:[E&&(0,t.jsx)("div",{className:"mx-5 mt-4 rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-xs text-destructive",children:E}),S?(0,t.jsx)("div",{className:"py-12 text-center text-sm text-muted-foreground",children:u("dialog.loading")}):N?(0,t.jsx)(g,{draft:N,onChange:(e,t)=>{C(a=>a?{...a,[e]:t}:a)}}):(0,t.jsx)(x,{providers:h,providerModels:h.map(e=>{let t;return{id:e.id,models:(t=e.name,p.filter(e=>e.provider===t))}}),onEdit:e=>{k(e),C({...e})},onDelete:R,onAddModel:e=>{d||i(!1),o(e)}})]}),N&&(0,t.jsxs)("div",{className:"flex justify-end gap-2 border-t px-5 py-3",children:[(0,t.jsx)(r.Button,{variant:"outline",size:"sm",onClick:z,disabled:M,children:m("cancel")}),(0,t.jsx)(r.Button,{size:"sm",onClick:O,disabled:M||!N.name,children:m(M?"saving":"save")})]})]});return d?(0,t.jsx)("div",{className:"h-full flex flex-col",children:I}):(0,t.jsx)(s.Dialog,{open:e,onOpenChange:e=>{e||z(),i(e)},children:(0,t.jsx)(s.DialogContent,{className:"sm:max-w-2xl max-h-[85vh] flex flex-col p-0 gap-0",children:I})})}])},841734,e=>{"use strict";var t=e.i(344180),a=e.i(764556),n=e.i(244073),s=e.i(887836),r=e.i(916950),i=e.i(209988),o=e.i(260218),l=e.i(681622),d=e.i(191118),c=e.i(239340),u=e.i(460578),m=e.i(996652),p=e.i(917955),f=e.i(887354),h=e.i(401058),x=e.i(137340),g=e.i(953700),v=e.i(962562),y=e.i(129981),b=e.i(193251),j=e.i(977694),w=e.i(513501),k=e.i(989484);let N=(0,s.default)(()=>e.A(863812).then(e=>e.default),{loadableGenerated:{modules:[158480]},ssr:!1,loading:()=>(0,t.jsx)("div",{className:"flex items-center justify-center h-full text-muted-foreground text-sm",children:"Loading editor..."})});e.s(["OutputStylesDialog",0,function({open:e,onOpenChange:s,standalone:C}){let S=(0,n.useTranslations)("outputStyles"),T=(0,n.useTranslations)("common"),[M,P]=(0,a.useState)("local"),[E,D]=(0,a.useState)([]),[z,F]=(0,a.useState)([]),[O,R]=(0,a.useState)(!1),[I,A]=(0,a.useState)(""),[L,B]=(0,a.useState)([]),[$,H]=(0,a.useState)(!1),[U,W]=(0,a.useState)(new Set),[_,V]=(0,a.useState)(!1),[J,Y]=(0,a.useState)([]),[q,K]=(0,a.useState)(null),[X,G]=(0,a.useState)(!1),[Q,Z]=(0,a.useState)(""),[ee,et]=(0,a.useState)(""),[ea,en]=(0,a.useState)(""),[es,er]=(0,a.useState)(!1),[ei,eo]=(0,a.useState)(null),[el,ed]=(0,a.useState)([]),[ec,eu]=(0,a.useState)(!1),em=(0,a.useCallback)(async()=>{R(!0);try{let e=await fetch("/api/output-styles");e.ok&&D(await e.json())}catch{}R(!1)},[]),ep=(0,a.useCallback)(async()=>{try{let e=await fetch("/api/output-styles/agents");e.ok&&F(await e.json())}catch{}},[]),ef=(0,a.useCallback)(async()=>{H(!0);try{let e=await (0,r.fetchStoreIndex)("output-styles/index.json");B(e)}catch{}H(!1)},[]);(0,a.useEffect)(()=>{(e||C)&&(em(),ep(),ef())},[e,C,em,ep,ef]);let eh=new Set(E.filter(e=>e.storeId).map(e=>e.storeId));function ex(e){let t=e.match(/^---\r?\n([\s\S]*?)\r?\n---\r?\n?/);if(!t)return{content:e};let a=t[1],n=e.slice(t[0].length),s=a.match(/^name:\s*(.+)$/m),r=a.match(/^description:\s*(.+)$/m);return{name:s?.[1]?.trim(),description:r?.[1]?.trim(),content:n}}let eg=async()=>{if(0!==J.length){if(1===J.length){let e=await J[0].file.text(),t=ex(e),a=t.name||J[0].file.name.replace(/\.(md|txt|markdown)$/i,"");Y([]),V(!1),K(null),G(!0),Z(a),et(t.description||""),en(t.content||e);return}for(let e of J){let t=await e.file.text(),a=ex(t),n=a.name||e.file.name.replace(/\.(md|txt|markdown)$/i,"");await fetch("/api/output-styles",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:n,content:a.content||t,description:a.description})})}Y([]),V(!1),em()}},ev=async e=>{if(!(eh.has(e.id)||U.has(e.id))){W(t=>new Set(t).add(e.id));try{let t=await fetch(`/public/output-styles/${e.filename}`);if(!t.ok)return;let a=await t.text(),n=ex(a),s=await fetch("/api/output-styles",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:e.name,content:n.content||a,storeId:e.id,description:n.description})});if(s.ok){let e=await s.json();D(t=>[...t,e])}}catch{}W(t=>{let a=new Set(t);return a.delete(e.id),a})}},ey=()=>{K(null),G(!1),Z(""),et(""),en("")},eb=async()=>{if(Q.trim()&&ea.trim()){er(!0);try{let e=q?`/api/output-styles/${q.id}`:"/api/output-styles",t=q?"PUT":"POST",a=await fetch(e,{method:t,headers:{"Content-Type":"application/json"},body:JSON.stringify({name:Q,content:ea,description:ee||void 0})});if(a.ok){let e=await a.json();D(t=>q?t.map(t=>t.id===e.id?e:t):[...t,e]),ey()}}catch{}er(!1)}},ej=async e=>{try{(await fetch(`/api/output-styles/${e.id}`,{method:"DELETE"})).ok&&D(t=>t.filter(t=>t.id!==e.id))}catch{}},ew=async()=>{if(ei&&0!==el.length){eu(!0);try{await fetch(`/api/output-styles/${ei.id}/apply`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({agentIds:el})}),eo(null)}catch{}eu(!1)}},ek=E.filter(e=>{if(!I)return!0;let t=I.toLowerCase();return e.name.toLowerCase().includes(t)||e.content.toLowerCase().includes(t)}),eN=L.filter(e=>{if(!I)return!0;let t=I.toLowerCase();return e.name.toLowerCase().includes(t)||e.id.toLowerCase().includes(t)}),eC=(C||e)&&!ei&&!q&&!X,eS=(0,t.jsx)("div",{className:"flex items-center gap-1 border-b border-border px-1",children:[["local",k.FileText,S("tabLocal")],["store",w.Store,S("tabStore")]].map(([e,a,n])=>(0,t.jsxs)("button",{onClick:()=>P(e),className:`flex items-center gap-1.5 px-3 py-2 text-sm font-medium border-b-2 transition-colors ${M===e?"border-primary text-foreground":"border-transparent text-muted-foreground hover:text-foreground"}`,children:[(0,t.jsx)(a,{className:"size-3.5"}),n]},e))}),eT=(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 ml-auto shrink-0 pt-2",children:[(0,t.jsxs)(m.Popover,{open:_,onOpenChange:V,children:[(0,t.jsx)(m.PopoverTrigger,{render:(0,t.jsxs)(o.Button,{variant:"outline",size:"sm",children:[(0,t.jsx)(y.Upload,{className:"size-3.5 mr-1"}),S("import")]})}),(0,t.jsx)(m.PopoverContent,{className:"w-80",align:"end",children:(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsx)("p",{className:"text-sm font-medium",children:S("importTitle")}),(0,t.jsx)(u.FileUpload,{value:J,onChange:Y,accept:{"text/markdown":[".md",".txt"],"":[".md",".txt"]},placeholder:S("importPlaceholder"),maxFiles:10}),(0,t.jsx)(o.Button,{size:"sm",onClick:eg,disabled:0===J.length,className:"w-full",children:S("importConfirm")})]})})]}),(0,t.jsxs)(o.Button,{variant:"outline",size:"sm",onClick:()=>{K(null),G(!0),Z(""),et(""),en("")},children:[(0,t.jsx)(g.Plus,{className:"size-3.5 mr-1"}),S("create")]})]}),(0,t.jsx)(d.ScrollArea,{className:"flex-1",children:O?(0,t.jsx)("div",{className:"flex items-center justify-center py-12 text-muted-foreground text-sm",children:T("loading")}):0===ek.length?(0,t.jsx)("div",{className:"flex items-center justify-center py-12 text-muted-foreground text-sm",children:S("empty")}):(0,t.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3 pr-2",children:ek.map(e=>(0,t.jsx)("div",{className:"rounded-xl border border-border bg-background p-4 hover:bg-accent/30 transition-colors cursor-pointer",onClick:()=>{K(e),G(!1),Z(e.name),et(e.description||""),en(e.content)},children:(0,t.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,t.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,t.jsxs)("div",{className:"flex items-center gap-1.5 min-w-0",children:[(0,t.jsx)(v.Pencil,{className:"size-3.5 text-muted-foreground shrink-0"}),(0,t.jsx)("span",{className:"font-medium text-sm truncate",children:e.name})]}),(0,t.jsxs)("div",{className:"flex items-center gap-0.5 shrink-0",onClick:e=>e.stopPropagation(),children:[(0,t.jsxs)(o.Button,{variant:"outline",size:"sm",className:"h-6 px-1.5 text-xs",onClick:()=>{eo(e),ed([])},children:[(0,t.jsx)(j.Rocket,{className:"size-3 mr-0.5"}),S("apply")]}),(0,t.jsxs)(p.DropdownMenu,{children:[(0,t.jsx)(p.DropdownMenuTrigger,{render:(0,t.jsx)(o.Button,{variant:"ghost",size:"icon",className:"size-6"}),children:(0,t.jsx)(h.MoreVertical,{className:"size-3"})}),(0,t.jsx)(p.DropdownMenuContent,{align:"end",children:(0,t.jsxs)(p.DropdownMenuItem,{className:"text-destructive focus:text-destructive",onClick:()=>ej(e),children:[(0,t.jsx)(x.Trash2,{className:"size-3 mr-1.5"}),S("delete")]})})]})]})]}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground line-clamp-3",children:e.description||e.content.slice(0,200)})]})},e.id))})})]}),eM=(0,t.jsx)(d.ScrollArea,{className:"flex-1",children:$?(0,t.jsx)("div",{className:"flex items-center justify-center py-12 text-muted-foreground text-sm",children:T("loading")}):0===eN.length?(0,t.jsx)("div",{className:"flex items-center justify-center py-12 text-muted-foreground text-sm",children:S("storeEmpty")}):(0,t.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3 pr-2",children:eN.map(e=>{let a=eh.has(e.id),n=U.has(e.id);return(0,t.jsx)("div",{className:"rounded-xl border border-border bg-background p-4 hover:bg-accent/30 transition-colors",children:(0,t.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,t.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,t.jsxs)("div",{className:"flex items-center gap-1.5 min-w-0",children:[(0,t.jsx)(w.Store,{className:"size-3.5 text-muted-foreground shrink-0"}),(0,t.jsx)("span",{className:"font-medium text-sm truncate",children:e.name})]}),(0,t.jsx)(o.Button,{variant:a?"ghost":"outline",size:"sm",className:"h-6 px-1.5 text-xs shrink-0",disabled:a||n,onClick:()=>ev(e),children:a?(0,t.jsx)(t.Fragment,{children:S("imported")}):n?(0,t.jsx)(t.Fragment,{children:S("importing")}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(b.Download,{className:"size-3 mr-0.5"}),S("importTo")]})})]}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:e.id})]})},e.id)})})}),eP=(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(i.DialogHeader,{children:(0,t.jsx)("div",{className:"flex items-center justify-between pr-8",children:(0,t.jsxs)("div",{className:"hidden md:block",children:[C?(0,t.jsx)("h2",{className:"text-base font-semibold",children:S("title")}):(0,t.jsx)(i.DialogTitle,{children:S("title")}),C?(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:S("description")}):(0,t.jsx)(i.DialogDescription,{children:S("description")})]})})}),eS,(0,t.jsx)("div",{className:"flex flex-1 min-h-0 gap-4 pt-2",children:(0,t.jsxs)("div",{className:"flex-1 min-w-0 flex flex-col gap-3",children:[(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsx)(f.Search,{className:"size-3.5 absolute left-2.5 top-1/2 -translate-y-1/2 text-muted-foreground"}),(0,t.jsx)(l.Input,{value:I,onChange:e=>A(e.target.value),placeholder:S("search"),className:"pl-8"})]}),"local"===M?eT:eM]})})]});return(0,t.jsxs)(t.Fragment,{children:[C&&eC&&(0,t.jsx)("div",{className:"h-full flex flex-col",children:eP}),!C&&(0,t.jsx)(i.Dialog,{open:eC,onOpenChange:s,children:(0,t.jsx)(i.DialogContent,{className:"!w-[80vw] !max-w-[80vw] !h-[80vh] flex flex-col",children:eP})}),(0,t.jsx)(i.Dialog,{open:!!q||X,onOpenChange:e=>{e||ey()},children:(0,t.jsxs)(i.DialogContent,{className:"sm:max-w-2xl h-[80vh] flex flex-col",children:[(0,t.jsxs)(i.DialogHeader,{children:[(0,t.jsx)(i.DialogTitle,{children:q?S("editTitle",{name:q.name}):S("createTitle")}),(0,t.jsx)(i.DialogDescription,{children:S("editDescription")})]}),(0,t.jsx)(l.Input,{value:Q,onChange:e=>Z(e.target.value),placeholder:S("namePlaceholder")}),(0,t.jsx)(l.Input,{value:ee,onChange:e=>et(e.target.value),placeholder:S("descriptionPlaceholder")}),(0,t.jsx)("div",{className:"flex-1 min-h-0 overflow-hidden rounded-md border border-border",children:(0,t.jsx)(N,{height:"100%",language:"markdown",value:ea,onChange:e=>en(e||""),theme:"vs-dark",options:{fontSize:13,minimap:{enabled:!1},scrollBeyondLastLine:!1,padding:{top:8},renderLineHighlight:"gutter",wordWrap:"on"}})}),(0,t.jsxs)("div",{className:"flex justify-end gap-2 pt-2",children:[(0,t.jsx)(o.Button,{variant:"outline",onClick:ey,disabled:es,children:T("cancel")}),(0,t.jsx)(o.Button,{onClick:eb,disabled:es||!Q.trim()||!ea.trim(),children:T(es?"saving":"save")})]})]})}),(0,t.jsx)(c.AgentPickerDialog,{open:!!ei,onClose:()=>eo(null),onConfirm:ew,title:S("applyTitle",{name:ei?.name||""}),description:S("applyDescription"),agents:z.map(e=>({id:e.id,name:e.name,avatarUrl:e.avatarUrl,description:e.description})),selected:el,onToggle:e=>ed(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]),cancelText:T("cancel"),confirmText:S("applyConfirm",{count:el.length}),loading:ec})]})}])},756638,e=>{"use strict";var t=e.i(344180),a=e.i(764556),n=e.i(244073),s=e.i(887836),r=e.i(916950),i=e.i(209988),o=e.i(260218),l=e.i(681622),d=e.i(191118),c=e.i(239340),u=e.i(460578),m=e.i(996652),p=e.i(917955),f=e.i(887354),h=e.i(401058),x=e.i(137340),g=e.i(977694),v=e.i(111343),y=e.i(953700),b=e.i(426022),j=e.i(129981),w=e.i(193251),k=e.i(513501),N=e.i(989484);let C=(0,s.default)(()=>e.A(863812).then(e=>e.default),{loadableGenerated:{modules:[158480]},ssr:!1,loading:()=>(0,t.jsx)("div",{className:"flex items-center justify-center h-full text-muted-foreground text-sm",children:"Loading editor..."})});e.s(["PromptsDialog",0,function({open:e,onOpenChange:s,standalone:S}){let T=(0,n.useTranslations)("prompts"),M=(0,n.useTranslations)("common"),[P,E]=(0,a.useState)("local"),[D,z]=(0,a.useState)([]),[F,O]=(0,a.useState)([]),[R,I]=(0,a.useState)(!1),[A,L]=(0,a.useState)(""),[B,$]=(0,a.useState)([]),[H,U]=(0,a.useState)(!1),[W,_]=(0,a.useState)(new Set),[V,J]=(0,a.useState)(!1),[Y,q]=(0,a.useState)([]),[K,X]=(0,a.useState)(null),[G,Q]=(0,a.useState)([]),[Z,ee]=(0,a.useState)(!1),[et,ea]=(0,a.useState)(null),[en,es]=(0,a.useState)(!1),[er,ei]=(0,a.useState)(""),[eo,el]=(0,a.useState)(""),[ed,ec]=(0,a.useState)(!1),eu=(0,a.useCallback)(async()=>{I(!0);try{let e=await fetch("/api/prompt-templates");e.ok&&z(await e.json())}catch{}I(!1)},[]),em=(0,a.useCallback)(async()=>{try{let e=await fetch("/api/prompt-templates/agents");e.ok&&O(await e.json())}catch{}},[]),ep=(0,a.useCallback)(async()=>{U(!0);try{let e=await (0,r.fetchStoreIndex)("prompt/index.json");$(e)}catch{}U(!1)},[]);(0,a.useEffect)(()=>{(e||S)&&(eu(),em(),ep())},[e,S,eu,em,ep]);let ef=new Set(D.filter(e=>e.storeId).map(e=>e.storeId)),eh=async()=>{if(0!==Y.length){if(1===Y.length){let e=await Y[0].file.text(),t=Y[0].file.name.replace(/\.(md|txt|markdown)$/i,"");q([]),J(!1),ea(null),es(!0),ei(t),el(e);return}for(let e of Y){let t=await e.file.text(),a=e.file.name.replace(/\.(md|txt|markdown)$/i,"");await fetch("/api/prompt-templates",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:a,content:t})})}q([]),J(!1),eu()}},ex=async e=>{if(!(ef.has(e.id)||W.has(e.id))){_(t=>new Set(t).add(e.id));try{let t=await fetch(`/public/prompt/${e.filename}`);if(!t.ok)return;let a=await t.text(),n=await fetch("/api/prompt-templates",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:e.name,content:a,storeId:e.id})});if(n.ok){let e=await n.json();z(t=>[...t,e])}}catch{}_(t=>{let a=new Set(t);return a.delete(e.id),a})}},eg=()=>{ea(null),es(!1),ei(""),el("")},ev=async()=>{if(er.trim()&&eo.trim()){ec(!0);try{if(et){let e=await fetch(`/api/prompt-templates/${et.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:er,content:eo})});if(e.ok){let t=await e.json();z(e=>e.map(e=>e.id===t.id?t:e)),eg()}}else{let e=await fetch("/api/prompt-templates",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:er,content:eo})});if(e.ok){let t=await e.json();z(e=>[...e,t]),eg()}}}catch{}ec(!1)}},ey=async e=>{try{(await fetch(`/api/prompt-templates/${e.id}`,{method:"DELETE"})).ok&&z(t=>t.filter(t=>t.id!==e.id))}catch{}},eb=async()=>{if(K&&0!==G.length){ee(!0);try{await fetch(`/api/prompt-templates/${K.id}/apply`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({agentIds:G})}),X(null)}catch{}ee(!1)}},ej=D.filter(e=>{if(!A)return!0;let t=A.toLowerCase();return e.name.toLowerCase().includes(t)||e.content.toLowerCase().includes(t)}),ew=B.filter(e=>{if(!A)return!0;let t=A.toLowerCase();return e.name.toLowerCase().includes(t)||e.id.toLowerCase().includes(t)}),ek=(S||e)&&!K&&!et&&!en,eN=F.map(e=>({id:e.id,name:e.name,avatarUrl:e.avatarUrl,description:e.description})),eC=(0,t.jsx)("div",{className:"flex items-center gap-1 border-b border-border px-1",children:[["local",N.FileText,T("tabLocal")],["store",k.Store,T("tabStore")]].map(([e,a,n])=>(0,t.jsxs)("button",{onClick:()=>E(e),className:`flex items-center gap-1.5 px-3 py-2 text-sm font-medium border-b-2 transition-colors ${P===e?"border-primary text-foreground":"border-transparent text-muted-foreground hover:text-foreground"}`,children:[(0,t.jsx)(a,{className:"size-3.5"}),n]},e))}),eS=(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 ml-auto shrink-0 pt-2",children:[(0,t.jsxs)(m.Popover,{open:V,onOpenChange:J,children:[(0,t.jsx)(m.PopoverTrigger,{render:(0,t.jsxs)(o.Button,{variant:"outline",size:"sm",children:[(0,t.jsx)(j.Upload,{className:"size-3.5 mr-1"}),T("import")]})}),(0,t.jsx)(m.PopoverContent,{className:"w-80",align:"end",children:(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsx)("p",{className:"text-sm font-medium",children:T("importTitle")}),(0,t.jsx)(u.FileUpload,{value:Y,onChange:q,accept:{"text/markdown":[".md",".txt"],"":[".md",".txt"]},placeholder:T("importPlaceholder"),maxFiles:10}),(0,t.jsx)(o.Button,{size:"sm",onClick:eh,disabled:0===Y.length,className:"w-full",children:T("importConfirm")})]})})]}),(0,t.jsxs)(o.Button,{variant:"outline",size:"sm",onClick:()=>{ea(null),es(!0),ei(""),el("")},children:[(0,t.jsx)(y.Plus,{className:"size-3.5 mr-1"}),T("create")]})]}),(0,t.jsx)(d.ScrollArea,{className:"flex-1",children:R?(0,t.jsx)("div",{className:"flex items-center justify-center py-12 text-muted-foreground text-sm",children:M("loading")}):0===ej.length?(0,t.jsx)("div",{className:"flex items-center justify-center py-12 text-muted-foreground text-sm",children:T("empty")}):(0,t.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3 pr-2",children:ej.map(e=>(0,t.jsx)("div",{className:"rounded-xl border border-border bg-background p-4 hover:bg-accent/30 transition-colors cursor-pointer",onClick:()=>{ea(e),es(!1),ei(e.name),el(e.content)},children:(0,t.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,t.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,t.jsxs)("div",{className:"flex items-center gap-1.5 min-w-0",children:[(0,t.jsx)(b.MessageSquare,{className:"size-3.5 text-muted-foreground shrink-0"}),(0,t.jsx)("span",{className:"font-medium text-sm truncate",children:e.name})]}),(0,t.jsxs)("div",{className:"flex items-center gap-0.5 shrink-0",onClick:e=>e.stopPropagation(),children:[(0,t.jsxs)(o.Button,{variant:"outline",size:"sm",className:"h-6 px-1.5 text-xs",onClick:()=>{X(e),Q([])},children:[(0,t.jsx)(g.Rocket,{className:"size-3 mr-0.5"}),T("apply")]}),(0,t.jsxs)(p.DropdownMenu,{children:[(0,t.jsx)(p.DropdownMenuTrigger,{render:(0,t.jsx)(o.Button,{variant:"ghost",size:"icon",className:"size-6"}),children:(0,t.jsx)(h.MoreVertical,{className:"size-3"})}),(0,t.jsx)(p.DropdownMenuContent,{align:"end",children:(0,t.jsxs)(p.DropdownMenuItem,{className:"text-destructive focus:text-destructive",onClick:()=>ey(e),children:[(0,t.jsx)(x.Trash2,{className:"size-3 mr-1.5"}),T("delete")]})})]})]})]}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground line-clamp-3",children:e.content.slice(0,200).replace(/^#\s+/,"")})]})},e.id))})})]}),eT=(0,t.jsx)(d.ScrollArea,{className:"flex-1",children:H?(0,t.jsx)("div",{className:"flex items-center justify-center py-12 text-muted-foreground text-sm",children:M("loading")}):0===ew.length?(0,t.jsx)("div",{className:"flex items-center justify-center py-12 text-muted-foreground text-sm",children:T("storeEmpty")}):(0,t.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3 pr-2",children:ew.map(e=>{let a=ef.has(e.id),n=W.has(e.id);return(0,t.jsx)("div",{className:"rounded-xl border border-border bg-background p-4 hover:bg-accent/30 transition-colors",children:(0,t.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,t.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,t.jsxs)("div",{className:"flex items-center gap-1.5 min-w-0",children:[(0,t.jsx)(k.Store,{className:"size-3.5 text-muted-foreground shrink-0"}),(0,t.jsx)("span",{className:"font-medium text-sm truncate",children:e.name})]}),(0,t.jsx)(o.Button,{variant:a?"ghost":"outline",size:"sm",className:"h-6 px-1.5 text-xs shrink-0",disabled:a||n,onClick:()=>ex(e),children:a?(0,t.jsx)(t.Fragment,{children:T("imported")}):n?(0,t.jsx)(t.Fragment,{children:T("importing")}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(w.Download,{className:"size-3 mr-0.5"}),T("importTo")]})})]}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:e.id})]})},e.id)})})}),eM=(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(i.DialogHeader,{children:(0,t.jsx)("div",{className:"flex items-center justify-between pr-8",children:(0,t.jsxs)("div",{className:"hidden md:block",children:[S?(0,t.jsx)("h2",{className:"text-base font-semibold",children:T("title")}):(0,t.jsx)(i.DialogTitle,{children:T("title")}),S?(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:T("description")}):(0,t.jsx)(i.DialogDescription,{children:T("description")})]})})}),eC,(0,t.jsx)("div",{className:"flex flex-1 min-h-0 gap-4 pt-2",children:(0,t.jsxs)("div",{className:"flex-1 min-w-0 flex flex-col gap-3",children:[(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsx)(f.Search,{className:"size-3.5 absolute left-2.5 top-1/2 -translate-y-1/2 text-muted-foreground"}),(0,t.jsx)(l.Input,{value:A,onChange:e=>L(e.target.value),placeholder:T("search"),className:"pl-8"})]}),"local"===P?eS:eT]})})]});return(0,t.jsxs)(t.Fragment,{children:[S&&ek&&(0,t.jsx)("div",{className:"h-full flex flex-col",children:eM}),!S&&(0,t.jsx)(i.Dialog,{open:ek,onOpenChange:s,children:(0,t.jsx)(i.DialogContent,{className:"!w-[80vw] !max-w-[80vw] !h-[80vh] flex flex-col",children:eM})}),(0,t.jsx)(i.Dialog,{open:!!et||en,onOpenChange:e=>{e||eg()},children:(0,t.jsxs)(i.DialogContent,{className:"!w-[80vw] !max-w-[80vw] !h-[80vh] flex flex-col",children:[(0,t.jsx)(i.DialogHeader,{children:(0,t.jsxs)("div",{className:"flex items-center justify-between pr-8",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)(i.DialogTitle,{children:et?T("editTitle",{name:et.name}):T("createTitle")}),(0,t.jsx)(i.DialogDescription,{children:T("editDescription")})]}),(0,t.jsxs)(o.Button,{size:"sm",onClick:ev,disabled:ed||!er.trim()||!eo.trim(),children:[(0,t.jsx)(v.Save,{className:"size-3.5 mr-1"}),M("save")]})]})}),(0,t.jsx)("div",{className:"space-y-3 pb-2",children:(0,t.jsx)(l.Input,{value:er,onChange:e=>ei(e.target.value),placeholder:T("namePlaceholder")})}),(0,t.jsx)("div",{className:"flex-1 min-h-0",children:(0,t.jsx)(C,{height:"100%",language:"markdown",value:eo,onChange:e=>el(e||""),theme:"vs-dark",options:{fontSize:13,minimap:{enabled:!1},scrollBeyondLastLine:!1,padding:{top:8},renderLineHighlight:"gutter",wordWrap:"on"}})})]})}),(0,t.jsx)(c.AgentPickerDialog,{open:!!K,onClose:()=>X(null),onConfirm:eb,title:T("applyTitle",{name:K?.name||""}),description:T("applyDescription"),agents:eN,selected:G,onToggle:e=>Q(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]),cancelText:M("cancel"),confirmText:T("applyConfirm",{count:G.length}),loading:Z})]})}])},638322,e=>{"use strict";var t,a,n=e.i(344180);e.s([],935002),e.i(935002),e.i(8890);var s=e.i(764556),r=e.i(155461),i=e.i(166392),o=e.i(277642),l=e.i(267805);let d=s.createContext(void 0);function c(e){let t=s.useContext(d);if(void 0===t&&!e)throw Error((0,l.default)(72));return t}var u=e.i(92615),m=e.i(422561),p=e.i(29905),f=e.i(410421),h=e.i(150129);function x(e){return null!=e&&null!=e.clientX}var g=e.i(538501),v=e.i(427396),y=e.i(602453),b=e.i(279501),j=e.i(106206),w=e.i(332976),k=e.i(493696),N=e.i(549154),C=e.i(107164),S=e.i(742665),T=e.i(695011),M=e.i(561213);let P={...T.popupStoreSelectors,disabled:(0,w.createSelector)(e=>e.disabled),instantType:(0,w.createSelector)(e=>e.instantType),isInstantPhase:(0,w.createSelector)(e=>e.isInstantPhase),trackCursorAxis:(0,w.createSelector)(e=>e.trackCursorAxis),disableHoverablePopup:(0,w.createSelector)(e=>e.disableHoverablePopup),lastOpenChangeReason:(0,w.createSelector)(e=>e.openChangeReason),closeOnClick:(0,w.createSelector)(e=>e.closeOnClick),closeDelay:(0,w.createSelector)(e=>e.closeDelay),hasViewport:(0,w.createSelector)(e=>e.hasViewport)};class E extends k.ReactStore{constructor(e){super({...(0,T.createInitialPopupStoreState)(),disabled:!1,instantType:void 0,isInstantPhase:!1,trackCursorAxis:"none",disableHoverablePopup:!1,openChangeReason:null,closeOnClick:!0,closeDelay:0,hasViewport:!1,...e},{popupRef:s.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerElements:new M.PopupTriggerMap},P)}setOpen=(e,t)=>{let a=t.reason,n=a===S.REASONS.triggerHover,s=e&&a===S.REASONS.triggerFocus,r=!e&&(a===S.REASONS.triggerPress||a===S.REASONS.escapeKey);if(t.preventUnmountOnClose=()=>{this.set("preventUnmountingOnClose",!0)},this.context.onOpenChange?.(e,t),t.isCanceled)return;this.state.floatingRootContext.dispatchOpenChange(e,t);let i=()=>{let n={open:e,openChangeReason:a};s?n.instantType="focus":r?n.instantType="dismiss":a===S.REASONS.triggerHover&&(n.instantType=void 0);let i=t.trigger?.id??null;(i||e)&&(n.activeTriggerId=i,n.activeTriggerElement=t.trigger??null),this.update(n)};n?j.flushSync(i):i()};static useStore(e,t){let a=(0,N.useRefWithInit)(()=>new E(t)).current,n=e??a,s=(0,C.useSyncedFloatingRootContext)({popupStore:n,onOpenChange:n.setOpen});return n.state.floatingRootContext=s,n}}let D=(0,r.fastComponent)(function(e){let{disabled:t=!1,defaultOpen:a=!1,open:r,disableHoverablePopup:l=!1,trackCursorAxis:c="none",actionsRef:j,onOpenChange:w,onOpenChangeComplete:k,handle:N,triggerId:C,defaultTriggerId:T=null,children:M}=e,P=E.useStore(N?.store,{open:a,openProp:r,activeTriggerId:T,triggerIdProp:C});(0,i.useOnFirstRender)(()=>{void 0===r&&!1===P.state.open&&!0===a&&P.update({open:!0,activeTriggerId:T})}),P.useControlledProp("openProp",r),P.useControlledProp("triggerIdProp",C),P.useContextCallback("onOpenChange",w),P.useContextCallback("onOpenChangeComplete",k);let D=P.useState("open"),z=!t&&D,F=P.useState("activeTriggerId"),O=P.useState("payload");P.useSyncedValues({trackCursorAxis:c,disableHoverablePopup:l}),(0,o.useIsoLayoutEffect)(()=>{D&&t&&P.setOpen(!1,(0,y.createChangeEventDetails)(S.REASONS.disabled))},[D,t,P]),P.useSyncedValue("disabled",t),(0,b.useImplicitActiveTrigger)(P);let{forceUnmount:R,transitionStatus:I}=(0,b.useOpenStateTransitions)(z,P),A=P.select("floatingRootContext"),L=P.useState("isInstantPhase"),B=P.useState("instantType"),$=P.useState("lastOpenChangeReason"),H=s.useRef(null);(0,o.useIsoLayoutEffect)(()=>{"ending"===I&&$===S.REASONS.none||"ending"!==I&&L?("delay"!==B&&(H.current=B),P.set("instantType","delay")):null!==H.current&&(P.set("instantType",H.current),H.current=null)},[I,L,$,B,P]),(0,o.useIsoLayoutEffect)(()=>{z&&null==F&&P.set("payload",void 0)},[P,F,z]);let U=s.useCallback(()=>{P.setOpen(!1,(0,y.createChangeEventDetails)(S.REASONS.imperativeAction))},[P]);s.useImperativeHandle(j,()=>({unmount:R,close:U}),[R,U]);let W=(0,g.useDismiss)(A,{enabled:!t,referencePress:()=>P.select("closeOnClick")}),_=function(e,t={}){let a="rootStore"in e?e.rootStore:e,n=a.useState("open"),r=a.useState("floatingElement"),i=a.useState("domReferenceElement"),o=a.context.dataRef,{enabled:l=!0,axis:d="both"}=t,c=s.useRef(!1),g=s.useRef(null),[v,y]=s.useState(),[b,j]=s.useState([]),w=(0,p.useStableCallback)((e,t,n)=>{if(!c.current&&(!o.current.openEvent||x(o.current.openEvent))){var s,r;let l,c,u;a.set("positionReference",(s=n??i,r={x:e,y:t,axis:d,dataRef:o,pointerType:v},l=null,c=null,u=!1,{contextElement:s||void 0,getBoundingClientRect(){let e=s?.getBoundingClientRect()||{width:0,height:0,x:0,y:0},t="x"===r.axis||"both"===r.axis,a="y"===r.axis||"both"===r.axis,n=["mouseenter","mousemove"].includes(r.dataRef.current.openEvent?.type||"")&&"touch"!==r.pointerType,i=e.width,o=e.height,d=e.x,m=e.y;return null==l&&r.x&&t&&(l=e.x-r.x),null==c&&r.y&&a&&(c=e.y-r.y),d-=l||0,m-=c||0,i=0,o=0,!u||n?(i="y"===r.axis?e.width:0,o="x"===r.axis?e.height:0,d=t&&null!=r.x?r.x:d,m=a&&null!=r.y?r.y:m):u&&!n&&(o="x"===r.axis?e.height:o,i="y"===r.axis?e.width:i),u=!0,{width:i,height:o,x:d,y:m,top:m,right:d+i,bottom:m+o,left:d}}}))}}),k=(0,p.useStableCallback)(e=>{n?g.current||j([]):w(e.clientX,e.clientY,e.currentTarget)}),N=(0,h.isMouseLikePointerType)(v)?r:n,C=s.useCallback(()=>{if(!N||!l)return;let e=(0,u.getWindow)(r);if(!o.current.openEvent||x(o.current.openEvent))return g.current=(0,m.addEventListener)(e,"mousemove",function(e){let t=(0,f.getTarget)(e);(0,f.contains)(r,t)?(g.current?.(),g.current=null):w(e.clientX,e.clientY)}),()=>{g.current?.(),g.current=null};a.set("positionReference",i)},[N,l,r,o,i,a,w]);s.useEffect(()=>C(),[C,b]),s.useEffect(()=>{l&&!r&&(c.current=!1)},[l,r]),s.useEffect(()=>{!l&&n&&(c.current=!0)},[l,n]);let S=s.useMemo(()=>{function e(e){y(e.pointerType)}return{onPointerDown:e,onPointerEnter:e,onMouseMove:k,onMouseEnter:k}},[k]);return s.useMemo(()=>l?{reference:S,trigger:S}:{},[l,S])}(A,{enabled:!t&&"none"!==c,axis:"none"===c?void 0:c}),{getReferenceProps:V,getFloatingProps:J,getTriggerProps:Y}=(0,v.useInteractions)([W,_]),q=s.useMemo(()=>V(),[V]),K=s.useMemo(()=>Y(),[Y]),X=s.useMemo(()=>J(),[J]);return P.useSyncedValues({activeTriggerProps:q,inactiveTriggerProps:K,popupProps:X}),(0,n.jsx)(d.Provider,{value:P,children:"function"==typeof M?M({payload:O}):M})});var z=e.i(817955),F=e.i(969490),O=e.i(139236);let R=s.createContext(void 0);var I=e.i(499198),A=e.i(232449),L=e.i(49863);let B=s.createContext({hasProvider:!1,timeoutMs:0,delayRef:{current:0},initialDelayRef:{current:0},timeout:new A.Timeout,currentIdRef:{current:null},currentContextRef:{current:null}});function $(e){let{children:t,delay:a,timeoutMs:r=0}=e,i=s.useRef(a),o=s.useRef(a),l=s.useRef(null),d=s.useRef(null),c=(0,A.useTimeout)();return(0,n.jsx)(B.Provider,{value:s.useMemo(()=>({hasProvider:!0,delayRef:i,initialDelayRef:o,currentIdRef:l,timeoutMs:r,currentContextRef:d,timeout:c}),[r,c]),children:t})}var H=e.i(604921),U=e.i(480283);let W=((t={})[t.popupOpen=z.CommonTriggerDataAttributes.popupOpen]="popupOpen",t.triggerDisabled="data-trigger-disabled",t),_=(0,r.fastComponentRef)(function(e,t){let{className:a,render:n,handle:r,payload:i,disabled:d,delay:u,closeOnClick:m=!0,closeDelay:p,id:f,style:h,...x}=e,g=c(!0),v=r?.store??g;if(!v)throw Error((0,l.default)(82));let j=(0,O.useBaseUiId)(f),w=v.useState("isTriggerActive",j),k=v.useState("isOpenedByTrigger",j),N=v.useState("floatingRootContext"),C=s.useRef(null),T=u??600,M=p??0,{registerTrigger:P,isMountedByThisTrigger:E}=(0,b.useTriggerDataForwarding)(j,C,v,{payload:i,closeOnClick:m,closeDelay:M}),D=s.useContext(R),{delayRef:A,isInstantPhase:$,hasProvider:_}=function(e,t={open:!1}){let a="rootStore"in e?e.rootStore:e,n=a.useState("floatingId"),{open:r}=t,{currentIdRef:i,delayRef:l,timeoutMs:d,initialDelayRef:c,currentContextRef:u,hasProvider:m,timeout:p}=s.useContext(B),[f,h]=s.useState(!1);return(0,o.useIsoLayoutEffect)(()=>{function e(){h(!1),u.current?.setIsInstantPhase(!1),i.current=null,u.current=null,l.current=c.current}if(i.current&&!r&&i.current===n){if(h(!1),d)return p.start(d,()=>{a.select("open")||i.current&&i.current!==n||e()}),()=>{p.clear()};e()}},[r,n,i,l,d,c,u,p,a]),(0,o.useIsoLayoutEffect)(()=>{if(!r)return;let e=u.current,t=i.current;p.clear(),u.current={onOpenChange:a.setOpen,setIsInstantPhase:h},i.current=n,l.current={open:0,close:(0,L.getDelay)(c.current,"close")},null!==t&&t!==n?(h(!0),e?.setIsInstantPhase(!0),e?.onOpenChange(!1,(0,y.createChangeEventDetails)(S.REASONS.none))):(h(!1),e?.setIsInstantPhase(!1))},[r,n,a,i,l,d,c,u,p]),(0,o.useIsoLayoutEffect)(()=>()=>{u.current=null},[u]),s.useMemo(()=>({hasProvider:m,delayRef:l,isInstantPhase:f}),[m,l,f])}(N,{open:k});v.useSyncedValue("isInstantPhase",$);let V=v.useState("disabled"),J=d??V,Y=v.useState("trackCursorAxis"),q=v.useState("disableHoverablePopup"),K=(0,U.useHoverReferenceInteraction)(N,{enabled:!J,mouseOnly:!0,move:!1,handleClose:q||"both"===Y?null:(0,I.safePolygon)(),restMs(){let e=D?.delay,t="object"==typeof A.current?A.current.open:void 0,a=T;return _&&(a=0!==t?u??e??T:0),a},delay(){let e="object"==typeof A.current?A.current.close:void 0,t=M;return null==p&&_&&(t=e),{close:t}},triggerElementRef:C,isActiveTrigger:w,isClosing:()=>"ending"===v.select("transitionStatus")}),X=(0,H.useFocus)(N,{enabled:!J}).reference,G=v.useState("triggerProps",E);return(0,F.useRenderElement)("button",e,{state:{open:k},ref:[t,P,C],props:[K,X,G,{onPointerDown(){v.set("closeOnClick",m)},id:j,[W.triggerDisabled]:J?"":void 0},x],stateAttributesMapping:z.triggerOpenStateMapping})}),V=s.createContext(void 0);var J=e.i(384389);let Y=s.forwardRef(function(e,t){let{keepMounted:a=!1,...s}=e;return c().useState("mounted")||a?(0,n.jsx)(V.Provider,{value:a,children:(0,n.jsx)(J.FloatingPortalLite,{ref:t,...s})}):null}),q=s.createContext(void 0);function K(){let e=s.useContext(q);if(void 0===e)throw Error((0,l.default)(71));return e}var X=e.i(576557),G=e.i(576487),Q=e.i(909852),Z=e.i(263635);let ee=s.forwardRef(function(e,t){let{render:a,className:r,anchor:i,positionMethod:o="absolute",side:d="top",align:u="center",sideOffset:m=0,alignOffset:p=0,collisionBoundary:f="clipping-ancestors",collisionPadding:h=5,arrowPadding:x=5,sticky:g=!1,disableAnchorTracking:v=!1,collisionAvoidance:y=G.POPUP_COLLISION_AVOIDANCE,style:b,...j}=e,w=c(),k=function(){let e=s.useContext(V);if(void 0===e)throw Error((0,l.default)(70));return e}(),N=w.useState("open"),C=w.useState("mounted"),S=w.useState("trackCursorAxis"),T=w.useState("disableHoverablePopup"),M=w.useState("floatingRootContext"),P=w.useState("instantType"),E=w.useState("transitionStatus"),D=w.useState("hasViewport"),z=(0,X.useAnchorPositioning)({anchor:i,positionMethod:o,floatingRootContext:M,mounted:C,side:d,sideOffset:m,align:u,alignOffset:p,collisionBoundary:f,collisionPadding:h,sticky:g,arrowPadding:x,disableAnchorTracking:v,keepMounted:k,collisionAvoidance:y,adaptiveOrigin:D?Q.adaptiveOrigin:void 0}),F=s.useMemo(()=>({open:N,side:z.side,align:z.align,anchorHidden:z.anchorHidden,instant:"none"!==S?"tracking-cursor":P}),[N,z.side,z.align,z.anchorHidden,S,P]),O=(0,Z.usePositioner)(e,F,{styles:z.positionerStyles,transitionStatus:E,props:j,refs:[t,w.useStateSetter("positionerElement")],hidden:!C,inert:!N||"both"===S||T});return(0,n.jsx)(q.Provider,{value:z,children:O})});var et=e.i(282458),ea=e.i(273598),en=e.i(328657),es=e.i(795914);let er={...z.popupStateMapping,...et.transitionStatusMapping},ei=s.forwardRef(function(e,t){let{className:a,render:n,style:s,...r}=e,i=c(),{side:o,align:l}=K(),d=i.useState("open"),u=i.useState("instantType"),m=i.useState("transitionStatus"),p=i.useState("popupProps"),f=i.useState("floatingRootContext");(0,ea.useOpenChangeComplete)({open:d,ref:i.context.popupRef,onComplete(){d&&i.context.onOpenChangeComplete?.(!0)}});let h=i.useState("disabled"),x=i.useState("closeDelay");return(0,es.useHoverFloatingInteraction)(f,{enabled:!h,closeDelay:x}),(0,F.useRenderElement)("div",e,{state:{open:d,side:o,align:l,instant:u,transitionStatus:m},ref:[t,i.context.popupRef,i.useStateSetter("popupElement")],props:[p,(0,en.getDisabledMountTransitionStyles)(m),r],stateAttributesMapping:er})}),eo=s.forwardRef(function(e,t){let{className:a,render:n,style:s,...r}=e,i=c(),o=i.useState("open"),l=i.useState("instantType"),{arrowRef:d,side:u,align:m,arrowUncentered:p,arrowStyles:f}=K();return(0,F.useRenderElement)("div",e,{state:{open:o,side:u,align:m,uncentered:p,instant:l},ref:[t,d],props:[{style:f,"aria-hidden":!0},r],stateAttributesMapping:z.popupStateMapping})}),el=((a={}).popupWidth="--popup-width",a.popupHeight="--popup-height",a);var ed=e.i(3310);let ec={activationDirection:e=>e?{"data-activation-direction":e}:null},eu=s.forwardRef(function(e,t){let{render:a,className:n,style:s,children:r,...i}=e,o=c(),l=K(),d=o.useState("instantType"),{children:u,state:m}=(0,ed.usePopupViewport)({store:o,side:l.side,cssVars:el,children:r}),p={activationDirection:m.activationDirection,transitioning:m.transitioning,instant:d};return(0,F.useRenderElement)("div",e,{state:p,ref:t,props:[i,{children:u}],stateAttributesMapping:ec})});class em{constructor(){this.store=new E}open(e){let t=e?this.store.context.triggerElements.getById(e):void 0;if(e&&!t)throw Error((0,l.default)(81,e));this.store.setOpen(!0,(0,y.createChangeEventDetails)(S.REASONS.imperativeAction,void 0,t))}close(){this.store.setOpen(!1,(0,y.createChangeEventDetails)(S.REASONS.imperativeAction,void 0,void 0))}get isOpen(){return this.store.state.open}}e.s(["Arrow",0,eo,"Handle",0,em,"Popup",0,ei,"Portal",0,Y,"Positioner",0,ee,"Provider",0,function(e){let{delay:t,closeDelay:a,timeout:r=400}=e,i=s.useMemo(()=>({delay:t,closeDelay:a}),[t,a]),o=s.useMemo(()=>({open:t,close:a}),[t,a]);return(0,n.jsx)(R.Provider,{value:i,children:(0,n.jsx)($,{delay:o,timeoutMs:r,children:e.children})})},"Root",0,D,"Trigger",0,_,"Viewport",0,eu,"createHandle",0,function(){return new em}],638295);var ep=e.i(638295),ep=ep,ef=e.i(465458);e.s(["Tooltip",0,function({...e}){return(0,n.jsx)(ep.Root,{"data-slot":"tooltip",...e})},"TooltipContent",0,function({className:e,side:t="top",sideOffset:a=4,align:s="center",alignOffset:r=0,children:i,...o}){return(0,n.jsx)(ep.Portal,{children:(0,n.jsx)(ep.Positioner,{align:s,alignOffset:r,side:t,sideOffset:a,className:"isolate z-50",children:(0,n.jsxs)(ep.Popup,{"data-slot":"tooltip-content",className:(0,ef.cn)("z-50 inline-flex w-fit max-w-xs origin-(--transform-origin) items-center gap-1.5 rounded-md bg-foreground px-3 py-1.5 text-xs text-background has-data-[slot=kbd]:pr-1.5 data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 **:data-[slot=kbd]:relative **:data-[slot=kbd]:isolate **:data-[slot=kbd]:z-50 **:data-[slot=kbd]:rounded-sm data-[state=delayed-open]:animate-in data-[state=delayed-open]:fade-in-0 data-[state=delayed-open]:zoom-in-95 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",e),...o,children:[i,(0,n.jsx)(ep.Arrow,{className:"z-50 size-2.5 translate-y-[calc(-50%-2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground data-[side=bottom]:top-1 data-[side=inline-end]:top-1/2! data-[side=inline-end]:-left-1 data-[side=inline-end]:-translate-y-1/2 data-[side=inline-start]:top-1/2! data-[side=inline-start]:-right-1 data-[side=inline-start]:-translate-y-1/2 data-[side=left]:top-1/2! data-[side=left]:-right-1 data-[side=left]:-translate-y-1/2 data-[side=right]:top-1/2! data-[side=right]:-left-1 data-[side=right]:-translate-y-1/2 data-[side=top]:-bottom-2.5"})]})})})},"TooltipProvider",0,function({delay:e=0,...t}){return(0,n.jsx)(ep.Provider,{"data-slot":"tooltip-provider",delay:e,...t})},"TooltipTrigger",0,function({...e}){return(0,n.jsx)(ep.Trigger,{"data-slot":"tooltip-trigger",...e})}],638322)},817854,e=>{"use strict";var t=e.i(344180),a=e.i(465458);e.s(["Label",0,function({className:e,...n}){return(0,t.jsx)("label",{"data-slot":"label",className:(0,a.cn)("flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",e),...n})}])},244996,444741,e=>{"use strict";let t=(0,e.i(433721).default)("circle-check",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);e.s(["default",0,t],444741),e.s(["CheckCircle2",0,t],244996)},92457,e=>{"use strict";let t=(0,e.i(433721).default)("monitor",[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]]);e.s(["Monitor",0,t],92457)},36539,e=>{"use strict";let t=(0,e.i(433721).default)("bell",[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326",key:"11g9vi"}]]);e.s(["default",0,t])},255742,e=>{"use strict";let t=(0,e.i(433721).default)("star",[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z",key:"r04s7s"}]]);e.s(["Star",0,t],255742)},111343,e=>{"use strict";let t=(0,e.i(433721).default)("save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]);e.s(["Save",0,t],111343)},974267,(e,t,a)=>{"use strict";Object.defineProperty(a,"__esModule",{value:!0}),Object.defineProperty(a,"BailoutToCSR",{enumerable:!0,get:function(){return s}});let n=e.r(981225);function s({reason:e,children:t}){if("u"<typeof window)throw Object.defineProperty(new n.BailoutToCSRError(e),"__NEXT_ERROR_CODE",{value:"E394",enumerable:!1,configurable:!0});return t}},404590,(e,t,a)=>{"use strict";function n(e){return e.split("/").map(e=>encodeURIComponent(e)).join("/")}Object.defineProperty(a,"__esModule",{value:!0}),Object.defineProperty(a,"encodeURIPath",{enumerable:!0,get:function(){return n}})},172441,(e,t,a)=>{"use strict";Object.defineProperty(a,"__esModule",{value:!0}),Object.defineProperty(a,"PreloadChunks",{enumerable:!0,get:function(){return l}});let n=e.r(344180),s=e.r(106206),r=e.r(94932),i=e.r(404590),o=e.r(745137);function l({moduleIds:e}){if("u">typeof window)return null;let t=r.workAsyncStorage.getStore();if(void 0===t)return null;let a=[];if(t.reactLoadableManifest&&e){let n=t.reactLoadableManifest;for(let t of e){if(!n[t])continue;let e=n[t].files;a.push(...e)}}if(0===a.length)return null;let d=(0,o.getAssetTokenQuery)();return(0,n.jsx)(n.Fragment,{children:a.map(e=>{let a=`${t.assetPrefix}/_next/${(0,i.encodeURIPath)(e)}${d}`;return e.endsWith(".css")?(0,n.jsx)("link",{precedence:"dynamic",href:a,rel:"stylesheet",as:"style",nonce:t.nonce},e):((0,s.preload)(a,{as:"script",fetchPriority:"low",nonce:t.nonce}),null)})})}},672479,(e,t,a)=>{"use strict";Object.defineProperty(a,"__esModule",{value:!0}),Object.defineProperty(a,"default",{enumerable:!0,get:function(){return d}});let n=e.r(344180),s=e.r(764556),r=e.r(974267),i=e.r(172441);function o(e){return{default:e&&"default"in e?e.default:e}}let l={loader:()=>Promise.resolve(o(()=>null)),loading:null,ssr:!0},d=function(e){let t={...l,...e},a=(0,s.lazy)(()=>t.loader().then(o)),d=t.loading;function c(e){let o=d?(0,n.jsx)(d,{isLoading:!0,pastDelay:!0,error:null}):null,l=!t.ssr||!!t.loading,c=l?s.Suspense:s.Fragment,u=t.ssr?(0,n.jsxs)(n.Fragment,{children:["u"<typeof window?(0,n.jsx)(i.PreloadChunks,{moduleIds:t.modules}):null,(0,n.jsx)(a,{...e})]}):(0,n.jsx)(r.BailoutToCSR,{reason:"next/dynamic",children:(0,n.jsx)(a,{...e})});return(0,n.jsx)(c,{...l?{fallback:o}:{},children:u})}return c.displayName="LoadableComponent",c}},887836,(e,t,a)=>{"use strict";Object.defineProperty(a,"__esModule",{value:!0}),Object.defineProperty(a,"default",{enumerable:!0,get:function(){return s}});let n=e.r(481258)._(e.r(672479));function s(e,t){let a={};"function"==typeof e&&(a.loader=e);let s={...a,...t};return(0,n.default)({...s,modules:s.loadableGenerated?.modules})}("function"==typeof a.default||"object"==typeof a.default&&null!==a.default)&&void 0===a.default.__esModule&&(Object.defineProperty(a.default,"__esModule",{value:!0}),Object.assign(a.default,a),t.exports=a.default)},977694,e=>{"use strict";let t=(0,e.i(433721).default)("rocket",[["path",{d:"M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5",key:"qeys4"}],["path",{d:"M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09",key:"u4xsad"}],["path",{d:"M9 12a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.4 22.4 0 0 1-4 2z",key:"676m9"}],["path",{d:"M9 12H4s.55-3.03 2-4c1.62-1.08 5 .05 5 .05",key:"92ym6u"}]]);e.s(["Rocket",0,t],977694)},401058,e=>{"use strict";let t=(0,e.i(433721).default)("ellipsis-vertical",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}]]);e.s(["MoreVertical",0,t],401058)},239340,e=>{"use strict";var t=e.i(344180),a=e.i(209988),n=e.i(260218),s=e.i(611176),r=e.i(972846),i=e.i(465458);e.s(["AgentPickerDialog",0,function({open:e,onClose:o,onConfirm:l,title:d,description:c,agents:u,selected:m,onToggle:p,cancelText:f,confirmText:h,loading:x}){return(0,t.jsx)(a.Dialog,{open:e,onOpenChange:e=>{e||o()},children:(0,t.jsxs)(a.DialogContent,{className:"sm:max-w-sm flex flex-col gap-0 overflow-hidden p-0",children:[(0,t.jsxs)(a.DialogHeader,{className:"shrink-0 px-6 py-4",children:[(0,t.jsx)(a.DialogTitle,{children:d}),c&&(0,t.jsx)(a.DialogDescription,{children:c})]}),(0,t.jsxs)("div",{className:"min-h-0 flex-1 pb-2 overflow-y-auto px-6 space-y-3",children:[(0,t.jsx)("div",{className:"space-y-0.5",children:u.map(e=>(0,t.jsxs)("button",{type:"button",onClick:()=>p(e.id),className:"flex items-center gap-2 w-full px-2 py-1.5 rounded-md hover:bg-muted text-left text-sm transition-colors",children:[(0,t.jsx)(s.AgentIcon,{agentId:e.id,name:e.name,avatarUrl:e.avatarUrl,className:"size-5 rounded-full"}),(0,t.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,t.jsx)("span",{className:"block truncate",children:e.name}),e.description&&(0,t.jsx)("span",{className:"block truncate text-xs text-muted-foreground",children:e.description})]}),(0,t.jsx)("div",{className:(0,i.cn)("flex items-center justify-center size-4 rounded border shrink-0",m.includes(e.id)?"bg-primary border-primary text-primary-foreground":"border-input")})]},e.id))}),m.length>0&&(0,t.jsx)("div",{className:"flex flex-wrap gap-1.5",children:m.map(e=>{let a=u.find(t=>t.id===e);return(0,t.jsxs)("span",{className:"inline-flex items-center gap-1 rounded-md bg-muted px-2 py-0.5 text-xs max-w-[160px] min-w-0",children:[(0,t.jsx)(s.AgentIcon,{agentId:e,name:a?.name,avatarUrl:a?.avatarUrl,className:"size-3.5 rounded-full shrink-0"}),(0,t.jsx)("span",{className:"truncate",children:a?.name||e}),(0,t.jsx)("button",{type:"button",onClick:()=>p(e),className:"hover:text-destructive shrink-0 cursor-pointer",children:(0,t.jsx)(r.X,{className:"size-3"})})]},e)})})]}),(0,t.jsxs)("div",{className:"shrink-0 flex justify-end gap-2 border-t px-6 py-4",children:[(0,t.jsx)(n.Button,{variant:"outline",onClick:o,children:f||"Cancel"}),(0,t.jsx)(n.Button,{onClick:l,disabled:x||0===m.length,children:h||"Confirm"})]})]})})}])},973767,e=>{"use strict";let t=(0,e.i(433721).default)("star-off",[["path",{d:"m10.344 4.688 1.181-2.393a.53.53 0 0 1 .95 0l2.31 4.679a2.12 2.12 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.237 3.152",key:"19ctli"}],["path",{d:"m17.945 17.945.43 2.505a.53.53 0 0 1-.771.56l-4.618-2.428a2.12 2.12 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.12 2.12 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a8 8 0 0 0 .4-.099",key:"ptqqvy"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);e.s(["StarOff",0,t],973767)},191202,e=>{"use strict";let t=(0,e.i(433721).default)("plug",[["path",{d:"M12 22v-5",key:"1ega77"}],["path",{d:"M15 8V2",key:"18g5xt"}],["path",{d:"M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z",key:"1xoxul"}],["path",{d:"M9 8V2",key:"14iosj"}]]);e.s(["Plug",0,t],191202)},22906,e=>{"use strict";var t=e.i(344180),a=e.i(764556),n=e.i(244073),s=e.i(887836),r=e.i(209988),i=e.i(260218),o=e.i(681622),l=e.i(788010),d=e.i(191118),c=e.i(917955),u=e.i(996652),m=e.i(188815),p=e.i(611176),f=e.i(239340),h=e.i(255742),x=e.i(973767),g=e.i(129981),v=e.i(887354),y=e.i(191202),b=e.i(401058),j=e.i(137340),w=e.i(977694),k=e.i(111343),N=e.i(465458);e.i(462506);let C=(0,s.default)(()=>e.A(863812).then(e=>e.default),{loadableGenerated:{modules:[158480]},ssr:!1,loading:()=>(0,t.jsx)("div",{className:"flex items-center justify-center h-full text-muted-foreground text-sm",children:"Loading editor..."})});e.s(["McpsDialog",0,function({open:e,onOpenChange:s,standalone:S}){let T=(0,n.useTranslations)("mcps"),M=(0,n.useTranslations)("common"),[P,E]=(0,a.useState)([]),[D,z]=(0,a.useState)([]),[F,O]=(0,a.useState)(!1),[R,I]=(0,a.useState)(""),[A,L]=(0,a.useState)("all"),[B,$]=(0,a.useState)(""),[H,U]=(0,a.useState)(!1),[W,_]=(0,a.useState)(""),[V,J]=(0,a.useState)(""),[Y,q]=(0,a.useState)(null),[K,X]=(0,a.useState)([]),[G,Q]=(0,a.useState)(null),[Z,ee]=(0,a.useState)(""),et=(0,a.useCallback)(async()=>{O(!0);try{let e=await fetch("/api/mcps");e.ok&&E(await e.json())}catch{}O(!1)},[]),ea=(0,a.useCallback)(async()=>{try{let e=await fetch("/api/agents/presets");if(e.ok){let t=await e.json();z(t.map(e=>({id:e.id,name:e.name,avatarUrl:e.avatarUrl,description:e.description})))}}catch{}},[]);(0,a.useEffect)(()=>{(e||S)&&(et(),ea())},[e,S,et,ea]);let en=async e=>{try{let t=await fetch(`/api/mcps/${encodeURIComponent(e.name)}/favorite`,{method:"POST"});if(t.ok){let{favorited:a}=await t.json();E(t=>t.map(t=>t.name===e.name?{...t,favorited:a}:t))}}catch{}},es=async()=>{J("");try{JSON.parse(W)}catch{J(T("importInvalidJson"));return}try{let e=await fetch("/api/mcps/import",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({jsonText:W})});if(e.ok)_(""),U(!1),et();else{let t=await e.json();J(t.error||T("importFailed"))}}catch{J(T("importFailed"))}},er=async()=>{let e;if(G){try{e=JSON.parse(Z)}catch{return}try{(await fetch(`/api/mcps/${encodeURIComponent(G.name)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({config:e})})).ok&&(E(t=>t.map(t=>t.name===G.name?{...t,config:e}:t)),Q(null))}catch{}}},ei=async e=>{try{(await fetch(`/api/mcps/${encodeURIComponent(e.name)}`,{method:"DELETE"})).ok&&E(t=>t.filter(t=>t.name!==e.name))}catch{}},eo=async()=>{if(Y){for(let e of D){let t=Y.boundAgents.some(t=>t.id===e.id),a=K.includes(e.id);if(t&&!a){let t=await fetch(`/api/agents/presets/${e.id}`);if(!t.ok)continue;let a=await t.json(),n=a.mcps||{},s={...n.mcpServers||{}};delete s[Y.name],await fetch(`/api/agents/presets/${e.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,mcps:{...n,mcpServers:s}})})}else if(!t&&a){let t=await fetch(`/api/agents/presets/${e.id}`);if(!t.ok)continue;let a=await t.json(),n=a.mcps||{},s={...n.mcpServers||{}};Y.name in s||(s[Y.name]=Y.config,await fetch(`/api/agents/presets/${e.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,mcps:{...n,mcpServers:s}})}))}}q(null),et()}},el=P.filter(e=>{if(R){let t=R.toLowerCase();if(!e.name.toLowerCase().includes(t)&&!e.description.toLowerCase().includes(t))return!1}return("favorites"!==A||!!e.favorited)&&("agent"!==A||!B||!!e.boundAgents.some(e=>e.id===B))}),ed=(S||e)&&!Y&&!G,ec=(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(r.DialogHeader,{children:(0,t.jsxs)("div",{className:"flex items-center justify-between pr-8 pt-2",children:[(0,t.jsxs)("div",{className:"hidden md:block",children:[S?(0,t.jsx)("h2",{className:"text-base font-semibold",children:T("title")}):(0,t.jsx)(r.DialogTitle,{children:T("title")}),S?(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:T("description")}):(0,t.jsx)(r.DialogDescription,{children:T("description")})]}),(0,t.jsx)("div",{className:"flex items-center gap-2",children:(0,t.jsxs)(u.Popover,{open:H,onOpenChange:U,children:[(0,t.jsx)(u.PopoverTrigger,{render:(0,t.jsxs)(i.Button,{variant:"outline",size:"sm",children:[(0,t.jsx)(g.Upload,{className:"size-3.5 mr-1"}),T("import")]})}),(0,t.jsx)(u.PopoverContent,{className:"w-96",align:"end",children:(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsx)("p",{className:"text-sm font-medium",children:T("importTitle")}),(0,t.jsx)(l.Textarea,{value:W,onChange:e=>{_(e.target.value),J("")},placeholder:'{\n "mcpServers": {\n "server-name": {\n "command": "npx",\n "args": ["-y", "package"],\n "env": {}\n }\n }\n}',className:"font-mono text-xs min-h-[180px] resize-none"}),V&&(0,t.jsx)("p",{className:"text-xs text-destructive",children:V}),(0,t.jsx)(i.Button,{size:"sm",onClick:es,disabled:!W.trim(),className:"w-full",children:T("importConfirm")})]})})]})})]})}),(0,t.jsxs)("div",{className:"flex flex-1 min-h-0 gap-4 pt-2",children:[(0,t.jsxs)("div",{className:"hidden md:flex w-44 shrink-0 flex-col gap-3",children:[(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsxs)(i.Button,{variant:"all"===A?"secondary":"ghost",size:"sm",className:"w-full justify-start",onClick:()=>{L("all"),$("")},children:[(0,t.jsx)(y.Plug,{className:"size-3.5 mr-1.5"}),T("filterAll")]}),(0,t.jsxs)(i.Button,{variant:"favorites"===A?"secondary":"ghost",size:"sm",className:"w-full justify-start",onClick:()=>{L("favorites"),$("")},children:[(0,t.jsx)(h.Star,{className:"size-3.5 mr-1.5"}),T("filterFavorites")]})]}),D.length>0&&(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)("p",{className:"text-xs font-medium text-muted-foreground px-2",children:T("filterByAgent")}),(0,t.jsx)(d.ScrollArea,{className:"max-h-48",children:D.map(e=>(0,t.jsxs)(i.Button,{variant:"agent"===A&&B===e.id?"secondary":"ghost",size:"sm",className:"w-full justify-start",onClick:()=>{L("agent"),$(e.id)},children:[(0,t.jsx)(p.AgentIcon,{agentId:e.id,name:e.name,avatarUrl:e.avatarUrl,className:"size-4 mr-1.5 rounded-full"}),(0,t.jsx)("span",{className:"truncate",children:e.name})]},e.id))})]})]}),(0,t.jsxs)("div",{className:"flex-1 min-w-0 flex flex-col gap-3",children:[(0,t.jsxs)("div",{className:"flex md:hidden flex-col gap-2",children:[(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsx)(v.Search,{className:"size-3.5 absolute left-2.5 top-1/2 -translate-y-1/2 text-muted-foreground"}),(0,t.jsx)(o.Input,{value:R,onChange:e=>I(e.target.value),placeholder:T("search"),className:"pl-8"})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsxs)("div",{className:"flex rounded-lg border border-input p-0.5",children:[(0,t.jsx)("button",{type:"button",className:(0,N.cn)("px-2.5 py-1 rounded-md text-xs font-medium transition-colors","all"===A?"bg-muted":"text-muted-foreground hover:text-foreground"),onClick:()=>{L("all"),$("")},children:T("filterAll")}),(0,t.jsxs)("button",{type:"button",className:(0,N.cn)("px-2.5 py-1 rounded-md text-xs font-medium transition-colors","favorites"===A?"bg-muted":"text-muted-foreground hover:text-foreground"),onClick:()=>{L("favorites"),$("")},children:[(0,t.jsx)(h.Star,{className:"size-3 inline-block mr-0.5 -mt-px"}),T("filterFavorites")]})]}),D.length>0&&(0,t.jsx)(m.SearchSelect,{value:"agent"===A?B:"",onChange:e=>{e?(L("agent"),$(e)):(L("all"),$(""))},options:D.map(e=>({value:e.id,label:e.name})),placeholder:T("filterByAgent"),allowCustom:!1,className:"flex-1 min-w-0"})]})]}),(0,t.jsxs)("div",{className:"hidden md:block relative",children:[(0,t.jsx)(v.Search,{className:"size-3.5 absolute left-2.5 top-1/2 -translate-y-1/2 text-muted-foreground"}),(0,t.jsx)(o.Input,{value:R,onChange:e=>I(e.target.value),placeholder:T("search"),className:"pl-8"})]}),(0,t.jsx)(d.ScrollArea,{className:"flex-1",children:F?(0,t.jsx)("div",{className:"flex items-center justify-center py-12 text-muted-foreground text-sm",children:M("loading")}):0===el.length?(0,t.jsx)("div",{className:"flex items-center justify-center py-12 text-muted-foreground text-sm",children:T("empty")}):(0,t.jsx)("div",{className:"grid grid-cols-1 gap-3 pr-2",children:el.map(e=>(0,t.jsxs)("div",{className:"rounded-xl border border-border bg-background p-4 hover:bg-accent/30 transition-colors cursor-pointer",onClick:()=>{Q(e),ee(JSON.stringify(e.config,null,2))},children:[(0,t.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,t.jsx)(y.Plug,{className:"size-3.5 text-muted-foreground"}),(0,t.jsx)("span",{className:"font-medium text-sm",children:e.name}),(0,t.jsx)("button",{type:"button",className:"flex items-center justify-center size-5 rounded hover:bg-accent cursor-pointer",onClick:t=>{t.stopPropagation(),en(e)},children:e.favorited?(0,t.jsx)(h.Star,{className:"size-3.5 text-yellow-500 fill-yellow-500"}):(0,t.jsx)(x.StarOff,{className:"size-3.5 text-muted-foreground"})})]}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground mt-1 line-clamp-2",children:e.description||e.config.command||e.config.url||JSON.stringify(e.config).slice(0,100)})]}),(0,t.jsxs)("div",{className:"flex items-center gap-1 shrink-0",onClick:e=>e.stopPropagation(),children:[(0,t.jsxs)(i.Button,{variant:"outline",size:"sm",onClick:()=>{q(e),X(e.boundAgents.map(e=>e.id))},children:[(0,t.jsx)(w.Rocket,{className:"size-3.5 mr-1"}),T("apply")]}),(0,t.jsxs)(c.DropdownMenu,{children:[(0,t.jsx)(c.DropdownMenuTrigger,{render:(0,t.jsx)(i.Button,{variant:"ghost",size:"icon",className:"size-7"}),children:(0,t.jsx)(b.MoreVertical,{className:"size-3.5"})}),(0,t.jsx)(c.DropdownMenuContent,{align:"end",children:(0,t.jsxs)(c.DropdownMenuItem,{className:"text-destructive focus:text-destructive",onClick:()=>ei(e),children:[(0,t.jsx)(j.Trash2,{className:"size-3.5 mr-1.5"}),T("delete")]})})]})]})]}),e.boundAgents.length>0&&(0,t.jsxs)("div",{className:"flex items-center gap-1.5 mt-2.5 pt-2.5 border-t border-border/50",children:[e.boundAgents.map(e=>(0,t.jsx)(p.AgentIcon,{agentId:e.id,name:e.name,avatarUrl:e.avatarUrl,className:"size-5 rounded-full"},e.id)),(0,t.jsx)("span",{className:"text-xs text-muted-foreground ml-1",children:e.boundAgents.length})]})]},e.name))})})]})]})]});return(0,t.jsxs)(t.Fragment,{children:[S&&ed&&(0,t.jsx)("div",{className:"h-full flex flex-col",children:ec}),!S&&(0,t.jsx)(r.Dialog,{open:ed,onOpenChange:s,children:(0,t.jsx)(r.DialogContent,{className:"!w-[80vw] !max-w-[80vw] !h-[80vh] flex flex-col",children:ec})}),(0,t.jsx)(r.Dialog,{open:!!G,onOpenChange:e=>{e||Q(null)},children:(0,t.jsxs)(r.DialogContent,{className:"!w-[80vw] !max-w-[80vw] !h-[80vh] flex flex-col",children:[(0,t.jsx)(r.DialogHeader,{children:(0,t.jsxs)("div",{className:"flex items-center justify-between pr-8",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)(r.DialogTitle,{children:T("editTitle",{name:G?.name||""})}),(0,t.jsx)(r.DialogDescription,{children:T("editDescription")})]}),(0,t.jsxs)(i.Button,{size:"sm",onClick:er,children:[(0,t.jsx)(k.Save,{className:"size-3.5 mr-1"}),M("save")]})]})}),(0,t.jsx)("div",{className:"flex-1 min-h-0 pt-2",children:(0,t.jsx)(C,{height:"100%",language:"json",value:Z,onChange:e=>ee(e||""),theme:"vs-dark",options:{fontSize:13,minimap:{enabled:!1},scrollBeyondLastLine:!1,padding:{top:8},renderLineHighlight:"gutter",wordWrap:"on",formatOnPaste:!0}})})]})}),(0,t.jsx)(f.AgentPickerDialog,{open:!!Y,onClose:()=>q(null),onConfirm:eo,title:T("bindTitle",{name:Y?.name||""}),description:T("bindDescription"),agents:D,selected:K,onToggle:e=>{X(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},cancelText:M("cancel"),confirmText:M("confirm")})]})}])},962562,995684,e=>{"use strict";let t=(0,e.i(433721).default)("pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]);e.s(["default",0,t],995684),e.s(["Pencil",0,t],962562)},992764,e=>{"use strict";var t=e.i(942917);e.s(["ChevronRight",()=>t.default])},62669,e=>{"use strict";let t=(0,e.i(433721).default)("loader-circle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);e.s(["Loader2",0,t],62669)},378371,e=>{"use strict";let t=(0,e.i(433721).default)("arrow-up",[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]]);e.s(["ArrowUp",0,t],378371)},973370,220336,e=>{"use strict";let t=(0,e.i(433721).default)("folder",[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]);e.s(["default",0,t],220336),e.s(["Folder",0,t],973370)},411649,e=>{"use strict";let t=(0,e.i(433721).default)("house",[["path",{d:"M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8",key:"5wwlr5"}],["path",{d:"M3 10a2 2 0 0 1 .709-1.528l7-6a2 2 0 0 1 2.582 0l7 6A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"r6nss1"}]]);e.s(["Home",0,t],411649)},550080,e=>{"use strict";var t=e.i(144988);e.s(["File",()=>t.default])},198699,e=>{"use strict";let t=(0,e.i(433721).default)("folder-plus",[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]);e.s(["FolderPlus",0,t],198699)},434805,e=>{"use strict";var t=e.i(344180),a=e.i(764556),n=e.i(244073),s=e.i(550080),r=e.i(973370),i=e.i(451534),o=e.i(992764),l=e.i(378371),d=e.i(411649),c=e.i(62669),u=e.i(198699),m=e.i(344118),p=e.i(972846),f=e.i(433721);let h=(0,f.default)("shield-check",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]),x=(0,f.default)("shield-alert",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]]),g=(0,f.default)("shield-off",[["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M5 5a1 1 0 0 0-1 1v7c0 5 3.5 7.5 7.67 8.94a1 1 0 0 0 .67.01c2.35-.82 4.48-1.97 5.9-3.71",key:"1jlk70"}],["path",{d:"M9.309 3.652A12.252 12.252 0 0 0 11.24 2.28a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1v7a9.784 9.784 0 0 1-.08 1.264",key:"18rp1v"}]]);var v=e.i(465458),y=e.i(681622),b=e.i(996652);e.s(["FolderPicker",0,function({value:e,onChange:f,className:j,placeholder:w="/path/to/project",allowFiles:k=!1,fileFilter:N}){let[C,S]=(0,a.useState)(!1),[T,M]=(0,a.useState)(e||""),[P,E]=(0,a.useState)([]),[D,z]=(0,a.useState)([]),F=(0,n.useTranslations)("folderPicker"),[O,R]=(0,a.useState)(null),[I,A]=(0,a.useState)(!1),[L,B]=(0,a.useState)(""),[$,H]=(0,a.useState)(!1),[U,W]=(0,a.useState)(""),[_,V]=(0,a.useState)(null),[J,Y]=(0,a.useState)(!1),q=(0,a.useRef)(null),K=(0,a.useRef)(null),X=(0,a.useRef)(null),G=(0,a.useCallback)(async e=>{if(!e)return void V(null);Y(!0);try{let t=await fetch(`/api/folder/check-permissions?path=${encodeURIComponent(e)}`);if(!t.ok)return void V(null);let a=await t.json();V(a)}catch{V(null)}finally{Y(!1)}},[]),Q=(0,a.useCallback)(async e=>{A(!0),B("");try{let t=`/api/folder/browse?path=${encodeURIComponent(e)}`;k&&(t+="&files=1",N&&(t+=`&fileFilter=${encodeURIComponent(N)}`));let a=await fetch(t);if(!a.ok)throw Error((await a.json()).error||"Failed to browse");let n=await a.json();M(n.path),E(n.directories),z(n.files??[]),R(n.parent),G(n.path)}catch(e){B(e instanceof Error?e.message:String(e))}finally{A(!1)}},[G,k,N]);(0,a.useEffect)(()=>{C&&Q(e||"")},[C,Q,e]),(0,a.useEffect)(()=>{$&&X.current&&X.current.focus()},[$]);let Z=e=>{Q(e)},ee=async()=>{let e=U.trim();if(!e)return;let t=T.includes("/")?"/":"\\",a=T?`${T}${t}${e}`:e;try{let e=await fetch("/api/folder/create",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:a})});if(!e.ok)throw Error((await e.json()).error||"Failed to create folder");H(!1),W(""),f(a),M(a),S(!1)}catch(e){B(e instanceof Error?e.message:String(e))}},et=P.length>0||D.length>0;return(0,t.jsx)("div",{className:(0,v.cn)("relative",j),children:(0,t.jsxs)("div",{className:"flex gap-1.5",children:[(0,t.jsx)(y.Input,{className:"rounded-xl py-2.5",placeholder:w,value:e,onChange:e=>{f(e.target.value)},onKeyDown:t=>{"Enter"===t.key&&(t.preventDefault(),Q(e))},ref:q}),(0,t.jsxs)(b.Popover,{open:C,onOpenChange:e=>{S(e),e||(H(!1),W(""))},children:[(0,t.jsxs)(b.PopoverTrigger,{className:(0,v.cn)("flex items-center gap-1.5 rounded-xl border px-3 py-2.5 text-sm transition-colors",C?"border-primary bg-primary/5 text-primary":"border-border bg-background text-muted-foreground hover:bg-accent hover:text-accent-foreground"),children:[(0,t.jsx)(i.FolderOpen,{className:"size-4"}),"Browse"]}),(0,t.jsx)(b.PopoverContent,{align:"start",className:"w-[var(--radix-popover-trigger-width)] p-0 overflow-hidden rounded-xl",style:{height:360},children:(0,t.jsxs)("div",{className:"flex h-full flex-col",children:[(0,t.jsxs)("div",{className:"flex items-center gap-1.5 border-b border-border px-3 py-2",children:[(0,t.jsx)("button",{type:"button",onClick:()=>Z(""),className:"flex size-7 items-center justify-center rounded-md hover:bg-accent transition-colors cursor-pointer",title:"Home",children:(0,t.jsx)(d.Home,{className:"size-3.5"})}),(0,t.jsx)("button",{type:"button",onClick:()=>{O&&Q(O)},className:"flex size-7 items-center justify-center rounded-md hover:bg-accent transition-colors cursor-pointer",title:"Go up",children:(0,t.jsx)(l.ArrowUp,{className:"size-3.5"})}),(0,t.jsx)(y.Input,{className:"truncate bg-muted text-xs text-muted-foreground font-mono focus-visible:bg-background h-7",value:T,onChange:e=>M(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),Q(T))}}),(0,t.jsx)("button",{type:"button",onClick:()=>{H(!0),W("")},className:"flex size-7 items-center justify-center rounded-md hover:bg-accent transition-colors cursor-pointer",title:F("newFolder"),children:(0,t.jsx)(u.FolderPlus,{className:"size-3.5"})}),!k&&(0,t.jsx)("button",{type:"button",onClick:()=>{f(T),S(!1)},className:"flex size-7 items-center justify-center rounded-md bg-primary text-primary-foreground hover:bg-primary/90 transition-colors cursor-pointer",title:F("select"),children:(0,t.jsx)(m.Check,{className:"size-3.5"})})]}),$&&(0,t.jsxs)("div",{className:"flex items-center gap-1.5 border-b border-border px-3 py-1.5",children:[(0,t.jsx)(u.FolderPlus,{className:"size-4 text-muted-foreground shrink-0"}),(0,t.jsx)(y.Input,{ref:X,className:"flex-1 h-7 text-sm",placeholder:F("folderNamePlaceholder"),value:U,onChange:e=>W(e.target.value),onKeyDown:e=>{"Enter"===e.key?(e.preventDefault(),ee()):"Escape"===e.key&&(H(!1),W(""))}}),(0,t.jsx)("button",{type:"button",onClick:ee,className:"flex size-6 items-center justify-center rounded-md hover:bg-accent transition-colors cursor-pointer",disabled:!U.trim(),children:(0,t.jsx)(m.Check,{className:"size-3.5 text-primary"})}),(0,t.jsx)("button",{type:"button",onClick:()=>{H(!1),W("")},className:"flex size-6 items-center justify-center rounded-md hover:bg-accent transition-colors cursor-pointer",children:(0,t.jsx)(p.X,{className:"size-3.5 text-muted-foreground"})})]}),(0,t.jsx)("div",{ref:K,className:"flex-1 overflow-y-auto p-1.5",children:I?(0,t.jsxs)("div",{className:"flex items-center justify-center py-8 text-muted-foreground",children:[(0,t.jsx)(c.Loader2,{className:"size-4 animate-spin mr-2"}),"Loading..."]}):L?(0,t.jsx)("div",{className:"px-3 py-8 text-center text-xs text-destructive",children:L}):et?(0,t.jsxs)(t.Fragment,{children:[P.map(e=>(0,t.jsxs)("button",{type:"button",onClick:()=>Z(e.path),onDoubleClick:()=>{f(e.path),S(!1)},className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-sm hover:bg-accent transition-colors text-left",children:[(0,t.jsx)(r.Folder,{className:"size-4 text-muted-foreground shrink-0"}),(0,t.jsx)("span",{className:"flex-1 truncate",children:e.name}),(0,t.jsx)(o.ChevronRight,{className:"size-3 text-muted-foreground shrink-0"})]},e.path)),D.map(e=>(0,t.jsxs)("button",{type:"button",onClick:()=>{f(e.path),S(!1)},className:"flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-sm hover:bg-accent transition-colors text-left",children:[(0,t.jsx)(s.File,{className:"size-4 text-muted-foreground shrink-0"}),(0,t.jsx)("span",{className:"flex-1 truncate font-mono text-xs",children:e.name})]},e.path))]}):(0,t.jsx)("div",{className:"px-3 py-8 text-center text-xs text-muted-foreground",children:"No subdirectories"})}),(0,t.jsx)("div",{className:"border-t border-border px-3 py-1.5 flex items-center gap-2 text-xs",children:J?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(c.Loader2,{className:"size-3 animate-spin text-muted-foreground"}),(0,t.jsx)("span",{className:"text-muted-foreground",children:"Checking permissions..."})]}):_?(0,t.jsx)(t.Fragment,{children:_.readable&&_.writable?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(h,{className:"size-3.5 text-green-500"}),(0,t.jsx)("span",{className:"text-green-600 dark:text-green-400",children:"Read/Write"})]}):_.readable&&!_.writable?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(x,{className:"size-3.5 text-amber-500"}),(0,t.jsx)("span",{className:"text-amber-600 dark:text-amber-400",children:"Read-only — files cannot be written here"})]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(g,{className:"size-3.5 text-destructive"}),(0,t.jsx)("span",{className:"text-destructive",children:_.error||"No access"})]})}):(0,t.jsx)("span",{className:"text-muted-foreground",children:F("selectDirectory")})})]})})]})]})})}],434805)},524,e=>{"use strict";var t=e.i(344180),a=e.i(764556),n=e.i(209988),s=e.i(260218),r=e.i(355819),i=e.i(193251),o=e.i(62669),l=e.i(511800),d=e.i(681622),c=e.i(434805),u=e.i(660748),m=e.i(244073);function p({open:e,onOpenChange:f,workspace:h,onSubmit:x}){let g=(0,m.useTranslations)("workspace"),v=(0,m.useTranslations)("common"),y=(0,r.useAgentStore)(e=>e.agents),[b,j]=(0,a.useState)(h?.name??""),[w,k]=(0,a.useState)(h?.boundDirs[0]??""),[N,C]=(0,a.useState)(!1),[S,T]=(0,a.useState)(!1),[M,P]=(0,a.useState)(""),[E,D]=(0,a.useState)(!1),[z,F]=(0,a.useState)(null),O=!!h,R=async()=>{if(b&&w){C(!0);try{await x({name:b,boundDirs:[w]}),f(!1)}finally{C(!1)}}},I=(0,a.useCallback)(async()=>{if(M&&w){D(!0),F(null);try{let e=await fetch("/api/workspaces/clone",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:M,targetDir:w})});if(!e.ok){let t=await e.json();F({phase:"error",progress:0,error:t.error||g("clone.cloneFailed")}),D(!1);return}let t=e.body?.getReader();if(!t){F({phase:"error",progress:0,error:g("clone.noResponseBody")}),D(!1);return}let a=new TextDecoder,n="";for(;;){let{done:e,value:s}=await t.read();if(e)break;let r=(n+=a.decode(s,{stream:!0})).split("\n");for(let e of(n=r.pop()||"",r))if(e.startsWith("data: "))try{let t=JSON.parse(e.slice(6));F(t),("done"===t.phase||"error"===t.phase)&&(D(!1),"done"===t.phase&&t.cloneDir&&(k(t.cloneDir),b||j(M.split("/").pop()?.replace(".git","")||""),T(!1),P(""),F(null)))}catch{}}}catch(e){F({phase:"error",progress:0,error:e instanceof Error?e.message:String(e)}),D(!1)}}},[M,w,b,g]);return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(n.Dialog,{open:e,onOpenChange:f,children:(0,t.jsxs)(n.DialogContent,{children:[(0,t.jsxs)(n.DialogHeader,{children:[(0,t.jsx)(n.DialogTitle,{children:O?g("dialog.editTitle"):g("dialog.newTitle")}),(0,t.jsx)(n.DialogDescription,{children:O?g("dialog.editDescription"):g("dialog.newDescription")})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-3 py-2",children:[(0,t.jsx)(d.Input,{className:"rounded-xl py-2.5",placeholder:g("dialog.namePlaceholder"),value:b,onChange:e=>j(e.target.value),onKeyDown:e=>"Enter"===e.key&&e.preventDefault()}),(0,t.jsx)("div",{children:(0,t.jsx)(c.FolderPicker,{value:w,onChange:k,placeholder:"/path/to/project"})}),!O&&(0,t.jsxs)(s.Button,{type:"button",variant:"outline",size:"sm",className:"w-full gap-1.5",onClick:()=>T(!0),disabled:!w,title:w?g("clone.fromGitTooltip"):g("clone.selectFolderFirst"),children:[(0,t.jsx)(i.Download,{className:"size-4"}),g("clone.createFromGit")]}),O&&y.length>0&&(0,t.jsxs)("div",{className:"rounded-xl border border-border p-3",children:[(0,t.jsxs)("div",{className:"mb-2 flex items-center gap-2 text-sm font-medium",children:[(0,t.jsx)("span",{className:"text-muted-foreground",children:y.length}),(0,t.jsx)("span",{children:g("agents")})]}),(0,t.jsx)("div",{className:"flex flex-wrap gap-1.5",children:y.map(e=>(0,t.jsx)("span",{className:"inline-flex items-center gap-1 rounded-md bg-muted px-2 py-0.5 text-xs",children:e.name||e.role},e.id))})]})]}),(0,t.jsxs)(n.DialogFooter,{children:[(0,t.jsx)(s.Button,{variant:"outline",onClick:()=>f(!1),disabled:N,children:v("cancel")}),(0,t.jsx)(s.Button,{onClick:R,disabled:!b||!w||N,children:v(O?"save":"create")})]})]})}),(0,t.jsx)(n.Dialog,{open:S,onOpenChange:e=>{E||T(e)},children:(0,t.jsxs)(n.DialogContent,{children:[(0,t.jsxs)(n.DialogHeader,{children:[(0,t.jsx)(n.DialogTitle,{children:g("clone.title")}),(0,t.jsx)(n.DialogDescription,{children:g("clone.description")})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-3 py-2",children:[(0,t.jsx)(d.Input,{className:"rounded-xl py-2.5",placeholder:"https://github.com/user/repo.git",value:M,onChange:e=>P(e.target.value),onKeyDown:e=>"Enter"===e.key&&e.preventDefault(),disabled:E}),(0,t.jsxs)("p",{className:"text-xs text-muted-foreground",children:[g("clone.cloneTo"),w,"/",M?M.split("/").pop()?.replace(".git","")||"repo":"..."]}),z&&"done"!==z.phase&&"error"!==z.phase&&(0,t.jsxs)("div",{className:"space-y-1.5",children:[(0,t.jsxs)(u.Progress,{value:z.progress,children:[(0,t.jsx)(u.ProgressLabel,{children:g(`clone.phase.${z.phase}`)}),(0,t.jsxs)("span",{className:"ml-auto text-sm text-muted-foreground tabular-nums",children:[z.progress,"%"]}),(0,t.jsx)(u.ProgressTrack,{children:(0,t.jsx)(u.ProgressIndicator,{})})]}),null!=z.received&&null!=z.total&&(0,t.jsxs)("p",{className:"text-xs text-muted-foreground",children:[z.received," / ",z.total," ",g("clone.objects")]})]}),z?.phase==="error"&&(0,t.jsxs)("div",{className:"flex items-start gap-2 rounded-lg border border-destructive/50 bg-destructive/5 p-3",children:[(0,t.jsx)(l.AlertCircle,{className:"size-4 mt-0.5 shrink-0 text-destructive"}),(0,t.jsx)("p",{className:"text-sm text-destructive",children:z.error})]})]}),(0,t.jsxs)(n.DialogFooter,{children:[(0,t.jsx)(s.Button,{variant:"outline",onClick:()=>{E||T(!1)},disabled:E,children:v("cancel")}),(0,t.jsx)(s.Button,{onClick:I,disabled:!M||E,children:E?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(o.Loader2,{className:"size-4 animate-spin"}),g("clone.cloning")]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(i.Download,{className:"size-4"}),g("clone.clone")]})})]})]})})]})}e.s(["WorkspaceDialog",0,function({open:e,onOpenChange:a,workspace:n,onSubmit:s}){return(0,t.jsx)(p,{open:e,onOpenChange:a,workspace:n,onSubmit:s},e?n?.id??"new":"closed")}])},842809,203922,e=>{"use strict";let t=new Map;function a(e,a,n){return null==e?"":(function(e,a){let n=JSON.stringify({locale:e,options:a}),s=t.get(n);if(s)return s;let r=new Intl.NumberFormat(e,a);return t.set(n,r),r})(a,n).format(e)}e.s(["formatNumber",0,a,"formatNumberValue",0,function(e,t,n){return null==e?"":n?a(e,t,n):a(e/100,t,{style:"percent"})}],842809),e.s(["valueToPercent",0,function(e,t,a){return(e-t)*100/(a-t)}],203922)},612505,e=>{"use strict";let t=(0,e.i(433721).default)("circle-alert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);e.s(["default",0,t])},511800,e=>{"use strict";var t=e.i(612505);e.s(["AlertCircle",()=>t.default])},660748,e=>{"use strict";var t,a=e.i(344180);e.s([],606106),e.i(606106),e.i(8890);var n=e.i(764556),s=e.i(106045),r=e.i(236706),i=e.i(842809),o=e.i(969490),l=e.i(267805);let d=n.createContext(void 0);function c(){let e=n.useContext(d);if(void 0===e)throw Error((0,l.default)(51));return e}let u=((t={}).complete="data-complete",t.indeterminate="data-indeterminate",t.progressing="data-progressing",t),m={status:e=>"progressing"===e?{[u.progressing]:""}:"complete"===e?{[u.complete]:""}:"indeterminate"===e?{[u.indeterminate]:""}:null};function p(e,t){return null==t?"indeterminate progress":e||`${t}%`}let f=n.forwardRef(function(e,t){let{format:l,getAriaValueText:c=p,locale:u,max:f=100,min:h=0,value:x,render:g,className:v,children:y,style:b,...j}=e,[w,k]=n.useState(),N=(0,s.useValueAsRef)(l),C="indeterminate";Number.isFinite(x)&&(C=x===f?"complete":"progressing");let S=(0,i.formatNumberValue)(x,u,N.current),T=n.useMemo(()=>({status:C}),[C]),M={"aria-labelledby":w,"aria-valuemax":f,"aria-valuemin":h,"aria-valuenow":x??void 0,"aria-valuetext":c(S,x),role:"progressbar",children:(0,a.jsxs)(n.Fragment,{children:[y,(0,a.jsx)("span",{role:"presentation",style:r.visuallyHidden,children:"x"})]})},P=n.useMemo(()=>({formattedValue:S,max:f,min:h,setLabelId:k,state:T,status:C,value:x}),[S,f,h,k,T,C,x]),E=(0,o.useRenderElement)("div",e,{state:T,ref:t,props:[M,j],stateAttributesMapping:m});return(0,a.jsx)(d.Provider,{value:P,children:E})}),h=n.forwardRef(function(e,t){let{render:a,className:n,style:s,...r}=e,{state:i}=c();return(0,o.useRenderElement)("div",e,{state:i,ref:t,props:r,stateAttributesMapping:m})});var x=e.i(203922);let g=n.forwardRef(function(e,t){let{render:a,className:s,style:r,...i}=e,{max:l,min:d,value:u,state:p}=c(),f=Number.isFinite(u)&&null!==u?(0,x.valueToPercent)(u,d,l):null,h=n.useCallback(()=>null==f?{}:{insetInlineStart:0,height:"inherit",width:`${f}%`},[f]);return(0,o.useRenderElement)("div",e,{state:p,ref:t,props:[{style:h()},i],stateAttributesMapping:m})}),v=n.forwardRef(function(e,t){let{className:a,render:n,children:s,style:r,...i}=e,{value:l,formattedValue:d,state:u}=c(),p=null==l?"indeterminate":d,f=null==l?null:d;return(0,o.useRenderElement)("span",e,{state:u,ref:t,props:[{"aria-hidden":!0,children:"function"==typeof s?s(p,l):f},i],stateAttributesMapping:m})});var y=e.i(559713);let b=n.forwardRef(function(e,t){let{render:a,className:n,style:s,id:r,...i}=e,{setLabelId:l,state:d}=c(),u=(0,y.useRegisteredLabelId)(r,l);return(0,o.useRenderElement)("span",e,{state:d,ref:t,props:[{id:u,role:"presentation"},i],stateAttributesMapping:m})});e.s(["Indicator",0,g,"Label",0,b,"Root",0,f,"Track",0,h,"Value",0,v],729535);var j=e.i(729535),j=j,w=e.i(465458);function k({className:e,...t}){return(0,a.jsx)(j.Track,{className:(0,w.cn)("relative flex h-1 w-full items-center overflow-x-hidden rounded-full bg-muted",e),"data-slot":"progress-track",...t})}function N({className:e,...t}){return(0,a.jsx)(j.Indicator,{"data-slot":"progress-indicator",className:(0,w.cn)("h-full bg-primary transition-all",e),...t})}e.s(["Progress",0,function({className:e,children:t,value:n,...s}){return(0,a.jsxs)(j.Root,{value:n,"data-slot":"progress",className:(0,w.cn)("flex flex-wrap gap-3",e),...s,children:[t,(0,a.jsx)(k,{children:(0,a.jsx)(N,{})})]})},"ProgressIndicator",0,N,"ProgressLabel",0,function({className:e,...t}){return(0,a.jsx)(j.Label,{className:(0,w.cn)("text-sm font-medium",e),"data-slot":"progress-label",...t})},"ProgressTrack",0,k],660748)},361421,e=>{"use strict";let t=(0,e.i(433721).default)("folder-search",[["path",{d:"M10.7 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v4.1",key:"1bw5m7"}],["path",{d:"m21 21-1.9-1.9",key:"1g2n9r"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}]]);e.s(["default",0,t])},244644,e=>{"use strict";var t=e.i(361421);e.s(["FolderSearch",()=>t.default])},980476,e=>{e.v(t=>Promise.all(["static/chunks/05f8cnmzqd5wb.js","static/chunks/128ugqd34tr_-.js"].map(t=>e.l(t))).then(()=>t(65666)))},863812,e=>{e.v(t=>Promise.all(["static/chunks/168ojsxhm7ypc.js"].map(t=>e.l(t))).then(()=>t(158480)))},930010,e=>{e.v(e=>Promise.resolve().then(()=>e(360112)))}]);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,940361,e=>{"use strict";var t=e.i(344180);e.s([],2365),e.i(2365);var n=e.i(764556),a=e.i(394822),s=e.i(174465),r=e.i(648224),i=e.i(35359);e.i(8890);var l=e.i(422561),o=e.i(526850),c=e.i(232449),d=e.i(410421),u=e.i(150129),m=e.i(969490),x=e.i(602453),p=e.i(817955),g=e.i(742665),h=e.i(87709);let f=n.forwardRef(function(e,t){let{render:a,className:r,style:f,...j}=e,{setAnchor:v,actionsRef:b,internalBackdropRef:C,backdropRef:y,positionerRef:N,allowMouseUpTriggerRef:w,initialCursorPointRef:k,rootId:D}=(0,s.useContextMenuRootContext)(!1),{store:M}=(0,i.useMenuRootContext)(!1),S=M.useState("open"),A=M.useState("disabled"),T=n.useRef(null),I=n.useRef(null),R=(0,c.useTimeout)(),z=(0,c.useTimeout)(),P=n.useRef(!1);function O(e,t,n){let a=n.type.startsWith("touch");k.current={x:e,y:t},v({getBoundingClientRect:()=>DOMRect.fromRect({width:10*!!a,height:10*!!a,x:e,y:t})}),P.current=!1,b.current?.setOpen(!0,(0,x.createChangeEventDetails)(g.REASONS.triggerPress,n)),z.start(500,()=>{P.current=!0})}function B(){R.clear(),I.current=null}return n.useEffect(()=>{let e=(0,o.ownerDocument)(T.current);return(0,l.addEventListener)(e,"contextmenu",function(e){if(A)return;let t=(0,d.getTarget)(e);((0,d.contains)(T.current,t)||(0,d.contains)(C.current,t)||(0,d.contains)(y.current,t))&&e.preventDefault()})},[y,A,C]),(0,m.useRenderElement)("div",e,{state:{open:S},ref:[T,t],props:[{onContextMenu:function(e){if(A)return;w.current=!0,(0,u.stopEvent)(e),O(e.clientX,e.clientY,e.nativeEvent);let t=(0,o.ownerDocument)(T.current);(0,l.addEventListener)(t,"mouseup",e=>{if(w.current=!1,!P.current)return;z.clear(),P.current=!1;let t=(0,d.getTarget)(e);(0,d.contains)(N.current,t)||D&&t&&(0,h.findRootOwnerId)(t)===D||b.current?.setOpen(!1,(0,x.createChangeEventDetails)(g.REASONS.cancelOpen,e))},{once:!0})},onTouchStart:function(e){if(!A&&(w.current=!1,1===e.touches.length)){e.stopPropagation();let t=e.touches[0];I.current={x:t.clientX,y:t.clientY},R.start(500,()=>{I.current&&O(I.current.x,I.current.y,e.nativeEvent)})}},onTouchMove:function(e){if(R.isStarted()&&I.current&&1===e.touches.length){let t=e.touches[0],n=Math.abs(t.clientX-I.current.x),a=Math.abs(t.clientY-I.current.y);(n>10||a>10)&&R.clear()}},onTouchEnd:B,onTouchCancel:B,style:{WebkitTouchCallout:"none"}},j],stateAttributesMapping:p.pressableTriggerOpenStateMapping})});var j=e.i(487455),v=e.i(293209),b=e.i(503662),C=e.i(33427),y=e.i(324573),N=e.i(582883),w=e.i(277658),k=e.i(349204),D=e.i(28051),M=e.i(597375),S=e.i(81752),A=e.i(59354),T=e.i(300637),I=e.i(281478),R=e.i(65255),z=e.i(327794),P=e.i(362962);e.s(["Arrow",()=>y.MenuArrow,"Backdrop",()=>j.MenuBackdrop,"CheckboxItem",()=>D.MenuCheckboxItem,"CheckboxItemIndicator",()=>M.MenuCheckboxItemIndicator,"Group",()=>N.MenuGroup,"GroupLabel",()=>w.MenuGroupLabel,"Item",()=>k.MenuItem,"LinkItem",()=>S.MenuLinkItem,"Popup",()=>C.MenuPopup,"Portal",()=>v.MenuPortal,"Positioner",()=>b.MenuPositioner,"RadioGroup",()=>A.MenuRadioGroup,"RadioItem",()=>T.MenuRadioItem,"RadioItemIndicator",()=>I.MenuRadioItemIndicator,"Root",0,function(e){let[l,o]=n.useState({getBoundingClientRect:()=>DOMRect.fromRect({width:0,height:0,x:0,y:0})}),c=n.useRef(null),d=n.useRef(null),u=n.useRef(null),m=n.useRef(null),x=n.useRef(!0),p=n.useRef(null),g=(0,a.useId)(),h=n.useMemo(()=>({anchor:l,setAnchor:o,actionsRef:u,backdropRef:c,internalBackdropRef:d,positionerRef:m,allowMouseUpTriggerRef:x,initialCursorPointRef:p,rootId:g}),[l,g]);return(0,t.jsx)(s.ContextMenuRootContext.Provider,{value:h,children:(0,t.jsx)(i.MenuRootContext.Provider,{value:void 0,children:(0,t.jsx)(r.Menu.Root,{...e})})})},"Separator",()=>P.Separator,"SubmenuRoot",()=>R.MenuSubmenuRoot,"SubmenuTrigger",()=>z.MenuSubmenuTrigger,"Trigger",0,f],912001);var O=e.i(912001),O=O,B=e.i(465458),E=e.i(932031);function _({className:e,align:n="start",alignOffset:a=4,side:s="right",sideOffset:r=0,...i}){return(0,t.jsx)(O.Portal,{children:(0,t.jsx)(O.Positioner,{className:"isolate z-50 outline-none",align:n,alignOffset:a,side:s,sideOffset:r,children:(0,t.jsx)(O.Popup,{"data-slot":"context-menu-content",className:(0,B.cn)("z-50 max-h-(--available-height) min-w-36 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover p-1 text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 outline-none data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",e),...i})})})}e.i(299648),e.s(["ContextMenu",0,function({...e}){return(0,t.jsx)(O.Root,{"data-slot":"context-menu",...e})},"ContextMenuContent",0,_,"ContextMenuItem",0,function({className:e,inset:n,variant:a="default",...s}){return(0,t.jsx)(O.Item,{"data-slot":"context-menu-item","data-inset":n,"data-variant":a,className:(0,B.cn)("group/context-menu-item relative flex cursor-default items-center gap-1.5 rounded-md px-1.5 py-1 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-inset:pl-7 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 focus:*:[svg]:text-accent-foreground data-[variant=destructive]:*:[svg]:text-destructive",e),...s})},"ContextMenuSeparator",0,function({className:e,...n}){return(0,t.jsx)(O.Separator,{"data-slot":"context-menu-separator",className:(0,B.cn)("-mx-1 my-1 h-px bg-border",e),...n})},"ContextMenuSub",0,function({...e}){return(0,t.jsx)(O.SubmenuRoot,{"data-slot":"context-menu-sub",...e})},"ContextMenuSubContent",0,function({...e}){return(0,t.jsx)(_,{"data-slot":"context-menu-sub-content",className:"shadow-lg",side:"right",...e})},"ContextMenuSubTrigger",0,function({className:e,inset:n,children:a,...s}){return(0,t.jsxs)(O.SubmenuTrigger,{"data-slot":"context-menu-sub-trigger","data-inset":n,className:(0,B.cn)("flex cursor-default items-center gap-1.5 rounded-md px-1.5 py-1 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-inset:pl-7 data-open:bg-accent data-open:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...s,children:[a,(0,t.jsx)(E.ChevronRightIcon,{className:"ml-auto"})]})},"ContextMenuTrigger",0,function({className:e,...n}){return(0,t.jsx)(O.Trigger,{"data-slot":"context-menu-trigger",className:(0,B.cn)("select-none",e),...n})}],940361)},414053,725161,e=>{"use strict";var t=e.i(433721);let n=(0,t.default)("archive-restore",[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h2",key:"tvwodi"}],["path",{d:"M20 8v11a2 2 0 0 1-2 2h-2",key:"1gkqxj"}],["path",{d:"m9 15 3-3 3 3",key:"1pd0qc"}],["path",{d:"M12 12v9",key:"192myk"}]]);e.s(["ArchiveRestore",0,n],414053);let a=(0,t.default)("arrow-up-down",[["path",{d:"m21 16-4 4-4-4",key:"f6ql7i"}],["path",{d:"M17 20V4",key:"1ejh1v"}],["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}]]);e.s(["ArrowUpDown",0,a],725161)},734649,e=>{"use strict";var t=e.i(344180),n=e.i(764556);e.s([],764940),e.i(764940);var a=e.i(956834),s=e.i(625386),r=e.i(530089),i=e.i(975983),l=e.i(16223),o=e.i(583901),c=e.i(512519),d=e.i(152851),u=e.i(481181),m=e.i(476343),x=e.i(272248),p=e.i(625144),g=e.i(225171);e.s(["Backdrop",()=>l.DialogBackdrop,"Close",()=>o.DialogClose,"Description",()=>c.DialogDescription,"Handle",()=>g.DialogHandle,"Popup",()=>d.DialogPopup,"Portal",()=>u.DialogPortal,"Root",0,function(e){let{children:l,open:o,defaultOpen:c=!1,onOpenChange:d,onOpenChangeComplete:u,actionsRef:m,handle:x,triggerId:p,defaultTriggerId:g=null}=e,h=(0,r.useDialogRootContext)(!0),f=!!h,j=i.DialogStore.useStore(x?.store,{open:c,openProp:o,activeTriggerId:g,triggerIdProp:p,modal:!0,disablePointerDismissal:!0,nested:f,role:"alertdialog"});j.useControlledProp("openProp",o),j.useControlledProp("triggerIdProp",p),j.useSyncedValue("nested",f),j.useContextCallback("onOpenChange",d),j.useContextCallback("onOpenChangeComplete",u);let v=j.useState("payload");(0,s.useDialogRoot)({store:j,actionsRef:m,parentContext:h?.store.context,isDrawer:!1,onOpenChange:d,triggerIdProp:p});let b=n.useMemo(()=>({store:j}),[j]);return(0,t.jsx)(a.IsDrawerContext.Provider,{value:!1,children:(0,t.jsx)(r.DialogRootContext.Provider,{value:b,children:"function"==typeof l?l({payload:v}):l})})},"Title",()=>m.DialogTitle,"Trigger",()=>x.DialogTrigger,"Viewport",()=>p.DialogViewport,"createHandle",0,function(){return new g.DialogHandle(new i.DialogStore({modal:!0,disablePointerDismissal:!0,role:"alertdialog"}))}],756198);var h=e.i(756198),h=h,f=e.i(465458),j=e.i(260218),v=e.i(250226);function b({...e}){return(0,t.jsx)(h.Portal,{"data-slot":"alert-dialog-portal",...e})}function C({className:e,...n}){return(0,t.jsx)(h.Backdrop,{"data-slot":"alert-dialog-overlay",className:(0,f.cn)("fixed inset-0 isolate z-50 bg-black/10 duration-100 supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0",e),...n})}e.s(["AlertDialog",0,function({ignoreBack:e=!1,...a}){let s=n.useId(),r=(0,v.useMobilePanelStore)(e=>e.registerOverlay),i=(0,v.useMobilePanelStore)(e=>e.unregisterOverlay),l="open"in a?a.open:"defaultOpen"in a?a.defaultOpen:void 0,o=a.onOpenChange,c=n.useRef(o);return n.useEffect(()=>{c.current=o},[o]),n.useEffect(()=>l&&!e&&c.current?(r(s,()=>c.current?.(!1,{reason:void 0})),()=>i(s)):void i(s),[e,l,s,r,i]),(0,t.jsx)(h.Root,{"data-slot":"alert-dialog",...a})},"AlertDialogAction",0,function({className:e,...n}){return(0,t.jsx)(j.Button,{"data-slot":"alert-dialog-action",className:(0,f.cn)(e),...n})},"AlertDialogCancel",0,function({className:e,variant:n="outline",size:a="default",...s}){return(0,t.jsx)(h.Close,{"data-slot":"alert-dialog-cancel",className:(0,f.cn)(e),render:(0,t.jsx)(j.Button,{variant:n,size:a}),...s})},"AlertDialogContent",0,function({className:e,size:n="default",...a}){return(0,t.jsxs)(b,{children:[(0,t.jsx)(C,{}),(0,t.jsx)(h.Popup,{"data-slot":"alert-dialog-content","data-size":n,className:(0,f.cn)("group/alert-dialog-content fixed top-1/2 left-1/2 z-50 grid w-full -translate-x-1/2 -translate-y-1/2 gap-4 rounded-xl bg-popover p-4 text-popover-foreground ring-1 ring-foreground/10 duration-100 outline-none data-[size=default]:max-w-xs data-[size=sm]:max-w-xs data-[size=default]:sm:max-w-sm data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",e),...a})]})},"AlertDialogDescription",0,function({className:e,...n}){return(0,t.jsx)(h.Description,{"data-slot":"alert-dialog-description",className:(0,f.cn)("text-sm text-balance text-muted-foreground md:text-pretty *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground",e),...n})},"AlertDialogFooter",0,function({className:e,...n}){return(0,t.jsx)("div",{"data-slot":"alert-dialog-footer",className:(0,f.cn)("-mx-4 -mb-4 flex flex-col-reverse gap-2 rounded-b-xl border-t bg-muted/50 p-4 group-data-[size=sm]/alert-dialog-content:grid group-data-[size=sm]/alert-dialog-content:grid-cols-2 sm:flex-row sm:justify-end",e),...n})},"AlertDialogHeader",0,function({className:e,...n}){return(0,t.jsx)("div",{"data-slot":"alert-dialog-header",className:(0,f.cn)("grid grid-rows-[auto_1fr] place-items-center gap-1.5 text-center has-data-[slot=alert-dialog-media]:grid-rows-[auto_auto_1fr] has-data-[slot=alert-dialog-media]:gap-x-4 sm:group-data-[size=default]/alert-dialog-content:place-items-start sm:group-data-[size=default]/alert-dialog-content:text-left sm:group-data-[size=default]/alert-dialog-content:has-data-[slot=alert-dialog-media]:grid-rows-[auto_1fr]",e),...n})},"AlertDialogTitle",0,function({className:e,...n}){return(0,t.jsx)(h.Title,{"data-slot":"alert-dialog-title",className:(0,f.cn)("font-heading text-base font-medium sm:group-data-[size=default]/alert-dialog-content:group-has-data-[slot=alert-dialog-media]/alert-dialog-content:col-start-2",e),...n})}],734649)},595390,e=>{"use strict";var t=e.i(344180),n=e.i(764556),a=e.i(681622),s=e.i(611176),r=e.i(972846);let i=e=>!["scheduler","task_creator","bot"].includes(e.description||"")&&"agent-generator"!==e.id;e.s(["MemberPicker",0,function({candidates:e,selected:l,onToggle:o,searchPlaceholder:c,emptyText:d,label:u,filter:m}){let[x,p]=(0,n.useState)(""),g=e.filter(m??i).sort((e,t)=>(e.sortIndex??0)-(t.sortIndex??0)).filter(e=>`${e.label} ${e.description||""}`.toLowerCase().includes(x.toLowerCase()));return(0,t.jsxs)("div",{className:"space-y-2",children:[u&&(0,t.jsx)("label",{className:"text-sm font-medium",children:u}),(0,t.jsx)(a.Input,{value:x,onChange:e=>p(e.target.value),placeholder:c}),(0,t.jsxs)("div",{className:"max-h-40 overflow-y-auto space-y-0.5",children:[0===g.length&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground py-2 text-center",children:d||"No items found"}),g.map(e=>(0,t.jsxs)("button",{type:"button",onClick:()=>o(e.id),className:"flex items-center gap-2 w-full px-2 py-1.5 rounded-md hover:bg-muted text-left text-sm transition-colors",children:[(0,t.jsx)(s.AgentIcon,{agentId:"user"!==e.id?e.id:void 0,name:e.label,className:"size-5 rounded-full"}),(0,t.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,t.jsx)("span",{className:"block truncate",children:e.label}),e.description&&(0,t.jsx)("span",{className:"block truncate text-xs text-muted-foreground",children:e.description})]}),(0,t.jsx)("div",{className:`flex items-center justify-center size-4 rounded border shrink-0 ${l.includes(e.id)?"bg-primary border-primary text-primary-foreground":"border-input"}`})]},e.id))]}),l.length>0&&(0,t.jsx)("div",{className:"flex flex-wrap gap-1.5",children:l.map(n=>{let a=e.find(e=>e.id===n),i=a?.label||n;return(0,t.jsxs)("span",{className:"inline-flex items-center gap-1 rounded-md bg-muted px-2 py-0.5 text-xs max-w-[160px] min-w-0",children:["user"===n?(0,t.jsx)("span",{className:"truncate",children:i}):(0,t.jsxs)("span",{className:"inline-flex items-center gap-1 min-w-0",children:[(0,t.jsx)(s.AgentIcon,{agentId:n,name:i,className:"size-3.5 rounded-full shrink-0"}),(0,t.jsx)("span",{className:"truncate",children:i})]}),(0,t.jsx)("button",{type:"button",onClick:()=>o(n),className:"hover:text-destructive shrink-0 cursor-pointer",children:(0,t.jsx)(r.X,{className:"size-3"})})]},n)})})]})}])},272736,e=>{"use strict";function t(e){return e.name?.trim()||e.role}e.s(["getAgentDisplayName",0,t,"getMemberDisplayName",0,function(e,n){if("user"===n)return"user";let a=e.find(e=>e.id===n);return a?t(a):n},"normalizeChannelMembersToAgentIds",0,function(e,t){let n=new Set(e.map(e=>e.id)),a=[],s=new Set;for(let e of t)n.has(e)&&(s.has(e)||(s.add(e),a.push(e)));return a}])},79882,e=>{"use strict";let t=(0,e.i(433721).default)("archive",[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8",key:"1s80jp"}],["path",{d:"M10 12h4",key:"a56b0p"}]]);e.s(["Archive",0,t],79882)},478117,e=>{"use strict";var t=e.i(344180),n=e.i(764556),a=e.i(244073),s=e.i(209988),r=e.i(681622),i=e.i(260218),l=e.i(188815),o=e.i(595390),c=e.i(272736);e.s(["ChannelDialog",0,function({open:e,onOpenChange:d,channel:u,agents:m=[],onSubmit:x}){let p=(0,a.useTranslations)("chat"),g=(0,a.useTranslations)("common"),h=[{value:"general",label:p("channel.general")},{value:"issue",label:p("channel.issue")},{value:"agent",label:p("channel.agent")}],[f,j]=(0,n.useState)(""),[v,b]=(0,n.useState)("general"),[C,y]=(0,n.useState)([]),[N,w]=(0,n.useState)(0),k=m.filter(e=>!1!==e.enabled).map((e,t)=>({id:e.id,label:(0,c.getMemberDisplayName)(m,e.id),sortIndex:t}));return(0,n.useEffect)(()=>{e&&queueMicrotask(()=>{u?(j(u.name),b(u.type),y([...u.members])):(j(""),b("general"),y(["user"])),w(e=>e+1)})},[e,u]),(0,t.jsx)(s.Dialog,{open:e,onOpenChange:d,children:(0,t.jsxs)(s.DialogContent,{className:"sm:max-w-md max-h-[85vh] p-0 gap-0 flex flex-col overflow-hidden",children:[(0,t.jsxs)(s.DialogHeader,{className:"px-4 py-4 shrink-0",children:[(0,t.jsx)(s.DialogTitle,{children:p(u?"channel.edit":"channel.create")}),(0,t.jsx)(s.DialogDescription,{children:p(u?"channel.edit":"channel.create")})]}),(0,t.jsx)("div",{className:"flex-1 min-h-0 overflow-y-auto px-4 pb-4",children:(0,t.jsxs)("div",{className:"space-y-4 pt-2",children:[(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)("label",{className:"text-sm font-medium",children:g("name")}),(0,t.jsx)(r.Input,{value:f,onChange:e=>j(e.target.value),placeholder:p("channel.namePlaceholder"),onKeyDown:e=>"Enter"===e.key&&e.preventDefault()})]}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)("label",{className:"text-sm font-medium",children:p("channel.type")}),(0,t.jsx)(l.SearchSelect,{value:v,onChange:e=>b(e),options:h,allowCustom:!1,placeholder:p("channel.selectType")})]}),(0,t.jsx)(o.MemberPicker,{candidates:k,selected:C,onToggle:e=>{y(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},label:p("channel.members"),searchPlaceholder:p("channel.addMember"),emptyText:p("channel.noAgents")||"No agents found"},N),(0,t.jsxs)("div",{className:"flex justify-end gap-2 pt-2",children:[(0,t.jsx)(i.Button,{variant:"outline",onClick:()=>d(!1),children:g("cancel")}),(0,t.jsx)(i.Button,{onClick:()=>{x({name:f.trim(),type:v,members:C}),d(!1)},children:g(u?"save":"create")})]})]})})]})})}])},976648,e=>{"use strict";var t=e.i(344180),n=e.i(764556),a=e.i(244073),s=e.i(31807),r=e.i(355819),i=e.i(325443),l=e.i(227634),o=e.i(938306),c=e.i(511800),d=e.i(953700),u=e.i(962562),m=e.i(451534),x=e.i(79882),p=e.i(414053),g=e.i(315775),h=e.i(137340),f=e.i(344118),j=e.i(725161),v=e.i(260218),b=e.i(562918),C=e.i(465458),y=e.i(613087),N=e.i(478117),w=e.i(272736),k=e.i(157408),D=e.i(940361),M=e.i(256186),S=e.i(917955),A=e.i(734649),T=e.i(992764);let I={general:{className:"bg-muted text-muted-foreground",icon:l.Hash},issue:{className:"bg-amber-500/15 text-amber-600",icon:c.AlertCircle},agent:{className:"bg-blue-500/15 text-blue-600",icon:o.MessageCircle}};function R(e){if(!e||0===e.length)return null;let t=e[e.length-1];return t?{text:(t.content??"").replace(/<[^>]*>/g,"").slice(0,60)||"...",status:t.status}:null}let z=["today","yesterday","thisWeek","earlier"],P={today:"timeToday",yesterday:"timeYesterday",thisWeek:"timeThisWeek",earlier:"timeEarlier"};e.s(["ChannelList",0,function({workspaceId:e}){let l=(0,a.useTranslations)("chat"),c=(0,a.useTranslations)("common"),{channels:O,activeChannelId:B,messages:E,loadChannels:_,createChannel:H,updateChannel:L,deleteChannel:$,setActiveChannel:G,upsertChannel:W}=(0,s.useChannelStore)(),[F,V]=(0,n.useState)(!1),[Y,q]=(0,n.useState)(null),[U,X]=(0,n.useState)(!1),[K,J]=(0,n.useState)("none"),[Q,Z]=(0,n.useState)({}),[ee,et]=(0,n.useState)(!1),[en,ea]=(0,n.useState)(null),[es,er]=(0,n.useState)("createdAt"),[ei,el]=(0,n.useState)("desc"),[eo,ec]=(0,n.useState)(!0),ed=(0,r.useAgentStore)(e=>e.agents),eu=(0,r.useAgentStore)(e=>e.ensure),em=(0,n.useMemo)(()=>O.filter(e=>!e.archived),[O]),ex=(0,n.useMemo)(()=>O.filter(e=>e.archived),[O]),ep=(0,n.useMemo)(()=>{let e=[...em];return e.sort((e,t)=>{let n=0;switch(es){case"createdAt":n=new Date(e.createdAt).getTime()-new Date(t.createdAt).getTime();break;case"lastReply":{let a=E[e.id]?.at(-1)?.createdAt,s=E[t.id]?.at(-1)?.createdAt;n=(a?new Date(a).getTime():0)-(s?new Date(s).getTime():0);break}case"type":n=e.type.localeCompare(t.type)}return"desc"===ei?-n:n}),e},[em,es,ei,E]),eg=(0,n.useMemo)(()=>{if("none"===K)return null;if("time"===K){let e={};for(let t of ep){let n=function(e){let t=new Date(e),n=new Date,a=new Date(n.getFullYear(),n.getMonth(),n.getDate()),s=new Date(a.getTime()-864e5),r=new Date(a.getTime()-6048e5);return t>=a?"today":t>=s?"yesterday":t>=r?"thisWeek":"earlier"}(t.createdAt);e[n]||(e[n]=[]),e[n].push(t)}return z.filter(t=>e[t]?.length).map(t=>({key:t,label:c(P[t]),items:e[t]}))}return["general","issue","agent"].filter(e=>ep.some(t=>t.type===e)).map(e=>({key:e,label:l(`channel.${e}`),items:ep.filter(t=>t.type===e)}))},[K,ep,c,l]);(0,n.useEffect)(()=>{ec(!0),_(e).finally(()=>ec(!1)),eu()},[e,_,eu]),(0,n.useEffect)(()=>{let t=(0,k.getWS)(e).on("channel.updated",e=>{W(e)});return()=>{t()}},[e,W]);let eh=e=>{let n,a=R(E[e.id]),s=I[e.type],r=a?.status==="streaming"||a?.status==="pending",o=e.members.filter(e=>"user"!==e);return(0,t.jsxs)(D.ContextMenu,{children:[(0,t.jsxs)(D.ContextMenuTrigger,{className:(0,C.cn)("flex items-start gap-2.5 w-full px-3 py-2 text-sm hover:bg-accent transition-colors text-left",B===e.id&&"bg-accent text-accent-foreground"),onClick:()=>G(e.id),children:[(n=s.icon,(0,t.jsx)(n,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0 mt-1"})),(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,t.jsx)("span",{className:"truncate font-medium text-[13px]",children:e.name}),(0,t.jsx)(b.Badge,{variant:"secondary",className:(0,C.cn)("text-[10px] px-1 py-0 h-4 rounded",s.className),children:l(`channel.${e.type}`)}),r&&(0,t.jsxs)("span",{className:"relative flex h-2 w-2",children:[(0,t.jsx)("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-blue-400 opacity-75"}),(0,t.jsx)("span",{className:"relative inline-flex rounded-full h-2 w-2 bg-blue-500"})]}),o.length>0&&(0,t.jsx)(i.Bot,{className:"h-3 w-3 text-muted-foreground shrink-0"})]}),a?(0,t.jsx)("p",{className:"text-xs text-muted-foreground truncate mt-0.5",children:a.text}):(0,t.jsx)("p",{className:"text-xs text-muted-foreground/50 mt-0.5",children:l("emptyState")})]})]}),(0,t.jsxs)(D.ContextMenuContent,{children:[(0,t.jsxs)(D.ContextMenuItem,{onClick:()=>ev(e),children:[(0,t.jsx)(u.Pencil,{className:"size-3.5"}),c("edit")]}),(0,t.jsxs)(D.ContextMenuItem,{onClick:()=>eb(e.id),children:[(0,t.jsx)(m.FolderOpen,{className:"size-3.5"}),c("open")]}),(0,t.jsx)(D.ContextMenuSeparator,{}),(0,t.jsxs)(D.ContextMenuItem,{onClick:()=>eC(e),children:[(0,t.jsx)(x.Archive,{className:"size-3.5"}),l("channel.archive")]}),(0,t.jsxs)(D.ContextMenuItem,{className:"text-destructive focus:text-destructive",onClick:()=>ea(e),children:[(0,t.jsx)(h.Trash2,{className:"size-3.5"}),c("delete")]})]})]},e.id)},ef=async()=>{en&&(await $(e,en.id),ea(null))},ej=async t=>{let n=(0,w.normalizeChannelMembersToAgentIds)(ed,t.members);Y?await L(e,Y.id,{name:t.name,type:t.type,members:n}):await H(e,t.name,t.type,n)},ev=e=>{q(e),V(!0)},eb=async t=>{await fetch(`/api/workspaces/${e}/files/reveal?channelId=${t}`,{method:"POST"})},eC=async t=>{await L(e,t.id,{archived:!t.archived})},ey=async()=>{await Promise.all(ex.map(t=>$(e,t.id))),et(!1)};return(0,t.jsxs)("div",{className:"flex flex-col h-full",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between px-2 py-1.5 border-b text-xs font-medium text-muted-foreground",children:[(0,t.jsx)("span",{children:l("channel.general")}),(0,t.jsxs)("div",{className:"flex items-center gap-0.5",children:[(0,t.jsx)("button",{onClick:()=>V(!0),className:"p-0.5 hover:bg-accent rounded cursor-pointer",children:(0,t.jsx)(d.Plus,{className:"size-3.5"})}),(0,t.jsxs)(S.DropdownMenu,{children:[(0,t.jsx)(S.DropdownMenuTrigger,{className:"p-0.5 hover:bg-accent rounded",children:(0,t.jsx)(j.ArrowUpDown,{className:"size-3.5"})}),(0,t.jsx)(S.DropdownMenuContent,{align:"end",className:"min-w-40",children:[{field:"createdAt",label:c("sortByCreated")},{field:"lastReply",label:c("sortByLastReply")},{field:"type",label:c("sortByStatus")}].map(({field:e,label:n})=>(0,t.jsxs)(S.DropdownMenuItem,{onClick:()=>{es===e?el(e=>"asc"===e?"desc":"asc"):(er(e),el("desc"))},children:[es===e&&(0,t.jsx)(f.Check,{className:"size-3.5"}),n,es===e&&(0,t.jsx)("span",{className:"ml-auto text-[10px] text-muted-foreground",children:"asc"===ei?"↑":"↓"})]},e))})]}),(0,t.jsxs)(S.DropdownMenu,{children:[(0,t.jsx)(S.DropdownMenuTrigger,{className:"p-0.5 hover:bg-accent rounded",children:(0,t.jsx)(g.MoreHorizontal,{className:"size-3.5"})}),(0,t.jsxs)(S.DropdownMenuContent,{align:"end",className:"min-w-48",children:[(0,t.jsxs)(S.DropdownMenuItem,{onClick:()=>J("none"),children:["none"===K&&(0,t.jsx)(f.Check,{className:"size-3.5"}),c("groupNone")]}),(0,t.jsxs)(S.DropdownMenuItem,{onClick:()=>J("time"),children:["time"===K&&(0,t.jsx)(f.Check,{className:"size-3.5"}),c("groupByTime")]}),(0,t.jsxs)(S.DropdownMenuItem,{onClick:()=>J("status"),children:["status"===K&&(0,t.jsx)(f.Check,{className:"size-3.5"}),c("groupByStatus")]}),(0,t.jsx)(S.DropdownMenuSeparator,{}),(0,t.jsxs)(S.DropdownMenuItem,{disabled:0===ex.length,onClick:()=>et(!0),children:[(0,t.jsx)(h.Trash2,{className:"size-3.5"}),l("channel.clearArchived")]})]})]})]})]}),(0,t.jsxs)("div",{className:"flex-1 overflow-y-auto",children:[eo?(0,t.jsx)("div",{className:"p-2 space-y-1",children:(0,t.jsx)(y.SkeletonGroup,{count:4,children:e=>(0,t.jsxs)("div",{className:"flex items-start gap-2.5 px-3 py-2",children:[(0,t.jsx)(y.Skeleton,{className:"size-3.5 rounded shrink-0 mt-1"}),(0,t.jsxs)("div",{className:"flex-1 min-w-0 space-y-1.5",children:[(0,t.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,t.jsx)(y.Skeleton,{className:"h-4 w-20"}),(0,t.jsx)(y.Skeleton,{className:"h-4 w-8 rounded-full"})]}),(0,t.jsx)(y.Skeleton,{className:"h-3 w-3/4"})]})]},e)})}):null,eo||0!==em.length||0!==ex.length?null:(0,t.jsxs)("div",{className:"flex flex-col items-center justify-center h-full gap-3 px-4 text-center",children:[(0,t.jsx)("div",{className:"rounded-full bg-muted p-3",children:(0,t.jsx)(o.MessageCircle,{className:"h-5 w-5 text-muted-foreground"})}),(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-sm font-medium",children:l("channel.noMembers")}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:l("channel.create")})]}),(0,t.jsxs)(v.Button,{size:"sm",variant:"outline",onClick:()=>V(!0),children:[(0,t.jsx)(d.Plus,{className:"h-3.5 w-3.5 mr-1"}),c("add")]})]}),!eo&&"none"===K&&ep.map(e=>eh(e)),!eo&&"none"!==K&&eg?.map(e=>(0,t.jsxs)(M.Collapsible,{open:!1!==Q[e.key],onOpenChange:t=>Z(n=>({...n,[e.key]:t})),children:[(0,t.jsxs)(M.CollapsibleTrigger,{className:"flex items-center gap-1 w-full px-3 py-1.5 text-xs font-medium text-muted-foreground hover:bg-accent transition-colors",children:[(0,t.jsx)(T.ChevronRight,{className:(0,C.cn)("size-3 transition-transform",!1!==Q[e.key]&&"rotate-90")}),e.label," (",e.items.length,")"]}),(0,t.jsx)(M.CollapsibleContent,{children:e.items.map(e=>eh(e))})]},e.key)),!eo&&ex.length>0&&(0,t.jsxs)(M.Collapsible,{open:U,onOpenChange:X,children:[(0,t.jsxs)(M.CollapsibleTrigger,{className:"flex items-center gap-1 w-full px-3 py-1.5 text-xs font-medium text-muted-foreground hover:bg-accent transition-colors",children:[(0,t.jsx)(T.ChevronRight,{className:(0,C.cn)("size-3 transition-transform",U&&"rotate-90")}),(0,t.jsx)(x.Archive,{className:"size-3"}),l("channel.archived")," (",ex.length,")"]}),(0,t.jsx)(M.CollapsibleContent,{children:ex.map(e=>{let n,a=R(E[e.id]),s=I[e.type];return(0,t.jsxs)(D.ContextMenu,{children:[(0,t.jsxs)(D.ContextMenuTrigger,{className:(0,C.cn)("flex items-start gap-2.5 w-full px-3 py-2 text-sm hover:bg-accent transition-colors text-left opacity-60",B===e.id&&"bg-accent text-accent-foreground opacity-100"),onClick:()=>G(e.id),children:[(n=s.icon,(0,t.jsx)(n,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0 mt-1"})),(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,t.jsx)("span",{className:"truncate font-medium text-[13px]",children:e.name}),(0,t.jsx)(b.Badge,{variant:"secondary",className:(0,C.cn)("text-[10px] px-1 py-0 h-4 rounded",s.className),children:l(`channel.${e.type}`)})]}),a?(0,t.jsx)("p",{className:"text-xs text-muted-foreground truncate mt-0.5",children:a.text}):(0,t.jsx)("p",{className:"text-xs text-muted-foreground/50 mt-0.5",children:l("emptyState")})]})]}),(0,t.jsxs)(D.ContextMenuContent,{children:[(0,t.jsxs)(D.ContextMenuItem,{onClick:()=>G(e.id),children:[(0,t.jsx)(m.FolderOpen,{className:"size-3.5"}),c("open")]}),(0,t.jsx)(D.ContextMenuSeparator,{}),(0,t.jsxs)(D.ContextMenuItem,{onClick:()=>eC(e),children:[(0,t.jsx)(p.ArchiveRestore,{className:"size-3.5"}),l("channel.unarchive")]})]})]},e.id)})})]})]}),(0,t.jsx)(N.ChannelDialog,{open:F,onOpenChange:e=>{V(e),e||q(null)},workspaceId:e,channel:Y,agents:ed,onSubmit:ej}),(0,t.jsx)(A.AlertDialog,{open:ee,onOpenChange:et,children:(0,t.jsxs)(A.AlertDialogContent,{children:[(0,t.jsxs)(A.AlertDialogHeader,{children:[(0,t.jsx)(A.AlertDialogTitle,{children:l("channel.clearArchived")}),(0,t.jsx)(A.AlertDialogDescription,{children:l("channel.clearArchivedConfirm",{count:ex.length})})]}),(0,t.jsxs)(A.AlertDialogFooter,{children:[(0,t.jsx)(A.AlertDialogCancel,{children:c("cancel")}),(0,t.jsx)(A.AlertDialogAction,{onClick:ey,children:c("delete")})]})]})}),(0,t.jsx)(A.AlertDialog,{open:!!en,onOpenChange:e=>!e&&ea(null),children:(0,t.jsxs)(A.AlertDialogContent,{children:[(0,t.jsxs)(A.AlertDialogHeader,{children:[(0,t.jsx)(A.AlertDialogTitle,{children:c("delete")}),(0,t.jsx)(A.AlertDialogDescription,{children:l("channel.deleteConfirm",{name:en?.name??""})})]}),(0,t.jsxs)(A.AlertDialogFooter,{children:[(0,t.jsx)(A.AlertDialogCancel,{children:c("cancel")}),(0,t.jsx)(A.AlertDialogAction,{onClick:ef,children:c("delete")})]})]})})]})}])},878166,e=>{e.n(e.i(976648))}]);
|