profclaw 0.0.1-beta.2 → 2.0.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/CHANGELOG.md +21 -38
- package/CONTRIBUTING.md +3 -5
- package/README.md +128 -63
- package/dist/chat/execution/tools/index.d.ts +1 -1
- package/dist/chat/execution/tools/index.js +41 -2
- package/dist/chat/providers/slack/index.d.ts +2 -2
- package/dist/cli/commands/models.js +39 -26
- package/dist/cli/commands/onboard.js +64 -79
- package/dist/cli/commands/setup.js +293 -90
- package/dist/cli/index.js +0 -6
- package/dist/cli/providers.d.ts +15 -0
- package/dist/cli/providers.js +41 -0
- package/dist/core/deployment.js +2 -0
- package/dist/providers/ai-sdk.js +26 -6
- package/dist/routes/channels.d.ts +12 -0
- package/dist/routes/channels.js +166 -0
- package/dist/server/route-loader.js +1 -0
- package/dist/server.js +115 -109
- package/package.json +1 -1
- package/skills/git-workflow/SKILL.md +3 -3
- package/ui/dist/assets/{ActivityView-DIPQSJ_d.js → ActivityView-BeshZXmE.js} +1 -1
- package/ui/dist/assets/{AgentList-CqyaYrcq.js → AgentList-QVHeldPi.js} +1 -1
- package/ui/dist/assets/{AnalyticsDashboard-C-mjuGHT.js → AnalyticsDashboard-C9R97dXE.js} +1 -1
- package/ui/dist/assets/{AreaChart-CfYWmbtr.js → AreaChart-B73gaiVQ.js} +1 -1
- package/ui/dist/assets/{CartesianChart-BaQ3It0c.js → CartesianChart-CXYL2R-A.js} +1 -1
- package/ui/dist/assets/{ChatView-DxxQy6pl.js → ChatView-qjZErlrp.js} +1 -1
- package/ui/dist/assets/{CostsDashboard-CDBBcGkg.js → CostsDashboard-O4DCLy1i.js} +1 -1
- package/ui/dist/assets/{EstimateSelect-CDjf5qKl.js → EstimateSelect-1hQf4Osk.js} +1 -1
- package/ui/dist/assets/{FloatingChatbot-CZHjvJIe.js → FloatingChatbot-BZBzrJxd.js} +1 -1
- package/ui/dist/assets/{InviteCodeManagement-DTm-IPTm.js → InviteCodeManagement-LEoGqYeA.js} +1 -1
- package/ui/dist/assets/{ProjectDetail-DlYUcOss.js → ProjectDetail--gPfvATB.js} +1 -1
- package/ui/dist/assets/{ProjectIcon-BMRpnM04.js → ProjectIcon-Chd_ofsw.js} +1 -1
- package/ui/dist/assets/{ProjectList-D85TN0i0.js → ProjectList-BvUfVB6c.js} +1 -1
- package/ui/dist/assets/{Settings-CgPqzUvj.js → Settings-1kaf7VHE.js} +1 -1
- package/ui/dist/assets/{StatusIndicator-yig0uZEA.js → StatusIndicator-pRfkNcdV.js} +1 -1
- package/ui/dist/assets/{SummaryDetail-CwLAfHgJ.js → SummaryDetail-DV3AmONk.js} +1 -1
- package/ui/dist/assets/{SummaryList-BvS5Idnu.js → SummaryList-B6kXiTxL.js} +1 -1
- package/ui/dist/assets/{TaskDetail-zarC1fOt.js → TaskDetail-CV6CzbOS.js} +1 -1
- package/ui/dist/assets/{TaskList-CyJq3ANE.js → TaskList-DL7brQKd.js} +1 -1
- package/ui/dist/assets/{TicketBoard-BlWr3-iH.js → TicketBoard-CrkkFj7C.js} +1 -1
- package/ui/dist/assets/{TicketDetail-DmqWKj2W.js → TicketDetail-hnnYclpD.js} +1 -1
- package/ui/dist/assets/{TicketList-Scj4pMWa.js → TicketList-CsDAyQCL.js} +1 -1
- package/ui/dist/assets/{UserManagement-BH7uG7dw.js → UserManagement-BGFQyTSr.js} +1 -1
- package/ui/dist/assets/{ViewSwitcher-3HzZUdWn.js → ViewSwitcher-CnL0OqA8.js} +1 -1
- package/ui/dist/assets/{alert-dialog-DWPb2IfQ.js → alert-dialog-SKM6Gjz4.js} +1 -1
- package/ui/dist/assets/{archive-CGck7gxR.js → archive-BsLa7brF.js} +1 -1
- package/ui/dist/assets/{badge-DEmc3Z_l.js → badge-CVHH1a-v.js} +1 -1
- package/ui/dist/assets/{brain-CfFdLVqb.js → brain-6o_RHVpe.js} +1 -1
- package/ui/dist/assets/{bug-DqSGPUUE.js → bug-CmZI7jqM.js} +1 -1
- package/ui/dist/assets/{calendar-BuZ4zbPW.js → calendar-Bf0t2B82.js} +1 -1
- package/ui/dist/assets/{chevron-up-DcJ4LL_N.js → chevron-up-CoUsOvZj.js} +1 -1
- package/ui/dist/assets/{circle-x-C78PNZjF.js → circle-x-Dgw11LgT.js} +1 -1
- package/ui/dist/assets/{constants-DhDjZe4P.js → constants-Q5Zivl-a.js} +1 -1
- package/ui/dist/assets/{cpu-Ck6AoG8c.js → cpu-DiPMQICV.js} +1 -1
- package/ui/dist/assets/{database-CA2w8Lvt.js → database-BwTfupDi.js} +1 -1
- package/ui/dist/assets/{dialog-BOdGWhgE.js → dialog-BUqN9Psj.js} +1 -1
- package/ui/dist/assets/{ellipsis-FhHKRbfl.js → ellipsis-UJx4Xnf6.js} +1 -1
- package/ui/dist/assets/{ellipsis-vertical-CO0UqE4-.js → ellipsis-vertical-DoULYEKn.js} +1 -1
- package/ui/dist/assets/{file-code-ChnhYYj1.js → file-code-B2UrJLwi.js} +1 -1
- package/ui/dist/assets/{folder-open-CHwA1-ve.js → folder-open-BJi577JH.js} +1 -1
- package/ui/dist/assets/{funnel-ByEjRFNB.js → funnel-PkaD_HSR.js} +1 -1
- package/ui/dist/assets/{git-branch-GTOPQgU4.js → git-branch-C_K30am0.js} +1 -1
- package/ui/dist/assets/{git-commit-horizontal-F5M84Kut.js → git-commit-horizontal-IT6ecxWQ.js} +1 -1
- package/ui/dist/assets/{globe-CQWfr7hT.js → globe-f-jjCa_g.js} +1 -1
- package/ui/dist/assets/{hash-nKC9gtLg.js → hash-DNEv8Elo.js} +1 -1
- package/ui/dist/assets/{history-DfFSA9xJ.js → history-BQSBo_1Q.js} +1 -1
- package/ui/dist/assets/{index-DHGvP9mp.js → index-BUmnwPQr.js} +1 -1
- package/ui/dist/assets/{index-Z4-RtZcs.js → index-BfF5G4Cw.js} +1 -1
- package/ui/dist/assets/{index-DeI8lKRR.js → index-C8N375c2.js} +1 -1
- package/ui/dist/assets/index-CuxnqVVz.css +1 -0
- package/ui/dist/assets/{index-Ca3vk7Gq.js → index-CzMM3QOk.js} +1 -1
- package/ui/dist/assets/{index--JkIxVXb.js → index-lJlNPFVJ.js} +3 -3
- package/ui/dist/assets/{index-a4Fxq0Hb.js → index-nS3EErDg.js} +1 -1
- package/ui/dist/assets/{layers-DFeLExSa.js → layers-jFqVrWMD.js} +1 -1
- package/ui/dist/assets/{layout-dashboard-WmgjMhWF.js → layout-dashboard-CcKt1hXw.js} +1 -1
- package/ui/dist/assets/{lightbulb-Bo8hEr7B.js → lightbulb-Jhp7FvbU.js} +1 -1
- package/ui/dist/assets/{link-2-YqrpQXBH.js → link-2-DdO7ostF.js} +1 -1
- package/ui/dist/assets/{markdown-renderer-Croje6Xe.js → markdown-renderer-n1ToC4XQ.js} +1 -1
- package/ui/dist/assets/{message-square-CD0H5hot.js → message-square-CBgH65X7.js} +1 -1
- package/ui/dist/assets/{pencil-DpFnj5dn.js → pencil-CYXCEPQh.js} +1 -1
- package/ui/dist/assets/{play-DVgea_jT.js → play-d1ONaH0-.js} +1 -1
- package/ui/dist/assets/{popover-JXecfWG5.js → popover-CrmZgoWu.js} +1 -1
- package/ui/dist/assets/{progress-C1ghf1Fu.js → progress-uv4SPkL5.js} +1 -1
- package/ui/dist/assets/{rocket-BFxPYGx9.js → rocket-DhvUetsk.js} +1 -1
- package/ui/dist/assets/{select-MADP8m6Q.js → select-CeQ8AHGy.js} +1 -1
- package/ui/dist/assets/{send-eYnW_7n-.js → send-P0r5D7td.js} +1 -1
- package/ui/dist/assets/{server-CPMaysH8.js → server-CVHTZB72.js} +1 -1
- package/ui/dist/assets/{settings-2-scXUOuE_.js → settings-2-ocj5uHGx.js} +1 -1
- package/ui/dist/assets/{sheet-r6NSOxi-.js → sheet-DuQExSho.js} +1 -1
- package/ui/dist/assets/{shield-check-PEr7nmVw.js → shield-check-DfVdE34l.js} +1 -1
- package/ui/dist/assets/{shield-off-CLtXio62.js → shield-off-8l0J6R-8.js} +1 -1
- package/ui/dist/assets/{skeleton-C9oEzNlU.js → skeleton-TFiFJ3nB.js} +1 -1
- package/ui/dist/assets/{smartphone-DusFfY0U.js → smartphone-77_g3SQn.js} +1 -1
- package/ui/dist/assets/{square-e1yxB2eR.js → square-Ckzsr3Rn.js} +1 -1
- package/ui/dist/assets/{switch-tNs0n-kz.js → switch-CAePkd6k.js} +1 -1
- package/ui/dist/assets/{table-CXxtLicg.js → table-ZjAZ7hkt.js} +1 -1
- package/ui/dist/assets/{tag-tAwMmQ9G.js → tag-C35mgoEv.js} +1 -1
- package/ui/dist/assets/{textarea-BjiEeIWh.js → textarea-DsVPnSgR.js} +1 -1
- package/ui/dist/assets/{timer-Vel1N3RP.js → timer-DHJBS2w1.js} +1 -1
- package/ui/dist/assets/{tooltip-ZMwtfr1J.js → tooltip-BYmQ331W.js} +1 -1
- package/ui/dist/assets/{trash-2-eM-CNwsZ.js → trash-2-keO5tKPE.js} +1 -1
- package/ui/dist/assets/{trending-up-BGafmjRo.js → trending-up-BBv8KbrY.js} +1 -1
- package/ui/dist/assets/{wand-sparkles-DPvcd9Pi.js → wand-sparkles-BusQ52ZK.js} +1 -1
- package/ui/dist/assets/{wrench-B8s3zYVV.js → wrench-02YaOSiK.js} +1 -1
- package/ui/dist/index.html +2 -2
- package/dist/chat/auto-reply.d.ts +0 -90
- package/dist/chat/auto-reply.js +0 -272
- package/dist/chat/execution/pty.d.ts +0 -92
- package/dist/chat/execution/pty.js +0 -285
- package/dist/chat/execution/tools/glinr-ops.d.ts +0 -202
- package/dist/chat/execution/tools/glinr-ops.js +0 -694
- package/dist/cli/commands/browser.d.ts +0 -3
- package/dist/cli/commands/browser.js +0 -138
- package/dist/cli/commands/canvas.d.ts +0 -3
- package/dist/cli/commands/canvas.js +0 -155
- package/dist/cli/commands/nodes.d.ts +0 -3
- package/dist/cli/commands/nodes.js +0 -193
- package/dist/diagnostics/exporters.d.ts +0 -21
- package/dist/diagnostics/exporters.js +0 -138
- package/dist/diagnostics/index.d.ts +0 -10
- package/dist/diagnostics/index.js +0 -9
- package/dist/diagnostics/middleware.d.ts +0 -12
- package/dist/diagnostics/middleware.js +0 -58
- package/dist/diagnostics/tracer.d.ts +0 -133
- package/dist/diagnostics/tracer.js +0 -257
- package/dist/discovery/index.d.ts +0 -8
- package/dist/discovery/index.js +0 -7
- package/dist/discovery/mdns.d.ts +0 -40
- package/dist/discovery/mdns.js +0 -249
- package/dist/plugins/registry.d.ts +0 -122
- package/dist/plugins/registry.js +0 -352
- package/dist/plugins/sandbox.d.ts +0 -77
- package/dist/plugins/sandbox.js +0 -287
- package/dist/plugins/search/brave.d.ts +0 -9
- package/dist/plugins/search/brave.js +0 -157
- package/dist/plugins/search/duckduckgo.d.ts +0 -9
- package/dist/plugins/search/duckduckgo.js +0 -171
- package/dist/plugins/search/index.d.ts +0 -13
- package/dist/plugins/search/index.js +0 -23
- package/dist/plugins/search/searxng.d.ts +0 -9
- package/dist/plugins/search/searxng.js +0 -170
- package/dist/plugins/search/serper.d.ts +0 -9
- package/dist/plugins/search/serper.js +0 -135
- package/dist/plugins/search/tavily.d.ts +0 -9
- package/dist/plugins/search/tavily.js +0 -146
- package/dist/providers/adapters/anthropic.d.ts +0 -26
- package/dist/providers/adapters/anthropic.js +0 -306
- package/dist/providers/adapters/base.d.ts +0 -53
- package/dist/providers/adapters/base.js +0 -99
- package/dist/providers/adapters/ollama.d.ts +0 -30
- package/dist/providers/adapters/ollama.js +0 -292
- package/dist/utils/ai-cache.d.ts +0 -72
- package/dist/utils/ai-cache.js +0 -204
- package/dist/utils/file-lock.d.ts +0 -85
- package/dist/utils/file-lock.js +0 -204
- package/ui/dist/assets/index-WclMPci1.css +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as r,i as n}from"./index
|
|
1
|
+
import{j as r,i as n}from"./index-lJlNPFVJ.js";import{S as f,a as h,b,c as o,d as x}from"./select-CeQ8AHGy.js";import{H as l}from"./hash-DNEv8Elo.js";const j=[0,1,2,3,5,8,13,21];function w({value:t,onChange:s,disabled:c=!1,className:d,compact:i=!1,placeholder:a="Estimate"}){const m=e=>{s(e==="__none__"?null:parseInt(e,10))},g=e=>e===0?"0 pts (trivial)":e===1?"1 pt (tiny)":e===2?"2 pts (small)":e===3?"3 pts (medium)":e===5?"5 pts (large)":e===8?"8 pts (x-large)":e===13?"13 pts (huge)":e===21?"21 pts (epic)":`${e} pts`,u=e=>e==null?null:`${e} pts`;return r.jsxs(f,{value:t!=null?String(t):"__none__",onValueChange:m,disabled:c,children:[r.jsx(h,{className:n("bg-white/5 border-white/10 rounded-xl",i&&"w-[100px]",d),children:r.jsx(b,{placeholder:a,children:t!=null?r.jsxs("span",{className:"flex items-center gap-1.5",children:[r.jsx(l,{className:"h-3.5 w-3.5 text-muted-foreground"}),r.jsx("span",{children:u(t)})]}):r.jsxs("span",{className:"flex items-center gap-1.5 text-muted-foreground",children:[r.jsx(l,{className:"h-3.5 w-3.5"}),r.jsx("span",{children:a})]})})}),r.jsxs(o,{className:"glass-heavy rounded-xl border-white/10",children:[r.jsx(x,{value:"__none__",children:r.jsx("span",{className:"text-muted-foreground",children:"No estimate"})}),j.map(e=>r.jsx(x,{value:String(e),children:r.jsxs("span",{className:"flex items-center gap-2",children:[r.jsx("span",{className:n("w-5 h-5 rounded-md flex items-center justify-center text-xs font-medium",e===0&&"bg-zinc-500/20 text-zinc-400",e===1&&"bg-green-500/20 text-green-400",e===2&&"bg-emerald-500/20 text-emerald-400",e===3&&"bg-blue-500/20 text-blue-400",e===5&&"bg-yellow-500/20 text-yellow-400",e===8&&"bg-orange-500/20 text-orange-400",e===13&&"bg-red-500/20 text-red-400",e===21&&"bg-purple-500/20 text-purple-400"),children:e}),r.jsx("span",{children:g(e)})]})},e))]})]})}function S({value:t,className:s}){return t==null?null:r.jsxs("span",{className:n("inline-flex items-center gap-1 px-1.5 py-0.5 rounded-md text-xs font-medium",t===0&&"bg-zinc-500/20 text-zinc-400",t===1&&"bg-green-500/20 text-green-400",t===2&&"bg-emerald-500/20 text-emerald-400",t===3&&"bg-blue-500/20 text-blue-400",t===5&&"bg-yellow-500/20 text-yellow-400",t===8&&"bg-orange-500/20 text-orange-400",t===13&&"bg-red-500/20 text-red-400",t>=21&&"bg-purple-500/20 text-purple-400",s),children:[r.jsx(l,{className:"h-3 w-3"}),t]})}export{S as E,w as a};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{bN as Y,n as ce,r,u as M,o as U,j as e,S as W,D as de,x as me,i as x,a5 as pe,y as ue,aw as he,z as fe,k as I,X as xe,R as ge,B as ee,an as ye,L as te,T as Q,F as J,a as we,N as be,bO as ke,Z as je,V as ve,aj as Ne,U as Ce,g as Se,m as g,ak as Ae}from"./index--JkIxVXb.js";import{M as Me,a as Ie,b as qe}from"./markdown-renderer-Croje6Xe.js";import{C as X}from"./cpu-Ck6AoG8c.js";import{T as De}from"./trash-2-eM-CNwsZ.js";import{S as ze}from"./send-eYnW_7n-.js";import{M as He}from"./message-square-CD0H5hot.js";import{L as Te}from"./layout-dashboard-WmgjMhWF.js";import{B as We}from"./brain-CfFdLVqb.js";import{W as Ee}from"./wrench-B8s3zYVV.js";import{C as Le}from"./circle-x-C78PNZjF.js";import"./defineProperty-CoXUr7_6.js";const Z="profclaw_chatbot_conversation_";function Pe(i,a){return a?`${Z}${i}_${a}`:`${Z}${i}`}const o={dashboard:{type:"dashboard",name:"Dashboard",icon:Te,description:"Overview of your workspace with stats and recent activity",capabilities:["View workspace statistics and metrics","See recent tickets and tasks","Check team activity and progress","Get insights on productivity trends"],quickActions:[{label:"Status report",prompt:"Give me a status report of my workspace. What are the key metrics and any items needing attention?"},{label:"What's new?",prompt:"What's happened recently in my workspace? Any updates I should know about?"},{label:"Productivity tips",prompt:"Based on my current workload, what productivity tips do you have?"}]},tickets:{type:"tickets",name:"Tickets",icon:Q,description:"Manage and track your tickets",capabilities:["Create new tickets","Search and filter tickets","Update ticket status and priority","Add comments and checklists","Assign tickets to team members"],quickActions:[{label:"Create ticket",prompt:"Help me create a new ticket. Ask me what it should be about."},{label:"Find tickets",prompt:"Help me find tickets. What would you like to search for?"},{label:"Ticket overview",prompt:"Give me an overview of my tickets - how many are open, in progress, and done?"}]},ticketDetail:{type:"ticket-detail",name:"Ticket Details",icon:Q,description:"Viewing a specific ticket",capabilities:["Update this ticket (status, priority, description)","Add comments to this ticket","Create checklists and subtasks","Link related tickets","Generate AI summaries"],quickActions:[{label:"Summarize",prompt:"Summarize this ticket and its current status for me."},{label:"Suggest next steps",prompt:"Based on this ticket, what should be the next steps to resolve it?"},{label:"Draft comment",prompt:"Help me draft a status update comment for this ticket."}]},projects:{type:"projects",name:"Projects",icon:J,description:"Manage your projects and sprints",capabilities:["Create new projects","View project progress","Manage sprints and iterations","See project analytics"],quickActions:[{label:"Create project",prompt:"Help me create a new project. What should it be called and what prefix should it use?"},{label:"Project status",prompt:"Give me a status update on all my projects."},{label:"Sprint planning",prompt:"Help me plan a new sprint. What tickets should be included?"}]},projectDetail:{type:"project-detail",name:"Project Details",icon:J,description:"Viewing a specific project",capabilities:["View project metrics and progress","Manage sprints for this project","See all tickets in this project","Update project settings"],quickActions:[{label:"Project summary",prompt:"Give me a summary of this project - progress, blockers, and upcoming work."},{label:"Sprint status",prompt:"What's the status of the current sprint in this project?"},{label:"Create ticket",prompt:"Help me create a new ticket for this project."}]},tasks:{type:"tasks",name:"Tasks",icon:we,description:"View and manage AI agent tasks",capabilities:["View pending and completed tasks","Retry failed tasks","See task execution details","Monitor agent activity"],quickActions:[{label:"Task status",prompt:"Give me an overview of my task queue - pending, running, and completed."},{label:"Failed tasks",prompt:"Are there any failed tasks that need attention?"},{label:"Agent activity",prompt:"What are my AI agents currently working on?"}]},summaries:{type:"summaries",name:"Summaries",icon:be,description:"AI-generated session summaries",capabilities:["Browse past session summaries","Search for specific work","Review completed work history"],quickActions:[{label:"Recent work",prompt:"What work has been completed recently? Show me recent summaries."},{label:"Find summary",prompt:"Help me find a summary about a specific topic or task."}]},costs:{type:"costs",name:"Cost Dashboard",icon:ke,description:"Track AI usage and costs",capabilities:["View token usage statistics","Monitor cost trends","See cost breakdown by model","Set usage alerts"],quickActions:[{label:"Cost summary",prompt:"What's my AI usage and cost this month?"},{label:"Compare models",prompt:"Compare the costs between different AI models I use."}]},gateway:{type:"gateway",name:"AI Gateway",icon:je,description:"Manage AI agent workflows",capabilities:["Execute AI workflows","Configure agents","Monitor gateway status"],quickActions:[{label:"Run workflow",prompt:"Help me run an AI workflow. What task should I execute?"},{label:"Gateway status",prompt:"What's the status of the AI gateway?"}]},agents:{type:"agents",name:"Agents",icon:ee,description:"Configure AI agents",capabilities:["View available agents","Configure agent settings","Monitor agent health"],quickActions:[{label:"Agent status",prompt:"Show me the status of all AI agents."},{label:"Configure agent",prompt:"Help me configure an AI agent."}]},settings:{type:"settings",name:"Settings",icon:ve,description:"Configure profClaw settings",capabilities:["Configure AI providers","Manage integrations","Update preferences"],quickActions:[{label:"Setup help",prompt:"Help me set up and configure profClaw."},{label:"Provider config",prompt:"Help me configure an AI provider."}]},webhooks:{type:"webhooks",name:"Webhooks",icon:Ne,description:"Manage webhook integrations",capabilities:["View webhook status","Test webhook connections","Configure webhook endpoints"],quickActions:[{label:"Webhook status",prompt:"Show me the status of all webhooks."},{label:"Setup webhook",prompt:"Help me set up a new webhook integration."}]},failed:{type:"failed",name:"Failed Tasks",icon:Ce,description:"Review and retry failed tasks",capabilities:["View failed task details","Retry failed tasks","Analyze failure patterns"],quickActions:[{label:"Analyze failures",prompt:"Analyze the failed tasks and tell me what went wrong."},{label:"Retry all",prompt:"Help me retry the failed tasks."}]},memory:{type:"memory",name:"Memory",icon:We,description:"AI memory and context",capabilities:["Search memory for past context","View memory statistics","Manage memory files"],quickActions:[{label:"Search memory",prompt:"Search my memory for information about..."},{label:"Memory stats",prompt:"What's stored in my AI memory?"}]},cron:{type:"cron",name:"Scheduled Jobs",icon:Se,description:"Manage automated scheduled tasks",capabilities:["Create new scheduled jobs","View job status and history","Trigger jobs manually","Pause and resume jobs","Monitor execution logs"],quickActions:[{label:"Job status",prompt:"Show me the status of all my scheduled jobs. How many are active, paused, or failed?"},{label:"Recent failures",prompt:"Are there any failed scheduled jobs? Show me the recent failures and what went wrong."},{label:"Create job",prompt:"Help me create a new scheduled job. What task should it automate and how often should it run?"},{label:"Job history",prompt:"Show me the execution history of my scheduled jobs. Which ones ran recently?"}]},default:{type:"default",name:"profClaw",icon:W,description:"AI-powered task management",capabilities:["Answer questions about profClaw","Help with navigation","Provide general assistance"],quickActions:[{label:"Help",prompt:"What can you help me with in profClaw?"},{label:"Navigate",prompt:"Help me find what I need in profClaw."}]}};function Re(){const a=Y().pathname;return r.useMemo(()=>{if(a==="/"||a==="/chat")return{context:o.default};if(a==="/analytics")return{context:o.dashboard};const n=a.match(/^\/tickets\/([^/]+)$/);if(n&&n[1]!=="board")return{context:o.ticketDetail,entityId:n[1]};if(a==="/tickets"||a==="/tickets/board")return{context:o.tickets};const m=a.match(/^\/projects\/([^/]+)$/);if(m)return{context:o.projectDetail,entityId:m[1]};if(a==="/projects")return{context:o.projects};const p=a.match(/^\/tasks\/([^/]+)$/);return p?{context:o.tasks,entityId:p[1]}:a==="/tasks"?{context:o.tasks}:a.startsWith("/summaries")?{context:o.summaries}:a==="/costs"?{context:o.costs}:a==="/gateway"?{context:o.gateway}:a==="/agents"?{context:o.agents}:a.startsWith("/settings")?{context:o.settings}:a==="/webhooks"?{context:o.webhooks}:a==="/failed"?{context:o.failed}:a==="/memory"?{context:o.memory}:a==="/cron"?{context:o.cron}:{context:o.default}},[a])}function Fe({toolCall:i}){const[a,n]=r.useState(!1);return e.jsxs("div",{className:"mt-2 p-2 rounded-lg bg-muted/50 border border-border/50 text-xs",children:[e.jsxs("button",{onClick:()=>n(!a),className:"flex items-center gap-2 w-full text-left",children:[e.jsx(Ee,{className:"h-3 w-3 text-blue-500"}),e.jsx("span",{className:"font-medium",children:i.name}),i.status==="success"&&e.jsx(Ae,{className:"h-3 w-3 text-green-500 ml-auto"}),i.status==="error"&&e.jsx(Le,{className:"h-3 w-3 text-red-500 ml-auto"}),i.status==="pending"&&e.jsx(te,{className:"h-3 w-3 animate-spin text-yellow-500 ml-auto"})]}),a&&e.jsxs("div",{className:"mt-2 space-y-1",children:[e.jsxs("div",{className:"text-muted-foreground",children:[e.jsx("span",{className:"font-medium",children:"Args:"}),e.jsx("pre",{className:"mt-1 p-1 bg-background rounded text-[10px] overflow-x-auto",children:JSON.stringify(i.arguments,null,2)})]}),i.result!==void 0&&i.result!==null&&e.jsxs("div",{className:"text-muted-foreground",children:[e.jsx("span",{className:"font-medium",children:"Result:"}),e.jsx("pre",{className:"mt-1 p-1 bg-background rounded text-[10px] overflow-x-auto max-h-24 overflow-y-auto",children:typeof i.result=="string"?i.result:JSON.stringify(i.result,null,2)})]})]})]})}function Ze(){const i=Y(),a=ce(),{context:n,entityId:m}=Re(),[p,E]=r.useState(!1),[C,se]=r.useState(!1),[w,f]=r.useState([]),[b,q]=r.useState(""),[D,k]=r.useState(null),[L,z]=r.useState(null),[j,P]=r.useState(!1),R=r.useRef(null),H=r.useRef(null),ae=i.pathname==="/"||i.pathname==="/chat"||i.pathname.startsWith("/chat/"),{data:F}=M({queryKey:["ticket",m],queryFn:()=>g.tickets.get(m,!1),enabled:n.type==="ticket-detail"&&!!m}),{data:V}=M({queryKey:["project",m],queryFn:()=>g.projects.get(m),enabled:n.type==="project-detail"&&!!m}),{data:S}=M({queryKey:["chat-providers"],queryFn:()=>g.chat.providers(),staleTime:6e4}),{data:$}=M({queryKey:["chat","models"],queryFn:()=>g.chat.models(),staleTime:6e4}),[y,K]=r.useState(()=>typeof window<"u"&&localStorage.getItem("profclaw-floating-chat-model")||""),re=t=>{K(t),localStorage.setItem("profclaw-floating-chat-model",t)},T=r.useMemo(()=>$?.aliases||[],[$]),h=r.useMemo(()=>S?.providers||[],[S]),_=r.useMemo(()=>new Set(h.map(t=>t.type)),[h]),G=r.useMemo(()=>T.filter(t=>_.has(t.provider)).reduce((t,s)=>{const c=s.provider;return(!t[c]||s.alias.length<t[c].alias.length)&&(t[c]=s),t},{}),[T,_]),v=r.useMemo(()=>Object.values(G).sort((t,s)=>{const c=h.find(u=>u.type===t.provider)?.healthy?1:0;return(h.find(u=>u.type===s.provider)?.healthy?1:0)-c||t.provider.localeCompare(s.provider)}),[G,h]);r.useEffect(()=>{if(!y&&v.length>0){const t=v.find(s=>h.find(c=>c.type===s.provider)?.healthy);t&&K(t.alias)}},[y,v,h]);const N=Pe(n.type,m);r.useEffect(()=>{p&&(async()=>{const s=localStorage.getItem(N);if(s){P(!0);try{const c=await g.chat.conversations.get(s);k(s);const d=c.messages.filter(l=>l.role!=="system").map(l=>({id:l.id,role:l.role,content:l.content,timestamp:new Date(l.createdAt),model:l.model,provider:l.provider,toolCalls:l.toolCalls?.map(le=>({...le,status:"success"}))}));f(d);const u=d.filter(l=>l.role==="assistant").pop();u?.model&&z(u.model)}catch{localStorage.removeItem(N),k(null),f([])}finally{P(!1)}}else k(null),f([])})()},[N,p]),r.useEffect(()=>{R.current?.scrollIntoView({behavior:"smooth"})},[w]),r.useEffect(()=>{p&&!j&&setTimeout(()=>H.current?.focus(),100)},[p,j]);const ne=U({mutationFn:async()=>{const t=`${n.name} Chat`;return(await g.chat.conversations.create({title:t,presetId:"profclaw-assistant",ticketId:n.type==="ticket-detail"?m:void 0,projectId:n.type==="project-detail"?m:void 0})).conversation.id},onSuccess:t=>{k(t),localStorage.setItem(N,t)}}),A=U({mutationFn:async t=>{let s=D;s||(s=await ne.mutateAsync());const c={id:`user-${Date.now()}`,role:"user",content:t,timestamp:new Date};f(l=>[...l,c]);const d=`assistant-${Date.now()}`;f(l=>[...l,{id:d,role:"assistant",content:"",timestamp:new Date,isLoading:!0}]);const u=await g.chat.conversations.sendMessageWithTools(s,{content:t,enableTools:!0,model:y||void 0});return{loadingId:d,response:u}},onSuccess:({loadingId:t,response:s})=>{s.assistantMessage.model&&z(s.assistantMessage.model),f(c=>c.map(d=>d.id===t?{...d,id:s.assistantMessage.id,content:s.assistantMessage.content,isLoading:!1,model:s.assistantMessage.model,provider:s.assistantMessage.provider,toolCalls:s.assistantMessage.toolCalls?.map(u=>({...u,status:"success"}))}:d)),s.assistantMessage.toolCalls?.length&&(a.invalidateQueries({queryKey:["tickets"]}),a.invalidateQueries({queryKey:["projects"]}),a.invalidateQueries({queryKey:["tasks"]}))},onError:t=>{f(s=>[...s.filter(d=>!d.isLoading),{id:`error-${Date.now()}`,role:"assistant",content:`Sorry, I encountered an error: ${t instanceof Error?t.message:"Unknown error"}`,timestamp:new Date}])}}),O=()=>{if(!b.trim()||A.isPending)return;const t=b.trim();q(""),A.mutate(t)},ie=t=>{t.key==="Enter"&&!t.shiftKey&&(t.preventDefault(),O())},oe=async()=>{if(D){try{await g.chat.conversations.delete(D)}catch{}localStorage.removeItem(N),k(null)}f([]),z(null)},B=n.icon;return ae?null:e.jsxs(e.Fragment,{children:[p&&e.jsxs("div",{className:x("fixed z-50 flex flex-col overflow-hidden transition-all duration-300 ease-out","bottom-24 right-4 sm:right-6","glass-heavy","rounded-[2rem] shadow-2xl shadow-primary/10",C?"w-[calc(100vw-2rem)] sm:w-130 md:w-150 lg:w-170 h-[72vh] sm:h-155 md:h-180":"w-[calc(100vw-2rem)] sm:w-105 md:w-120 h-[62vh] sm:h-140 md:h-155"),children:[e.jsxs("div",{className:"flex items-center justify-between px-5 py-4 bg-primary/5",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"relative h-9 w-9 rounded-xl glass-heavy flex items-center justify-center shadow-lg shadow-primary/5",children:[e.jsx(W,{className:"h-5 w-5 text-primary"}),e.jsx("span",{className:"absolute -top-1.5 -right-1.5 px-1.5 py-0.5 text-[8px] font-black uppercase rounded-lg bg-primary text-primary-foreground leading-none shadow-sm",children:"Beta"})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-black tracking-tight uppercase tracking-[0.1em]",children:"profClaw Assistant"}),e.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] text-muted-foreground font-semibold",children:[e.jsx(B,{className:"h-3 w-3"}),e.jsx("span",{className:"uppercase tracking-widest",children:n.name}),m&&F&&e.jsxs("span",{className:"text-sky-600 dark:text-sky-400",children:["• ",F.sequence]}),m&&V&&e.jsxs("span",{className:"text-sky-600 dark:text-sky-400",children:["• ",V.key]})]})]})]}),v.length>0&&e.jsxs(de,{children:[e.jsx(me,{asChild:!0,children:e.jsxs("button",{className:"flex items-center gap-1.5 px-2.5 py-1.5 rounded-xl text-[10px] font-bold bg-primary/10 hover:bg-primary/20 transition-all shadow-sm",children:[e.jsx("span",{className:x("h-1.5 w-1.5 rounded-full",h.find(t=>t.type===T.find(s=>s.alias===y)?.provider)?.healthy?"bg-emerald-500 shadow-[0_0_8px_var(--success)]":"bg-amber-400 shadow-[0_0_8px_var(--warning)]")}),e.jsx(X,{className:"h-3.5 w-3.5 text-primary"}),e.jsx("span",{className:"capitalize max-w-20 truncate text-primary font-black",children:y||L||"Model"}),e.jsx(pe,{className:"h-3 w-3 text-primary opacity-50"})]})}),e.jsxs(ue,{align:"end",className:"w-52 glass-heavy shadow-2xl",children:[e.jsx("div",{className:"px-2 py-1.5 text-[9px] font-medium text-muted-foreground uppercase tracking-wider",children:"Select Model"}),e.jsx(he,{}),v.map(t=>{const c=h.find(l=>l.type===t.provider)?.healthy,d=(y||L)===t.alias,u=t.provider==="ollama";return e.jsxs(fe,{onClick:()=>re(t.alias),className:x("flex items-center justify-between cursor-pointer text-xs py-2",d&&"bg-primary/20"),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:x("h-1.5 w-1.5 rounded-full",c?"bg-emerald-500":"bg-amber-400")}),e.jsx("span",{className:x("capitalize font-bold",d&&"text-primary"),children:t.alias})]}),e.jsx("span",{className:"text-[9px] text-muted-foreground",children:u?"Local":t.provider})]},t.alias)})]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[w.length>0&&e.jsx(I,{variant:"ghost",size:"sm",onClick:oe,className:"h-7 w-7 p-0",title:"Clear chat",children:e.jsx(De,{className:"h-3.5 w-3.5"})}),e.jsx(I,{variant:"ghost",size:"sm",onClick:()=>se(!C),className:"h-7 w-7 p-0",title:C?"Minimize":"Expand",children:C?e.jsx(Me,{className:"h-3.5 w-3.5"}):e.jsx(Ie,{className:"h-3.5 w-3.5"})}),e.jsx(I,{variant:"ghost",size:"sm",onClick:()=>E(!1),className:"h-7 w-7 p-0",title:"Close",children:e.jsx(xe,{className:"h-3.5 w-3.5"})})]})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-3.5 scrollbar-none liquid-fade-y",children:[j?e.jsxs("div",{className:"flex flex-col items-center justify-center h-full",children:[e.jsx(ge,{className:"h-6 w-6 animate-spin text-sky-500 mb-2"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Loading conversation..."})]}):w.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-center px-4",children:[e.jsx("div",{className:"h-12 w-12 rounded-xl bg-sky-500/10 flex items-center justify-center mb-3",children:e.jsx(B,{className:"h-6 w-6 text-sky-500"})}),e.jsxs("h4",{className:"text-sm font-medium mb-1",children:[n.name," Assistant"]}),e.jsxs("p",{className:"text-xs text-muted-foreground mb-4 max-w-70",children:[n.description,". How can I help?"]}),e.jsxs("div",{className:"w-full space-y-2",children:[e.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wide",children:"Quick Actions"}),e.jsx("div",{className:"flex flex-col gap-2",children:n.quickActions.map(t=>e.jsx("button",{onClick:()=>{q(t.prompt),setTimeout(()=>H.current?.focus(),0)},className:"px-3 py-2 text-xs text-left rounded-lg bg-muted/50 hover:bg-muted transition-colors border border-transparent hover:border-border",children:t.label},t.label))})]}),e.jsxs("div",{className:"mt-4 pt-4 border-t border-border w-full",children:[e.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wide mb-2",children:"I can help you"}),e.jsx("ul",{className:"text-[11px] text-muted-foreground text-left space-y-1",children:n.capabilities.slice(0,3).map((t,s)=>e.jsxs("li",{className:"flex items-start gap-1.5",children:[e.jsx("span",{className:"text-sky-500 mt-0.5",children:"•"}),t]},s))})]}),S?.default&&e.jsxs("div",{className:"mt-4 pt-2 text-[10px] text-muted-foreground/70 flex items-center gap-1",children:[e.jsx(X,{className:"h-3 w-3"}),e.jsxs("span",{children:["Powered by ",S.default]})]})]}):w.map(t=>e.jsxs("div",{className:x("flex gap-3",t.role==="user"?"justify-end":"justify-start"),children:[t.role==="assistant"&&e.jsx("div",{className:"h-7 w-7 rounded-full bg-zinc-100 dark:bg-zinc-800 flex items-center justify-center shrink-0",children:e.jsx(ee,{className:"h-4 w-4 text-zinc-500"})}),e.jsx("div",{className:x("max-w-[85%] rounded-[1.5rem] px-5 py-3.5 text-[14px] leading-relaxed shadow-lg transition-all",t.role==="user"?"bg-primary text-primary-foreground rounded-tr-sm ml-auto shadow-primary/10":"glass text-foreground rounded-tl-sm shadow-sm",t.role==="assistant"&&"mr-auto"),children:t.isLoading?e.jsxs("div",{className:"flex items-center gap-2 py-0.5",children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-zinc-400 dark:bg-zinc-600 animate-bounce delay-0"}),e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-zinc-400 dark:bg-zinc-600 animate-bounce delay-150"}),e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-zinc-400 dark:bg-zinc-600 animate-bounce delay-300"})]}):t.role==="assistant"?e.jsxs(e.Fragment,{children:[e.jsx(qe,{content:t.content}),t.toolCalls&&t.toolCalls.length>0&&e.jsx("div",{className:"mt-2 space-y-1",children:t.toolCalls.map(s=>e.jsx(Fe,{toolCall:s},s.id))})]}):e.jsx("p",{className:"whitespace-pre-wrap",children:t.content})}),t.role==="user"&&e.jsx("div",{className:"h-8 w-8 rounded-xl glass-heavy flex items-center justify-center shrink-0 shadow-lg",children:e.jsx(ye,{className:"h-4.5 w-4.5 text-primary"})})]},t.id)),e.jsx("div",{ref:R})]}),e.jsxs("div",{className:"p-4 bg-primary/5",children:[e.jsxs("div",{className:"flex items-end gap-2",children:[e.jsx("textarea",{ref:H,value:b,onChange:t=>q(t.target.value),onKeyDown:ie,placeholder:`Ask about ${n.name.toLowerCase()}...`,rows:1,disabled:j,className:"flex-1 px-4 py-3 text-sm glass rounded-[1.5rem] resize-none focus:outline-none focus:ring-1 focus:ring-primary/20 focus:bg-white/50 dark:focus:bg-black/50 min-h-11 max-h-32 placeholder:text-muted-foreground/50 disabled:opacity-50 transition-all font-medium",style:{height:"auto",overflow:b.split(`
|
|
1
|
+
import{bN as Y,n as ce,r,u as M,o as U,j as e,S as W,D as de,x as me,i as x,a5 as pe,y as ue,aw as he,z as fe,k as I,X as xe,R as ge,B as ee,an as ye,L as te,T as Q,F as J,a as we,N as be,bO as ke,Z as je,V as ve,aj as Ne,U as Ce,g as Se,m as g,ak as Ae}from"./index-lJlNPFVJ.js";import{M as Me,a as Ie,b as qe}from"./markdown-renderer-n1ToC4XQ.js";import{C as X}from"./cpu-DiPMQICV.js";import{T as De}from"./trash-2-keO5tKPE.js";import{S as ze}from"./send-P0r5D7td.js";import{M as He}from"./message-square-CBgH65X7.js";import{L as Te}from"./layout-dashboard-CcKt1hXw.js";import{B as We}from"./brain-6o_RHVpe.js";import{W as Ee}from"./wrench-02YaOSiK.js";import{C as Le}from"./circle-x-Dgw11LgT.js";import"./defineProperty-CoXUr7_6.js";const Z="profclaw_chatbot_conversation_";function Pe(i,a){return a?`${Z}${i}_${a}`:`${Z}${i}`}const o={dashboard:{type:"dashboard",name:"Dashboard",icon:Te,description:"Overview of your workspace with stats and recent activity",capabilities:["View workspace statistics and metrics","See recent tickets and tasks","Check team activity and progress","Get insights on productivity trends"],quickActions:[{label:"Status report",prompt:"Give me a status report of my workspace. What are the key metrics and any items needing attention?"},{label:"What's new?",prompt:"What's happened recently in my workspace? Any updates I should know about?"},{label:"Productivity tips",prompt:"Based on my current workload, what productivity tips do you have?"}]},tickets:{type:"tickets",name:"Tickets",icon:Q,description:"Manage and track your tickets",capabilities:["Create new tickets","Search and filter tickets","Update ticket status and priority","Add comments and checklists","Assign tickets to team members"],quickActions:[{label:"Create ticket",prompt:"Help me create a new ticket. Ask me what it should be about."},{label:"Find tickets",prompt:"Help me find tickets. What would you like to search for?"},{label:"Ticket overview",prompt:"Give me an overview of my tickets - how many are open, in progress, and done?"}]},ticketDetail:{type:"ticket-detail",name:"Ticket Details",icon:Q,description:"Viewing a specific ticket",capabilities:["Update this ticket (status, priority, description)","Add comments to this ticket","Create checklists and subtasks","Link related tickets","Generate AI summaries"],quickActions:[{label:"Summarize",prompt:"Summarize this ticket and its current status for me."},{label:"Suggest next steps",prompt:"Based on this ticket, what should be the next steps to resolve it?"},{label:"Draft comment",prompt:"Help me draft a status update comment for this ticket."}]},projects:{type:"projects",name:"Projects",icon:J,description:"Manage your projects and sprints",capabilities:["Create new projects","View project progress","Manage sprints and iterations","See project analytics"],quickActions:[{label:"Create project",prompt:"Help me create a new project. What should it be called and what prefix should it use?"},{label:"Project status",prompt:"Give me a status update on all my projects."},{label:"Sprint planning",prompt:"Help me plan a new sprint. What tickets should be included?"}]},projectDetail:{type:"project-detail",name:"Project Details",icon:J,description:"Viewing a specific project",capabilities:["View project metrics and progress","Manage sprints for this project","See all tickets in this project","Update project settings"],quickActions:[{label:"Project summary",prompt:"Give me a summary of this project - progress, blockers, and upcoming work."},{label:"Sprint status",prompt:"What's the status of the current sprint in this project?"},{label:"Create ticket",prompt:"Help me create a new ticket for this project."}]},tasks:{type:"tasks",name:"Tasks",icon:we,description:"View and manage AI agent tasks",capabilities:["View pending and completed tasks","Retry failed tasks","See task execution details","Monitor agent activity"],quickActions:[{label:"Task status",prompt:"Give me an overview of my task queue - pending, running, and completed."},{label:"Failed tasks",prompt:"Are there any failed tasks that need attention?"},{label:"Agent activity",prompt:"What are my AI agents currently working on?"}]},summaries:{type:"summaries",name:"Summaries",icon:be,description:"AI-generated session summaries",capabilities:["Browse past session summaries","Search for specific work","Review completed work history"],quickActions:[{label:"Recent work",prompt:"What work has been completed recently? Show me recent summaries."},{label:"Find summary",prompt:"Help me find a summary about a specific topic or task."}]},costs:{type:"costs",name:"Cost Dashboard",icon:ke,description:"Track AI usage and costs",capabilities:["View token usage statistics","Monitor cost trends","See cost breakdown by model","Set usage alerts"],quickActions:[{label:"Cost summary",prompt:"What's my AI usage and cost this month?"},{label:"Compare models",prompt:"Compare the costs between different AI models I use."}]},gateway:{type:"gateway",name:"AI Gateway",icon:je,description:"Manage AI agent workflows",capabilities:["Execute AI workflows","Configure agents","Monitor gateway status"],quickActions:[{label:"Run workflow",prompt:"Help me run an AI workflow. What task should I execute?"},{label:"Gateway status",prompt:"What's the status of the AI gateway?"}]},agents:{type:"agents",name:"Agents",icon:ee,description:"Configure AI agents",capabilities:["View available agents","Configure agent settings","Monitor agent health"],quickActions:[{label:"Agent status",prompt:"Show me the status of all AI agents."},{label:"Configure agent",prompt:"Help me configure an AI agent."}]},settings:{type:"settings",name:"Settings",icon:ve,description:"Configure profClaw settings",capabilities:["Configure AI providers","Manage integrations","Update preferences"],quickActions:[{label:"Setup help",prompt:"Help me set up and configure profClaw."},{label:"Provider config",prompt:"Help me configure an AI provider."}]},webhooks:{type:"webhooks",name:"Webhooks",icon:Ne,description:"Manage webhook integrations",capabilities:["View webhook status","Test webhook connections","Configure webhook endpoints"],quickActions:[{label:"Webhook status",prompt:"Show me the status of all webhooks."},{label:"Setup webhook",prompt:"Help me set up a new webhook integration."}]},failed:{type:"failed",name:"Failed Tasks",icon:Ce,description:"Review and retry failed tasks",capabilities:["View failed task details","Retry failed tasks","Analyze failure patterns"],quickActions:[{label:"Analyze failures",prompt:"Analyze the failed tasks and tell me what went wrong."},{label:"Retry all",prompt:"Help me retry the failed tasks."}]},memory:{type:"memory",name:"Memory",icon:We,description:"AI memory and context",capabilities:["Search memory for past context","View memory statistics","Manage memory files"],quickActions:[{label:"Search memory",prompt:"Search my memory for information about..."},{label:"Memory stats",prompt:"What's stored in my AI memory?"}]},cron:{type:"cron",name:"Scheduled Jobs",icon:Se,description:"Manage automated scheduled tasks",capabilities:["Create new scheduled jobs","View job status and history","Trigger jobs manually","Pause and resume jobs","Monitor execution logs"],quickActions:[{label:"Job status",prompt:"Show me the status of all my scheduled jobs. How many are active, paused, or failed?"},{label:"Recent failures",prompt:"Are there any failed scheduled jobs? Show me the recent failures and what went wrong."},{label:"Create job",prompt:"Help me create a new scheduled job. What task should it automate and how often should it run?"},{label:"Job history",prompt:"Show me the execution history of my scheduled jobs. Which ones ran recently?"}]},default:{type:"default",name:"profClaw",icon:W,description:"AI-powered task management",capabilities:["Answer questions about profClaw","Help with navigation","Provide general assistance"],quickActions:[{label:"Help",prompt:"What can you help me with in profClaw?"},{label:"Navigate",prompt:"Help me find what I need in profClaw."}]}};function Re(){const a=Y().pathname;return r.useMemo(()=>{if(a==="/"||a==="/chat")return{context:o.default};if(a==="/analytics")return{context:o.dashboard};const n=a.match(/^\/tickets\/([^/]+)$/);if(n&&n[1]!=="board")return{context:o.ticketDetail,entityId:n[1]};if(a==="/tickets"||a==="/tickets/board")return{context:o.tickets};const m=a.match(/^\/projects\/([^/]+)$/);if(m)return{context:o.projectDetail,entityId:m[1]};if(a==="/projects")return{context:o.projects};const p=a.match(/^\/tasks\/([^/]+)$/);return p?{context:o.tasks,entityId:p[1]}:a==="/tasks"?{context:o.tasks}:a.startsWith("/summaries")?{context:o.summaries}:a==="/costs"?{context:o.costs}:a==="/gateway"?{context:o.gateway}:a==="/agents"?{context:o.agents}:a.startsWith("/settings")?{context:o.settings}:a==="/webhooks"?{context:o.webhooks}:a==="/failed"?{context:o.failed}:a==="/memory"?{context:o.memory}:a==="/cron"?{context:o.cron}:{context:o.default}},[a])}function Fe({toolCall:i}){const[a,n]=r.useState(!1);return e.jsxs("div",{className:"mt-2 p-2 rounded-lg bg-muted/50 border border-border/50 text-xs",children:[e.jsxs("button",{onClick:()=>n(!a),className:"flex items-center gap-2 w-full text-left",children:[e.jsx(Ee,{className:"h-3 w-3 text-blue-500"}),e.jsx("span",{className:"font-medium",children:i.name}),i.status==="success"&&e.jsx(Ae,{className:"h-3 w-3 text-green-500 ml-auto"}),i.status==="error"&&e.jsx(Le,{className:"h-3 w-3 text-red-500 ml-auto"}),i.status==="pending"&&e.jsx(te,{className:"h-3 w-3 animate-spin text-yellow-500 ml-auto"})]}),a&&e.jsxs("div",{className:"mt-2 space-y-1",children:[e.jsxs("div",{className:"text-muted-foreground",children:[e.jsx("span",{className:"font-medium",children:"Args:"}),e.jsx("pre",{className:"mt-1 p-1 bg-background rounded text-[10px] overflow-x-auto",children:JSON.stringify(i.arguments,null,2)})]}),i.result!==void 0&&i.result!==null&&e.jsxs("div",{className:"text-muted-foreground",children:[e.jsx("span",{className:"font-medium",children:"Result:"}),e.jsx("pre",{className:"mt-1 p-1 bg-background rounded text-[10px] overflow-x-auto max-h-24 overflow-y-auto",children:typeof i.result=="string"?i.result:JSON.stringify(i.result,null,2)})]})]})]})}function Ze(){const i=Y(),a=ce(),{context:n,entityId:m}=Re(),[p,E]=r.useState(!1),[C,se]=r.useState(!1),[w,f]=r.useState([]),[b,q]=r.useState(""),[D,k]=r.useState(null),[L,z]=r.useState(null),[j,P]=r.useState(!1),R=r.useRef(null),H=r.useRef(null),ae=i.pathname==="/"||i.pathname==="/chat"||i.pathname.startsWith("/chat/"),{data:F}=M({queryKey:["ticket",m],queryFn:()=>g.tickets.get(m,!1),enabled:n.type==="ticket-detail"&&!!m}),{data:V}=M({queryKey:["project",m],queryFn:()=>g.projects.get(m),enabled:n.type==="project-detail"&&!!m}),{data:S}=M({queryKey:["chat-providers"],queryFn:()=>g.chat.providers(),staleTime:6e4}),{data:$}=M({queryKey:["chat","models"],queryFn:()=>g.chat.models(),staleTime:6e4}),[y,K]=r.useState(()=>typeof window<"u"&&localStorage.getItem("profclaw-floating-chat-model")||""),re=t=>{K(t),localStorage.setItem("profclaw-floating-chat-model",t)},T=r.useMemo(()=>$?.aliases||[],[$]),h=r.useMemo(()=>S?.providers||[],[S]),_=r.useMemo(()=>new Set(h.map(t=>t.type)),[h]),G=r.useMemo(()=>T.filter(t=>_.has(t.provider)).reduce((t,s)=>{const c=s.provider;return(!t[c]||s.alias.length<t[c].alias.length)&&(t[c]=s),t},{}),[T,_]),v=r.useMemo(()=>Object.values(G).sort((t,s)=>{const c=h.find(u=>u.type===t.provider)?.healthy?1:0;return(h.find(u=>u.type===s.provider)?.healthy?1:0)-c||t.provider.localeCompare(s.provider)}),[G,h]);r.useEffect(()=>{if(!y&&v.length>0){const t=v.find(s=>h.find(c=>c.type===s.provider)?.healthy);t&&K(t.alias)}},[y,v,h]);const N=Pe(n.type,m);r.useEffect(()=>{p&&(async()=>{const s=localStorage.getItem(N);if(s){P(!0);try{const c=await g.chat.conversations.get(s);k(s);const d=c.messages.filter(l=>l.role!=="system").map(l=>({id:l.id,role:l.role,content:l.content,timestamp:new Date(l.createdAt),model:l.model,provider:l.provider,toolCalls:l.toolCalls?.map(le=>({...le,status:"success"}))}));f(d);const u=d.filter(l=>l.role==="assistant").pop();u?.model&&z(u.model)}catch{localStorage.removeItem(N),k(null),f([])}finally{P(!1)}}else k(null),f([])})()},[N,p]),r.useEffect(()=>{R.current?.scrollIntoView({behavior:"smooth"})},[w]),r.useEffect(()=>{p&&!j&&setTimeout(()=>H.current?.focus(),100)},[p,j]);const ne=U({mutationFn:async()=>{const t=`${n.name} Chat`;return(await g.chat.conversations.create({title:t,presetId:"profclaw-assistant",ticketId:n.type==="ticket-detail"?m:void 0,projectId:n.type==="project-detail"?m:void 0})).conversation.id},onSuccess:t=>{k(t),localStorage.setItem(N,t)}}),A=U({mutationFn:async t=>{let s=D;s||(s=await ne.mutateAsync());const c={id:`user-${Date.now()}`,role:"user",content:t,timestamp:new Date};f(l=>[...l,c]);const d=`assistant-${Date.now()}`;f(l=>[...l,{id:d,role:"assistant",content:"",timestamp:new Date,isLoading:!0}]);const u=await g.chat.conversations.sendMessageWithTools(s,{content:t,enableTools:!0,model:y||void 0});return{loadingId:d,response:u}},onSuccess:({loadingId:t,response:s})=>{s.assistantMessage.model&&z(s.assistantMessage.model),f(c=>c.map(d=>d.id===t?{...d,id:s.assistantMessage.id,content:s.assistantMessage.content,isLoading:!1,model:s.assistantMessage.model,provider:s.assistantMessage.provider,toolCalls:s.assistantMessage.toolCalls?.map(u=>({...u,status:"success"}))}:d)),s.assistantMessage.toolCalls?.length&&(a.invalidateQueries({queryKey:["tickets"]}),a.invalidateQueries({queryKey:["projects"]}),a.invalidateQueries({queryKey:["tasks"]}))},onError:t=>{f(s=>[...s.filter(d=>!d.isLoading),{id:`error-${Date.now()}`,role:"assistant",content:`Sorry, I encountered an error: ${t instanceof Error?t.message:"Unknown error"}`,timestamp:new Date}])}}),O=()=>{if(!b.trim()||A.isPending)return;const t=b.trim();q(""),A.mutate(t)},ie=t=>{t.key==="Enter"&&!t.shiftKey&&(t.preventDefault(),O())},oe=async()=>{if(D){try{await g.chat.conversations.delete(D)}catch{}localStorage.removeItem(N),k(null)}f([]),z(null)},B=n.icon;return ae?null:e.jsxs(e.Fragment,{children:[p&&e.jsxs("div",{className:x("fixed z-50 flex flex-col overflow-hidden transition-all duration-300 ease-out","bottom-24 right-4 sm:right-6","glass-heavy","rounded-[2rem] shadow-2xl shadow-primary/10",C?"w-[calc(100vw-2rem)] sm:w-130 md:w-150 lg:w-170 h-[72vh] sm:h-155 md:h-180":"w-[calc(100vw-2rem)] sm:w-105 md:w-120 h-[62vh] sm:h-140 md:h-155"),children:[e.jsxs("div",{className:"flex items-center justify-between px-5 py-4 bg-primary/5",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"relative h-9 w-9 rounded-xl glass-heavy flex items-center justify-center shadow-lg shadow-primary/5",children:[e.jsx(W,{className:"h-5 w-5 text-primary"}),e.jsx("span",{className:"absolute -top-1.5 -right-1.5 px-1.5 py-0.5 text-[8px] font-black uppercase rounded-lg bg-primary text-primary-foreground leading-none shadow-sm",children:"Beta"})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-black tracking-tight uppercase tracking-[0.1em]",children:"profClaw Assistant"}),e.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] text-muted-foreground font-semibold",children:[e.jsx(B,{className:"h-3 w-3"}),e.jsx("span",{className:"uppercase tracking-widest",children:n.name}),m&&F&&e.jsxs("span",{className:"text-sky-600 dark:text-sky-400",children:["• ",F.sequence]}),m&&V&&e.jsxs("span",{className:"text-sky-600 dark:text-sky-400",children:["• ",V.key]})]})]})]}),v.length>0&&e.jsxs(de,{children:[e.jsx(me,{asChild:!0,children:e.jsxs("button",{className:"flex items-center gap-1.5 px-2.5 py-1.5 rounded-xl text-[10px] font-bold bg-primary/10 hover:bg-primary/20 transition-all shadow-sm",children:[e.jsx("span",{className:x("h-1.5 w-1.5 rounded-full",h.find(t=>t.type===T.find(s=>s.alias===y)?.provider)?.healthy?"bg-emerald-500 shadow-[0_0_8px_var(--success)]":"bg-amber-400 shadow-[0_0_8px_var(--warning)]")}),e.jsx(X,{className:"h-3.5 w-3.5 text-primary"}),e.jsx("span",{className:"capitalize max-w-20 truncate text-primary font-black",children:y||L||"Model"}),e.jsx(pe,{className:"h-3 w-3 text-primary opacity-50"})]})}),e.jsxs(ue,{align:"end",className:"w-52 glass-heavy shadow-2xl",children:[e.jsx("div",{className:"px-2 py-1.5 text-[9px] font-medium text-muted-foreground uppercase tracking-wider",children:"Select Model"}),e.jsx(he,{}),v.map(t=>{const c=h.find(l=>l.type===t.provider)?.healthy,d=(y||L)===t.alias,u=t.provider==="ollama";return e.jsxs(fe,{onClick:()=>re(t.alias),className:x("flex items-center justify-between cursor-pointer text-xs py-2",d&&"bg-primary/20"),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:x("h-1.5 w-1.5 rounded-full",c?"bg-emerald-500":"bg-amber-400")}),e.jsx("span",{className:x("capitalize font-bold",d&&"text-primary"),children:t.alias})]}),e.jsx("span",{className:"text-[9px] text-muted-foreground",children:u?"Local":t.provider})]},t.alias)})]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[w.length>0&&e.jsx(I,{variant:"ghost",size:"sm",onClick:oe,className:"h-7 w-7 p-0",title:"Clear chat",children:e.jsx(De,{className:"h-3.5 w-3.5"})}),e.jsx(I,{variant:"ghost",size:"sm",onClick:()=>se(!C),className:"h-7 w-7 p-0",title:C?"Minimize":"Expand",children:C?e.jsx(Me,{className:"h-3.5 w-3.5"}):e.jsx(Ie,{className:"h-3.5 w-3.5"})}),e.jsx(I,{variant:"ghost",size:"sm",onClick:()=>E(!1),className:"h-7 w-7 p-0",title:"Close",children:e.jsx(xe,{className:"h-3.5 w-3.5"})})]})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-3.5 scrollbar-none liquid-fade-y",children:[j?e.jsxs("div",{className:"flex flex-col items-center justify-center h-full",children:[e.jsx(ge,{className:"h-6 w-6 animate-spin text-sky-500 mb-2"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Loading conversation..."})]}):w.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-center px-4",children:[e.jsx("div",{className:"h-12 w-12 rounded-xl bg-sky-500/10 flex items-center justify-center mb-3",children:e.jsx(B,{className:"h-6 w-6 text-sky-500"})}),e.jsxs("h4",{className:"text-sm font-medium mb-1",children:[n.name," Assistant"]}),e.jsxs("p",{className:"text-xs text-muted-foreground mb-4 max-w-70",children:[n.description,". How can I help?"]}),e.jsxs("div",{className:"w-full space-y-2",children:[e.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wide",children:"Quick Actions"}),e.jsx("div",{className:"flex flex-col gap-2",children:n.quickActions.map(t=>e.jsx("button",{onClick:()=>{q(t.prompt),setTimeout(()=>H.current?.focus(),0)},className:"px-3 py-2 text-xs text-left rounded-lg bg-muted/50 hover:bg-muted transition-colors border border-transparent hover:border-border",children:t.label},t.label))})]}),e.jsxs("div",{className:"mt-4 pt-4 border-t border-border w-full",children:[e.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wide mb-2",children:"I can help you"}),e.jsx("ul",{className:"text-[11px] text-muted-foreground text-left space-y-1",children:n.capabilities.slice(0,3).map((t,s)=>e.jsxs("li",{className:"flex items-start gap-1.5",children:[e.jsx("span",{className:"text-sky-500 mt-0.5",children:"•"}),t]},s))})]}),S?.default&&e.jsxs("div",{className:"mt-4 pt-2 text-[10px] text-muted-foreground/70 flex items-center gap-1",children:[e.jsx(X,{className:"h-3 w-3"}),e.jsxs("span",{children:["Powered by ",S.default]})]})]}):w.map(t=>e.jsxs("div",{className:x("flex gap-3",t.role==="user"?"justify-end":"justify-start"),children:[t.role==="assistant"&&e.jsx("div",{className:"h-7 w-7 rounded-full bg-zinc-100 dark:bg-zinc-800 flex items-center justify-center shrink-0",children:e.jsx(ee,{className:"h-4 w-4 text-zinc-500"})}),e.jsx("div",{className:x("max-w-[85%] rounded-[1.5rem] px-5 py-3.5 text-[14px] leading-relaxed shadow-lg transition-all",t.role==="user"?"bg-primary text-primary-foreground rounded-tr-sm ml-auto shadow-primary/10":"glass text-foreground rounded-tl-sm shadow-sm",t.role==="assistant"&&"mr-auto"),children:t.isLoading?e.jsxs("div",{className:"flex items-center gap-2 py-0.5",children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-zinc-400 dark:bg-zinc-600 animate-bounce delay-0"}),e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-zinc-400 dark:bg-zinc-600 animate-bounce delay-150"}),e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-zinc-400 dark:bg-zinc-600 animate-bounce delay-300"})]}):t.role==="assistant"?e.jsxs(e.Fragment,{children:[e.jsx(qe,{content:t.content}),t.toolCalls&&t.toolCalls.length>0&&e.jsx("div",{className:"mt-2 space-y-1",children:t.toolCalls.map(s=>e.jsx(Fe,{toolCall:s},s.id))})]}):e.jsx("p",{className:"whitespace-pre-wrap",children:t.content})}),t.role==="user"&&e.jsx("div",{className:"h-8 w-8 rounded-xl glass-heavy flex items-center justify-center shrink-0 shadow-lg",children:e.jsx(ye,{className:"h-4.5 w-4.5 text-primary"})})]},t.id)),e.jsx("div",{ref:R})]}),e.jsxs("div",{className:"p-4 bg-primary/5",children:[e.jsxs("div",{className:"flex items-end gap-2",children:[e.jsx("textarea",{ref:H,value:b,onChange:t=>q(t.target.value),onKeyDown:ie,placeholder:`Ask about ${n.name.toLowerCase()}...`,rows:1,disabled:j,className:"flex-1 px-4 py-3 text-sm glass rounded-[1.5rem] resize-none focus:outline-none focus:ring-1 focus:ring-primary/20 focus:bg-white/50 dark:focus:bg-black/50 min-h-11 max-h-32 placeholder:text-muted-foreground/50 disabled:opacity-50 transition-all font-medium",style:{height:"auto",overflow:b.split(`
|
|
2
2
|
`).length>3?"auto":"hidden"},onInput:t=>{const s=t.target;s.style.height="auto",s.style.height=Math.min(s.scrollHeight,120)+"px"}}),e.jsx(I,{onClick:O,disabled:!b.trim()||A.isPending||j,size:"sm",className:"h-11 w-11 p-0 rounded-2xl bg-primary hover:bg-primary-hover text-primary-foreground shadow-xl shadow-primary/20 hover:scale-110 active:scale-95 transition-all",children:A.isPending?e.jsx(te,{className:"h-4 w-4 animate-spin"}):e.jsx(ze,{className:"h-4 w-4"})})]}),e.jsxs("p",{className:"text-[10px] text-muted-foreground text-center mt-2 font-medium opacity-60",children:["Press Enter to send • Shift+Enter for new line",w.length>0&&" • Session auto-saved"]})]})]}),e.jsx("button",{onClick:()=>E(!p),className:x("fixed bottom-6 right-6 z-50 h-[60px] w-[60px] rounded-[1.5rem] flex items-center justify-center transition-all duration-300 ease-out hover:scale-110 active:scale-90 shadow-2xl",p?"glass-heavy text-primary shadow-primary/10":"bg-primary text-primary-foreground shadow-primary/30"),title:p?"Close chat":`Open profClaw Assistant (${n.name})`,children:p?e.jsx(He,{className:"h-6 w-6"}):e.jsx(W,{className:"h-6 w-6"})})]})}export{Ze as FloatingChatbot,Ze as default};
|
package/ui/dist/assets/{InviteCodeManagement-DTm-IPTm.js → InviteCodeManagement-LEoGqYeA.js}
RENAMED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{c as pe,n as je,r as a,u as q,o as C,t as r,j as e,U as O,af as fe,k as n,R as Ne,i as Q,P as B,L as D,w as we,g as ve,D as be,x as ye,y as Ce,bo as De,aw as F,z as $,Q as k,C as S,O as K}from"./index--JkIxVXb.js";import{A as U,a as H,b as _,c as J,d as V,e as X,f as Y,g as W}from"./alert-dialog-DWPb2IfQ.js";import{G as Z}from"./globe-CQWfr7hT.js";import{E as ke}from"./ellipsis-FhHKRbfl.js";import{T as Se}from"./trash-2-eM-CNwsZ.js";import{C as Ae}from"./circle-x-C78PNZjF.js";const Me=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]],ee=pe("lock",Me),Te="http://localhost:3000";async function x(t,l={}){const i=await fetch(`${Te}/api/users${t}`,{...l,headers:{"Content-Type":"application/json",...l.headers},credentials:"include"});if(!i.ok){const g=await i.json().catch(()=>({error:"Unknown error"}));throw new Error(g.error||`HTTP ${i.status}`)}return i.json()}const m={list:()=>x("/admin/invites"),generate:t=>x("/admin/invites",{method:"POST",body:JSON.stringify(t)}),delete:t=>x(`/admin/invites/${t}`,{method:"DELETE"}),getRegistrationMode:()=>x("/admin/registration-mode"),setRegistrationMode:t=>x("/admin/registration-mode",{method:"PATCH",body:JSON.stringify({mode:t})})};function Pe(){const t=je(),[l,i]=a.useState(""),[g,p]=a.useState(!1),[se,A]=a.useState(!1),[u,te]=a.useState([]),[M,T]=a.useState(1),[I,L]=a.useState(""),[j,E]=a.useState(""),[G,R]=a.useState(null),[f,N]=a.useState(null),[ae,w]=a.useState(!1),{data:c,isLoading:v,error:z,refetch:ne}=q({queryKey:["admin","inviteCodes"],queryFn:()=>m.list()}),{data:d}=q({queryKey:["admin","registrationMode"],queryFn:()=>m.getRegistrationMode()}),b=C({mutationFn:m.generate,onSuccess:s=>{te(s.codes),p(!1),A(!0),T(1),L(""),E(""),t.invalidateQueries({queryKey:["admin","inviteCodes"]}),r.success(`Generated ${s.codes.length} invite code(s)`)},onError:s=>r.error(s.message)}),le=C({mutationFn:m.delete,onSuccess:()=>{t.invalidateQueries({queryKey:["admin","inviteCodes"]}),r.success("Invite code deleted")},onError:s=>r.error(s.message)}),h=C({mutationFn:s=>m.setRegistrationMode(s),onSuccess:s=>{t.invalidateQueries({queryKey:["admin","registrationMode"]}),r.success(`Registration mode set to ${s.mode}`)},onError:s=>r.error(s.message)}),y=(s,o)=>{navigator.clipboard.writeText(s),R(o),setTimeout(()=>R(null),2e3),r.success(`${o} copied`)},re=s=>s.usedBy?{label:"Used",color:"bg-zinc-500/10 text-zinc-500",icon:S}:s.expiresAt&&new Date>new Date(s.expiresAt)?{label:"Expired",color:"bg-red-500/10 text-red-500",icon:Ae}:{label:"Available",color:"bg-green-500/10 text-green-500",icon:S},P=c?.invites?.filter(s=>(s.label||"").toLowerCase().includes(l.toLowerCase())||s.id.toLowerCase().includes(l.toLowerCase())||(s.createdBy||"").toLowerCase().includes(l.toLowerCase()))||[],ie=()=>{b.mutate({count:M,label:I||void 0,expiresInDays:j?parseInt(j,10):void 0})},de=s=>{N(s)},oe=()=>{f&&(le.mutate(f.id),N(null))},ce=()=>{const s=d?.mode==="invite"?"open":"invite";if(s==="open"){w(!0);return}h.mutate(s)},xe=()=>{h.mutate("open"),w(!1)},me=c?.invites?.filter(s=>!s.usedBy&&(!s.expiresAt||new Date<=new Date(s.expiresAt))).length||0,ue=c?.invites?.filter(s=>s.usedBy).length||0,he=c?.invites?.filter(s=>!s.usedBy&&s.expiresAt&&new Date>new Date(s.expiresAt)).length||0;return z?e.jsx("div",{className:"p-6",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[e.jsx(O,{className:"h-12 w-12 text-destructive mb-4"}),e.jsx("h2",{className:"text-xl font-semibold mb-2",children:"Access Denied"}),e.jsx("p",{className:"text-muted-foreground",children:z.message})]})}):e.jsxs("div",{className:"p-6 space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"text-2xl font-bold flex items-center gap-3",children:[e.jsx(fe,{className:"h-6 w-6"}),"Invite Codes"]}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"Generate and manage invite codes for user registration"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(n,{variant:"outline",onClick:()=>ne(),disabled:v,className:"rounded-xl",children:[e.jsx(Ne,{className:Q("h-4 w-4 mr-2",v&&"animate-spin")}),"Refresh"]}),e.jsxs(n,{onClick:()=>p(!0),className:"rounded-xl",children:[e.jsx(B,{className:"h-4 w-4 mr-2"}),"Generate Codes"]})]})]}),e.jsxs("div",{className:"rounded-2xl glass shadow-lg p-4 flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[d?.mode==="invite"?e.jsx("div",{className:"h-10 w-10 rounded-full bg-amber-500/10 flex items-center justify-center",children:e.jsx(ee,{className:"h-5 w-5 text-amber-500"})}):e.jsx("div",{className:"h-10 w-10 rounded-full bg-green-500/10 flex items-center justify-center",children:e.jsx(Z,{className:"h-5 w-5 text-green-500"})}),e.jsxs("div",{children:[e.jsxs("p",{className:"font-medium",children:["Registration Mode: ",e.jsx("span",{className:"capitalize",children:d?.mode||"..."})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:d?.mode==="invite"?"New users need an invite code to sign up":"Anyone can sign up without an invite code"})]})]}),e.jsxs(n,{variant:"outline",onClick:ce,disabled:h.isPending,className:"rounded-xl",children:[h.isPending?e.jsx(D,{className:"h-4 w-4 animate-spin mr-2"}):d?.mode==="invite"?e.jsx(Z,{className:"h-4 w-4 mr-2"}):e.jsx(ee,{className:"h-4 w-4 mr-2"}),"Switch to ",d?.mode==="invite"?"Open":"Invite"]})]}),e.jsxs("div",{className:"relative max-w-md",children:[e.jsx(we,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx("input",{type:"text",placeholder:"Search by label or ID...",value:l,onChange:s=>i(s.target.value),className:"w-full pl-10 pr-4 py-2 field-lg"})]}),e.jsx("div",{className:"rounded-2xl glass shadow-lg overflow-hidden",children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-white/5 bg-muted/30",children:[e.jsx("th",{className:"text-left p-4 text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Label"}),e.jsx("th",{className:"text-left p-4 text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Status"}),e.jsx("th",{className:"text-left p-4 text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Expires"}),e.jsx("th",{className:"text-left p-4 text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Created"}),e.jsx("th",{className:"text-right p-4 text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Actions"})]})}),e.jsx("tbody",{children:v?e.jsx("tr",{children:e.jsx("td",{colSpan:5,className:"p-8 text-center",children:e.jsx(D,{className:"h-6 w-6 animate-spin mx-auto text-muted-foreground"})})}):P.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:5,className:"p-8 text-center text-muted-foreground",children:l?"No matching invite codes":"No invite codes yet. Generate some to get started."})}):P.map(s=>{const o=re(s),ge=o.icon;return e.jsxs("tr",{className:"border-b border-white/5 last:border-0 hover:bg-muted/20 transition-colors",children:[e.jsx("td",{className:"p-4",children:e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:s.label||e.jsx("span",{className:"text-muted-foreground",children:"No label"})}),e.jsxs("p",{className:"text-xs text-muted-foreground font-mono",children:[s.id.slice(0,8),"..."]})]})}),e.jsx("td",{className:"p-4",children:e.jsxs("span",{className:Q("inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-xs font-semibold",o.color),children:[e.jsx(ge,{className:"h-3 w-3"}),o.label]})}),e.jsx("td",{className:"p-4 text-sm text-muted-foreground",children:s.expiresAt?e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(ve,{className:"h-3.5 w-3.5"}),new Date(s.expiresAt).toLocaleDateString()]}):e.jsx("span",{className:"text-muted-foreground/50",children:"Never"})}),e.jsx("td",{className:"p-4 text-sm text-muted-foreground",children:s.createdAt?new Date(s.createdAt).toLocaleDateString():"-"}),e.jsx("td",{className:"p-4",children:e.jsx("div",{className:"flex items-center justify-end gap-2",children:e.jsxs(be,{children:[e.jsx(ye,{asChild:!0,children:e.jsx(n,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 rounded-lg",children:e.jsx(ke,{className:"h-4 w-4"})})}),e.jsxs(Ce,{align:"end",className:"w-48",children:[e.jsx(De,{children:"Actions"}),e.jsx(F,{}),e.jsxs($,{onClick:()=>y(s.id,"ID"),children:[e.jsx(k,{className:"h-4 w-4 mr-2"}),"Copy ID"]}),e.jsx(F,{}),e.jsxs($,{onClick:()=>de(s),className:"text-destructive focus:text-destructive",children:[e.jsx(Se,{className:"h-4 w-4 mr-2"}),"Delete"]})]})]})})})]},s.id)})})]})})}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-4 gap-4",children:[e.jsxs("div",{className:"p-4 rounded-2xl glass shadow-lg",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Total"}),e.jsx("p",{className:"text-2xl font-bold",children:c?.total||0})]}),e.jsxs("div",{className:"p-4 rounded-2xl glass shadow-lg",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Available"}),e.jsx("p",{className:"text-2xl font-bold text-green-500",children:me})]}),e.jsxs("div",{className:"p-4 rounded-2xl glass shadow-lg",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Used"}),e.jsx("p",{className:"text-2xl font-bold text-zinc-500",children:ue})]}),e.jsxs("div",{className:"p-4 rounded-2xl glass shadow-lg",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Expired"}),e.jsx("p",{className:"text-2xl font-bold text-red-500",children:he})]})]}),g&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm",children:e.jsxs("div",{className:"glass-heavy rounded-2xl shadow-2xl w-full max-w-md mx-4 p-6",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("div",{className:"h-12 w-12 rounded-full bg-primary/10 flex items-center justify-center",children:e.jsx(B,{className:"h-6 w-6 text-primary"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold",children:"Generate Invite Codes"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Create new codes for user registration"})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium mb-1 block",children:"Number of codes"}),e.jsx("input",{type:"number",min:1,max:50,value:M,onChange:s=>T(Math.min(50,Math.max(1,parseInt(s.target.value,10)||1))),className:"w-full field-lg"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium mb-1 block",children:"Label (optional)"}),e.jsx("input",{type:"text",value:I,onChange:s=>L(s.target.value),placeholder:'e.g., "For onboarding batch 2"',className:"w-full field-lg"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium mb-1 block",children:"Expires in (days, optional)"}),e.jsx("input",{type:"number",min:1,max:365,value:j,onChange:s=>E(s.target.value),placeholder:"e.g., 7",className:"w-full field-lg"})]}),e.jsxs("div",{className:"flex gap-2 pt-2",children:[e.jsx(n,{variant:"outline",className:"flex-1 rounded-xl",onClick:()=>p(!1),children:"Cancel"}),e.jsx(n,{className:"flex-1 rounded-xl",onClick:ie,disabled:b.isPending,children:b.isPending?e.jsx(D,{className:"h-4 w-4 animate-spin"}):"Generate"})]})]})]})}),e.jsx(U,{open:!!f,onOpenChange:s=>!s&&N(null),children:e.jsxs(H,{children:[e.jsxs(_,{children:[e.jsx(J,{children:"Delete Invite Code"}),e.jsx(V,{children:"Are you sure you want to delete this invite code? This action cannot be undone."})]}),e.jsxs(X,{children:[e.jsx(Y,{className:"rounded-xl",children:"Cancel"}),e.jsx(W,{onClick:oe,className:"rounded-xl bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})}),e.jsx(U,{open:ae,onOpenChange:w,children:e.jsxs(H,{children:[e.jsxs(_,{children:[e.jsx(J,{children:"Switch to Open Registration?"}),e.jsx(V,{children:"Anyone will be able to sign up without an invite code. You can switch back to invite-only at any time."})]}),e.jsxs(X,{children:[e.jsx(Y,{className:"rounded-xl",children:"Cancel"}),e.jsx(W,{onClick:xe,className:"rounded-xl",children:"Switch to Open"})]})]})}),se&&u.length>0&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm",children:e.jsxs("div",{className:"glass-heavy rounded-2xl shadow-2xl w-full max-w-md mx-4 p-6",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("div",{className:"h-12 w-12 rounded-full bg-green-500/10 flex items-center justify-center",children:e.jsx(S,{className:"h-6 w-6 text-green-500"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold",children:"Invite Codes Generated"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[u.length," code(s) ready to share"]})]})]}),e.jsx("div",{className:"space-y-2 max-h-64 overflow-y-auto",children:u.map(s=>e.jsxs("div",{className:"flex items-center gap-2 p-3 rounded-xl bg-muted/30",children:[e.jsx("code",{className:"flex-1 font-mono text-sm font-semibold",children:s.code}),e.jsx(n,{size:"sm",variant:"ghost",className:"h-8 w-8 p-0",onClick:()=>y(s.code,s.id),children:G===s.id?e.jsx(K,{className:"h-4 w-4 text-green-500"}):e.jsx(k,{className:"h-4 w-4"})})]},s.id))}),e.jsxs(n,{size:"sm",variant:"outline",className:"w-full mt-3 rounded-xl",onClick:()=>y(u.map(s=>s.code).join(`
|
|
1
|
+
import{c as pe,n as je,r as a,u as q,o as C,t as r,j as e,U as O,af as fe,k as n,R as Ne,i as Q,P as B,L as D,w as we,g as ve,D as be,x as ye,y as Ce,bo as De,aw as F,z as $,Q as k,C as S,O as K}from"./index-lJlNPFVJ.js";import{A as U,a as H,b as _,c as J,d as V,e as X,f as Y,g as W}from"./alert-dialog-SKM6Gjz4.js";import{G as Z}from"./globe-f-jjCa_g.js";import{E as ke}from"./ellipsis-UJx4Xnf6.js";import{T as Se}from"./trash-2-keO5tKPE.js";import{C as Ae}from"./circle-x-Dgw11LgT.js";const Me=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]],ee=pe("lock",Me),Te="http://localhost:3000";async function x(t,l={}){const i=await fetch(`${Te}/api/users${t}`,{...l,headers:{"Content-Type":"application/json",...l.headers},credentials:"include"});if(!i.ok){const g=await i.json().catch(()=>({error:"Unknown error"}));throw new Error(g.error||`HTTP ${i.status}`)}return i.json()}const m={list:()=>x("/admin/invites"),generate:t=>x("/admin/invites",{method:"POST",body:JSON.stringify(t)}),delete:t=>x(`/admin/invites/${t}`,{method:"DELETE"}),getRegistrationMode:()=>x("/admin/registration-mode"),setRegistrationMode:t=>x("/admin/registration-mode",{method:"PATCH",body:JSON.stringify({mode:t})})};function Pe(){const t=je(),[l,i]=a.useState(""),[g,p]=a.useState(!1),[se,A]=a.useState(!1),[u,te]=a.useState([]),[M,T]=a.useState(1),[I,L]=a.useState(""),[j,E]=a.useState(""),[G,R]=a.useState(null),[f,N]=a.useState(null),[ae,w]=a.useState(!1),{data:c,isLoading:v,error:z,refetch:ne}=q({queryKey:["admin","inviteCodes"],queryFn:()=>m.list()}),{data:d}=q({queryKey:["admin","registrationMode"],queryFn:()=>m.getRegistrationMode()}),b=C({mutationFn:m.generate,onSuccess:s=>{te(s.codes),p(!1),A(!0),T(1),L(""),E(""),t.invalidateQueries({queryKey:["admin","inviteCodes"]}),r.success(`Generated ${s.codes.length} invite code(s)`)},onError:s=>r.error(s.message)}),le=C({mutationFn:m.delete,onSuccess:()=>{t.invalidateQueries({queryKey:["admin","inviteCodes"]}),r.success("Invite code deleted")},onError:s=>r.error(s.message)}),h=C({mutationFn:s=>m.setRegistrationMode(s),onSuccess:s=>{t.invalidateQueries({queryKey:["admin","registrationMode"]}),r.success(`Registration mode set to ${s.mode}`)},onError:s=>r.error(s.message)}),y=(s,o)=>{navigator.clipboard.writeText(s),R(o),setTimeout(()=>R(null),2e3),r.success(`${o} copied`)},re=s=>s.usedBy?{label:"Used",color:"bg-zinc-500/10 text-zinc-500",icon:S}:s.expiresAt&&new Date>new Date(s.expiresAt)?{label:"Expired",color:"bg-red-500/10 text-red-500",icon:Ae}:{label:"Available",color:"bg-green-500/10 text-green-500",icon:S},P=c?.invites?.filter(s=>(s.label||"").toLowerCase().includes(l.toLowerCase())||s.id.toLowerCase().includes(l.toLowerCase())||(s.createdBy||"").toLowerCase().includes(l.toLowerCase()))||[],ie=()=>{b.mutate({count:M,label:I||void 0,expiresInDays:j?parseInt(j,10):void 0})},de=s=>{N(s)},oe=()=>{f&&(le.mutate(f.id),N(null))},ce=()=>{const s=d?.mode==="invite"?"open":"invite";if(s==="open"){w(!0);return}h.mutate(s)},xe=()=>{h.mutate("open"),w(!1)},me=c?.invites?.filter(s=>!s.usedBy&&(!s.expiresAt||new Date<=new Date(s.expiresAt))).length||0,ue=c?.invites?.filter(s=>s.usedBy).length||0,he=c?.invites?.filter(s=>!s.usedBy&&s.expiresAt&&new Date>new Date(s.expiresAt)).length||0;return z?e.jsx("div",{className:"p-6",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[e.jsx(O,{className:"h-12 w-12 text-destructive mb-4"}),e.jsx("h2",{className:"text-xl font-semibold mb-2",children:"Access Denied"}),e.jsx("p",{className:"text-muted-foreground",children:z.message})]})}):e.jsxs("div",{className:"p-6 space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"text-2xl font-bold flex items-center gap-3",children:[e.jsx(fe,{className:"h-6 w-6"}),"Invite Codes"]}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"Generate and manage invite codes for user registration"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(n,{variant:"outline",onClick:()=>ne(),disabled:v,className:"rounded-xl",children:[e.jsx(Ne,{className:Q("h-4 w-4 mr-2",v&&"animate-spin")}),"Refresh"]}),e.jsxs(n,{onClick:()=>p(!0),className:"rounded-xl",children:[e.jsx(B,{className:"h-4 w-4 mr-2"}),"Generate Codes"]})]})]}),e.jsxs("div",{className:"rounded-2xl glass shadow-lg p-4 flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[d?.mode==="invite"?e.jsx("div",{className:"h-10 w-10 rounded-full bg-amber-500/10 flex items-center justify-center",children:e.jsx(ee,{className:"h-5 w-5 text-amber-500"})}):e.jsx("div",{className:"h-10 w-10 rounded-full bg-green-500/10 flex items-center justify-center",children:e.jsx(Z,{className:"h-5 w-5 text-green-500"})}),e.jsxs("div",{children:[e.jsxs("p",{className:"font-medium",children:["Registration Mode: ",e.jsx("span",{className:"capitalize",children:d?.mode||"..."})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:d?.mode==="invite"?"New users need an invite code to sign up":"Anyone can sign up without an invite code"})]})]}),e.jsxs(n,{variant:"outline",onClick:ce,disabled:h.isPending,className:"rounded-xl",children:[h.isPending?e.jsx(D,{className:"h-4 w-4 animate-spin mr-2"}):d?.mode==="invite"?e.jsx(Z,{className:"h-4 w-4 mr-2"}):e.jsx(ee,{className:"h-4 w-4 mr-2"}),"Switch to ",d?.mode==="invite"?"Open":"Invite"]})]}),e.jsxs("div",{className:"relative max-w-md",children:[e.jsx(we,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx("input",{type:"text",placeholder:"Search by label or ID...",value:l,onChange:s=>i(s.target.value),className:"w-full pl-10 pr-4 py-2 field-lg"})]}),e.jsx("div",{className:"rounded-2xl glass shadow-lg overflow-hidden",children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-white/5 bg-muted/30",children:[e.jsx("th",{className:"text-left p-4 text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Label"}),e.jsx("th",{className:"text-left p-4 text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Status"}),e.jsx("th",{className:"text-left p-4 text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Expires"}),e.jsx("th",{className:"text-left p-4 text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Created"}),e.jsx("th",{className:"text-right p-4 text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Actions"})]})}),e.jsx("tbody",{children:v?e.jsx("tr",{children:e.jsx("td",{colSpan:5,className:"p-8 text-center",children:e.jsx(D,{className:"h-6 w-6 animate-spin mx-auto text-muted-foreground"})})}):P.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:5,className:"p-8 text-center text-muted-foreground",children:l?"No matching invite codes":"No invite codes yet. Generate some to get started."})}):P.map(s=>{const o=re(s),ge=o.icon;return e.jsxs("tr",{className:"border-b border-white/5 last:border-0 hover:bg-muted/20 transition-colors",children:[e.jsx("td",{className:"p-4",children:e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:s.label||e.jsx("span",{className:"text-muted-foreground",children:"No label"})}),e.jsxs("p",{className:"text-xs text-muted-foreground font-mono",children:[s.id.slice(0,8),"..."]})]})}),e.jsx("td",{className:"p-4",children:e.jsxs("span",{className:Q("inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-xs font-semibold",o.color),children:[e.jsx(ge,{className:"h-3 w-3"}),o.label]})}),e.jsx("td",{className:"p-4 text-sm text-muted-foreground",children:s.expiresAt?e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(ve,{className:"h-3.5 w-3.5"}),new Date(s.expiresAt).toLocaleDateString()]}):e.jsx("span",{className:"text-muted-foreground/50",children:"Never"})}),e.jsx("td",{className:"p-4 text-sm text-muted-foreground",children:s.createdAt?new Date(s.createdAt).toLocaleDateString():"-"}),e.jsx("td",{className:"p-4",children:e.jsx("div",{className:"flex items-center justify-end gap-2",children:e.jsxs(be,{children:[e.jsx(ye,{asChild:!0,children:e.jsx(n,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 rounded-lg",children:e.jsx(ke,{className:"h-4 w-4"})})}),e.jsxs(Ce,{align:"end",className:"w-48",children:[e.jsx(De,{children:"Actions"}),e.jsx(F,{}),e.jsxs($,{onClick:()=>y(s.id,"ID"),children:[e.jsx(k,{className:"h-4 w-4 mr-2"}),"Copy ID"]}),e.jsx(F,{}),e.jsxs($,{onClick:()=>de(s),className:"text-destructive focus:text-destructive",children:[e.jsx(Se,{className:"h-4 w-4 mr-2"}),"Delete"]})]})]})})})]},s.id)})})]})})}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-4 gap-4",children:[e.jsxs("div",{className:"p-4 rounded-2xl glass shadow-lg",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Total"}),e.jsx("p",{className:"text-2xl font-bold",children:c?.total||0})]}),e.jsxs("div",{className:"p-4 rounded-2xl glass shadow-lg",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Available"}),e.jsx("p",{className:"text-2xl font-bold text-green-500",children:me})]}),e.jsxs("div",{className:"p-4 rounded-2xl glass shadow-lg",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Used"}),e.jsx("p",{className:"text-2xl font-bold text-zinc-500",children:ue})]}),e.jsxs("div",{className:"p-4 rounded-2xl glass shadow-lg",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Expired"}),e.jsx("p",{className:"text-2xl font-bold text-red-500",children:he})]})]}),g&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm",children:e.jsxs("div",{className:"glass-heavy rounded-2xl shadow-2xl w-full max-w-md mx-4 p-6",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("div",{className:"h-12 w-12 rounded-full bg-primary/10 flex items-center justify-center",children:e.jsx(B,{className:"h-6 w-6 text-primary"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold",children:"Generate Invite Codes"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Create new codes for user registration"})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium mb-1 block",children:"Number of codes"}),e.jsx("input",{type:"number",min:1,max:50,value:M,onChange:s=>T(Math.min(50,Math.max(1,parseInt(s.target.value,10)||1))),className:"w-full field-lg"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium mb-1 block",children:"Label (optional)"}),e.jsx("input",{type:"text",value:I,onChange:s=>L(s.target.value),placeholder:'e.g., "For onboarding batch 2"',className:"w-full field-lg"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium mb-1 block",children:"Expires in (days, optional)"}),e.jsx("input",{type:"number",min:1,max:365,value:j,onChange:s=>E(s.target.value),placeholder:"e.g., 7",className:"w-full field-lg"})]}),e.jsxs("div",{className:"flex gap-2 pt-2",children:[e.jsx(n,{variant:"outline",className:"flex-1 rounded-xl",onClick:()=>p(!1),children:"Cancel"}),e.jsx(n,{className:"flex-1 rounded-xl",onClick:ie,disabled:b.isPending,children:b.isPending?e.jsx(D,{className:"h-4 w-4 animate-spin"}):"Generate"})]})]})]})}),e.jsx(U,{open:!!f,onOpenChange:s=>!s&&N(null),children:e.jsxs(H,{children:[e.jsxs(_,{children:[e.jsx(J,{children:"Delete Invite Code"}),e.jsx(V,{children:"Are you sure you want to delete this invite code? This action cannot be undone."})]}),e.jsxs(X,{children:[e.jsx(Y,{className:"rounded-xl",children:"Cancel"}),e.jsx(W,{onClick:oe,className:"rounded-xl bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})}),e.jsx(U,{open:ae,onOpenChange:w,children:e.jsxs(H,{children:[e.jsxs(_,{children:[e.jsx(J,{children:"Switch to Open Registration?"}),e.jsx(V,{children:"Anyone will be able to sign up without an invite code. You can switch back to invite-only at any time."})]}),e.jsxs(X,{children:[e.jsx(Y,{className:"rounded-xl",children:"Cancel"}),e.jsx(W,{onClick:xe,className:"rounded-xl",children:"Switch to Open"})]})]})}),se&&u.length>0&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm",children:e.jsxs("div",{className:"glass-heavy rounded-2xl shadow-2xl w-full max-w-md mx-4 p-6",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("div",{className:"h-12 w-12 rounded-full bg-green-500/10 flex items-center justify-center",children:e.jsx(S,{className:"h-6 w-6 text-green-500"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold",children:"Invite Codes Generated"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[u.length," code(s) ready to share"]})]})]}),e.jsx("div",{className:"space-y-2 max-h-64 overflow-y-auto",children:u.map(s=>e.jsxs("div",{className:"flex items-center gap-2 p-3 rounded-xl bg-muted/30",children:[e.jsx("code",{className:"flex-1 font-mono text-sm font-semibold",children:s.code}),e.jsx(n,{size:"sm",variant:"ghost",className:"h-8 w-8 p-0",onClick:()=>y(s.code,s.id),children:G===s.id?e.jsx(K,{className:"h-4 w-4 text-green-500"}):e.jsx(k,{className:"h-4 w-4"})})]},s.id))}),e.jsxs(n,{size:"sm",variant:"outline",className:"w-full mt-3 rounded-xl",onClick:()=>y(u.map(s=>s.code).join(`
|
|
2
2
|
`),"all-codes"),children:[G==="all-codes"?e.jsx(K,{className:"h-4 w-4 mr-2 text-green-500"}):e.jsx(k,{className:"h-4 w-4 mr-2"}),"Copy All"]}),e.jsxs("p",{className:"text-xs text-amber-500 flex items-start gap-2 mt-3",children:[e.jsx(O,{className:"h-4 w-4 flex-shrink-0 mt-0.5"}),"Save these codes now. They cannot be retrieved later."]}),e.jsx(n,{className:"w-full rounded-xl mt-3",onClick:()=>A(!1),children:"Done"})]})})]})}export{Pe as InviteCodeManagement};
|