Created At: 2026-11-19T08:19:52Z Completed At: 2026-11-19T08:19:53Z Command exited with code 0. Command output: apps/frontend/src/components/pages/BotDetailsPage.tsx:1413: https://api.yourdomain.com/webhooks/telegram/{currentBotId} apps/frontend/src/context/BotContext.tsx:226: webhookUrl: b.webhook_url || `/webhooks/telegram/${b.id}`, apps/frontend/src/context/BotContext.tsx:315: webhookUrl: botData.webhook_url || `/webhooks/telegram/${botData.id}`, apps/frontend/dist/assets/index-DZatOka8.js:36: */function ft(){return ft=Object.assign?Object.assign.bind():function(t){for(var s=1;s{let r=t[a];return s.concat(Array.isArray(r)?r.map(o=>[a,o]):[[a,r]])},[]))}function Pn(t,s){let a=Vt(t);return s&&s.forEach((r,o)=>{a.has(o)||s.getAll(o).forEach(n=>{a.append(o,n)})}),a}const In=["onClick","relative","reloadDocument","replace","state","target","to","preventScrollReset","viewTransition"],En=["aria-current","caseSensitive","className","end","style","to","viewTransition","children"],Rn="6";try{window.__reactRouterVersion=Rn}catch{}const Ln=l.createContext({isTransitioning:!1}),Mn="startTransition",Ns=Sa[Mn];function Bn(t){let{basename:s,children:a,future:r,window:o}=t,n=l.useRef();n.current==null&&(n.current=Mr({window:o,v5Compat:!0}));let i=n.current,[h,u]=l.useState({action:i.action,location:i.location}),{v7_startTransition:x}=r||{},m=l.useCallback(b=>{x&&Ns?Ns(()=>u(b)):u(b)},[u,x]);return l.useLayoutEffect(()=>i.listen(m),[i,m]),l.useEffect(()=>yn(r),[r]),l.createElement(_n,{basename:s,children:a,location:h.location,navigationType:h.action,navigator:i,future:r})}const On=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",Dn=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,I=l.forwardRef(function(s,a){let{onClick:r,relative:o,reloadDocument:n,replace:i,state:h,target:u,to:x,preventScrollReset:m,viewTransition:b}=s,j=pa(s,In),{basename:f}=l.useContext(Be),g,v=!1;if(typeof x=="string"&&Dn.test(x)&&(g=x,On))try{let N=new URL(window.location.href),k=x.startsWith("//")?new URL(N.protocol+x):new URL(x),_=Xe(k.pathname,f);k.origin===N.origin&&_!=null?x=_+k.search+k.hash:v=!0}catch{}let c=nn(x,{relative:o}),w=Un(x,{replace:i,state:h,target:u,preventScrollReset:m,relative:o,viewTransition:b});function p(N){r&&r(N),N.defaultPrevented||w(N)}return l.createElement("a",ft({},j,{href:g||c,onClick:v||n?r:p,ref:a,target:u}))}),$n=l.forwardRef(function(s,a){let{"aria-current":r="page",caseSensitive:o=!1,className:n="",end:i=!1,style:h,to:u,viewTransition:x,children:m}=s,b=pa(s,En),j=kt(u,{relative:b.relative}),f=Te(),g=l.useContext(la),{navigator:v,basename:c}=l.useContext(Be),w=g!=null&&Hn(j)&&x===!0,p=v.encodeLocation?v.encodeLocation(j).pathname:j.pathname,N=f.pathname,k=g&&g.navigation&&g.navigation.location?g.navigation.location.pathname:null;o||(N=N.toLowerCase(),k=k?k.toLowerCase():null,p=p.toLowerCase()),k&&c&&(k=Xe(k,c)||k);const _=p!=="/"&&p.endsWith("/")?p.length-1:p.length;let A=N===p||!i&&N.startsWith(p)&&N.charAt(_)==="/",C=k!=null&&(k===p||!i&&k.startsWith(p)&&k.charAt(p.length)==="/"),U={isActive:A,isPending:C,isTransitioning:w},M=A?r:void 0,$;typeof n=="function"?$=n(U):$=[n,A?"active":null,C?"pending":null,w?"transitioning":null].filter(Boolean).join(" ");let D=typeof h=="function"?h(U):h;return l.createElement(I,ft({},b,{"aria-current":M,className:$,ref:a,style:D,to:u,viewTransition:x}),typeof m=="function"?m(U):m)});var Ht;(function(t){t.UseScrollRestoration="useScrollRestoration",t.UseSubmit="useSubmit",t.UseSubmitFetcher="useSubmitFetcher",t.UseFetcher="useFetcher",t.useViewTransitionState="useViewTransitionState"})(Ht||(Ht={}));var ys;(function(t){t.UseFetcher="useFetcher",t.UseFetchers="useFetchers",t.UseScrollRestoration="useScrollRestoration"})(ys||(ys={}));function Fn(t){let s=l.useContext(yt);return s||ie(!1),s}function Un(t,s){let{target:a,replace:r,state:o,preventScrollReset:n,relative:i,viewTransition:h}=s===void 0?{}:s,u=Ne(),x=Te(),m=kt(t,{relative:i});return l.useCallback(b=>{if(An(b,a)){b.preventDefault();let j=r!==void 0?r:gt(x)===gt(m);u(t,{replace:j,state:o,preventScrollReset:n,relative:i,viewTransition:h})}},[x,u,m,r,o,a,t,n,i,h])}function Vn(t){let s=l.useRef(Vt(t)),a=l.useRef(!1),r=Te(),o=l.useMemo(()=>Pn(r.search,a.current?null:s.current),[r.search]),n=Ne(),i=l.useCallback((h,u)=>{const x=Vt(typeof h=="function"?h(o):h);a.current=!0,n("?"+x,u)},[n,o]);return[o,i]}function Hn(t,s){s===void 0&&(s={});let a=l.useContext(Ln);a==null&&ie(!1);let{basename:r}=Fn(Ht.useViewTransitionState),o=kt(t,{relative:s.relative});if(!a.isTransitioning)return!1;let n=Xe(a.currentLocation.pathname,r)||a.currentLocation.pathname,i=Xe(a.nextLocation.pathname,r)||a.nextLocation.pathname;return Ft(o.pathname,i)!=null||Ft(o.pathname,n)!=null}const ua=l.createContext(void 0),Gn=({children:t})=>{const[s,a]=l.useState(()=>localStorage.getItem("access_token")),[r,o]=l.useState(()=>localStorage.getItem("refresh_token")),[n,i]=l.useState(()=>{const g=localStorage.getItem("auth_user");if(g)try{return JSON.parse(g)}catch{return null}return null}),[h,u]=l.useState(!0),x=async g=>{var v,c;try{const w=await fetch("/api/v1/auth/me",{headers:{Authorization:`Bearer ${g}`}});if(w.ok){const p=await w.json();if(p.success&&p.data)return i(p.data),localStorage.setItem("auth_user",JSON.stringify(p.data)),p.data}else if(w.status===401&&r){const p=await fetch("/api/v1/auth/refresh",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refresh_token:r})});if(p.ok){const N=await p.json(),k=(v=N.data)==null?void 0:v.access_token,_=(c=N.data)==null?void 0:c.refresh_token;if(k)return a(k),localStorage.setItem("access_token",k),_&&(o(_),localStorage.setItem("refresh_token",_)),x(k)}j()}}catch(w){console.warn("Could not fetch user profile:",w)}return null};l.useEffect(()=>{s?x(s).finally(()=>u(!1)):u(!1)},[]);const m=async g=>{var v;u(!0);try{const c=await fetch("/api/v1/auth/telegram",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(g)}),w=await c.json();if(c.ok&&w.success&&w.data){const{access_token:p,refresh_token:N}=w.data;return a(p),o(N),localStorage.setItem("access_token",p),N&&localStorage.setItem("refresh_token",N),await x(p),u(!1),{success:!0}}else return u(!1),{success:!1,error:w.message||((v=w.error)==null?void 0:v.message)||"Telegram verification failed"}}catch(c){return u(!1),{success:!1,error:c.message||"Network error during login"}}},b=async(g,v)=>{var c;u(!0);try{const w=await fetch("/api/v1/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:g,password:v})}),p=await w.json();if(w.ok&&p.success&&p.data){const{access_token:N,refresh_token:k}=p.data;return a(N),o(k),localStorage.setItem("access_token",N),k&&localStorage.setItem("refresh_token",k),await x(N),u(!1),{success:!0}}else return u(!1),{success:!1,error:p.message||((c=p.error)==null?void 0:c.message)||"Invalid email or password"}}catch(w){return u(!1),{success:!1,error:w.message||"Network error during login"}}},j=()=>{r&&fetch("/api/v1/auth/logout",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refresh_token:r})}).catch(()=>{}),a(null),o(null),i(null),localStorage.removeItem("access_token"),localStorage.removeItem("refresh_token"),localStorage.removeItem("auth_user")},f=async()=>{s&&await x(s)};return e.jsx(ua.Provider,{value:{user:n,token:s,isAuthenticated:!!s,isLoading:h,loginWithTelegram:m,loginWithEmail:b,logout:j,refreshUserProfile:f},children:t})},Ue=()=>{const t=l.useContext(ua);if(!t)throw new Error("useAuth must be used within an AuthProvider");return t},ha=l.createContext(void 0),zn=({children:t})=>{const[s,a]=l.useState(()=>localStorage.getItem("app_theme")==="dark"?"dark":"light");l.useEffect(()=>{const n=document.documentElement;s==="light"?(n.classList.remove("dark"),n.classList.add("light")):(n.classList.remove("light"),n.classList.add("dark")),localStorage.setItem("app_theme",s)},[s]);const r=()=>{a(n=>n==="light"?"dark":"light")},o=n=>{a(n)};return e.jsx(ha.Provider,{value:{theme:s,toggleTheme:r,setTheme:o},children:t})},mt=()=>{const t=l.useContext(ha);if(!t)throw new Error("useTheme must be used within a ThemeProvider");return t},Gt=[{id:"welcome_message",name:"Welcome Message & Onboarding",category:"engagement",description:"Custom greeting message, dynamic placeholders ({first_name}, {bot_name}), and inline action buttons on /start.",is_enabled:!0,config:{welcome_text:"🌟 Welcome to our VIP Bot! Tap an option below to explore:",buttons_count:4}},{id:"force_join",name:"Force Join Channel Guard",category:"security",description:"Mandatory channel/group membership before unlocking bot commands. Verifies status via getChatMember.",is_enabled:!0,config:{channel_username:"@astraea_cloud",prompt_text:"⚠️ You must join our official Telegram channel to unlock this bot.",button_text:"📢 Join Official Channel"}},{id:"referrals",name:"Referral & Viral Growth Engine",category:"growth",description:"Generates subscriber deep-link invite links (/start ref_{userId}), tracks successful signups, and awards points.",is_enabled:!0,config:{points_per_referral:10,welcome_bonus_points:5,min_payout_points:50}},{id:"broadcasts",name:"Broadcast & Announcement Pipeline",category:"messaging",description:"Token-bucket broadcasts (25 msgs/sec), audience filtering, language targeting, and /optout compliance.",is_enabled:!0,config:{rate_limit_per_second:25,allow_opt_out:!0}},{id:"user_management",name:"Audience & Subscriber Directory",category:"management",description:"Real-time subscriber tracking, interaction count, automatic BCP 47 language preference detection.",is_enabled:!0,config:{auto_detect_locale:!0,track_interactions:!0}},{id:"auto_filter",name:"Auto Filter & Keyword Responder",category:"automation",description:"Matches subscriber text against trigger keywords and forbidden words. Provides instantaneous auto-replies.",is_enabled:!0,config:{rules_count:3,blocked_words:["scam","free nitro","hack"]}},{id:"payments",name:"In-Chat Payments & Invoicing",category:"monetization",description:"Seamless Razorpay & Stripe in-chat payment links with cryptographic webhook verification.",is_enabled:!1,config:{currency:"INR",gateway:"razorpay"}},{id:"subscriptions",name:"VIP Tiered Subscription Gates",category:"monetization",description:"Restricts channels, commands, and downloads to active paying VIP subscribers with auto-expiry.",is_enabled:!0,config:{plans_count:3,grace_period_days:2}},{id:"ai_assistant",name:"Autonomous AI Agent Concierge",category:"ai",description:"Multi-turn LLM support concierge powered by OpenAI/Anthropic/Gemini with encrypted API keys and tools.",is_enabled:!0,config:{model:"gemini-1.5-pro",temperature:.7,max_tokens:1024}}],Wn={id:"",name:"No Bot Connected",username:"none",status:"inactive",defaultLocale:"en",keyVersion:1,webhookUrl:"",usersCount:0,messages24h:0,latencyMs:0,uptimePct:100,createdAt:new Date().toISOString(),templateName:void 0,checklist:{tokenConnected:!1,templateSelected:!1,modulesConfigured:!1,welcomeMessageSet:!1,testedInTelegram:!1},modules:Gt.map(t=>({...t,is_enabled:!1}))},qn=[],ba=l.createContext(void 0),Jn=({children:t})=>{const[s,a]=l.useState(()=>{try{const f=localStorage.getItem("telebot_bots");if(f){const g=JSON.parse(f);if(Array.isArray(g))return g.filter(v=>!["b-001","b-002","b-003","b-004"].includes(v.id))}}catch{}return qn}),[r,o]=l.useState(()=>{try{const f=localStorage.getItem("telebot_active_bot_id");if(f&&!["b-001","b-002","b-003","b-004"].includes(f))return f}catch{}return""}),n=async()=>{try{const f=localStorage.getItem("access_token"),g={"Content-Type":"application/json"};f&&(g.Authorization=`Bearer ${f}`);const v=await fetch("/api/v1/bots",{headers:g});if(v.ok){const c=await v.json();if(Array.isArray(c.data)){const w=c.data.map(p=>({id:p.id,name:p.name,username:p.username,status:p.status||"active",defaultLocale:p.default_locale||"en",keyVersion:1,webhookUrl:p.webhook_url||`/webhooks/telegram/${p.id}`,usersCount:p.total_users||0,messages24h:0,latencyMs:35,uptimePct:100,createdAt:p.created_at,templateName:"Custom Bot Configuration",checklist:{tokenConnected:!0,templateSelected:!0,modulesConfigured:!0,welcomeMessageSet:!0,testedInTelegram:!1},modules:Gt}));a(w),w.length>0&&o(p=>w.some(N=>N.id===p)?p:w[0].id)}}}catch(f){console.warn("Could not fetch bots from backend:",f)}};l.useEffect(()=>{n()},[]),l.useEffect(()=>{try{localStorage.setItem("telebot_bots",JSON.stringify(s))}catch{}},[s]),l.useEffect(()=>{try{localStorage.setItem("telebot_active_bot_id",r)}catch{}},[r]);const i=s.find(f=>f.id===r||f.username===r)||(s.length>0?s[0]:Wn),h=f=>{const g=f.replace("@","").toLowerCase(),v=s.find(c=>c.id===f||c.username.toLowerCase()===g);v&&o(v.id)},u=async(f,g,v="en")=>{var A;const c=localStorage.getItem("access_token"),w={"Content-Type":"application/json"};c&&(w.Authorization=`Bearer ${c}`);const p=await fetch("/api/v1/bots",{method:"POST",headers:w,body:JSON.stringify({token:g.trim(),name:f.trim()||void 0,default_locale:v})}),N=await p.json().catch(()=>({}));if(!p.ok){const C=((A=N==null?void 0:N.error)==null?void 0:A.message)||(N==null?void 0:N.message)||(N==null?void 0:N.detail)||"Failed to register bot with Telegram API. Please verify your BotFather token.";throw new Error(C)}const k=N.data,_={id:k.id,name:k.name,username:k.username,status:k.status||"active",defaultLocale:k.default_locale||v,keyVersion:1,webhookUrl:k.webhook_url||`/webhooks/telegram/${k.id}`,usersCount:k.total_users||0,messages24h:0,latencyMs:35,uptimePct:100,createdAt:k.created_at||new Date().toISOString(),templateName:"Blank Telegram Starter",checklist:{tokenConnected:!0,templateSelected:!1,modulesConfigured:!1,welcomeMessageSet:!1,testedInTelegram:!1},modules:Gt.map(C=>({...C,is_enabled:C.id==="welcome_message"}))};return a(C=>[_,...C.filter(U=>U.id!==_.id)]),o(_.id),_},x=(f,g,v)=>{let c=!0;a(w=>w.map(p=>{if(p.id!==f)return p;const N=p.modules.map(k=>{if(k.id!==g)return k;const _=v!==void 0?v:!k.is_enabled;return c=_,{...k,is_enabled:_}});return{...p,modules:N,checklist:{...p.checklist,modulesConfigured:!0}}})),fetch(`/api/v1/bots/${f}/modules/${g}/toggle`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({is_enabled:c})}).catch(()=>{})},m=(f,g,v)=>{a(c=>c.map(w=>w.id!==f?w:{...w,modules:w.modules.map(p=>p.id===g?{...p,config:{...p.config,...v}}:p)}))},b=(f,g)=>{a(v=>v.map(c=>c.id!==f?c:{...c,checklist:{...c.checklist,[g]:!c.checklist[g]}}))},j=(f,g,v)=>{a(c=>c.map(w=>w.id!==f?w:{...w,templateName:g,checklist:{...w.checklist,templateSelected:!0,modulesConfigured:!0},modules:w.modules.map(p=>({...p,is_enabled:v.includes(p.id)||p.id==="welcome_message"}))}))};return e.jsx(ba.Provider,{value:{bots:s,currentBot:i,selectBot:h,registerBot:u,refreshBots:n,toggleBotModule:x,updateModuleConfig:m,toggleChecklistStep:b,applyTemplateToBot:j},children:t})},ce=()=>{const t=l.useContext(ba);if(!t)throw new Error("useBot must be used within a BotProvider");return t},_t={overview:"/dashboard",marketplace:"/marketplace","bot-builder":"/dashboard/builder","mcp-pro":"/dashboard/mcp",bots:"/dashboard/bots","bot-details":"/dashboard/bots/astraea-flagship","message-studio":"/dashboard/studio",broadcasts:"/dashboard/broadcasts","ai-agents":"/dashboard/agents",plugins:"/dashboard/plugins",users:"/dashboard/users",emojis:"/dashboard/emojis",languages:"/dashboard/languages",subscriptions:"/dashboard/subscriptions",payments:"/dashboard/payments",team:"/dashboard/team",analytics:"/dashboard/analytics",settings:"/dashboard/settings","audit-logs":"/dashboard/audit-logs","platform-admin":"/dashboard/admin"};function ga(t){return t==="/marketplace"||t.startsWith("/marketplace")?"marketplace":t==="/dashboard/builder"?"bot-builder":t==="/dashboard/mcp"?"mcp-pro":t==="/dashboard/studio"?"message-studio":t==="/dashboard/broadcasts"?"broadcasts":t==="/dashboard/agents"?"ai-agents":t==="/dashboard/plugins"?"plugins":t==="/dashboard/users"?"users":t==="/dashboard/emojis"?"emojis":t==="/dashboard/languages"?"languages":t==="/dashboard/subscriptions"?"subscriptions":t==="/dashboard/payments"?"payments":t==="/dashboard/team"?"team":t==="/dashboard/analytics"?"analytics":t==="/dashboard/settings"?"settings":t==="/dashboard/audit-logs"?"audit-logs":t==="/dashboard/admin"?"platform-admin":t==="/dashboard/bots"?"bots":t.startsWith("/dashboard/bots/")?"bot-details":"overview"}const Yn=[{label:"BOT STUDIO",items:[{id:"bots",name:"My Telegram Bots",icon:me,badge:"Connect"},{id:"bot-details",name:"Bot Modules & Features",icon:Ie,badge:"18 Plugins"}]},{label:"OPERATIONS & GROWTH",items:[{id:"broadcasts",name:"Broadcast Engine",icon:_e},{id:"users",name:"Subscribers & Referrals",icon:Le},{id:"subscriptions",name:"VIP & Monetization",icon:et}]},{label:"SYSTEM & CONTROL",items:[{id:"platform-admin",name:"Platform Superadmin",icon:ne,badge:"ROOT"},{id:"settings",name:"Platform Settings",icon:Aa}]}],Kn=({currentView:t,onNavigate:s,collapsed:a,onToggleCollapse:r,mobileOpen:o=!1,onCloseMobile:n})=>{const{theme:i,toggleTheme:h}=mt(),{currentBot:u,bots:x}=ce();Ne();const m=Te(),b=(x==null?void 0:x.length)||0,j=10,f=Math.min(Math.round(b/j*100),100);t||ga(m.pathname);const g=(v=!1)=>e.jsx("div",{className:"flex-1 overflow-y-auto px-3 py-6 space-y-6",children:Yn.map((c,w)=>e.jsxs("div",{className:"space-y-1",children:[(!a||v)&&e.jsx("div",{className:"px-3 text-[10px] font-mono tracking-ultra-wide text-pearl-400/80 uppercase font-semibold mb-2",children:c.label}),c.items.map(p=>{var A;const N=p.icon,k=p.id==="bot-details"?u?`/dashboard/bots/${((A=u.username)==null?void 0:A.replace("@",""))||u.id}`:"/dashboard/bots":_t[p.id],_=a&&!v;return e.jsx($n,{to:k,end:p.id==="overview",onClick:()=>{s&&s(p.id),n&&n()},title:_?p.name:void 0,className:({isActive:C})=>`w-full flex items-center gap-3 px-3 py-2.5 rounded text-xs font-mono tracking-wider transition-all relative ${C?"bg-[#2481CC]/12 text-[#2481CC] border border-[#2481CC]/35 shadow-sm font-semibold":"text-pearl-400 hover:text-pearl-100 hover:bg-space-850 border border-transparent"} ${_?"justify-center px-0":""}`,children:({isActive:C})=>e.jsxs(e.Fragment,{children:[e.jsx(N,{className:`w-4 h-4 shrink-0 ${C?"text-[#2481CC]":"text-pearl-400"}`}),!_&&e.jsx("span",{className:"truncate",children:p.name}),!_&&p.badge&&e.jsx("span",{className:`ml-auto px-1.5 py-0.5 rounded text-[9px] font-mono uppercase ${C?"bg-[#2481CC]/20 text-[#2481CC] border border-[#2481CC]/30 font-semibold":"bg-space-800 text-pearl-400 border border-white/10"}`,children:p.badge}),C&&e.jsx("span",{className:"absolute left-0 top-1/2 -translate-y-1/2 w-1 h-5 rounded-r bg-[#2481CC]"})]})},p.id)})]},w))});return e.jsxs(e.Fragment,{children:[o&&e.jsx("div",{className:"fixed inset-0 z-50 bg-black/80 backdrop-blur-sm md:hidden animate-fadeIn",onClick:n,"aria-hidden":"true"}),e.jsxs("aside",{className:`fixed top-0 left-0 bottom-0 z-50 w-72 bg-space-900 border-r border-white/10 flex flex-col transition-transform duration-300 md:hidden ${o?"translate-x-0 shadow-2xl":"-translate-x-full"}`,children:[e.jsxs("div",{className:"h-20 border-b border-white/10 px-5 flex items-center justify-between",children:[e.jsxs(I,{to:"/",onClick:n,className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-9 h-9 rounded-xl bg-[#2481CC] text-white flex items-center justify-center font-sans font-bold text-base shadow-telegram",children:e.jsx(we,{className:"w-4 h-4 text-white -rotate-12 translate-x-0.5"})}),e.jsxs("div",{children:[e.jsxs("div",{className:"font-sans text-sm tracking-tight text-pearl-50 font-bold leading-tight",children:["TeleBot",e.jsx("span",{className:"text-[#2481CC]",children:"Cloud"})]}),e.jsx("div",{className:"text-[10px] font-mono text-[#2481CC] uppercase tracking-wide font-medium",children:"Telegram Bot Builder"})]})]}),e.jsx("button",{onClick:n,className:"p-2 text-pearl-400 hover:text-pearl-100 hover:bg-white/5 rounded-md transition-colors","aria-label":"Close navigation",children:e.jsx(ae,{className:"w-5 h-5"})})]}),u&&e.jsxs("div",{className:"mx-3 mt-3 p-2.5 rounded-xl bg-space-850 border border-white/10 flex items-center justify-between",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-[9px] font-mono text-emerald-400 font-semibold uppercase",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-emerald-400 animate-pulse"}),e.jsx("span",{children:"ACTIVE BOT CONSOLE"})]}),e.jsx("div",{className:"text-xs font-semibold text-pearl-50 truncate mt-0.5",children:u.name}),e.jsxs("div",{className:"text-[10px] font-mono text-[#2481CC] truncate",children:["@",u.username]})]}),e.jsx(I,{to:"/dashboard/bots",onClick:n,className:"text-[10px] font-mono text-pearl-400 hover:text-[#2481CC] px-2 py-1 rounded bg-white/5 shrink-0",title:"Switch Bot",children:"Switch"})]}),g(!0),e.jsxs("div",{className:"p-4 border-t border-white/10 bg-space-900/50 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs font-mono text-pearl-400",children:[e.jsxs(I,{to:"/pricing",onClick:n,className:"hover:text-[#2481CC] flex items-center gap-1.5",children:[e.jsx(te,{className:"w-3.5 h-3.5 text-[#2481CC]"}),e.jsx("span",{children:"Pricing"})]}),e.jsxs("button",{onClick:h,className:"hover:text-[#2481CC] flex items-center gap-1.5 text-pearl-300 transition-colors",title:"Toggle Theme",children:[i==="light"?e.jsx(ht,{className:"w-3.5 h-3.5 text-slate-700"}):e.jsx(bt,{className:"w-3.5 h-3.5 text-amber-400"}),e.jsx("span",{children:i==="light"?"Dark":"Light"})]}),e.jsxs(I,{to:"/login",onClick:n,className:"hover:text-[#2481CC] flex items-center gap-1.5",children:[e.jsx(ut,{className:"w-3.5 h-3.5 text-[#2481CC]"}),e.jsx("span",{children:"Login"})]})]}),e.jsxs("div",{className:"p-3 rounded bg-space-850/80 border border-white/10",children:[e.jsxs("div",{className:"flex items-center justify-between text-[10px] font-mono text-pearl-400 mb-1",children:[e.jsx("span",{children:"TIER"}),e.jsx("span",{className:"text-[#2481CC] font-semibold",children:"PRO ENTERPRISE"})]}),e.jsx("div",{className:"w-full bg-space-800 rounded-full h-1 overflow-hidden",children:e.jsx("div",{className:"bg-[#2481CC] h-1",style:{width:`${f}%`}})}),e.jsxs("div",{className:"flex items-center justify-between text-[9px] font-mono text-pearl-400/80 mt-1.5",children:[e.jsxs("span",{children:[b," / ",j," Bots Active"]}),e.jsxs("span",{children:[f,"%"]})]})]})]})]}),e.jsxs("aside",{className:`hidden md:flex fixed top-0 left-0 bottom-0 z-40 bg-space-900/95 backdrop-blur-2xl border-r border-white/10 flex-col transition-all duration-300 ${a?"w-20":"w-64"}`,children:[e.jsx("div",{className:"h-20 border-b border-white/10 px-5 flex items-center justify-between",children:a?e.jsx(I,{to:"/",className:"w-10 h-10 mx-auto rounded-xl bg-[#2481CC] text-white flex items-center justify-center font-sans font-bold shadow-telegram",title:"TeleBot Cloud",children:e.jsx(we,{className:"w-5 h-5 text-white -rotate-12 translate-x-0.5"})}):e.jsxs(I,{to:"/",className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-9 h-9 rounded-xl bg-[#2481CC] text-white flex items-center justify-center font-sans font-bold text-base shadow-telegram",children:e.jsx(we,{className:"w-4 h-4 text-white -rotate-12 translate-x-0.5"})}),e.jsxs("div",{children:[e.jsxs("div",{className:"font-sans text-sm tracking-tight text-pearl-50 font-bold leading-tight",children:["TeleBot",e.jsx("span",{className:"text-[#2481CC]",children:"Cloud"})]}),e.jsx("div",{className:"text-[10px] font-mono text-[#2481CC] uppercase tracking-wide font-medium",children:"Telegram Bot Builder"})]})]})}),!a&&u?e.jsxs("div",{className:"mx-3 mt-3 p-2.5 rounded-xl bg-space-850/80 border border-white/10 flex items-center justify-between",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-[9px] font-mono text-emerald-400 font-semibold uppercase",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-emerald-400 animate-pulse"}),e.jsx("span",{children:"ACTIVE BOT CONSOLE"})]}),e.jsx("div",{className:"text-xs font-semibold text-pearl-50 truncate mt-0.5",children:u.name}),e.jsxs("div",{className:"text-[10px] font-mono text-[#2481CC] truncate",children:["@",u.username]})]}),e.jsx(I,{to:"/dashboard/bots",className:"text-[10px] font-mono text-pearl-400 hover:text-[#2481CC] px-2 py-1 rounded bg-white/5 shrink-0 ml-1",title:"Switch Bot",children:"Switch"})]}):a&&u?e.jsx("div",{className:"mx-auto mt-2 text-center",title:`Active Bot: ${u.name} (@${u.username})`,children:e.jsxs("div",{className:"w-8 h-8 mx-auto rounded-lg bg-[#2481CC]/15 border border-[#2481CC]/40 flex items-center justify-center text-[#2481CC] relative",children:[e.jsx(me,{className:"w-4 h-4"}),e.jsx("span",{className:"absolute -top-0.5 -right-0.5 w-2 h-2 rounded-full bg-emerald-400 animate-pulse"})]})}):null,g(!1),e.jsxs("div",{className:"p-3 border-t border-white/10 bg-space-900/50",children:[a?e.jsxs("div",{className:"flex flex-col items-center gap-2",children:[e.jsx(I,{to:"/login",title:"Sign In",className:"text-pearl-400 hover:text-[#2481CC] p-1",children:e.jsx(ut,{className:"w-4 h-4"})}),e.jsx("div",{className:"w-2 h-2 rounded-full bg-emerald-400 mx-auto",title:"System Operational"})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between text-[11px] font-mono text-pearl-400 px-1",children:[e.jsxs(I,{to:"/pricing",className:"hover:text-[#2481CC] flex items-center gap-1",children:[e.jsx(te,{className:"w-3 h-3 text-[#2481CC]"}),e.jsx("span",{children:"Pricing"})]}),e.jsxs("button",{onClick:h,className:"hover:text-[#2481CC] flex items-center gap-1 text-pearl-300 transition-colors",title:"Toggle Theme",children:[i==="light"?e.jsx(ht,{className:"w-3 h-3 text-slate-700"}):e.jsx(bt,{className:"w-3 h-3 text-amber-400"}),e.jsx("span",{children:i==="light"?"Dark":"Light"})]}),e.jsxs(I,{to:"/login",className:"hover:text-[#2481CC] flex items-center gap-1",children:[e.jsx(ut,{className:"w-3 h-3 text-[#2481CC]"}),e.jsx("span",{children:"Login"})]})]}),e.jsxs("div",{className:"p-3 rounded bg-space-850/80 border border-white/10",children:[e.jsxs("div",{className:"flex items-center justify-between text-[10px] font-mono text-pearl-400 mb-1",children:[e.jsx("span",{children:"TIER"}),e.jsx("span",{className:"text-[#2481CC] font-semibold",children:"PRO ENTERPRISE"})]}),e.jsx("div",{className:"w-full bg-space-800 rounded-full h-1 overflow-hidden",children:e.jsx("div",{className:"bg-[#2481CC] h-1",style:{width:`${f}%`}})}),e.jsxs("div",{className:"flex items-center justify-between text-[9px] font-mono text-pearl-400/80 mt-1.5",children:[e.jsxs("span",{children:[b," / ",j," Bots Active"]}),e.jsxs("span",{children:[f,"%"]})]})]})]}),e.jsx("button",{onClick:r,className:"mt-2 w-full py-2 flex items-center justify-center text-pearl-400 hover:text-[#2481CC] hover:bg-space-850 rounded-xl transition-colors text-xs",title:a?"Expand Sidebar":"Collapse Sidebar",children:a?e.jsx(ze,{className:"w-4 h-4"}):e.jsx(Ta,{className:"w-4 h-4"})})]})]})]})},fa=[{code:"en",name:"English",nativeName:"English",flag:"🇬🇧",isRtl:!1},{code:"hi",name:"Hindi",nativeName:"हिंदी",flag:"🇮🇳",isRtl:!1},{code:"hi-Latn",name:"Hinglish",nativeName:"Hinglish",flag:"🇮🇳",isRtl:!1},{code:"sa",name:"Sanskrit",nativeName:"संस्कृतम्",flag:"🕉️",isRtl:!1},{code:"ar",name:"Arabic",nativeName:"العربية",flag:"🇸🇦",isRtl:!0},{code:"ur",name:"Urdu",nativeName:"اردو",flag:"🇵🇰",isRtl:!0},{code:"bn",name:"Bengali",nativeName:"বাংলা",flag:"🇧🇩",isRtl:!1},{code:"ta",name:"Tamil",nativeName:"தமிழ்",flag:"🇮🇳",isRtl:!1},{code:"te",name:"Telugu",nativeName:"తెలుగు",flag:"🇮🇳",isRtl:!1},{code:"mr",name:"Marathi",nativeName:"मराठी",flag:"🇮🇳",isRtl:!1},{code:"gu",name:"Gujarati",nativeName:"ગુજરાતી",flag:"🇮🇳",isRtl:!1},{code:"es",name:"Spanish",nativeName:"Español",flag:"🇪🇸",isRtl:!1},{code:"fr",name:"French",nativeName:"Français",flag:"🇫🇷",isRtl:!1},{code:"de",name:"German",nativeName:"Deutsch",flag:"🇩🇪",isRtl:!1},{code:"ru",name:"Russian",nativeName:"Русский",flag:"🇷🇺",isRtl:!1},{code:"ja",name:"Japanese",nativeName:"日本語",flag:"🇯🇵",isRtl:!1}],ja="en",Cs=t=>{const s=fa.find(a=>a.code===t);return s?s.isRtl:!1},Qn={title:"Telegram SaaS Platform",overview:"Overview",bots:"Connected Bots",users:"Active Users",analytics:"Analytics",billing:"Billing & Plans",settings:"Workspace Settings"},Zn={save:"Save Changes",cancel:"Cancel",delete:"Delete",connect_bot:"Connect New Bot"},Xn={dashboard:Qn,actions:Zn},el={title:"टेलीग्राम सास प्लेटफॉर्म",overview:"अवलोकन",bots:"कनेक्टेड बॉट्स",users:"सक्रिय उपयोगकर्ता",analytics:"एनालिटिक्स",billing:"बिलिंग और योजनाएं",settings:"कार्यस्थान सेटिंग्स"},tl={save:"परिवर्तन सहेजें",cancel:"रद्द करें",delete:"हटाएं",connect_bot:"नया बॉट जोड़ें"},sl={dashboard:el,actions:tl},al={title:"Telegram SaaS Manch",overview:"Kul Jaankari",bots:"Jude Hue Bots",users:"Sakriya Users",analytics:"Stats aur Analytics",billing:"Billing aur Plans",settings:"Workspace Settings Badlein"},rl={save:"Changes Save Karein",cancel:"Radd Karein",delete:"Delete Karein",connect_bot:"Naya Bot Connect Karein"},nl={dashboard:al,actions:rl},ll={title:"टेलीग्राम सास मञ्चम्",overview:"सिंहावलोकनम्",bots:"संयोजिताः बॉट्स",users:"सक्रियाः प्रयोक्तारः",analytics:"विश्लेषणम्",billing:"शुल्कम् च योजनाः",settings:"कार्यस्थान व्यवस्था"},ol={save:"परिवर्तनानि रक्षतु",cancel:"निरसयतु",delete:"मार्जयतु",connect_bot:"नवीन बॉट योजयतु"},il={dashboard:ll,actions:ol},cl={title:"منصة تيليجرام ساس",overview:"نظرة عامة",bots:"البوتات المتصلة",users:"المستخدمون النشطون",analytics:"التحليلات",billing:"الفواتير والخطط",settings:"إعدادات مساحة العمل"},dl={save:"حفظ التغييرات",cancel:"إلغاء",delete:"حذف",connect_bot:"ربط بوت جديد"},ml={dashboard:cl,actions:dl},xl={title:"ٹیلیگرام ساس پلیٹ فارم",overview:"جائزہ",bots:"منسلک بوٹس",users:"فعال صارفین",analytics:"تجزیات",billing:"بلنگ اور منصوبے",settings:"ورک اسپیس کی ترتیبات"},pl={save:"تبدیلیاں محفوظ کریں",cancel:"منسوخ کریں",delete:"حذف کریں",connect_bot:"نیا بوٹ شامل کریں"},ul={dashboard:xl,actions:pl},hl={title:"টেলিগ্রাম সাস প্ল্যাটফর্ম",overview:"সারসংক্ষেপ",bots:"সংযুক্ত বট",users:"সক্রিয় ব্যবহারকারী",analytics:"বিশ্লেষণ",billing:"বিলিং এবং পরিকল্পনা",settings:"ওয়ার্কস্পেস সেটিংস"},bl={save:"সংরক্ষণ করুন",cancel:"বাতিল",delete:"মুছুন",connect_bot:"নতুন বট সংযুক্ত করুন"},gl={dashboard:hl,actions:bl},fl={title:"டெலிகிராம் SaaS தளம்",overview:"மேலோட்டம்",bots:"இணைக்கப்பட்ட பாட்கள்",users:"செயலில் உள்ள பயனர்கள்",analytics:"பகுப்பாய்வு",billing:"பில்லிங் & திட்டங்கள்",settings:"பணிவெளி அமைப்புகள்"},jl={save:"மாற்றங்களைச் சேமி",cancel:"ரத்து செய்",delete:"நீக்கு",connect_bot:"புதிய பாட் இணைக்கவும்"},vl={dashboard:fl,actions:jl},wl={title:"టెలిగ్రామ్ SaaS ప్లాట్‌ఫారమ్",overview:"అవలోకనం",bots:"కనెక్ట్ చేయబడిన బాట్లు",users:"క్రియాశీల వినియోగదారులు",analytics:"విశ్లేషణలు",billing:"బిల్లింగ్ & ప్లాన్లు",settings:"వర్క్‌స్పేస్ సెట్టింగులు"},Nl={save:"మార్పులను సేవ్ చేయండి",cancel:"రద్దు చేయండి",delete:"తొలగించండి",connect_bot:"కొత్త బాట్ కనెక్ట్ చేయండి"},yl={dashboard:wl,actions:Nl},Cl={title:"टेलिग्राम SaaS प्लॅटफॉर्म",overview:"आढावा",bots:"कनेक्ट केलेले बॉट्स",users:"सक्रिय वापरकर्ते",analytics:"अ‍ॅनालिटिक्स",billing:"बिलिंग आणि योजना",settings:"वर्कस्पेस सेटिंग्ज"},kl={save:"बदल जतन करा",cancel:"रद्द करा",delete:"हटवा",connect_bot:"नवीन बॉट कनेक्ट करा"},_l={dashboard:Cl,actions:kl},Sl={title:"ટેલિગ્રામ SaaS પ્લેટફોર્મ",overview:"અવલોકન",bots:"જોડાયેલા બોટ્સ",users:"સક્રિય વપરાશકર્તાઓ",analytics:"એનાલિટિક્સ",billing:"બિલિંગ અને યોજનાઓ",settings:"વર્કસ્પેસ સેટિંગ્સ"},Tl={save:"ફેરફારો સાચવો",cancel:"રદ કરો",delete:"કાઢી નાખો",connect_bot:"નવું બોટ જોડો"},Al={dashboard:Sl,actions:Tl},Pl={title:"Plataforma SaaS de Telegram",overview:"Visión General",bots:"Bots Conectados",users:"Usuarios Activos",analytics:"Analítica",billing:"Facturación y Planes",settings:"Configuración del Espacio de Trabajo"},Il={save:"Guardar Cambios",cancel:"Cancelar",delete:"Eliminar",connect_bot:"Conectar Nuevo Bot"},El={dashboard:Pl,actions:Il},Rl={title:"Plateforme SaaS Telegram",overview:"Vue d'ensemble",bots:"Bots Connectés",users:"Utilisateurs Actifs",analytics:"Analytique",billing:"Facturation & Plans",settings:"Paramètres de l'Espace de Travail"},Ll={save:"Enregistrer les Modifications",cancel:"Annuler",delete:"Supprimer",connect_bot:"Connecter un Nouveau Bot"},Ml={dashboard:Rl,actions:Ll},Bl={title:"Telegram SaaS-Plattform",overview:"Übersicht",bots:"Verbundene Bots",users:"Aktive Benutzer",analytics:"Analytik",billing:"Abrechnung & Tarife",settings:"Arbeitsbereich-Einstellungen"},Ol={save:"Änderungen speichern",cancel:"Abbrechen",delete:"Löschen",connect_bot:"Neuen Bot verbinden"},Dl={dashboard:Bl,actions:Ol},$l={title:"Telegram SaaS-платформа",overview:"Обзор",bots:"Подключенные боты",users:"Активные пользователи",analytics:"Аналитика",billing:"Тарифы и оплата",settings:"Настройки рабочей области"},Fl={save:"Сохранить изменения",cancel:"Отмена",delete:"Удалить",connect_bot:"Подключить нового бота"},Ul={dashboard:$l,actions:Fl},Vl={title:"Telegram SaaS プラットフォーム",overview:"概要",bots:"接続済みボット",users:"アクティブユーザー",analytics:"アナリティクス",billing:"請求とプラン",settings:"ワークスペース設定"},Hl={save:"変更を保存",cancel:"キャンセル",delete:"削除",connect_bot:"新しいボットを接続"},Gl={dashboard:Vl,actions:Hl},ks={en:Xn,hi:sl,"hi-Latn":nl,sa:il,ar:ml,ur:ul,bn:gl,ta:vl,te:yl,mr:_l,gu:Al,es:El,fr:Ml,de:Dl,ru:Ul,ja:Gl},zl=(t,s)=>{const[a,r]=s.split("."),o=ks[t]||ks[ja];return!o||!o[a]?r||s:o[a][r]||r},Wl=()=>{const[t,s]=l.useState(()=>localStorage.getItem("saas_locale")||ja),a=Cs(t),r=l.useCallback(n=>{s(n),localStorage.setItem("saas_locale",n),document.documentElement.lang=n,document.documentElement.dir=Cs(n)?"rtl":"ltr"},[]);l.useEffect(()=>{document.documentElement.lang=t,document.documentElement.dir=a?"rtl":"ltr"},[t,a]);const o=l.useCallback(n=>zl(t,n),[t]);return{currentLocale:t,isRtl:a,setLanguage:r,t:o,supportedLanguages:fa}},ql=()=>{const{currentLocale:t,setLanguage:s,supportedLanguages:a}=Wl();return e.jsx("div",{className:"relative inline-block text-left",children:e.jsx("select",{value:t,onChange:r=>s(r.target.value),className:"block w-auto max-w-[80px] xs:max-w-[110px] sm:max-w-[150px] md:max-w-none rounded-lg border border-white/10 bg-space-900 py-1 sm:py-1.5 pl-2 pr-6 text-[11px] sm:text-xs font-mono text-pearl-100 shadow-sm focus:border-[#2481CC] focus:ring-1 focus:ring-[#2481CC] focus:outline-none cursor-pointer truncate","aria-label":"Select Language",children:a.map(r=>e.jsxs("option",{value:r.code,children:[r.flag," ",r.name]},r.code))})})},Jl=({currentView:t,currentBotName:s,onSelectBotModal:a,collapsed:r,onOpenMobileMenu:o})=>{var $;const{user:n,isAuthenticated:i,logout:h}=Ue(),{theme:u,toggleTheme:x}=mt(),{currentBot:m,bots:b,selectBot:j}=ce();Te();const[f,g]=l.useState(3),[v,c]=l.useState(!1),[w,p]=l.useState(!1),[N,k]=l.useState(""),_=l.useRef(null);l.useEffect(()=>{const D=H=>{_.current&&!_.current.contains(H.target)&&p(!1)};return document.addEventListener("mousedown",D),()=>document.removeEventListener("mousedown",D)},[]);const A=(b||[]).filter(D=>D.name.toLowerCase().includes(N.toLowerCase())||D.username.toLowerCase().includes(N.toLowerCase())),[C,U]=l.useState([{id:"n-1",title:"Broadcast Campaign Completed",message:"Spring Flash Sale 2026 dispatched successfully to 14,280 recipients with 99.8% delivery.",type:"broadcast",priority:"normal",is_read:!1,created_at:new Date(Date.now()-1e3*60*15).toISOString()},{id:"n-2",title:"AI Usage Limit Warning",message:"Monthly AI token consumption reached 65% of Pro tier limit (650,000 / 1,000,000 tokens).",type:"billing",priority:"high",is_read:!1,created_at:new Date(Date.now()-1e3*60*120).toISOString()},{id:"n-3",title:"Crypto Price Plugin Triggered",message:"BTC/USD threshold crossed $96,000. Automated alert broadcast executed.",type:"plugin",priority:"low",is_read:!1,created_at:new Date(Date.now()-1e3*60*360).toISOString()}]);l.useEffect(()=>{fetch("/api/v1/notifications/unread-count").then(D=>D.ok?D.json():null).then(D=>{var H;((H=D==null?void 0:D.data)==null?void 0:H.unread_count)!==void 0&&g(D.data.unread_count)}).catch(()=>{})},[]);const M=async()=>{const D=C.filter(H=>!H.is_read).map(H=>H.id);if(D.length>0)try{await fetch("/api/v1/notifications/mark-read",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({notification_ids:D})})}catch{}U(H=>H.map(L=>({...L,is_read:!0}))),g(0)};return e.jsxs("header",{className:`fixed top-0 right-0 z-30 h-16 sm:h-20 bg-space-900/95 backdrop-blur-md border-b border-white/10 px-3 sm:px-6 flex items-center justify-between transition-all duration-300 left-0 ${r?"md:left-20":"md:left-64"}`,children:[e.jsxs("div",{className:"flex items-center gap-2 sm:gap-3 min-w-0 max-w-[40%] xs:max-w-[45%] sm:max-w-none",children:[e.jsx("button",{onClick:o,className:"p-1.5 sm:p-2 -ml-1 text-pearl-300 hover:text-[#2481CC] hover:bg-white/5 rounded-lg md:hidden transition-colors shrink-0","aria-label":"Open mobile navigation",children:e.jsx(Is,{className:"w-5 h-5"})}),e.jsxs("div",{className:"hidden sm:flex items-center gap-2 text-xs font-mono tracking-widest text-pearl-400 truncate",children:[e.jsx(I,{to:"/",className:"hover:text-[#2481CC] transition-colors shrink-0 font-semibold text-[#2481CC]",children:"TELEBOT"}),e.jsx("span",{className:"text-[#2481CC]/60",children:"/"}),e.jsx(I,{to:_t[t]||"/dashboard",className:"text-pearl-200 uppercase hover:text-[#2481CC] transition-colors truncate",children:t.replace("-"," ")})]}),e.jsx(I,{to:"/",className:"sm:hidden font-sans text-xs text-pearl-100 uppercase tracking-wide truncate font-bold hover:text-[#2481CC] min-w-0",children:t.replace("-"," ")})]}),e.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2.5 md:gap-4 shrink-0",children:[!b||b.length===0?e.jsxs(I,{to:"/dashboard/bots",className:"flex items-center gap-1.5 px-2.5 sm:px-3 py-1.5 rounded-lg bg-[#2481CC] hover:bg-[#1E72B3] text-white text-xs font-semibold shadow-telegram transition-all shrink-0",title:"Connect your first Telegram Bot via @BotFather",children:[e.jsx(oe,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"hidden sm:inline",children:"Connect Bot"}),e.jsx("span",{className:"sm:hidden",children:"+ Bot"})]}):e.jsxs("div",{className:"relative shrink-0",ref:_,children:[e.jsxs("button",{type:"button",onClick:()=>p(!w),className:"flex items-center gap-1.5 sm:gap-2 px-2 sm:px-3 py-1.5 rounded-lg bg-space-850/90 border border-white/10 text-xs font-mono text-pearl-100 hover:border-[#2481CC]/50 hover:bg-[#2481CC]/10 transition-colors shadow-sm",title:"Switch Telegram Bot Console (Play Console Architecture)",children:[e.jsx("span",{className:"w-2 h-2 rounded-full bg-emerald-400 animate-pulse shrink-0"}),e.jsxs("div",{className:"text-left hidden sm:block",children:[e.jsx("div",{className:"font-sans font-semibold text-pearl-50 text-[11px] leading-tight truncate max-w-[120px] md:max-w-[160px]",children:(m==null?void 0:m.name)||s}),e.jsxs("div",{className:"text-[9px] font-mono text-[#2481CC] leading-tight truncate max-w-[120px] md:max-w-[160px]",children:["@",(m==null?void 0:m.username)||"bot"]})]}),e.jsxs("span",{className:"sm:hidden font-sans font-semibold text-xs text-pearl-50 truncate max-w-[85px]",children:["@",(m==null?void 0:m.username)||"bot"]}),e.jsx(zt,{className:`w-3.5 h-3.5 text-pearl-400 ml-0.5 transition-transform shrink-0 ${w?"rotate-180 text-[#2481CC]":""}`})]}),w&&e.jsxs("div",{className:"fixed sm:absolute left-3 right-3 sm:left-auto sm:right-0 top-18 sm:top-full mt-2 w-auto sm:w-80 md:w-88 bg-space-900 border border-white/15 rounded-2xl shadow-2xl z-50 p-3 sm:p-4 space-y-2.5 backdrop-blur-2xl animate-in fade-in zoom-in-95 max-w-sm sm:max-w-none",children:[e.jsxs("div",{className:"flex items-center justify-between pb-2 border-b border-white/10",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(me,{className:"w-3.5 h-3.5 text-[#2481CC]"}),e.jsx("span",{className:"text-[10px] font-mono tracking-wider text-pearl-300 uppercase font-semibold",children:"Chosen Bot Workspace"})]}),e.jsxs("span",{className:"text-[9px] font-mono px-1.5 py-0.5 rounded bg-emerald-500/10 text-emerald-400 border border-emerald-500/20",children:[(b==null?void 0:b.length)||0," BOTS"]})]}),e.jsxs("div",{className:"relative",children:[e.jsx(qe,{className:"w-3.5 h-3.5 absolute left-2.5 top-1/2 -translate-y-1/2 text-pearl-400"}),e.jsx("input",{type:"text",value:N,onChange:D=>k(D.target.value),placeholder:"Filter bots by name...",className:"w-full pl-8 pr-3 py-1.5 rounded-lg bg-space-950 border border-white/10 text-xs font-mono text-pearl-100 placeholder:text-pearl-400/60 focus:outline-none focus:border-[#2481CC]",autoFocus:!0})]}),e.jsx("div",{className:"max-h-56 overflow-y-auto space-y-1 pr-1 custom-scrollbar",children:A.length===0?e.jsxs("div",{className:"py-4 text-center space-y-2",children:[e.jsx("p",{className:"text-xs text-pearl-400 font-sans",children:"No matching bots found"}),e.jsxs(I,{to:"/dashboard/bots",onClick:()=>p(!1),className:"btn-telegram-primary text-[10px] py-1 px-2.5 inline-flex items-center gap-1 mx-auto",children:[e.jsx(oe,{className:"w-3 h-3"}),e.jsx("span",{children:"Connect New Bot"})]})]}):A.map(D=>{const H=D.id===(m==null?void 0:m.id);return e.jsxs("button",{onClick:()=>{j(D.id),p(!1)},className:`w-full flex items-center justify-between p-2 rounded-lg text-left transition-colors ${H?"bg-[#2481CC]/15 border border-[#2481CC]/40 text-white":"hover:bg-space-850 text-pearl-200 border border-transparent"}`,children:[e.jsxs("div",{className:"flex items-center gap-2.5 min-w-0",children:[e.jsx("div",{className:`w-7 h-7 rounded-lg flex items-center justify-center shrink-0 ${H?"bg-[#2481CC] text-white shadow-telegram":"bg-space-800 text-pearl-300"}`,children:e.jsx(me,{className:"w-4 h-4"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"text-xs font-semibold text-pearl-50 truncate flex items-center gap-1.5",children:[e.jsx("span",{children:D.name}),H&&e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-emerald-400 animate-pulse"})]}),e.jsxs("div",{className:"text-[10px] font-mono text-[#2481CC] truncate",children:["@",D.username]})]})]}),e.jsx("div",{className:"text-right shrink-0 ml-2",children:H?e.jsx("span",{className:"text-[9px] font-mono px-1.5 py-0.5 rounded bg-[#2481CC]/25 text-[#2481CC] font-semibold",children:"ACTIVE"}):e.jsxs("span",{className:"text-[9px] font-mono text-pearl-400",children:[D.usersCount.toLocaleString()," users"]})})]},D.id)})}),e.jsxs("div",{className:"pt-2 border-t border-white/10 flex items-center justify-between gap-2",children:[e.jsxs(I,{to:"/dashboard/bots",onClick:()=>p(!1),className:"text-[11px] font-mono text-[#2481CC] hover:underline flex items-center gap-1",children:[e.jsx(We,{className:"w-3 h-3"}),e.jsx("span",{children:"All Bots Fleet"})]}),e.jsxs(I,{to:"/dashboard/bots",onClick:()=>p(!1),className:"btn-telegram-primary py-1 px-2.5 text-[10px] font-mono inline-flex items-center gap-1 shadow-telegram",children:[e.jsx(oe,{className:"w-3 h-3"}),e.jsx("span",{children:"Connect Bot"})]})]})]})]}),e.jsxs("div",{className:"hidden lg:flex items-center gap-2 px-3 py-1 rounded-full bg-emerald-500/10 border border-emerald-500/30 text-[10px] font-mono uppercase tracking-wider text-emerald-300",children:[e.jsx(_e,{className:"w-3 h-3 animate-pulse text-emerald-400"}),e.jsxs("span",{children:[(b==null?void 0:b.length)||0," ",(b==null?void 0:b.length)===1?"BOT":"BOTS"," ONLINE"]})]}),e.jsx("div",{className:"relative shrink-0 hidden md:block",children:e.jsx(ql,{})}),e.jsx("div",{className:"relative shrink-0",children:e.jsx("button",{id:"top-navbar-theme-toggle",onClick:x,className:"p-1.5 sm:p-2 rounded-lg bg-space-850 border border-white/10 text-pearl-300 hover:text-[#2481CC] hover:border-[#2481CC]/40 transition-colors relative flex items-center justify-center",title:u==="light"?"Switch to Rich Slate Dark Theme":"Switch to Clean Light Theme","aria-label":"Toggle theme",children:u==="light"?e.jsx(ht,{className:"w-4 h-4 text-slate-700"}):e.jsx(bt,{className:"w-4 h-4 text-amber-400"})})}),e.jsxs("div",{className:"relative shrink-0",children:[e.jsxs("button",{onClick:()=>c(!v),className:"p-1.5 sm:p-2 rounded-lg bg-space-850 border border-white/10 text-pearl-300 hover:text-[#2481CC] hover:border-[#2481CC]/40 transition-colors relative",title:"Notifications",children:[e.jsx(Pa,{className:"w-4 h-4"}),f>0&&e.jsx("span",{className:"absolute -top-1 -right-1 w-4 h-4 rounded-full bg-[#2481CC] text-white text-[9px] font-mono font-bold flex items-center justify-center shadow-sm",children:f})]}),v&&e.jsxs("div",{className:"fixed sm:absolute left-3 right-3 sm:left-auto sm:right-0 top-18 sm:top-full mt-2 w-auto sm:w-80 md:w-96 max-w-sm sm:max-w-none astraea-card rounded-2xl p-3 sm:p-4 border border-[#2481CC]/30 shadow-2xl z-50 animate-in fade-in duration-200",children:[e.jsxs("div",{className:"flex items-center justify-between pb-3 border-b border-white/10 mb-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs font-sans tracking-wide text-pearl-50 uppercase font-semibold",children:"In-App Alerts"}),f>0&&e.jsxs("span",{className:"px-1.5 py-0.5 rounded text-[9px] font-mono bg-[#2481CC]/20 text-[#2481CC] border border-[#2481CC]/30 font-semibold",children:[f," UNREAD"]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[f>0&&e.jsxs("button",{onClick:M,className:"text-[10px] font-mono text-[#2481CC] hover:underline flex items-center gap-1 font-medium",children:[e.jsx(W,{className:"w-3 h-3"})," Mark all read"]}),e.jsx("button",{onClick:()=>c(!1),className:"text-pearl-400 hover:text-pearl-100",children:e.jsx(ae,{className:"w-4 h-4"})})]})]}),e.jsx("div",{className:"space-y-2.5 max-h-80 overflow-y-auto pr-1",children:C.map(D=>e.jsxs("div",{className:`p-3 rounded-xl border text-xs font-mono transition-colors ${D.is_read?"bg-space-900/40 border-white/5 text-pearl-400":"bg-space-850 border-[#2481CC]/30 text-pearl-100 shadow-sm"}`,children:[e.jsxs("div",{className:"flex items-center justify-between font-semibold text-pearl-50 text-[11px] mb-1",children:[e.jsx("span",{className:"truncate",children:D.title}),e.jsx("span",{className:"text-[9px] text-pearl-400 shrink-0 ml-2",children:new Date(D.created_at).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})})]}),e.jsx("p",{className:"text-[11px] text-pearl-300 leading-relaxed font-sans",children:D.message})]},D.id))})]})]}),i&&n?e.jsxs("div",{className:"flex items-center gap-2.5 pl-3 border-l border-white/10",children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-gradient-to-tr from-[#2481CC] to-[#7DD3FC] p-[1px] shadow-sm shrink-0",children:n.avatar_url?e.jsx("img",{src:n.avatar_url,alt:"",className:"w-full h-full rounded-full object-cover"}):e.jsx("div",{className:"w-full h-full rounded-full bg-space-900 flex items-center justify-center text-xs font-mono font-bold text-[#2481CC]",children:(($=n.full_name)==null?void 0:$.slice(0,2).toUpperCase())||"TG"})}),e.jsxs("div",{className:"hidden xl:block text-left",children:[e.jsx("div",{className:"text-xs font-medium text-pearl-100 leading-tight truncate max-w-[120px]",children:n.full_name}),e.jsx("div",{className:"text-[9px] font-mono tracking-wider text-[#2481CC] uppercase font-medium",children:n.telegram_username?`@${n.telegram_username}`:"ACTIVE TENANT"})]}),e.jsx("button",{onClick:h,className:"text-pearl-400 hover:text-rose-400 p-1",title:"Sign Out",children:e.jsx(Es,{className:"w-4 h-4"})})]}):e.jsxs(I,{to:"/login",className:"flex items-center gap-1.5 sm:gap-2 pl-2 sm:pl-3 border-l border-white/10 btn-telegram-primary py-1 sm:py-1.5 px-2.5 sm:px-3 text-xs shrink-0 shadow-telegram",children:[e.jsx(ut,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"hidden sm:inline",children:"SIGN IN"})]})]})]})},Yl=[{id:"b-001",name:"Astraea Flagship Super Bot",username:"astraea_flagship_bot",status:"active",usersCount:14280,messages24h:38450,latencyMs:38,color:"#d4af37",orbitRadius:4.2,orbitSpeed:.008,orbitAngle:0,inclination:.25},{id:"b-002",name:"VIP Concierge & Support",username:"vip_concierge_bot",status:"active",usersCount:6890,messages24h:12400,latencyMs:42,color:"#e5c378",orbitRadius:6,orbitSpeed:.006,orbitAngle:Math.PI*.65,inclination:-.35},{id:"b-003",name:"Automated Flash Billing",username:"flash_billing_bot",status:"active",usersCount:9420,messages24h:21100,latencyMs:35,color:"#cbd5e1",orbitRadius:7.8,orbitSpeed:.0045,orbitAngle:Math.PI*1.35,inclination:.45},{id:"b-004",name:"Omni Broadcast Announcer",username:"omni_broadcast_bot",status:"syncing",usersCount:31200,messages24h:89400,latencyMs:48,color:"#94a3b8",orbitRadius:9.5,orbitSpeed:.0035,orbitAngle:Math.PI*1.85,inclination:-.15}],Kl=({bots:t=Yl,selectedBotId:s,onSelectBot:a,onOpenStudio:r,className:o=""})=>{const n=l.useRef(null),[i,h]=l.useState(()=>t.find(f=>f.id===s)||t[0]),[u,x]=l.useState(!0),[m,b]=l.useState(!0);l.useEffect(()=>{if(s){const f=t.find(g=>g.id===s);f&&h(f)}},[s,t]);const j=l.useCallback(f=>{h(f),a&&a(f)},[a]);return l.useEffect(()=>{const f=n.current;if(!f)return;try{const O=document.createElement("canvas");if(!(O.getContext("webgl")||O.getContext("experimental-webgl"))){b(!1);return}}catch{b(!1);return}const g=new pr;g.fog=new ur(197896,.025);const v=new hr(45,f.clientWidth/f.clientHeight,.1,1e3);v.position.set(0,7.5,16.5),v.lookAt(0,0,0);const c=new br({antialias:!0,alpha:!0,powerPreference:"high-performance"});c.setSize(f.clientWidth,f.clientHeight),c.setPixelRatio(Math.min(window.devicePixelRatio,2)),f.appendChild(c.domElement);const w=new gr(16777215,.4);g.add(w);const p=new fr(13938487,2.5,50);p.position.set(0,0,0),g.add(p);const N=new ds(16047262,1.2);N.position.set(12,18,12),g.add(N);const k=new ds(4878245,.8);k.position.set(-15,-10,-10),g.add(k);const _=new jr;g.add(_);const A=new ms(1.4,2),C=new xs({color:791330,emissive:13938487,emissiveIntensity:.35,roughness:.2,metalness:.85,wireframe:!1}),U=new Pt(A,C);_.add(U);const M=new ms(1.65,1),$=new vr({color:13938487,wireframe:!0,transparent:!0,opacity:.25}),D=new Pt(M,$);_.add(D);const H=600,L=new Float32Array(H*3);for(let O=0;O{const y=new Cr(0,0,O.orbitRadius,O.orbitRadius,0,2*Math.PI,!1,0).getPoints(120),d=new It().setFromPoints(y.map(Q=>new Et(Q.x,0,Q.y))),E=new ps({color:O.id===i.id?13938487:16777215,transparent:!0,opacity:O.id===i.id?.45:.1}),P=new us(d,E);P.rotation.x=O.inclination,g.add(P);const F=new kr(.38,32,32),V=new xs({color:O.id===i.id?13938487:2042173,emissive:O.id===i.id?13938487:988970,emissiveIntensity:O.id===i.id?.6:.2,roughness:.3,metalness:.8}),z=new Pt(F,V);z.userData={botId:O.id,botData:O},g.add(z),G.push(z);const Z=new It().setFromPoints([new Et(0,0,0),new Et(0,0,0)]),ve=new ps({color:13938487,transparent:!0,opacity:O.id===i.id?.35:.08}),re=new us(Z,ve);g.add(re),J.push({bot:O,mesh:z,ring:P,line:re,currentAngle:O.orbitAngle})});const pe=new Tr,q=new Sr;let Y=null,fe=0,Ce=7.5;const be=O=>{const K=f.getBoundingClientRect();q.x=(O.clientX-K.left)/K.width*2-1,q.y=-((O.clientY-K.top)/K.height)*2+1,fe=q.x*2.5,Ce=7.5+q.y*1.5,pe.setFromCamera(q,v);const y=pe.intersectObjects(G);if(y.length>0){const d=y[0].object;Y!==d&&(Y=d,f.style.cursor="pointer")}else Y&&(Y=null,f.style.cursor="default")},ye=()=>{var O;Y&&((O=Y.userData)!=null&&O.botData)&&j(Y.userData.botData)};f.addEventListener("mousemove",be),f.addEventListener("click",ye);let Ae,Pe=new _r;const S=()=>{Ae=requestAnimationFrame(S),Pe.getDelta(),v.position.x+=(fe-v.position.x)*.04,v.position.y+=(Ce-v.position.y)*.04,v.lookAt(0,0,0),_.rotation.y+=.005,D.rotation.x-=.003,D.rotation.z+=.004,B.rotation.y+=3e-4,J.forEach(O=>{u&&(O.currentAngle+=O.bot.orbitSpeed);const K=Math.cos(O.currentAngle)*O.bot.orbitRadius,y=Math.sin(O.currentAngle)*O.bot.orbitRadius,d=Math.sin(O.currentAngle)*Math.sin(O.bot.inclination)*1.8;O.mesh.position.set(K,d,y);const E=O.line.geometry.attributes.position;E.setXYZ(1,K,d,y),E.needsUpdate=!0;const P=O.bot.id===i.id,F=O.mesh.material;F.color.setHex(P?13938487:2042173),F.emissive.setHex(P?13938487:988970),F.emissiveIntensity=P?.75:.2;const V=O.ring.material;V.color.setHex(P?13938487:16777215),V.opacity=P?.45:.1;const z=O.line.material;z.opacity=P?.35:.08}),c.render(g,v)};S();const T=()=>{f&&(v.aspect=f.clientWidth/f.clientHeight,v.updateProjectionMatrix(),c.setSize(f.clientWidth,f.clientHeight))};return window.addEventListener("resize",T),()=>{cancelAnimationFrame(Ae),window.removeEventListener("resize",T),f.removeEventListener("mousemove",be),f.removeEventListener("click",ye),c.dispose(),c.domElement.parentNode&&c.domElement.parentNode.removeChild(c.domElement)}},[t,i.id,u,j]),e.jsxs("div",{className:`relative overflow-hidden rounded-xl border border-white/10 astraea-panel w-full max-w-full min-w-0 ${o}`,children:[e.jsx("div",{className:"absolute inset-0 cosmic-radial-bg pointer-events-none"}),m?e.jsx("div",{ref:n,className:"w-full h-[400px] sm:h-[480px] md:h-[540px] relative select-none"}):e.jsx("div",{className:"w-full h-[400px] sm:h-[480px] md:h-[540px] flex items-center justify-center p-8",children:e.jsxs("div",{className:"text-center max-w-md",children:[e.jsx(me,{className:"w-12 h-12 text-[#2481CC] mx-auto mb-4 animate-pulse"}),e.jsx("h3",{className:"text-lg font-bold tracking-tight text-pearl-100 uppercase",children:"Constellation Bot Cluster"}),e.jsx("p",{className:"text-xs text-pearl-400 mt-2",children:"Hardware accelerated WebGL view simplified for optimal device efficiency."})]})}),e.jsxs("div",{className:"absolute top-4 sm:top-5 left-4 sm:left-6 right-4 sm:right-6 flex items-center justify-between pointer-events-none",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"w-2 h-2 rounded-full bg-[#2481CC] animate-ping"}),e.jsx("span",{className:"text-[10px] font-mono tracking-wider text-[#2481CC] uppercase font-semibold",children:"Neural Constellation Mesh"})]}),e.jsx("h2",{className:"text-lg sm:text-xl md:text-2xl text-pearl-50 tracking-tight font-bold mt-0.5",children:"Dynamic Bot Orbit"})]}),e.jsxs("div",{className:"flex items-center gap-2 sm:gap-3 pointer-events-auto",children:[e.jsxs("button",{onClick:()=>x(!u),className:"btn-telegram-secondary py-1 px-2.5 sm:px-3 text-[10px] sm:text-[11px] gap-1.5",title:u?"Pause Orbit":"Resume Orbit",children:[e.jsx(ue,{className:`w-3.5 h-3.5 ${u?"animate-spin":""}`,style:{animationDuration:"6s"}}),e.jsx("span",{children:u?"ORBIT ACTIVE":"PAUSED"})]}),e.jsxs("div",{className:"hidden sm:flex items-center gap-2 px-3 py-1 rounded-lg bg-black/40 border border-white/10 text-xs font-mono text-pearl-300",children:[e.jsx(Fe,{className:"w-3.5 h-3.5 text-emerald-400"}),e.jsxs("span",{children:[t.length," NODES LINKED"]})]})]})]}),e.jsx("div",{className:"absolute top-20 sm:top-24 left-4 sm:left-6 right-4 sm:right-auto flex flex-wrap gap-1.5 sm:gap-2 pointer-events-auto max-h-24 overflow-y-auto sm:max-h-none scrollbar-none",children:t.map(f=>{const g=f.id===i.id;return e.jsxs("button",{onClick:()=>j(f),className:`px-2.5 py-1 sm:px-3 sm:py-1.5 rounded-lg text-[10px] sm:text-[11px] font-mono tracking-wider transition-all flex items-center gap-1.5 sm:gap-2 ${g?"bg-[#2481CC] border border-[#2481CC] text-white shadow-sm font-semibold":"bg-space-900/60 border border-white/10 text-pearl-400 hover:text-pearl-100 hover:border-white/25"}`,children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${f.status==="active"?"bg-emerald-400":"bg-amber-400"}`}),e.jsx("span",{children:f.name.split(" ")[0]})]},f.id)})}),e.jsx("div",{className:"absolute bottom-3 sm:bottom-5 left-3 sm:left-6 right-3 sm:right-6 pointer-events-auto",children:e.jsxs("div",{className:"astraea-card rounded-2xl p-3 sm:p-4 md:p-5 flex flex-col md:flex-row items-start md:items-center justify-between gap-3 sm:gap-4 border border-[#2481CC]/30 shadow-xl",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"w-12 h-12 rounded-xl bg-[#2481CC]/10 border border-[#2481CC]/30 flex items-center justify-center shrink-0",children:e.jsx(me,{className:"w-6 h-6 text-[#2481CC]"})}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"text-xs font-mono text-[#2481CC] font-semibold",children:["@",i.username]}),e.jsx("span",{className:"px-2 py-0.5 rounded text-[10px] font-mono uppercase bg-emerald-500/10 border border-emerald-500/30 text-emerald-300 font-semibold",children:i.status}),e.jsxs("span",{className:"hidden sm:inline-flex items-center gap-1 text-[10px] font-mono text-pearl-400",children:[e.jsx(ne,{className:"w-3 h-3 text-[#2481CC]"})," AES-256 Validated"]})]}),e.jsx("h3",{className:"text-base sm:text-lg text-pearl-50 font-bold tracking-tight mt-0.5",children:i.name})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3 sm:gap-6 md:gap-8 text-xs font-mono w-full md:w-auto justify-between md:justify-start",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] uppercase text-pearl-400 tracking-wider",children:"Active Audience"}),e.jsx("div",{className:"text-sm font-semibold text-pearl-100 mt-0.5",children:i.usersCount.toLocaleString()})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] uppercase text-pearl-400 tracking-wider",children:"24h Messages"}),e.jsx("div",{className:"text-sm font-semibold text-pearl-100 mt-0.5",children:i.messages24h.toLocaleString()})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] uppercase text-pearl-400 tracking-wider",children:"Response Latency"}),e.jsxs("div",{className:"text-sm font-semibold text-emerald-400 mt-0.5",children:[i.latencyMs," ms"]})]}),e.jsxs("div",{className:"flex items-center gap-2 w-full sm:w-auto justify-end",children:[e.jsx(I,{to:`/dashboard/bots/${i.username.replace("@","")||i.id}`,className:"btn-telegram-secondary text-[11px] py-2 px-3 inline-flex items-center gap-1",children:e.jsx("span",{children:"TELEMETRY"})}),e.jsxs(I,{to:"/dashboard/studio",onClick:()=>r&&r(i.id),className:"btn-telegram-primary text-[11px] py-2 px-3.5 inline-flex items-center gap-1",children:[e.jsx("span",{children:"STUDIO"}),e.jsx(ze,{className:"w-3.5 h-3.5"})]})]})]})]})})]})},va=({bot:t,onOpenTemplates:s,onOpenConnectModal:a})=>{const{toggleChecklistStep:r,toggleBotModule:o}=ce(),[n,i]=l.useState(null),[h,u]=l.useState(!1);if(!t)return e.jsxs("div",{className:"astraea-card rounded-2xl p-6 border border-white/10 shadow-sm text-center space-y-3",children:[e.jsx(me,{className:"w-10 h-10 text-[#2481CC] mx-auto"}),e.jsx("h3",{className:"text-base font-bold text-pearl-100",children:"No Bot Selected"}),e.jsx("p",{className:"text-xs text-pearl-400 font-sans",children:"Connect your Telegram Bot via BotFather to see the onboarding checklist."})]});const x=t.checklist||{tokenConnected:!1,templateSelected:!1,modulesConfigured:!1,welcomeMessageSet:!1,testedInTelegram:!1},m=Object.values(x).filter(Boolean).length,b=5,j=Math.round(m/b*100),f=()=>{navigator.clipboard.writeText("/newbot"),u(!0),setTimeout(()=>u(!1),2e3)},g=[{id:1,key:"tokenConnected",title:"Step 1: Connect Bot Token from @BotFather",subtitle:x.tokenConnected?"Verified via Telegram getMe & encrypted with AES-256-GCM":"Connect your bot to Telegram in 30 seconds (no coding required)",isComplete:x.tokenConnected,content:e.jsxs("div",{className:"space-y-3 pt-2 text-xs font-sans text-pearl-300",children:[e.jsxs("p",{className:"leading-relaxed",children:["Telegram bots are created through the official ",e.jsx("span",{className:"text-[#2481CC] font-semibold",children:"@BotFather"})," bot on Telegram. It provides an API token that allows our 24/7 cloud to run your bot."]}),e.jsxs("div",{className:"p-3 rounded-xl bg-space-900 border border-white/5 space-y-2 font-mono text-[11px]",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-pearl-400",children:"Quick BotFather Guide:"}),e.jsxs("button",{onClick:f,className:"text-[#2481CC] hover:underline flex items-center gap-1",children:[h?e.jsx(W,{className:"w-3 h-3 text-emerald-400"}):e.jsx(Ke,{className:"w-3 h-3"}),e.jsx("span",{children:h?"Copied /newbot":"Copy /newbot"})]})]}),e.jsxs("ol",{className:"list-decimal list-inside space-y-1 text-pearl-200",children:[e.jsxs("li",{children:["Open Telegram and search for ",e.jsx("strong",{className:"text-white",children:"@BotFather"})]}),e.jsxs("li",{children:["Send message: ",e.jsx("code",{className:"px-1 py-0.5 rounded bg-space-950 text-emerald-300",children:"/newbot"})]}),e.jsxs("li",{children:["Give your bot a name and username (e.g. ",e.jsx("code",{className:"px-1 py-0.5 rounded bg-space-950 text-emerald-300",children:"my_vip_store_bot"}),")"]}),e.jsx("li",{children:"Copy the HTTP API token provided by BotFather"})]})]}),e.jsxs("div",{className:"flex items-center gap-3 pt-1",children:[e.jsxs("button",{onClick:()=>a&&a(),className:"btn-telegram-primary py-1.5 px-3.5 text-xs shadow-telegram inline-flex items-center gap-1.5",children:[e.jsx(me,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:x.tokenConnected?"Update Bot Token":"Paste Bot Token"})]}),e.jsxs("a",{href:"https://t.me/BotFather",target:"_blank",rel:"noopener noreferrer",className:"btn-telegram-secondary py-1.5 px-3 text-xs inline-flex items-center gap-1.5",children:[e.jsx("span",{children:"Open @BotFather"}),e.jsx(Se,{className:"w-3 h-3"})]})]})]})},{id:2,key:"templateSelected",title:"Step 2: Choose a Ready-Made Template (25 Turnkey Options)",subtitle:x.templateSelected?`Applied: ${t.templateName||"Turnkey Bot Template"}`:"Pick a 1-click template so you never have to start from scratch",isComplete:x.templateSelected,content:e.jsxs("div",{className:"space-y-3 pt-2 text-xs font-sans text-pearl-300",children:[e.jsx("p",{className:"leading-relaxed",children:"Choose from 25 ready-made bot templates covering E-Commerce, VIP Subscriptions, Customer Support, Community Guard, Crypto Tracking, and Referral Viral Growth."}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-2 text-xs font-mono",children:[{name:"VIP Community & Subscriptions",desc:"Paid membership gates with Razorpay/Stripe"},{name:"Digital Store & E-Commerce",desc:"Product catalog with in-chat checkout"},{name:"Customer Support Desk",desc:"AI agent + human ticket escalation"}].map((v,c)=>e.jsxs("div",{className:"p-2.5 rounded-xl bg-space-900 border border-white/5 space-y-1",children:[e.jsx("div",{className:"font-semibold text-pearl-100",children:v.name}),e.jsx("div",{className:"text-[10px] text-pearl-400 font-sans",children:v.desc})]},c))}),e.jsxs("div",{className:"flex items-center gap-3 pt-1",children:[e.jsxs(I,{to:"/marketplace",className:"btn-telegram-primary py-1.5 px-3.5 text-xs shadow-telegram inline-flex items-center gap-1.5",children:[e.jsx(te,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"Browse 25+ Templates"})]}),e.jsx("button",{onClick:()=>r(t.id,"templateSelected"),className:"text-pearl-400 hover:text-pearl-200 text-xs font-mono",children:x.templateSelected?"Mark Incomplete":"Mark Complete"})]})]})},{id:3,key:"modulesConfigured",title:"Step 3: Enable Core Bot Features (1-Click Toggles)",subtitle:x.modulesConfigured?`${t.modules.filter(v=>v.is_enabled).length} of 9 core modules currently active`:"Turn on features like Welcome Messages, Referrals, Force Join, and AI Assistant",isComplete:x.modulesConfigured,content:e.jsxs("div",{className:"space-y-3 pt-2 text-xs font-sans text-pearl-300",children:[e.jsx("p",{className:"leading-relaxed",children:"Every feature on your bot is a standalone module. Toggle features on/off instantly without touching server configuration:"}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 gap-2",children:t.modules.slice(0,6).map(v=>e.jsxs("div",{className:`p-2.5 rounded-xl border flex items-center justify-between transition-all ${v.is_enabled?"bg-space-900 border-[#2481CC]/40":"bg-space-900/40 border-white/5"}`,children:[e.jsxs("div",{className:"min-w-0 pr-2",children:[e.jsx("div",{className:"font-semibold text-pearl-100 text-[11px] truncate",children:v.name}),e.jsx("div",{className:"text-[9px] font-mono text-pearl-400 capitalize",children:v.category})]}),e.jsx("button",{type:"button",onClick:()=>o(t.id,v.id),className:`w-9 h-5 rounded-full p-0.5 transition-colors relative shrink-0 ${v.is_enabled?"bg-[#2481CC]":"bg-space-800 border border-white/20"}`,children:e.jsx("div",{className:`w-4 h-4 rounded-full bg-white transition-transform ${v.is_enabled?"translate-x-4":"translate-x-0"}`})})]},v.id))}),e.jsx("div",{className:"flex items-center gap-3 pt-1",children:e.jsxs(I,{to:`/dashboard/bots/${t.username}`,className:"text-xs font-mono text-[#2481CC] hover:underline flex items-center gap-1 font-semibold",children:[e.jsx("span",{children:"Manage all 9 modules below"}),e.jsx(ke,{className:"w-3 h-3"})]})})]})},{id:4,key:"welcomeMessageSet",title:"Step 4: Customize Welcome Message & Inline Buttons",subtitle:x.welcomeMessageSet?"Custom welcome greeting and interactive inline buttons configured":"Design what users see when they tap /start in Telegram",isComplete:x.welcomeMessageSet,content:e.jsxs("div",{className:"space-y-3 pt-2 text-xs font-sans text-pearl-300",children:[e.jsxs("p",{className:"leading-relaxed",children:["Create rich welcome messages with emojis, custom bold text, dynamic user mentions (",e.jsx("code",{className:"px-1 py-0.5 rounded bg-space-950 font-mono text-emerald-300",children:"{first_name}"}),"), and clickable URL or callback buttons."]}),e.jsxs("div",{className:"flex items-center gap-3 pt-1",children:[e.jsxs(I,{to:"/dashboard/studio",className:"btn-telegram-primary py-1.5 px-3.5 text-xs shadow-telegram inline-flex items-center gap-1.5",children:[e.jsx(Ia,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"Open Welcome Message Studio"})]}),e.jsx("button",{onClick:()=>r(t.id,"welcomeMessageSet"),className:"text-pearl-400 hover:text-pearl-200 text-xs font-mono",children:x.welcomeMessageSet?"Mark Incomplete":"Mark Complete"})]})]})},{id:5,key:"testedInTelegram",title:"Step 5: Test Live in Telegram & Run 24/7 in Cloud",subtitle:x.testedInTelegram?"Bot verified live on Telegram! Cloud supervisor running 24/7":"Click to open your bot directly in Telegram and test live commands",isComplete:x.testedInTelegram,content:e.jsxs("div",{className:"space-y-3 pt-2 text-xs font-sans text-pearl-300",children:[e.jsx("p",{className:"leading-relaxed",children:"Your bot runs on our 24/7 managed cloud infrastructure with automatic recovery, Redis deduplication, and zero server maintenance."}),e.jsxs("div",{className:"p-3 rounded-xl bg-emerald-500/10 border border-emerald-500/30 flex items-center justify-between text-xs font-mono",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"w-2 h-2 rounded-full bg-emerald-400 animate-pulse"}),e.jsx("span",{className:"text-emerald-300 font-semibold",children:"24/7 Cloud Host Online"})]}),e.jsxs("span",{className:"text-pearl-400",children:[t.latencyMs," ms latency"]})]}),e.jsxs("div",{className:"flex items-center gap-3 pt-1",children:[e.jsxs("a",{href:`https://t.me/${t.username.replace("@","")}`,target:"_blank",rel:"noopener noreferrer",onClick:()=>{x.testedInTelegram||r(t.id,"testedInTelegram")},className:"btn-telegram-primary py-2 px-5 text-xs shadow-telegram inline-flex items-center gap-2 font-bold",children:[e.jsx(we,{className:"w-3.5 h-3.5"}),e.jsxs("span",{children:["Open @",t.username," in Telegram"]}),e.jsx(Se,{className:"w-3.5 h-3.5"})]}),e.jsx("button",{onClick:()=>r(t.id,"testedInTelegram"),className:"text-pearl-400 hover:text-pearl-200 text-xs font-mono",children:x.testedInTelegram?"Reset Status":"Mark Tested"})]})]})}];return e.jsxs("div",{className:"astraea-card rounded-2xl p-4 sm:p-6 border border-[#2481CC]/30 shadow-xl space-y-4",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-3 pb-3 border-b border-white/10",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-[10px] font-mono tracking-wider text-[#2481CC] uppercase font-bold",children:"Google Play Console Style Guided Setup"}),e.jsx("span",{className:"px-2 py-0.5 rounded-full text-[9px] font-mono font-semibold bg-emerald-500/15 text-emerald-300 border border-emerald-500/30",children:"BEGINNER FRIENDLY"})]}),e.jsxs("h2",{className:"text-lg sm:text-xl font-bold text-pearl-50 tracking-tight mt-0.5",children:["Set up your bot: ",e.jsxs("span",{className:"text-[#2481CC]",children:["@",t.username]})]}),e.jsx("p",{className:"text-xs text-pearl-400 font-sans mt-0.5",children:"Follow these 5 easy steps to launch and manage your Telegram bot — zero coding or server setup required."})]}),e.jsxs("div",{className:"flex items-center gap-3 self-start sm:self-auto shrink-0",children:[e.jsxs("div",{className:"text-right",children:[e.jsxs("div",{className:"text-xs font-mono font-bold text-pearl-100",children:[m," of ",b," steps completed"]}),e.jsxs("div",{className:"text-[10px] font-mono text-emerald-400",children:[j,"% Ready"]})]}),e.jsx("div",{className:"w-12 h-12 rounded-full border-2 border-white/10 flex items-center justify-center font-bold text-xs text-[#2481CC] relative bg-space-900",children:e.jsxs("span",{children:[j,"%"]})})]})]}),e.jsx("div",{className:"w-full bg-space-900 rounded-full h-2 overflow-hidden border border-white/5",children:e.jsx("div",{className:"bg-gradient-to-r from-[#2481CC] to-[#0088CC] h-full transition-all duration-500 rounded-full",style:{width:`${j}%`}})}),e.jsx("div",{className:"space-y-2.5 pt-1",children:g.map(v=>{const c=n===v.id;return e.jsxs("div",{className:`rounded-xl border transition-all ${v.isComplete?"bg-space-850/40 border-white/5":"bg-space-850/80 border-[#2481CC]/30 shadow-sm"}`,children:[e.jsxs("div",{onClick:()=>i(c?null:v.id),className:"p-3.5 sm:p-4 flex items-center justify-between cursor-pointer select-none",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[v.isComplete?e.jsx(ee,{className:"w-5 h-5 text-emerald-400 shrink-0"}):e.jsx(Ea,{className:"w-5 h-5 text-pearl-500 shrink-0"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h3",{className:`text-sm font-semibold tracking-tight truncate ${v.isComplete?"text-pearl-200 line-through opacity-75":"text-pearl-50 font-bold"}`,children:v.title}),e.jsx("p",{className:"text-xs text-pearl-400 font-sans truncate",children:v.subtitle})]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0 ml-2",children:[e.jsx("span",{className:`hidden sm:inline-block px-2 py-0.5 rounded text-[10px] font-mono uppercase font-semibold ${v.isComplete?"bg-emerald-500/10 text-emerald-300 border border-emerald-500/30":"bg-[#2481CC]/10 text-[#2481CC] border border-[#2481CC]/30"}`,children:v.isComplete?"COMPLETED":"ACTION REQUIRED"}),c?e.jsx(Rs,{className:"w-4 h-4 text-pearl-400"}):e.jsx(zt,{className:"w-4 h-4 text-pearl-400"})]})]}),c&&e.jsx("div",{className:"px-4 pb-4 border-t border-white/5 animate-in fade-in duration-200",children:v.content})]},v.id)})})]})},Ql=({onNavigate:t,onSelectBot:s})=>{var f,g,v;const a=Ne(),{currentBot:r,bots:o,selectBot:n,toggleBotModule:i}=ce(),[h,u]=l.useState(null),x=((f=r==null?void 0:r.modules)==null?void 0:f.filter(c=>c.is_enabled).length)||0,m=((g=r==null?void 0:r.modules)==null?void 0:g.length)||9,b=(c,w)=>{r&&(i(r.id,c,!w),u(`Module updated for @${r.username}!`),setTimeout(()=>u(null),2500))},j=c=>{switch(c){case"welcome_message":return te;case"force_join":return ne;case"referrals":return vt;case"broadcasts":return _e;case"user_management":return Le;case"auto_filter":return Wt;case"payments":return et;case"subscriptions":return ct;case"ai_assistant":return Me;default:return je}};return!o||o.length===0?e.jsx("div",{className:"space-y-8 animate-in fade-in duration-300 min-w-0 max-w-full",children:e.jsxs("div",{className:"astraea-card rounded-2xl p-6 sm:p-10 border border-white/10 shadow-sm relative overflow-hidden text-center max-w-3xl mx-auto my-8",children:[e.jsx("div",{className:"w-20 h-20 rounded-3xl bg-[#2481CC]/15 border border-[#2481CC]/40 flex items-center justify-center text-[#2481CC] mx-auto shadow-telegram mb-5",children:e.jsx(me,{className:"w-10 h-10"})}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"text-[10px] font-mono tracking-wider px-3 py-1 rounded-full bg-[#2481CC]/15 text-[#2481CC] border border-[#2481CC]/30 font-semibold uppercase inline-block",children:"24/7 Cloud Architecture Ready"}),e.jsx("h1",{className:"text-2xl sm:text-3xl font-bold text-pearl-50 tracking-tight",children:"Welcome to TeleBot Cloud"}),e.jsx("p",{className:"text-xs sm:text-sm text-pearl-400 font-sans max-w-xl mx-auto leading-relaxed",children:"You are in the production environment. Connect your Telegram BotFather token to configure your bot's 24/7 autonomous runtime, modular features, welcome screens, and broadcast pipeline."})]}),e.jsxs("div",{className:"pt-6 flex flex-col sm:flex-row items-center justify-center gap-3",children:[e.jsxs(I,{to:"/dashboard/bots",className:"btn-telegram-primary px-6 py-3 text-xs sm:text-sm shadow-telegram font-bold inline-flex items-center gap-2 w-full sm:w-auto justify-center",children:[e.jsx(oe,{className:"w-4 h-4"}),e.jsx("span",{children:"CONNECT BOT NOW"})]}),e.jsxs(I,{to:"/marketplace",className:"btn-telegram-secondary px-5 py-3 text-xs sm:text-sm inline-flex items-center gap-2 w-full sm:w-auto justify-center",children:[e.jsx(te,{className:"w-4 h-4 text-[#2481CC]"}),e.jsx("span",{children:"EXPLORE 25 TEMPLATES"})]})]}),e.jsxs("div",{className:"mt-8 pt-6 border-t border-white/10 grid grid-cols-1 sm:grid-cols-3 gap-3 text-left",children:[e.jsxs("div",{className:"p-3.5 rounded-xl bg-space-900 border border-white/5 space-y-1",children:[e.jsx("span",{className:"text-[10px] font-mono text-[#2481CC] font-bold",children:"1. @BotFather"}),e.jsx("p",{className:"text-xs text-pearl-200 font-sans",children:"Create a bot on Telegram with /newbot"})]}),e.jsxs("div",{className:"p-3.5 rounded-xl bg-space-900 border border-white/5 space-y-1",children:[e.jsx("span",{className:"text-[10px] font-mono text-[#2481CC] font-bold",children:"2. Paste Token"}),e.jsx("p",{className:"text-xs text-pearl-200 font-sans",children:"Cryptographically verified via getMe"})]}),e.jsxs("div",{className:"p-3.5 rounded-xl bg-space-900 border border-white/5 space-y-1",children:[e.jsx("span",{className:"text-[10px] font-mono text-[#2481CC] font-bold",children:"3. Launch 24/7"}),e.jsx("p",{className:"text-xs text-pearl-200 font-sans",children:"Modular engine & webhooks activate live"})]})]})]})}):e.jsxs("div",{className:"space-y-8 animate-in fade-in duration-300 min-w-0 max-w-full",children:[h&&e.jsxs("div",{className:"fixed bottom-6 right-6 z-50 px-4 py-2.5 rounded-xl bg-emerald-500 text-white font-mono text-xs shadow-telegram flex items-center gap-2 animate-in fade-in slide-in-from-bottom-2",children:[e.jsx(W,{className:"w-4 h-4"}),e.jsx("span",{children:h})]}),e.jsxs("div",{className:"astraea-card rounded-2xl p-4 sm:p-6 border border-white/10 shadow-sm relative overflow-hidden",children:[e.jsx("div",{className:"absolute top-0 right-0 w-64 h-64 bg-[#2481CC]/5 rounded-full blur-3xl pointer-events-none"}),e.jsxs("div",{className:"flex flex-col lg:flex-row lg:items-center justify-between gap-6 relative z-10",children:[e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsxs("div",{className:"w-14 h-14 sm:w-16 sm:h-16 rounded-2xl bg-[#2481CC]/15 border border-[#2481CC]/40 flex items-center justify-center text-[#2481CC] shadow-telegram shrink-0 relative",children:[e.jsx(me,{className:"w-7 h-7 sm:w-8 sm:h-8"}),e.jsx("span",{className:"absolute -bottom-1 -right-1 w-4 h-4 rounded-full bg-emerald-500 border-2 border-space-950 flex items-center justify-center",title:"24/7 Cloud Running",children:e.jsx("span",{className:"w-2 h-2 rounded-full bg-white animate-pulse"})})]}),e.jsxs("div",{className:"space-y-1.5 min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"text-[10px] font-mono tracking-wider px-2 py-0.5 rounded-full bg-[#2481CC]/15 text-[#2481CC] border border-[#2481CC]/30 font-semibold uppercase",children:"Chosen Bot Workspace"}),e.jsxs("span",{className:"text-[10px] font-mono px-2 py-0.5 rounded-full bg-emerald-500/10 text-emerald-400 border border-emerald-500/20 flex items-center gap-1 font-semibold",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-emerald-400 animate-pulse"}),"24/7 Managed Cloud Active"]}),(r==null?void 0:r.templateName)&&e.jsxs("span",{className:"text-[10px] font-mono px-2 py-0.5 rounded-full bg-space-850 text-pearl-300 border border-white/10 hidden sm:inline-block",children:["Template: ",r.templateName]})]}),e.jsxs("div",{className:"flex flex-wrap items-baseline gap-2.5",children:[e.jsx("h1",{className:"text-2xl sm:text-3xl font-bold text-pearl-50 tracking-tight truncate",children:(r==null?void 0:r.name)||"Astraea Super Bot"}),e.jsxs("a",{href:`https://t.me/${(r==null?void 0:r.username)||"astraea_flagship_bot"}`,target:"_blank",rel:"noopener noreferrer",className:"text-xs sm:text-sm font-mono text-[#2481CC] hover:underline flex items-center gap-1 font-semibold",title:"Open this bot in Telegram",children:[e.jsxs("span",{children:["@",(r==null?void 0:r.username)||"astraea_flagship_bot"]}),e.jsx(Se,{className:"w-3.5 h-3.5"})]})]}),e.jsxs("p",{className:"text-xs text-pearl-400 font-sans max-w-2xl leading-relaxed",children:["You are managing this bot's 24/7 cloud runtime, modular features, welcome screens, and broadcast pipeline. All actions below apply directly to ",e.jsxs("strong",{className:"text-pearl-200",children:["@",r==null?void 0:r.username]}),"."]})]})]}),e.jsxs("div",{className:"flex flex-wrap sm:flex-nowrap items-center gap-2.5 shrink-0",children:[e.jsxs("a",{href:`https://t.me/${(r==null?void 0:r.username)||"astraea_flagship_bot"}`,target:"_blank",rel:"noopener noreferrer",className:"btn-telegram-primary text-xs px-4 py-2.5 inline-flex items-center gap-2 shadow-telegram font-semibold w-full sm:w-auto justify-center",children:[e.jsx(Se,{className:"w-4 h-4"}),e.jsx("span",{children:"TEST LIVE IN TELEGRAM"})]}),e.jsxs(I,{to:`/dashboard/bots/${((v=r==null?void 0:r.username)==null?void 0:v.replace("@",""))||(r==null?void 0:r.id)||"astraea-flagship"}`,className:"btn-telegram-secondary text-xs px-3.5 py-2.5 inline-flex items-center gap-2 w-full sm:w-auto justify-center",children:[e.jsx(Ie,{className:"w-3.5 h-3.5 text-[#2481CC]"}),e.jsx("span",{children:"CONFIGURE MODULES"})]}),e.jsxs(I,{to:"/dashboard/bots",className:"px-3 py-2.5 rounded-xl bg-space-850 hover:bg-space-800 border border-white/10 text-pearl-200 hover:text-[#2481CC] text-xs font-mono inline-flex items-center gap-1.5 transition-colors",title:"View all bots directory",children:[e.jsx(We,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"SWITCH BOT"})]})]})]})]}),e.jsx(va,{bot:r,onOpenTemplates:()=>a("/marketplace"),onOpenConnectModal:()=>a("/dashboard/bots")}),e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-6 gap-2.5 sm:gap-3 md:gap-4",children:[{label:"Bot Subscribers",value:((r==null?void 0:r.usersCount)||14280).toLocaleString(),sub:"+14.2% organic growth",icon:Le,color:"text-[#2481CC]"},{label:"24h Messages",value:((r==null?void 0:r.messages24h)||38400).toLocaleString(),sub:`${(r==null?void 0:r.uptimePct)||99.98}% SLA verified`,icon:Oe,color:"text-pearl-100"},{label:"Active Modules",value:`${x} / ${m}`,sub:"1-click independent toggles",icon:Ie,color:"text-emerald-400"},{label:"Cloud Latency",value:`${(r==null?void 0:r.latencyMs)||38} ms`,sub:"Managed VPS infrastructure",icon:_e,color:"text-[#2481CC]"},{label:"Security Level",value:"AES-256",sub:"Hardware key version 1",icon:ne,color:"text-pearl-100"},{label:"Prepaid Wallet",value:"₹14,250",sub:"ACID Ledger Active",icon:Ls,color:"text-emerald-400"}].map((c,w)=>{const p=c.icon;return e.jsxs("div",{className:"astraea-card p-4 rounded-xl flex flex-col justify-between border border-white/10 hover:border-[#2481CC]/40 transition-colors",children:[e.jsxs("div",{className:"flex items-center justify-between text-pearl-400 text-xs mb-3",children:[e.jsx("span",{className:"font-mono text-[10px] uppercase tracking-widest text-pearl-400/90 truncate",children:c.label}),e.jsx(p,{className:`w-3.5 h-3.5 ${c.color} shrink-0`})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xl md:text-2xl font-bold text-pearl-50 tracking-tight",children:c.value}),e.jsxs("div",{className:"text-[10px] font-mono text-pearl-400 mt-1 flex items-center gap-1",children:[e.jsx("span",{className:"w-1 h-1 rounded-full bg-[#2481CC]"}),e.jsx("span",{className:"truncate",children:c.sub})]})]})]},w)})}),e.jsxs("div",{className:"astraea-panel rounded-2xl p-4 sm:p-6 border border-white/10 space-y-4",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-2 pb-4 border-b border-white/10",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"w-2 h-2 rounded-full bg-[#2481CC]"}),e.jsxs("h2",{className:"text-lg sm:text-xl font-bold text-pearl-50 tracking-tight",children:["Modular Features for @",r==null?void 0:r.username]})]}),e.jsx("p",{className:"text-xs text-pearl-400 font-sans mt-0.5",children:"Turn features on or off with 1 click. Zero programming needed — real backend execution controls."})]}),e.jsxs(I,{to:`/dashboard/bots/${(r==null?void 0:r.username)||"b-001"}`,className:"text-xs font-mono text-[#2481CC] hover:underline flex items-center gap-1 self-start sm:self-auto font-medium",children:[e.jsx("span",{children:"Advanced Module Settings"}),e.jsx(ze,{className:"w-3.5 h-3.5"})]})]}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3.5",children:((r==null?void 0:r.modules)||[]).map(c=>{const w=j(c.id);return e.jsxs("div",{className:`p-4 rounded-xl border transition-all flex flex-col justify-between ${c.is_enabled?"bg-space-850/80 border-[#2481CC]/40 shadow-sm":"bg-space-900/60 border-white/5 opacity-80 hover:opacity-100"}`,children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 mb-2.5",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("div",{className:`w-8 h-8 rounded-lg flex items-center justify-center shrink-0 ${c.is_enabled?"bg-[#2481CC]/20 text-[#2481CC] border border-[#2481CC]/40":"bg-space-800 text-pearl-400"}`,children:e.jsx(w,{className:"w-4 h-4"})}),e.jsx("div",{className:"min-w-0",children:e.jsx("span",{className:"text-[9px] font-mono uppercase tracking-wider px-1.5 py-0.5 rounded bg-space-800 text-pearl-400",children:c.category})})]}),e.jsx("button",{onClick:()=>b(c.id,c.is_enabled),className:`relative inline-flex h-6 w-11 shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out focus:outline-none ${c.is_enabled?"bg-[#2481CC]":"bg-space-750"}`,role:"switch","aria-checked":c.is_enabled,title:`Toggle ${c.name}`,children:e.jsx("span",{className:`pointer-events-none inline-block h-5 w-5 transform rounded-full bg-white shadow-lg ring-0 transition duration-200 ease-in-out ${c.is_enabled?"translate-x-5":"translate-x-0"}`})})]}),e.jsx("h3",{className:"text-sm font-semibold text-pearl-100 tracking-tight leading-snug",children:c.name}),e.jsx("p",{className:"text-xs text-pearl-400 font-sans mt-1 leading-relaxed line-clamp-2",children:c.description})]}),e.jsxs("div",{className:"mt-3 pt-3 border-t border-white/5 flex items-center justify-between text-[11px] font-mono",children:[e.jsxs("span",{className:c.is_enabled?"text-emerald-400 font-semibold flex items-center gap-1":"text-pearl-500 flex items-center gap-1",children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${c.is_enabled?"bg-emerald-400 animate-pulse":"bg-pearl-500"}`}),c.is_enabled?"Active on Bot":"Disabled"]}),e.jsx(I,{to:`/dashboard/bots/${(r==null?void 0:r.username)||"b-001"}`,className:"text-[#2481CC] hover:underline",children:"Configure →"})]})]},c.id)})})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6 min-w-0 max-w-full",children:[e.jsxs("div",{className:"lg:col-span-2 astraea-panel rounded-2xl p-4 sm:p-5 border border-white/10 min-w-0 max-w-full overflow-hidden",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between pb-4 border-b border-white/10 mb-4 gap-2",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg text-pearl-50 tracking-tight font-semibold",children:"Your Telegram Bot Fleet"}),e.jsx("p",{className:"text-xs text-pearl-400 font-mono mt-0.5",children:"Click any bot to instantly switch your dashboard workspace (Play Console Architecture)"})]}),e.jsxs(I,{to:"/dashboard/bots",className:"btn-telegram-primary text-xs px-3 py-1.5 inline-flex items-center gap-1.5 self-start sm:self-auto font-medium shadow-telegram",children:[e.jsx(oe,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"Connect New Bot"})]})]}),e.jsx("div",{className:"overflow-x-auto w-full max-w-full",children:e.jsxs("table",{className:"w-full text-left text-xs font-mono",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-white/10 text-[10px] text-pearl-400 uppercase tracking-widest",children:[e.jsx("th",{className:"pb-3 pl-2",children:"Bot Name"}),e.jsx("th",{className:"pb-3",children:"Username"}),e.jsx("th",{className:"pb-3",children:"Audience"}),e.jsx("th",{className:"pb-3",children:"Status"}),e.jsx("th",{className:"pb-3 pr-2 text-right",children:"Workspace Action"})]})}),e.jsx("tbody",{className:"divide-y divide-white/5",children:(o||[]).map(c=>{var p;const w=c.id===(r==null?void 0:r.id);return e.jsxs("tr",{className:`transition-colors ${w?"bg-[#2481CC]/10":"hover:bg-white/[0.02]"}`,children:[e.jsxs("td",{className:"py-3.5 pl-2 font-medium text-pearl-100 flex items-center gap-2.5",children:[e.jsx("div",{className:`w-7 h-7 rounded-lg flex items-center justify-center shrink-0 ${w?"bg-[#2481CC] text-white shadow-telegram":"bg-space-800 text-pearl-300"}`,children:e.jsx(me,{className:"w-3.5 h-3.5"})}),e.jsx("div",{className:"min-w-0",children:e.jsxs("div",{className:"font-semibold text-pearl-50 truncate flex items-center gap-1.5",children:[e.jsx("span",{children:c.name}),w&&e.jsx("span",{className:"text-[9px] font-mono px-1.5 py-0.2 rounded bg-[#2481CC]/30 text-[#2481CC] border border-[#2481CC]/40 font-bold",children:"CURRENT"})]})})]}),e.jsxs("td",{className:"py-3.5 text-[#2481CC] font-mono font-medium",children:["@",c.username]}),e.jsx("td",{className:"py-3.5 text-pearl-300",children:((p=c.usersCount)==null?void 0:p.toLocaleString())||"0"}),e.jsx("td",{className:"py-3.5",children:e.jsx("span",{className:"px-2 py-0.5 rounded text-[10px] font-mono uppercase bg-emerald-500/10 text-emerald-300 border border-emerald-500/30 font-semibold",children:c.status})}),e.jsx("td",{className:"py-3.5 pr-2 text-right",children:w?e.jsx("span",{className:"text-[11px] font-mono text-emerald-400 font-semibold",children:"● Active Console"}):e.jsx("button",{onClick:()=>n(c.id),className:"btn-telegram-secondary py-1 px-3 text-[11px] font-mono font-medium hover:border-[#2481CC]",children:"Switch to this Bot"})})]},c.id)})})]})})]}),e.jsxs("div",{className:"astraea-panel rounded-2xl p-5 border border-white/10 flex flex-col justify-between",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-[#2481CC]"}),e.jsxs("span",{className:"text-[10px] font-mono tracking-wider text-[#2481CC] uppercase font-semibold",children:["Quick Tools for @",r==null?void 0:r.username]})]}),e.jsx("h3",{className:"text-lg text-pearl-50 tracking-tight font-semibold mb-4",children:"Creative Portals"}),e.jsx("div",{className:"space-y-2.5",children:[{title:"Message Studio",desc:"Interactive inline button matrix & preview",view:"message-studio",icon:te},{title:"Autonomous AI Agents",desc:"Multi-turn Gemini, Claude & OpenAI assistants",view:"ai-agents",icon:Me},{title:"Campaign Broadcasts",desc:"25 msg/s rate-limited bulk notification engine",view:"broadcasts",icon:_e},{title:"Multi-Language Engine",desc:"16 BCP-47 locales with AI translation approval",view:"languages",icon:We}].map((c,w)=>{const p=c.icon;return e.jsxs(I,{to:_t[c.view],className:"w-full text-left p-3 rounded-lg bg-space-850/60 border border-white/5 hover:border-[#2481CC]/40 hover:bg-space-800 transition-all flex items-center justify-between group",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 rounded bg-space-800 border border-white/10 flex items-center justify-center text-[#2481CC] group-hover:border-[#2481CC]/40",children:e.jsx(p,{className:"w-4 h-4"})}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xs font-semibold text-pearl-100 group-hover:text-[#2481CC]",children:c.title}),e.jsx("div",{className:"text-[10px] font-mono text-pearl-400",children:c.desc})]})]}),e.jsx(Ms,{className:"w-4 h-4 text-pearl-400 group-hover:text-[#2481CC] transition-transform group-hover:translate-x-0.5 group-hover:-translate-y-0.5"})]},w)})})]}),e.jsxs("div",{className:"mt-6 p-3.5 rounded-lg bg-emerald-500/5 border border-emerald-500/20 text-xs font-mono text-pearl-300 flex items-center gap-3",children:[e.jsx(ne,{className:"w-5 h-5 text-emerald-400 shrink-0"}),e.jsxs("div",{className:"text-[11px] leading-relaxed",children:[e.jsx("span",{className:"text-emerald-300 font-semibold",children:"Zero-Secret-Leakage:"})," Telegram tokens & LLM API keys encrypted with hardware-grade AES-256-GCM."]})]})]})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-3 px-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs font-semibold text-pearl-100 uppercase tracking-wide",children:"Live Managed Cloud Bot Topology & Webhook Health"}),e.jsx("span",{className:"text-[10px] font-mono px-2 py-0.5 rounded bg-emerald-500/10 text-emerald-300 border border-emerald-500/20",children:"24/7 Cloud Running"})]}),e.jsx("span",{className:"text-[10px] font-mono text-pearl-400 hidden sm:inline",children:"Click bot node to inspect telemetry · Drag to rotate view"})]}),e.jsx(Kl,{onSelectBot:c=>{n(c.id),s&&s(c.id)},onOpenStudio:c=>{n(c),s&&s(c),t("message-studio")}})]})]})},lt=({className:t="w-6 h-6"})=>e.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",className:t,children:e.jsx("path",{d:"M12 0C5.373 0 0 5.373 0 12s5.373 12 12 12 12-5.373 12-12S18.627 0 12 0zm5.894 8.221l-1.97 9.28c-.145.658-.537.818-1.084.508l-3-2.21-1.446 1.394c-.16.16-.295.295-.605.295l.213-3.053 5.56-5.023c.242-.213-.054-.333-.373-.121l-6.871 4.326-2.962-.924c-.643-.204-.657-.643.136-.953l11.57-4.458c.538-.196 1.006.128.832.925z"})}),ss=()=>{const{isAuthenticated:t}=Ue(),{theme:s,toggleTheme:a}=mt(),r=Te(),[o,n]=l.useState(!1),i=r.pathname==="/login";return e.jsxs("header",{className:"sticky top-0 z-50 backdrop-blur-md bg-space-950/90 border-b border-white/10 w-full transition-colors duration-200",children:[e.jsxs("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 h-16 sm:h-20 flex items-center justify-between",children:[e.jsxs(I,{to:"/",className:"flex items-center gap-2.5 sm:gap-3 group shrink-0",children:[e.jsx("div",{className:"w-8 h-8 sm:w-10 sm:h-10 rounded-xl bg-[#2481CC] text-white flex items-center justify-center shadow-telegram group-hover:bg-[#1D74B7] transition shrink-0",children:e.jsx(lt,{className:"w-5 h-5 sm:w-6 sm:h-6 text-white"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2",children:[e.jsxs("span",{className:"font-sans font-bold text-base sm:text-lg text-pearl-50 tracking-tight",children:["TeleBot",e.jsx("span",{className:"text-[#2481CC]",children:"Cloud"})]}),e.jsx("span",{className:"px-1.5 py-0.5 rounded-full text-[9px] sm:text-[10px] font-mono bg-[#2481CC]/10 text-[#2481CC] border border-[#2481CC]/30 font-semibold",children:"SaaS"})]}),e.jsx("span",{className:"hidden sm:block text-[10px] font-mono text-pearl-400 uppercase tracking-wider",children:"Managed Telegram Bot Platform"})]})]}),e.jsxs("nav",{className:"hidden lg:flex items-center gap-8 text-sm font-medium text-pearl-300",children:[e.jsx(I,{to:"/#features",className:"hover:text-[#2481CC] transition",children:"Features"}),e.jsx(I,{to:"/#modules",className:"hover:text-[#2481CC] transition",children:"Modules"}),e.jsxs(I,{to:"/marketplace",className:"hover:text-[#2481CC] transition flex items-center gap-1.5",children:[e.jsx("span",{children:"Templates"}),e.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-mono bg-[#2481CC]/15 text-[#2481CC] font-semibold",children:"25"})]}),e.jsx(I,{to:"/pricing",className:`hover:text-[#2481CC] transition ${r.pathname==="/pricing"?"text-[#2481CC]":""}`,children:"Pricing"}),e.jsx(I,{to:"/#how-it-works",className:"hover:text-[#2481CC] transition",children:"How It Works"}),e.jsx(I,{to:"/#faq",className:"hover:text-[#2481CC] transition",children:"FAQ"})]}),e.jsxs("div",{className:"flex items-center gap-2 sm:gap-3 shrink-0",children:[e.jsx("button",{onClick:a,className:"p-1.5 sm:p-2 rounded-lg bg-space-900 border border-white/10 text-pearl-300 hover:text-[#2481CC] hover:border-[#2481CC]/40 transition shadow-sm flex items-center justify-center",title:s==="light"?"Switch to Dark Mode":"Switch to Light Mode","aria-label":"Toggle theme",children:s==="light"?e.jsx(ht,{className:"w-4 h-4 text-slate-700"}):e.jsx(bt,{className:"w-4 h-4 text-amber-400"})}),t?e.jsxs(I,{to:"/dashboard",className:"btn-telegram-primary py-1.5 sm:py-2 px-3 sm:px-4 text-xs font-semibold rounded-lg shadow-telegram inline-flex items-center gap-1.5",children:[e.jsx("span",{children:"DASHBOARD"}),e.jsx(ke,{className:"w-3.5 h-3.5"})]}):i?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(I,{to:"/pricing",className:"hidden sm:inline-flex btn-telegram-secondary py-1.5 sm:py-2 px-3 text-xs font-medium",children:"Pricing Plans"}),e.jsxs(I,{to:"/marketplace",className:"btn-telegram-primary py-1.5 sm:py-2 px-3.5 sm:px-4 text-xs font-semibold rounded-lg shadow-telegram inline-flex items-center gap-1.5",children:[e.jsx("span",{children:"EXPLORE TEMPLATES"}),e.jsx(ke,{className:"w-3.5 h-3.5"})]})]}):e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(I,{to:"/login",className:"btn-telegram-secondary py-1.5 sm:py-2 px-3 text-xs font-medium inline-flex items-center gap-1.5 border-[#2481CC]/40 text-[#2481CC] hover:bg-[#2481CC]/10",children:[e.jsx(lt,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"Log In"})]}),e.jsxs(I,{to:"/login",className:"hidden sm:inline-flex btn-telegram-primary py-1.5 sm:py-2 px-3.5 sm:px-4 text-xs font-semibold rounded-lg shadow-telegram items-center gap-1.5",children:[e.jsx("span",{children:"CREATE BOT"}),e.jsx(ke,{className:"w-3.5 h-3.5"})]})]}),e.jsx("button",{onClick:()=>n(!o),className:"lg:hidden p-2 rounded-lg bg-space-900 border border-white/10 text-pearl-300 hover:text-white","aria-label":"Toggle mobile menu",children:o?e.jsx(ae,{className:"w-5 h-5"}):e.jsx(Is,{className:"w-5 h-5"})})]})]}),o&&e.jsxs("div",{className:"lg:hidden border-t border-white/10 bg-space-950/95 backdrop-blur-xl px-4 pt-3 pb-6 space-y-3 animate-in slide-in-from-top-4 duration-200",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-2 text-xs font-medium text-pearl-300",children:[e.jsx(I,{to:"/#features",onClick:()=>n(!1),className:"p-2.5 rounded-lg bg-space-900 border border-white/5 hover:text-[#2481CC]",children:"Features"}),e.jsx(I,{to:"/#modules",onClick:()=>n(!1),className:"p-2.5 rounded-lg bg-space-900 border border-white/5 hover:text-[#2481CC]",children:"Modules & Plugins"}),e.jsxs(I,{to:"/marketplace",onClick:()=>n(!1),className:"p-2.5 rounded-lg bg-space-900 border border-white/5 hover:text-[#2481CC] flex items-center justify-between",children:[e.jsx("span",{children:"Templates"}),e.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-mono bg-[#2481CC]/20 text-[#2481CC]",children:"25"})]}),e.jsx(I,{to:"/pricing",onClick:()=>n(!1),className:"p-2.5 rounded-lg bg-space-900 border border-white/5 hover:text-[#2481CC]",children:"Pricing"}),e.jsx(I,{to:"/#how-it-works",onClick:()=>n(!1),className:"p-2.5 rounded-lg bg-space-900 border border-white/5 hover:text-[#2481CC]",children:"How It Works"}),e.jsx(I,{to:"/#faq",onClick:()=>n(!1),className:"p-2.5 rounded-lg bg-space-900 border border-white/5 hover:text-[#2481CC]",children:"FAQ"})]}),!t&&!i&&e.jsxs(I,{to:"/login",onClick:()=>n(!1),className:"w-full btn-telegram-primary py-2.5 text-xs font-semibold rounded-lg shadow-telegram flex items-center justify-center gap-2",children:[e.jsx(lt,{className:"w-4 h-4"}),e.jsx("span",{children:"Log In with Telegram"})]})]})]})},as=()=>e.jsx("footer",{className:"border-t border-white/10 bg-space-900 pt-16 pb-12 w-full mt-auto transition-colors duration-200",children:e.jsxs("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8",children:[e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-8 pb-12 border-b border-white/10",children:[e.jsxs("div",{className:"col-span-2 space-y-4",children:[e.jsxs(I,{to:"/",className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-9 h-9 rounded-xl bg-[#2481CC] text-white flex items-center justify-center shadow-telegram",children:e.jsx(lt,{className:"w-5 h-5 text-white"})}),e.jsxs("span",{className:"font-bold text-base text-pearl-50",children:["TeleBot",e.jsx("span",{className:"text-[#2481CC]",children:"Cloud"})]})]}),e.jsx("p",{className:"text-xs text-pearl-400 font-sans leading-relaxed max-w-sm",children:"The modern zero-code Telegram Bot Builder & 24/7 Managed Cloud SaaS. Run automated bot fleets, e-commerce stores, and communities without needing your own VPS or server setups."}),e.jsxs("div",{className:"flex items-center gap-2 text-xs font-mono text-emerald-400",children:[e.jsx("span",{className:"w-2 h-2 rounded-full bg-emerald-400 animate-pulse"}),e.jsx("span",{children:"All Cloud Systems Operational (99.98% SLA)"})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h4",{className:"text-xs font-mono uppercase tracking-wider text-pearl-200 font-semibold",children:"Product"}),e.jsxs("ul",{className:"space-y-2 text-xs text-pearl-400",children:[e.jsx("li",{children:e.jsx(I,{to:"/dashboard",className:"hover:text-[#2481CC] transition",children:"Dashboard"})}),e.jsx("li",{children:e.jsx(I,{to:"/dashboard/bots",className:"hover:text-[#2481CC] transition",children:"Bot Fleet"})}),e.jsx("li",{children:e.jsx(I,{to:"/marketplace",className:"hover:text-[#2481CC] transition",children:"25+ Templates"})}),e.jsx("li",{children:e.jsx(I,{to:"/dashboard/builder",className:"hover:text-[#2481CC] transition",children:"Visual Builder"})}),e.jsx("li",{children:e.jsx(I,{to:"/dashboard/studio",className:"hover:text-[#2481CC] transition",children:"Message Studio"})})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h4",{className:"text-xs font-mono uppercase tracking-wider text-pearl-200 font-semibold",children:"Plugins & Apps"}),e.jsxs("ul",{className:"space-y-2 text-xs text-pearl-400",children:[e.jsx("li",{children:e.jsx(I,{to:"/dashboard/users",className:"hover:text-[#2481CC] transition",children:"Referral & Earn"})}),e.jsx("li",{children:e.jsx(I,{to:"/dashboard/broadcasts",className:"hover:text-[#2481CC] transition",children:"Broadcast Engine"})}),e.jsx("li",{children:e.jsx(I,{to:"/dashboard/payments",className:"hover:text-[#2481CC] transition",children:"Crypto & Stars Pay"})}),e.jsx("li",{children:e.jsx(I,{to:"/dashboard/subscriptions",className:"hover:text-[#2481CC] transition",children:"VIP Subscriptions"})}),e.jsx("li",{children:e.jsx(I,{to:"/dashboard/agents",className:"hover:text-[#2481CC] transition",children:"AI Agent Concierge"})})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("h4",{className:"text-xs font-mono uppercase tracking-wider text-pearl-200 font-semibold",children:"Platform Access"}),e.jsxs("ul",{className:"space-y-2 text-xs text-pearl-400",children:[e.jsx("li",{children:e.jsx(I,{to:"/pricing",className:"hover:text-[#2481CC] transition",children:"Pricing Plans"})}),e.jsx("li",{children:e.jsx(I,{to:"/login",className:"hover:text-[#2481CC] transition",children:"Telegram Sign In"})}),e.jsx("li",{children:e.jsx(I,{to:"/dashboard/settings",className:"hover:text-[#2481CC] transition",children:"Settings"})}),e.jsx("li",{children:e.jsx(I,{to:"/dashboard/audit-logs",className:"hover:text-[#2481CC] transition",children:"Security Logs"})})]})]})]}),e.jsxs("div",{className:"pt-8 flex flex-col sm:flex-row items-center justify-between text-xs text-pearl-400 gap-4 font-mono",children:[e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("span",{children:"© 2026 TeleBot Cloud Platform. All rights reserved."})}),e.jsxs("div",{className:"flex items-center gap-6",children:[e.jsx(I,{to:"/pricing",className:"hover:text-pearl-100 transition",children:"Terms of Service"}),e.jsx(I,{to:"/pricing",className:"hover:text-pearl-100 transition",children:"Privacy Policy"}),e.jsxs("a",{href:"https://t.me/BotFather",target:"_blank",rel:"noopener noreferrer",className:"hover:text-[#2481CC] flex items-center gap-1 transition",children:[e.jsx("span",{children:"BotFather"}),e.jsx(Se,{className:"w-3 h-3"})]})]})]})]})}),xt=({className:t="w-6 h-6"})=>e.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",className:t,children:e.jsx("path",{d:"M12 0C5.373 0 0 5.373 0 12s5.373 12 12 12 12-5.373 12-12S18.627 0 12 0zm5.894 8.221l-1.97 9.28c-.145.658-.537.818-1.084.508l-3-2.21-1.446 1.394c-.16.16-.295.295-.605.295l.213-3.053 5.56-5.023c.242-.213-.054-.333-.373-.121l-6.871 4.326-2.962-.924c-.643-.204-.657-.643.136-.953l11.57-4.458c.538-.196 1.006.128.832.925z"})}),Zl=()=>{const{isAuthenticated:t}=Ue(),{theme:s,toggleTheme:a}=mt(),r=Ne(),[o,n]=l.useState(!1),[i,h]=l.useState(null),[u,x]=l.useState([{sender:"user",text:"/start",time:"12:00"},{sender:"bot",text:`👋 Welcome to TeleBot Cloud! apps/frontend/dist/assets/index-DZatOka8.js:107:You must join our channel to use this bot.`}),e.jsxs("div",{className:"space-y-1.5 pt-1",children:[e.jsx("div",{className:"w-full py-1.5 text-center text-xs font-mono font-semibold bg-[#2481CC]/20 text-[#2481CC] rounded-lg border border-[#2481CC]/30",children:n.button_text||"📢 Join Official Channel"}),e.jsx("div",{className:"w-full py-1.5 text-center text-xs font-mono font-semibold bg-space-850 text-pearl-300 rounded-lg border border-white/10",children:n.check_button_text||"🔄 Check Membership"})]})]})]})]}),a.id==="welcome_message"&&e.jsxs("div",{className:"space-y-5 animate-in fade-in",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("label",{className:"text-xs font-mono font-bold uppercase text-pearl-200",children:"Welcome Greeting Text (/start)"}),e.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] font-mono text-pearl-400",children:[e.jsx("span",{children:"Insert:"}),["{first_name}","{username}","{bot_name}"].map(d=>e.jsx("button",{type:"button",onClick:()=>{const E=n.welcome_text||"";T("welcome_text",E+" "+d)},className:"px-1.5 py-0.5 rounded bg-space-850 hover:bg-[#2481CC]/20 hover:text-[#2481CC] border border-white/10 text-pearl-300 transition-colors",children:d},d))]})]}),e.jsx("textarea",{rows:4,value:n.welcome_text||"",onChange:d=>T("welcome_text",d.target.value),placeholder:"🌟 Welcome to {bot_name}! Please select an option below:",className:"w-full p-3.5 rounded-xl bg-space-950 border border-white/10 text-xs font-mono text-pearl-100 focus:border-[#2481CC] focus:outline-none"})]}),e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-xl bg-space-950/70 border border-white/10",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-xs font-semibold text-pearl-100",children:"Formatting Mode"}),e.jsx("div",{className:"text-[11px] text-pearl-400",children:"Supports , , and tags"})]}),e.jsx("div",{className:"flex gap-1.5",children:["HTML","MarkdownV2"].map(d=>e.jsx("button",{type:"button",onClick:()=>T("parse_mode",d),className:`px-3 py-1.5 rounded-lg text-xs font-mono font-semibold transition-colors ${(n.parse_mode||"HTML")===d?"bg-[#2481CC] text-white shadow-telegram":"bg-space-900 text-pearl-400 hover:text-pearl-200"}`,children:d},d))})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("label",{className:"text-xs font-mono font-bold uppercase text-pearl-200",children:"Inline Action Buttons"}),e.jsxs("button",{type:"button",onClick:()=>{const d=n.buttons||[];T("buttons",[...d,[{text:"✨ New Action",callback_data:`action_${Date.now()}`}]])},className:"text-xs font-mono text-[#2481CC] hover:underline flex items-center gap-1 font-semibold",children:[e.jsx(oe,{className:"w-3.5 h-3.5"})," Add Button Row"]})]}),e.jsx("div",{className:"space-y-2",children:(n.buttons||[]).map((d,E)=>e.jsxs("div",{className:"p-3 rounded-xl bg-space-950/60 border border-white/10 space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between text-[11px] font-mono text-pearl-400",children:[e.jsxs("span",{children:["Row ",E+1]}),e.jsx("button",{type:"button",onClick:()=>{const P=[...n.buttons];P.splice(E,1),T("buttons",P)},className:"text-rose-400 hover:text-rose-300 p-1",children:e.jsx(Ge,{className:"w-3.5 h-3.5"})})]}),d.map((P,F)=>e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:[e.jsx("input",{type:"text",value:P.text||"",onChange:V=>{const z=[...n.buttons];z[E][F].text=V.target.value,T("buttons",z)},placeholder:"Button Label",className:"px-3 py-1.5 rounded-lg bg-space-900 border border-white/10 text-xs font-mono text-pearl-100"}),e.jsx("input",{type:"text",value:P.url||P.callback_data||"",onChange:V=>{const z=[...n.buttons];V.target.value.startsWith("http")?(delete z[E][F].callback_data,z[E][F].url=V.target.value):(delete z[E][F].url,z[E][F].callback_data=V.target.value),T("buttons",z)},placeholder:"URL (https://...) or callback_data",className:"px-3 py-1.5 rounded-lg bg-space-900 border border-white/10 text-xs font-mono text-pearl-100"})]},F))]},E))})]})]}),a.id==="referrals"&&e.jsxs("div",{className:"space-y-5 animate-in fade-in",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-3",children:[e.jsxs("div",{className:"p-3.5 rounded-xl bg-space-950/80 border border-white/10 space-y-1",children:[e.jsx("label",{className:"text-[11px] font-mono text-pearl-400 block font-semibold",children:"Points per Referral"}),e.jsx("input",{type:"number",min:1,value:n.points_per_referral??10,onChange:d=>T("points_per_referral",parseInt(d.target.value)||0),className:"w-full px-3 py-2 rounded-lg bg-space-900 border border-white/10 text-xs font-mono text-pearl-100 font-bold"})]}),e.jsxs("div",{className:"p-3.5 rounded-xl bg-space-950/80 border border-white/10 space-y-1",children:[e.jsx("label",{className:"text-[11px] font-mono text-pearl-400 block font-semibold",children:"Invited User Bonus"}),e.jsx("input",{type:"number",min:0,value:n.welcome_bonus_points??5,onChange:d=>T("welcome_bonus_points",parseInt(d.target.value)||0),className:"w-full px-3 py-2 rounded-lg bg-space-900 border border-white/10 text-xs font-mono text-pearl-100 font-bold"})]}),e.jsxs("div",{className:"p-3.5 rounded-xl bg-space-950/80 border border-white/10 space-y-1",children:[e.jsx("label",{className:"text-[11px] font-mono text-pearl-400 block font-semibold",children:"Min Redeem Points"}),e.jsx("input",{type:"number",min:1,value:n.min_payout_points??50,onChange:d=>T("min_payout_points",parseInt(d.target.value)||0),className:"w-full px-3 py-2 rounded-lg bg-space-900 border border-white/10 text-xs font-mono text-pearl-100 font-bold"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-xs font-mono font-bold uppercase text-pearl-200",children:"Referral Portal Card Template"}),e.jsx("textarea",{rows:5,value:n.invite_message||"",onChange:d=>T("invite_message",d.target.value),className:"w-full p-3.5 rounded-xl bg-space-950 border border-white/10 text-xs font-mono text-pearl-100 focus:border-[#2481CC] focus:outline-none"}),e.jsxs("div",{className:"flex flex-wrap gap-1.5 text-[10px] font-mono text-pearl-400",children:[e.jsx("span",{children:"Variables:"}),["{bot_username}","{user_id}","{referral_count}","{referral_points}"].map(d=>e.jsx("span",{className:"px-1.5 py-0.5 rounded bg-space-900 text-pearl-300 border border-white/5",children:d},d))]})]})]}),a.id==="auto_filter"&&e.jsxs("div",{className:"space-y-5 animate-in fade-in",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("label",{className:"text-xs font-mono font-bold uppercase text-pearl-200",children:"Keyword Auto-Reply Rules"}),e.jsxs("button",{type:"button",onClick:()=>{const d=n.rules||[];T("rules",[...d,{trigger:"help",match_type:"contains",response:"How can we assist you today?"}])},className:"text-xs font-mono text-[#2481CC] hover:underline flex items-center gap-1 font-semibold",children:[e.jsx(oe,{className:"w-3.5 h-3.5"})," Add Keyword Rule"]})]}),e.jsx("div",{className:"space-y-2.5",children:(n.rules||[]).map((d,E)=>e.jsxs("div",{className:"p-3.5 rounded-xl bg-space-950 border border-white/10 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"text",placeholder:"Trigger word (e.g. price)",value:d.trigger||"",onChange:P=>{const F=[...n.rules];F[E].trigger=P.target.value,T("rules",F)},className:"flex-1 px-3 py-1.5 rounded-lg bg-space-900 border border-white/10 text-xs font-mono text-pearl-100"}),e.jsxs("select",{value:d.match_type||"contains",onChange:P=>{const F=[...n.rules];F[E].match_type=P.target.value,T("rules",F)},className:"px-2.5 py-1.5 rounded-lg bg-space-900 border border-white/10 text-xs font-mono text-pearl-200",children:[e.jsx("option",{value:"contains",children:"Contains text"}),e.jsx("option",{value:"exact",children:"Exact match"})]}),e.jsx("button",{type:"button",onClick:()=>{const P=[...n.rules];P.splice(E,1),T("rules",P)},className:"text-rose-400 hover:text-rose-300 p-1.5",children:e.jsx(Ge,{className:"w-4 h-4"})})]}),e.jsx("input",{type:"text",placeholder:"Auto-response message sent to user",value:d.response||"",onChange:P=>{const F=[...n.rules];F[E].response=P.target.value,T("rules",F)},className:"w-full px-3 py-1.5 rounded-lg bg-space-900 border border-white/10 text-xs font-mono text-emerald-300"})]},E))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-xs font-mono font-bold uppercase text-pearl-200",children:"Prohibited & Spam Words"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",placeholder:"Add blocked word and press enter...",value:M,onChange:d=>$(d.target.value),onKeyDown:d=>{if(d.key==="Enter"&&(d.preventDefault(),M.trim())){const E=n.blocked_words||[];T("blocked_words",[...E,M.trim()]),$("")}},className:"flex-1 px-3 py-2 rounded-lg bg-space-950 border border-white/10 text-xs font-mono text-pearl-100"}),e.jsx("button",{type:"button",onClick:()=>{if(M.trim()){const d=n.blocked_words||[];T("blocked_words",[...d,M.trim()]),$("")}},className:"btn-telegram-secondary px-3 text-xs",children:"Add"})]}),e.jsx("div",{className:"flex flex-wrap gap-1.5 pt-1",children:(n.blocked_words||[]).map((d,E)=>e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded-lg text-xs font-mono bg-rose-500/10 border border-rose-500/30 text-rose-300",children:[d,e.jsx("button",{type:"button",onClick:()=>{const P=[...n.blocked_words];P.splice(E,1),T("blocked_words",P)},className:"hover:text-rose-100",children:"×"})]},E))})]}),e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-xl bg-space-950/70 border border-white/10",children:[e.jsx("span",{className:"text-xs font-semibold text-pearl-200",children:"Action when blocked word is detected:"}),e.jsxs("select",{value:n.action_on_blocked||"warn",onChange:d=>T("action_on_blocked",d.target.value),className:"px-3 py-1.5 rounded-lg bg-space-900 border border-white/10 text-xs font-mono text-pearl-100",children:[e.jsx("option",{value:"warn",children:"⚠️ Warn user in chat"}),e.jsx("option",{value:"delete",children:"🗑️ Delete message"}),e.jsx("option",{value:"ignore",children:"🚫 Silently ignore"})]})]})]}),a.id==="ai_assistant"&&e.jsxs("div",{className:"space-y-5 animate-in fade-in",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[11px] font-mono text-pearl-300 mb-1 block",children:"AI Large Language Model"}),e.jsxs("select",{value:n.model||"gpt-4o-mini",onChange:d=>T("model",d.target.value),className:"w-full px-3 py-2 rounded-xl bg-space-950 border border-white/10 text-xs font-mono text-pearl-100",children:[e.jsx("option",{value:"gpt-4o-mini",children:"OpenAI GPT-4o Mini (Fast & Cheap)"}),e.jsx("option",{value:"gpt-4o",children:"OpenAI GPT-4o (State of the Art)"}),e.jsx("option",{value:"claude-3-5-sonnet",children:"Anthropic Claude 3.5 Sonnet"})]})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"text-[11px] font-mono text-pearl-300 mb-1 block",children:["Temperature (",n.temperature??.5,")"]}),e.jsx("input",{type:"range",min:0,max:1,step:.1,value:n.temperature??.5,onChange:d=>T("temperature",parseFloat(d.target.value)),className:"w-full mt-2 accent-[#2481CC]"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("label",{className:"text-xs font-mono font-bold uppercase text-pearl-200",children:"System Instructions & Bot Persona"}),e.jsx("span",{className:"text-[10px] font-mono text-pearl-400",children:"1-Click Starter Presets:"})]}),e.jsx("div",{className:"flex flex-wrap gap-1.5 mb-2",children:[{label:"🎧 Support Desk",prompt:"You are the 24/7 Customer Support Concierge for this Telegram bot. Greet users warmly, resolve questions politely, and guide them clearly."},{label:"💼 VIP Sales Closer",prompt:"You are an enterprise sales advisor. Highlight the benefits of our VIP subscription tiers and offer assistance with checkout."},{label:"📚 FAQ Specialist",prompt:"You are a concise FAQ specialist. Answer subscriber queries with clear, numbered bullet points and helpful links."},{label:"🌐 Hindi/Multilingual",prompt:"Aap ek helpful AI assistant hain. User ki bhasha (Hindi, Hinglish, English) detect karein aur usi bhasha me naturally aur politely reply karein."}].map(d=>e.jsx("button",{type:"button",onClick:()=>T("system_prompt",d.prompt),className:"px-2 py-1 rounded-lg text-[11px] font-mono bg-space-900 border border-white/10 hover:border-[#2481CC] text-pearl-300 hover:text-white transition-colors",children:d.label},d.label))}),e.jsx("textarea",{rows:4,value:n.system_prompt||"",onChange:d=>T("system_prompt",d.target.value),placeholder:"You are an intelligent, polite AI Assistant for this Telegram bot...",className:"w-full p-3.5 rounded-xl bg-space-950 border border-white/10 text-xs font-mono text-pearl-100 focus:border-[#2481CC] focus:outline-none"})]}),e.jsxs("div",{className:"flex items-center justify-between p-3.5 rounded-xl bg-space-950/70 border border-white/10",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-xs font-semibold text-pearl-100",children:"Conversational Fallback"}),e.jsx("div",{className:"text-[11px] text-pearl-400",children:"When subscriber sends normal text (not a command), reply using AI"})]}),e.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:n.enable_fallback??!1,onChange:d=>T("enable_fallback",d.target.checked),className:"sr-only peer"}),e.jsx("div",{className:"w-11 h-6 bg-space-800 rounded-full peer peer-checked:after:translate-x-full after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-[#2481CC]"})]})]})]}),a.id==="broadcasts"&&e.jsxs("div",{className:"space-y-4 animate-in fade-in",children:[e.jsxs("div",{className:"p-4 rounded-xl bg-space-950 border border-white/10 space-y-2",children:[e.jsxs("div",{className:"flex justify-between items-center text-xs font-mono",children:[e.jsx("span",{className:"text-pearl-200",children:"Broadcast Rate Limit:"}),e.jsxs("span",{className:"text-[#2481CC] font-bold",children:[n.rate_limit_per_second??25," msgs/sec"]})]}),e.jsx("input",{type:"range",min:5,max:30,value:n.rate_limit_per_second??25,onChange:d=>T("rate_limit_per_second",parseInt(d.target.value)),className:"w-full accent-[#2481CC]"}),e.jsx("p",{className:"text-[11px] text-pearl-400",children:"Telegram standard limit is 30 msgs/second. We recommend 25 msgs/sec for optimal reliability."})]}),e.jsxs("div",{className:"flex items-center justify-between p-3.5 rounded-xl bg-space-950 border border-white/10",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-xs font-semibold text-pearl-100",children:"Allow Opt-Out Unsubscribe"}),e.jsx("div",{className:"text-[11px] text-pearl-400",children:"Subscribers can type /optout to stop receiving broadcasts"})]}),e.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:n.allow_opt_out??!0,onChange:d=>T("allow_opt_out",d.target.checked),className:"sr-only peer"}),e.jsx("div",{className:"w-11 h-6 bg-space-800 rounded-full peer peer-checked:after:translate-x-full after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-[#2481CC]"})]})]})]}),a.id==="payments"&&e.jsx("div",{className:"space-y-4 animate-in fade-in",children:e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[11px] font-mono text-pearl-300 mb-1 block",children:"Default Currency"}),e.jsxs("select",{value:n.currency||"INR",onChange:d=>T("currency",d.target.value),className:"w-full px-3 py-2 rounded-xl bg-space-950 border border-white/10 text-xs font-mono text-pearl-100",children:[e.jsx("option",{value:"INR",children:"INR (₹) - Indian Rupee"}),e.jsx("option",{value:"USD",children:"USD ($) - US Dollar"}),e.jsx("option",{value:"EUR",children:"EUR (€) - Euro"}),e.jsx("option",{value:"TON",children:"TON (💎) - Telegram Open Network"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[11px] font-mono text-pearl-300 mb-1 block",children:"Active Payment Gateway"}),e.jsxs("select",{value:n.gateway||"razorpay",onChange:d=>T("gateway",d.target.value),className:"w-full px-3 py-2 rounded-xl bg-space-950 border border-white/10 text-xs font-mono text-pearl-100",children:[e.jsx("option",{value:"razorpay",children:"Razorpay Checkout"}),e.jsx("option",{value:"stripe",children:"Stripe Payments"}),e.jsx("option",{value:"telegram_stars",children:"Telegram Stars ⭐"})]})]})]})}),a.id==="subscriptions"&&e.jsx("div",{className:"space-y-4 animate-in fade-in",children:e.jsxs("div",{children:[e.jsx("label",{className:"text-[11px] font-mono text-pearl-300 mb-1 block",children:"Grace Period Days after Expiry"}),e.jsx("input",{type:"number",min:0,value:n.grace_period_days??3,onChange:d=>T("grace_period_days",parseInt(d.target.value)||0),className:"w-full px-3 py-2 rounded-xl bg-space-950 border border-white/10 text-xs font-mono text-pearl-100 font-bold"})]})}),a.id==="user_management"&&e.jsx("div",{className:"space-y-4 animate-in fade-in",children:e.jsxs("div",{className:"flex items-center justify-between p-3.5 rounded-xl bg-space-950 border border-white/10",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-xs font-semibold text-pearl-100",children:"Auto-Detect Subscriber Locale"}),e.jsx("div",{className:"text-[11px] text-pearl-400",children:"Detect language preference from Telegram user profile"})]}),e.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:n.auto_detect_locale??!0,onChange:d=>T("auto_detect_locale",d.target.checked),className:"sr-only peer"}),e.jsx("div",{className:"w-11 h-6 bg-space-800 rounded-full peer peer-checked:after:translate-x-full after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-[#2481CC]"})]})]})}),a.id==="redeem_codes"&&e.jsx("div",{className:"space-y-4 animate-in fade-in",children:e.jsxs("div",{className:"p-4 rounded-xl bg-space-950/80 border border-white/10 space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs font-mono font-bold uppercase text-pearl-100",children:[e.jsx(Ve,{className:"w-4 h-4 text-[#2481CC]"}),e.jsx("span",{children:"Redeem Codes Module Settings"})]}),e.jsxs("p",{className:"text-xs text-pearl-300 font-sans leading-relaxed",children:["Allow subscribers to redeem promotional gift vouchers in chat. You can generate individual codes under the ",e.jsx("b",{children:"🎁 Redeem Codes"})," tab on the bot dashboard."]}),e.jsx("div",{className:"space-y-3 font-mono text-xs",children:e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] uppercase text-pearl-400 block mb-1",children:"Instructions / Prompt Message (Optional)"}),e.jsx("input",{type:"text",value:n.prompt_message||"Please send your redeem code (e.g. /redeem PROMO2026):",onChange:d=>i({...n,prompt_message:d.target.value}),className:"w-full px-3 py-2 rounded-xl bg-space-900 border border-white/10 text-pearl-100 focus:outline-none focus:border-[#2481CC]"})]})})]})}),a.id==="captcha_gate"&&e.jsx("div",{className:"space-y-4 animate-in fade-in",children:e.jsxs("div",{className:"p-4 rounded-xl bg-space-950/80 border border-white/10 space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs font-mono font-bold uppercase text-pearl-100",children:[e.jsx(ne,{className:"w-4 h-4 text-emerald-400"}),e.jsx("span",{children:"Anti-Spam Welcome Captcha Gate"})]}),e.jsx("p",{className:"text-xs text-pearl-300 font-sans leading-relaxed",children:"Force new users to solve a verification prompt before they can access commands, buttons, or group features. Blocks automated bot raids and scrapers."}),e.jsxs("div",{className:"space-y-3 font-mono text-xs",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] uppercase text-pearl-400 block mb-1",children:"Captcha Challenge Type"}),e.jsxs("select",{value:n.captcha_type||"button",onChange:d=>T("captcha_type",d.target.value),className:"w-full px-3 py-2 rounded-xl bg-space-900 border border-white/10 text-pearl-100 focus:outline-none focus:border-[#2481CC]",children:[e.jsx("option",{value:"button",children:"Interactive Button Tap (Fastest UX)"}),e.jsx("option",{value:"math",children:"Math Puzzle (e.g. 5 + 3 = ?)"}),e.jsx("option",{value:"emoji",children:"Emoji Selector"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] uppercase text-pearl-400 block mb-1",children:"Timeout (Seconds)"}),e.jsx("input",{type:"number",min:10,max:600,value:n.timeout_seconds??60,onChange:d=>T("timeout_seconds",parseInt(d.target.value)||60),className:"w-full px-3 py-2 rounded-xl bg-space-900 border border-white/10 text-pearl-100 focus:outline-none focus:border-[#2481CC]"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] uppercase text-pearl-400 block mb-1",children:"Verification Prompt Message"}),e.jsx("textarea",{rows:3,value:n.welcome_unverified_prompt||"",onChange:d=>T("welcome_unverified_prompt",d.target.value),placeholder:"🛡️ Anti-Bot Verification Required: Please tap the button below to prove you are human.",className:"w-full px-3 py-2 rounded-xl bg-space-900 border border-white/10 text-pearl-100 focus:outline-none focus:border-[#2481CC]"})]})]})]})}),a.id==="file_store"&&e.jsx("div",{className:"space-y-4 animate-in fade-in",children:e.jsxs("div",{className:"p-4 rounded-xl bg-space-950/80 border border-white/10 space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs font-mono font-bold uppercase text-pearl-100",children:[e.jsx(Kt,{className:"w-4 h-4 text-amber-400"}),e.jsx("span",{children:"File Store & Digital Goods Vault"})]}),e.jsx("p",{className:"text-xs text-pearl-300 font-sans leading-relaxed",children:"Deliver digital files, e-books, zip archives, and private links directly in Telegram upon VIP status or Points redemption."}),e.jsxs("div",{className:"space-y-3 font-mono text-xs",children:[e.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg bg-space-900 border border-white/5",children:[e.jsx("input",{type:"checkbox",id:"require_vip_for_downloads",checked:!!n.require_vip_for_downloads,onChange:d=>T("require_vip_for_downloads",d.target.checked),className:"rounded border-white/20 text-[#2481CC] focus:ring-0"}),e.jsx("label",{htmlFor:"require_vip_for_downloads",className:"text-xs text-pearl-200 cursor-pointer",children:"Require Active VIP Subscription for all file downloads"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] uppercase text-pearl-400 block mb-1",children:"Default Points Cost per File (If Points Required)"}),e.jsx("input",{type:"number",min:0,value:n.points_per_file??20,onChange:d=>T("points_per_file",parseInt(d.target.value)||0),className:"w-full px-3 py-2 rounded-xl bg-space-900 border border-white/10 text-pearl-100 focus:outline-none focus:border-[#2481CC]"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] uppercase text-pearl-400 block mb-1",children:"Store Header Greeting Message"}),e.jsx("textarea",{rows:2,value:n.store_greeting||"",onChange:d=>T("store_greeting",d.target.value),placeholder:"📁 Digital Products & File Vault: Browse exclusive files below",className:"w-full px-3 py-2 rounded-xl bg-space-900 border border-white/10 text-pearl-100 focus:outline-none focus:border-[#2481CC]"})]})]})]})}),a.id==="support_tickets"&&e.jsx("div",{className:"space-y-4 animate-in fade-in",children:e.jsxs("div",{className:"p-4 rounded-xl bg-space-950/80 border border-white/10 space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs font-mono font-bold uppercase text-pearl-100",children:[e.jsx(Oe,{className:"w-4 h-4 text-cyan-400"}),e.jsx("span",{children:"Live Support Tickets & Forum Relay"})]}),e.jsx("p",{className:"text-xs text-pearl-300 font-sans leading-relaxed",children:"User questions open support tickets that can be replied to directly by admins through the API or forwarded to an admin group."}),e.jsxs("div",{className:"space-y-3 font-mono text-xs",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] uppercase text-pearl-400 block mb-1",children:"Admin Group / Supergroup Chat ID"}),e.jsx("input",{type:"text",placeholder:"-1001234567890",value:n.admin_chat_id||"",onChange:d=>T("admin_chat_id",d.target.value),className:"w-full px-3 py-2 rounded-xl bg-space-900 border border-white/10 text-pearl-100 focus:outline-none focus:border-[#2481CC]"})]}),e.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg bg-space-900 border border-white/5",children:[e.jsx("input",{type:"checkbox",id:"enable_forum_topics",checked:!!(n.enable_forum_topics??!0),onChange:d=>T("enable_forum_topics",d.target.checked),className:"rounded border-white/20 text-[#2481CC] focus:ring-0"}),e.jsx("label",{htmlFor:"enable_forum_topics",className:"text-xs text-pearl-200 cursor-pointer",children:"Enable Forum Topics (Create a separate topic thread for each subscriber)"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] uppercase text-pearl-400 block mb-1",children:"Auto-Acknowledgement Message"}),e.jsx("textarea",{rows:2,value:n.auto_acknowledgement||"",onChange:d=>T("auto_acknowledgement",d.target.value),placeholder:"💬 Your message has been sent to our staff team. We will reply shortly.",className:"w-full px-3 py-2 rounded-xl bg-space-900 border border-white/10 text-pearl-100 focus:outline-none focus:border-[#2481CC]"})]})]})]})}),a.id==="crypto_payments"&&e.jsx("div",{className:"space-y-4 animate-in fade-in",children:e.jsxs("div",{className:"p-4 rounded-xl bg-space-950/80 border border-white/10 space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs font-mono font-bold uppercase text-pearl-100",children:[e.jsx(Qt,{className:"w-4 h-4 text-emerald-400"}),e.jsx("span",{children:"Crypto & Web3 Payment Gateway"})]}),e.jsx("p",{className:"text-xs text-pearl-300 font-sans leading-relaxed",children:"Accept decentralized payments in Toncoin, USDT (TRC-20), Bitcoin, or Telegram Stars directly within chat."}),e.jsxs("div",{className:"space-y-3 font-mono text-xs",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] uppercase text-pearl-400 block mb-1",children:"Merchant Payout Wallet Address (TON / TRC20)"}),e.jsx("input",{type:"text",placeholder:"EQD... or T...",value:n.wallet_address||"",onChange:d=>T("wallet_address",d.target.value),className:"w-full px-3 py-2 rounded-xl bg-space-900 border border-white/10 text-pearl-100 focus:outline-none focus:border-[#2481CC]"})]}),e.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg bg-space-900 border border-white/5",children:[e.jsx("input",{type:"checkbox",id:"auto_confirm",checked:!!(n.auto_confirm??!0),onChange:d=>T("auto_confirm",d.target.checked),className:"rounded border-white/20 text-[#2481CC] focus:ring-0"}),e.jsx("label",{htmlFor:"auto_confirm",className:"text-xs text-pearl-200 cursor-pointer",children:"Auto-confirm on-chain deposits and automatically activate VIP"})]})]})]})}),a.id==="auto_kick"&&e.jsx("div",{className:"space-y-4 animate-in fade-in",children:e.jsxs("div",{className:"p-4 rounded-xl bg-space-950/80 border border-white/10 space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs font-mono font-bold uppercase text-pearl-100",children:[e.jsx(Zt,{className:"w-4 h-4 text-rose-400"}),e.jsx("span",{children:"VIP Auto-Kick & Membership Revoker"})]}),e.jsx("p",{className:"text-xs text-pearl-300 font-sans leading-relaxed",children:"Periodically scans private VIP channels and kicks expired subscribers while revoking their single-use invite links."}),e.jsxs("div",{className:"space-y-3 font-mono text-xs",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] uppercase text-pearl-400 block mb-1",children:"Protected Private Channel / Group ID"}),e.jsx("input",{type:"text",placeholder:"-1001234567890",value:n.channel_id||"",onChange:d=>T("channel_id",d.target.value),className:"w-full px-3 py-2 rounded-xl bg-space-900 border border-white/10 text-pearl-100 focus:outline-none focus:border-[#2481CC]"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] uppercase text-pearl-400 block mb-1",children:"Grace Period (Hours before kicking expired member)"}),e.jsx("input",{type:"number",min:0,max:72,value:n.grace_period_hours??24,onChange:d=>T("grace_period_hours",parseInt(d.target.value)||0),className:"w-full px-3 py-2 rounded-xl bg-space-900 border border-white/10 text-pearl-100 focus:outline-none focus:border-[#2481CC]"})]}),e.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg bg-space-900 border border-white/5",children:[e.jsx("input",{type:"checkbox",id:"send_warning_dm",checked:!!(n.send_warning_dm??!0),onChange:d=>T("send_warning_dm",d.target.checked),className:"rounded border-white/20 text-[#2481CC] focus:ring-0"}),e.jsx("label",{htmlFor:"send_warning_dm",className:"text-xs text-pearl-200 cursor-pointer",children:"Send warning DM notification to member 12 hours before revocation"})]})]})]})}),a.id==="daily_rewards"&&e.jsx("div",{className:"space-y-4 animate-in fade-in",children:e.jsxs("div",{className:"p-4 rounded-xl bg-space-950/80 border border-white/10 space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs font-mono font-bold uppercase text-pearl-100",children:[e.jsx(te,{className:"w-4 h-4 text-amber-400"}),e.jsx("span",{children:"Daily Check-in & Streak Gamification"})]}),e.jsx("p",{className:"text-xs text-pearl-300 font-sans leading-relaxed",children:"Reward daily active users with bonus points and progressive streak multipliers to drive higher retention and daily return rate."}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-3 font-mono text-xs",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] uppercase text-pearl-400 block mb-1",children:"Base Points per Day"}),e.jsx("input",{type:"number",min:1,value:n.base_points??5,onChange:d=>T("base_points",parseInt(d.target.value)||1),className:"w-full px-3 py-2 rounded-xl bg-space-900 border border-white/10 text-pearl-100 focus:outline-none focus:border-[#2481CC]"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] uppercase text-pearl-400 block mb-1",children:"Streak Multiplier"}),e.jsx("input",{type:"number",step:"0.1",min:1,max:5,value:n.streak_multiplier??1.2,onChange:d=>T("streak_multiplier",parseFloat(d.target.value)||1),className:"w-full px-3 py-2 rounded-xl bg-space-900 border border-white/10 text-pearl-100 focus:outline-none focus:border-[#2481CC]"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] uppercase text-pearl-400 block mb-1",children:"Max Streak Days"}),e.jsx("input",{type:"number",min:1,max:365,value:n.max_streak_days??7,onChange:d=>T("max_streak_days",parseInt(d.target.value)||7),className:"w-full px-3 py-2 rounded-xl bg-space-900 border border-white/10 text-pearl-100 focus:outline-none focus:border-[#2481CC]"})]})]})]})}),a.id==="content_protection"&&e.jsx("div",{className:"space-y-4 animate-in fade-in",children:e.jsxs("div",{className:"p-4 rounded-xl bg-space-950/80 border border-white/10 space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs font-mono font-bold uppercase text-pearl-100",children:[e.jsx(Ze,{className:"w-4 h-4 text-rose-400"}),e.jsx("span",{children:"Anti-Leak DRM & Forward Guard"})]}),e.jsx("p",{className:"text-xs text-pearl-300 font-sans leading-relaxed",children:"Prevent subscribers from forwarding messages, downloading videos/audios, taking screenshots, or copying text from the bot."}),e.jsxs("div",{className:"space-y-3 font-mono text-xs",children:[e.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg bg-space-900 border border-white/5",children:[e.jsx("input",{type:"checkbox",id:"protect_all_messages",checked:!!(n.protect_all_messages??!0),onChange:d=>T("protect_all_messages",d.target.checked),className:"rounded border-white/20 text-[#2481CC] focus:ring-0"}),e.jsx("label",{htmlFor:"protect_all_messages",className:"text-xs text-pearl-200 cursor-pointer",children:"Protect all bot outgoing messages (Enforce Telegram protect_content flag)"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] uppercase text-pearl-400 block mb-1",children:"Watermark Text"}),e.jsx("input",{type:"text",value:n.watermark_text||"CONFIDENTIAL · VIP CONTENT",onChange:d=>T("watermark_text",d.target.value),className:"w-full px-3 py-2 rounded-xl bg-space-900 border border-white/10 text-pearl-100 focus:outline-none focus:border-[#2481CC]"})]})]})]})}),e.jsxs("div",{className:"p-4 rounded-xl bg-space-950/90 border border-white/10 space-y-3",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ne,{className:"w-4 h-4 text-[#2481CC]"}),e.jsxs("div",{children:[e.jsx("span",{className:"text-xs font-mono font-bold uppercase tracking-wider text-pearl-100 block",children:"Pre-Flight Module Verification"}),e.jsx("span",{className:"text-[10px] text-pearl-400 font-sans",children:"Automated Telegram Bot admin, topic thread & configuration check"})]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[a.id==="logs_tracker"&&n.enable_topics&&e.jsxs("button",{type:"button",disabled:N||w,onClick:()=>O(!0),className:"btn-telegram-secondary py-1.5 px-3 text-[11px] font-mono inline-flex items-center gap-1.5 text-purple-300 hover:text-white border-purple-500/40",children:[N?e.jsx(ue,{className:"w-3.5 h-3.5 animate-spin text-purple-400"}):e.jsx(we,{className:"w-3.5 h-3.5 text-purple-400"}),e.jsx("span",{children:N?"Testing Topic...":"🧪 Test Topic Creation"})]}),e.jsxs("button",{type:"button",disabled:w||N,onClick:()=>O(!1),className:"btn-telegram-secondary py-1.5 px-3 text-[11px] font-mono inline-flex items-center gap-1.5 text-[#2481CC] hover:text-white border-[#2481CC]/40",children:[w?e.jsx(ue,{className:"w-3.5 h-3.5 animate-spin text-[#2481CC]"}):e.jsx(je,{className:"w-3.5 h-3.5 text-[#2481CC]"}),e.jsx("span",{children:w?"Verifying Module...":"⚡ Run Verification Check"})]})]})]}),C?e.jsxs("div",{className:"space-y-2.5",children:[e.jsxs("div",{className:`p-3 rounded-xl border text-xs font-mono flex items-start justify-between gap-3 ${C.ok?"bg-emerald-500/10 border-emerald-500/30 text-emerald-300":C.warning?"bg-amber-500/10 border-amber-500/30 text-amber-300":"bg-rose-500/10 border-rose-500/30 text-rose-300"}`,children:[e.jsxs("div",{className:"flex items-start gap-2",children:[C.ok?e.jsx(ee,{className:"w-4 h-4 text-emerald-400 shrink-0 mt-0.5"}):C.warning?e.jsx(Ye,{className:"w-4 h-4 text-amber-400 shrink-0 mt-0.5"}):e.jsx(Yt,{className:"w-4 h-4 text-rose-400 shrink-0 mt-0.5"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-bold",children:C.ok?"Verification Passed: Module Ready for Live Execution":C.warning?`Warning: ${C.warning}`:"Verification Failed: Action Required"}),e.jsx("div",{className:"text-[11px] opacity-90 mt-0.5 font-sans",children:C.message||C.error})]})]}),e.jsx("span",{className:`px-2 py-0.5 rounded text-[10px] font-bold uppercase tracking-wider shrink-0 ${C.ok?"bg-emerald-500/20 text-emerald-300":"bg-rose-500/20 text-rose-300"}`,children:C.ok?"READY ✓":"ACTION NEEDED ✗"})]}),C.checks&&C.checks.length>0&&e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2 text-xs font-mono pt-1",children:C.checks.map((d,E)=>e.jsxs("div",{className:`p-2.5 rounded-lg border flex items-center justify-between gap-2 ${d.passed?"bg-emerald-500/5 border-emerald-500/20 text-pearl-200":"bg-rose-500/5 border-rose-500/25 text-rose-300"}`,children:[e.jsxs("div",{className:"flex items-center gap-2 truncate",children:[d.passed?e.jsx(W,{className:"w-3.5 h-3.5 text-emerald-400 shrink-0"}):e.jsx(ae,{className:"w-3.5 h-3.5 text-rose-400 shrink-0"}),e.jsx("span",{className:"truncate",children:d.name})]}),e.jsx("span",{className:`text-[10px] truncate shrink-0 max-w-[120px] ${d.passed?"text-emerald-400 font-medium":"text-rose-400 font-bold"}`,children:d.detail})]},E))}),C.topic_test&&e.jsxs("div",{className:`p-2.5 rounded-lg border text-xs font-mono ${C.topic_test.success?"bg-purple-500/10 border-purple-500/30 text-purple-300":"bg-rose-500/10 border-rose-500/30 text-rose-300"}`,children:[e.jsxs("div",{className:"font-bold flex items-center gap-1.5",children:[e.jsx(te,{className:"w-3.5 h-3.5 text-purple-400"}),e.jsx("span",{children:C.topic_test.success?"Telegram Forum Topic Created Live ✓":"Topic Creation Test Failed ✗"})]}),e.jsx("div",{className:"text-[11px] mt-0.5",children:C.topic_test.message||C.topic_test.error})]})]}):e.jsxs("p",{className:"text-[11px] font-sans text-pearl-400 leading-relaxed",children:["Click ",e.jsx("b",{children:"Run Verification Check"})," to validate all module configurations, permissions, and Telegram Bot Administrator rights before activating in production."]})]}),e.jsxs("div",{className:"pt-2 border-t border-white/10",children:[e.jsxs("button",{type:"button",onClick:()=>j(!b),className:"text-[11px] font-mono text-pearl-400 hover:text-[#2481CC] flex items-center gap-1.5 transition-colors",children:[e.jsx(zs,{className:"w-3.5 h-3.5"}),e.jsxs("span",{children:["Advanced Developer Mode: ",b?"Hide Raw JSON":"View Raw JSON"]}),b?e.jsx(Rs,{className:"w-3.5 h-3.5"}):e.jsx(zt,{className:"w-3.5 h-3.5"})]}),b&&e.jsxs("div",{className:"mt-3 space-y-2 animate-in fade-in",children:[e.jsx("textarea",{rows:6,value:f,onChange:d=>g(d.target.value),className:"w-full p-3 rounded-xl bg-space-950 border border-white/15 text-xs font-mono text-emerald-300 focus:outline-none"}),e.jsx("p",{className:"text-[10px] font-mono text-pearl-400",children:"Direct low-level payload synced with cloud execution engine."})]})]})]}),D==="message"&&e.jsx("div",{className:"space-y-6 animate-in fade-in",children:e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-12 gap-6",children:[e.jsxs("div",{className:"lg:col-span-7 space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("label",{className:"text-xs font-mono font-bold uppercase text-pearl-100 flex items-center gap-2",children:[e.jsx(Oe,{className:"w-4 h-4 text-[#2481CC]"}),e.jsx("span",{children:"Outgoing Telegram Message"})]}),e.jsx("span",{className:"text-[10px] font-mono text-emerald-400 bg-emerald-500/10 px-2 py-0.5 rounded border border-emerald-500/30 font-semibold",children:"HTML Mode Supported"})]}),e.jsxs("div",{className:"flex items-center gap-1.5 p-1.5 rounded-xl bg-space-950 border border-white/10 text-xs font-mono",children:[e.jsx("button",{type:"button",onClick:()=>be("",""),className:"p-1.5 px-2.5 rounded-lg hover:bg-white/10 text-pearl-100 font-bold border border-white/5",title:"Bold text",children:"B"}),e.jsx("button",{type:"button",onClick:()=>be("",""),className:"p-1.5 px-2.5 rounded-lg hover:bg-white/10 text-pearl-100 italic font-serif border border-white/5",title:"Italic text",children:"I"}),e.jsx("button",{type:"button",onClick:()=>be("",""),className:"p-1.5 px-2.5 rounded-lg hover:bg-white/10 text-pearl-100 border border-white/5",title:"Monospace Code",children:""}),e.jsxs("button",{type:"button",onClick:()=>be('',""),className:"p-1.5 px-2.5 rounded-lg hover:bg-white/10 text-[#2481CC] border border-white/5 font-semibold flex items-center gap-1",title:"Link",children:[e.jsx(Xa,{className:"w-3 h-3"}),e.jsx("span",{children:"Link"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("span",{className:"text-[10px] font-mono uppercase text-pearl-400 block font-semibold",children:"Dynamic Variables (Click to insert):"}),e.jsx("div",{className:"flex items-center gap-1.5 flex-wrap text-[10px] font-mono",children:["{first_name}","{user_id}","{username}","{streak_count}","{points_balance}","{referral_link}","{plan_name}"].map(d=>e.jsx("button",{type:"button",onClick:()=>Ce(d),className:"px-2 py-1 rounded-md bg-[#2481CC]/15 hover:bg-[#2481CC]/30 text-[#2481CC] border border-[#2481CC]/30 transition",children:d},d))})]}),e.jsx("textarea",{rows:8,value:Y,onChange:d=>fe(d.target.value),placeholder:"Enter the message text your bot will send when this module triggers (HTML formatting supported)...",className:"w-full px-3.5 py-3 rounded-xl bg-space-950 border border-white/15 text-xs font-mono text-pearl-50 placeholder:text-pearl-400/40 focus:border-[#2481CC] focus:outline-none leading-relaxed"})]}),e.jsxs("div",{className:"lg:col-span-5 space-y-3",children:[e.jsx("span",{className:"text-xs font-mono font-bold uppercase text-pearl-200 block",children:"📱 Telegram Live Preview"}),e.jsxs("div",{className:"p-4 rounded-2xl bg-[#0E1621] border border-white/10 shadow-xl space-y-3 font-sans",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-[#2481CC] text-white flex items-center justify-center font-bold text-xs shadow-sm",children:s.slice(0,2).toUpperCase()}),e.jsxs("div",{children:[e.jsxs("div",{className:"text-xs font-bold text-white leading-tight",children:["@",s]}),e.jsx("div",{className:"text-[10px] text-pearl-400",children:"Telegram Bot"})]})]}),e.jsxs("div",{className:"p-3.5 rounded-2xl rounded-tl-sm bg-[#182533] text-pearl-100 text-xs leading-relaxed space-y-2 border border-white/5",children:[e.jsx("div",{className:"whitespace-pre-wrap break-words",dangerouslySetInnerHTML:{__html:(Y||'No message text configured yet').replace(/\{first_name\}/g,"Alex").replace(/\{user_id\}/g,"789104").replace(/\{username\}/g,"alex_tg").replace(/\{streak_count\}/g,"5").replace(/\{points_balance\}/g,"120").replace(/\{referral_link\}/g,`https://t.me/${s}?start=ref789`).replace(/\{plan_name\}/g,"VIP Pro")}}),e.jsx("div",{className:"text-right text-[10px] text-pearl-400 font-mono",children:"12:45 PM ✓✓"})]}),h.enable_inline_button&&e.jsxs("div",{className:"space-y-1.5 pt-1 font-mono",children:[e.jsx("div",{className:"py-2 px-3 rounded-lg bg-[#242F3D] hover:bg-[#2F3D4E] text-[#2481CC] border border-white/5 text-center text-xs font-medium cursor-pointer shadow-sm",children:n.inline_button_text||a.inline_button_text||"🔘 Action Button"}),(n.custom_buttons||[]).map((d,E)=>e.jsx("div",{className:"py-2 px-3 rounded-lg bg-[#242F3D] text-pearl-200 border border-white/5 text-center text-xs font-medium",children:d.text},E))]})]})]})]})}),D==="buttons"&&e.jsxs("div",{className:"space-y-6 animate-in fade-in",children:[e.jsxs("div",{className:"p-4 rounded-xl bg-space-950/80 border border-[#2481CC]/30 space-y-3",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(je,{className:"w-4 h-4 text-[#2481CC]"}),e.jsx("span",{className:"text-xs font-mono font-bold uppercase text-pearl-100",children:"3-Way Trigger Controls (User Apne Hisab Se On/Off Kare)"})]})}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-2.5 font-mono text-xs",children:[e.jsxs("button",{type:"button",onClick:()=>u(d=>({...d,enable_command:!d.enable_command})),className:`p-3 rounded-xl border flex items-center justify-between transition-all ${h.enable_command?"bg-[#2481CC]/15 border-[#2481CC]/50 text-[#2481CC]":"bg-space-900 border-white/10 opacity-60"}`,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(He,{className:"w-4 h-4"}),e.jsx("span",{className:"font-semibold text-pearl-100",children:"1. Command"})]}),e.jsx("span",{className:`text-[10px] px-2 py-0.5 rounded font-bold ${h.enable_command?"bg-[#2481CC] text-white":"bg-space-800 text-pearl-400"}`,children:h.enable_command?"ON":"OFF"})]}),e.jsxs("button",{type:"button",onClick:()=>u(d=>({...d,enable_inline_button:!d.enable_inline_button})),className:`p-3 rounded-xl border flex items-center justify-between transition-all ${h.enable_inline_button?"bg-purple-500/15 border-purple-500/50 text-purple-400":"bg-space-900 border-white/10 opacity-60"}`,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(je,{className:"w-4 h-4"}),e.jsx("span",{className:"font-semibold text-pearl-100",children:"2. Callback"})]}),e.jsx("span",{className:`text-[10px] px-2 py-0.5 rounded font-bold ${h.enable_inline_button?"bg-purple-600 text-white":"bg-space-800 text-pearl-400"}`,children:h.enable_inline_button?"ON":"OFF"})]}),e.jsxs("button",{type:"button",onClick:()=>u(d=>({...d,enable_menu_button:!d.enable_menu_button})),className:`p-3 rounded-xl border flex items-center justify-between transition-all ${h.enable_menu_button?"bg-emerald-500/15 border-emerald-500/50 text-emerald-400":"bg-space-900 border-white/10 opacity-60"}`,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ie,{className:"w-4 h-4"}),e.jsx("span",{className:"font-semibold text-pearl-100",children:"3. Menu"})]}),e.jsx("span",{className:`text-[10px] px-2 py-0.5 rounded font-bold ${h.enable_menu_button?"bg-emerald-600 text-white":"bg-space-800 text-pearl-400"}`,children:h.enable_menu_button?"ON":"OFF"})]})]})]}),e.jsxs("div",{className:"p-4 rounded-xl bg-space-950/80 border border-white/10 space-y-4 font-mono text-xs",children:[e.jsx("h4",{className:"font-bold uppercase text-pearl-100 text-xs",children:"Button & Command Text Labels"}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] uppercase text-pearl-400 block mb-1",children:"Command Trigger (e.g. /redeem)"}),e.jsx("input",{type:"text",value:n.command_name||a.command_name||"",onChange:d=>T("command_name",d.target.value),className:"w-full px-3 py-2 rounded-xl bg-space-900 border border-white/10 text-pearl-100 focus:outline-none focus:border-[#2481CC]"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] uppercase text-pearl-400 block mb-1",children:"Inline Callback Button Text"}),e.jsx("input",{type:"text",value:n.inline_button_text||a.inline_button_text||"",onChange:d=>T("inline_button_text",d.target.value),className:"w-full px-3 py-2 rounded-xl bg-space-900 border border-white/10 text-pearl-100 focus:outline-none focus:border-[#2481CC]"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] uppercase text-pearl-400 block mb-1",children:"Reply Menu Keyboard Text"}),e.jsx("input",{type:"text",value:n.menu_button_text||a.menu_button_text||"",onChange:d=>T("menu_button_text",d.target.value),className:"w-full px-3 py-2 rounded-xl bg-space-900 border border-white/10 text-pearl-100 focus:outline-none focus:border-[#2481CC]"})]})]})]}),e.jsxs("div",{className:"p-4 rounded-xl bg-space-950/80 border border-white/10 space-y-3 font-mono text-xs",children:[e.jsx("h4",{className:"font-bold uppercase text-pearl-100 text-xs",children:"Extra Custom Action Buttons"}),e.jsx("p",{className:"text-[11px] text-pearl-400 font-sans",children:"Add custom URL buttons (e.g. your support group or website) or callback buttons below this module message:"}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-4 gap-2",children:[e.jsx("input",{type:"text",placeholder:"Button Label (e.g. 🌐 Website)",value:L,onChange:d=>se(d.target.value),className:"sm:col-span-2 px-3 py-2 rounded-xl bg-space-900 border border-white/10 text-pearl-100 focus:outline-none focus:border-[#2481CC]"}),e.jsxs("select",{value:le,onChange:d=>B(d.target.value),className:"px-3 py-2 rounded-xl bg-space-900 border border-white/10 text-pearl-100 focus:outline-none focus:border-[#2481CC]",children:[e.jsx("option",{value:"url",children:"URL Link"}),e.jsx("option",{value:"callback",children:"Callback Action"})]}),e.jsx("button",{type:"button",onClick:ye,className:"btn-telegram-primary py-2 px-3 justify-center text-xs font-semibold",children:"+ Add Button"})]}),e.jsx("input",{type:"text",placeholder:"Target URL or Callback (e.g. https://t.me/mychannel)",value:J,onChange:d=>G(d.target.value),className:"w-full px-3 py-2 rounded-xl bg-space-900 border border-white/10 text-pearl-100 focus:outline-none focus:border-[#2481CC]"}),(n.custom_buttons||[]).length>0&&e.jsx("div",{className:"space-y-1.5 pt-2",children:(n.custom_buttons||[]).map((d,E)=>e.jsxs("div",{className:"flex items-center justify-between p-2.5 rounded-lg bg-space-900 border border-white/5",children:[e.jsxs("span",{className:"text-pearl-200 font-semibold",children:[d.text," (",d.type,"): ",d.value]}),e.jsx("button",{type:"button",onClick:()=>Ae(E),className:"text-rose-400 hover:text-rose-300",children:e.jsx(Ge,{className:"w-3.5 h-3.5"})})]},E))})]})]}),D==="emojis"&&e.jsx("div",{className:"space-y-6 animate-in fade-in",children:e.jsxs("div",{className:"p-4 rounded-xl bg-space-950/80 border border-white/10 space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs font-mono font-bold uppercase text-pearl-100",children:[e.jsx(Bt,{className:"w-4 h-4 text-amber-400"}),e.jsx("span",{children:"Telegram Premium Custom Emojis & Icon Styling"})]}),e.jsx("p",{className:"text-xs text-pearl-300 font-sans leading-relaxed",children:"Telegram Premium bots can display custom animated vector emojis. Paste your custom Telegram emoji ID below or pick from standard bot emojis to insert:"}),e.jsxs("div",{className:"space-y-4 font-mono text-xs",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] uppercase text-pearl-400 block mb-1",children:"Custom Telegram Emoji ID (Optional)"}),e.jsx("input",{type:"text",placeholder:"e.g. 5368324170671202286",value:n.custom_emoji_id||"",onChange:d=>T("custom_emoji_id",d.target.value),className:"w-full px-3 py-2 rounded-xl bg-space-900 border border-white/10 text-pearl-100 focus:outline-none focus:border-[#2481CC]"}),e.jsx("span",{className:"text-[10px] text-pearl-400 mt-1 block font-sans",children:"Obtained from Telegram Custom Emoji sticker sets via @BotFather."})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] uppercase text-pearl-400 block mb-2",children:"Quick Click-to-Append Emojis into Message:"}),e.jsx("div",{className:"grid grid-cols-6 sm:grid-cols-12 gap-2",children:Pe.map(d=>e.jsx("button",{type:"button",onClick:()=>S(d),className:"p-2.5 rounded-xl bg-space-900 hover:bg-[#2481CC]/20 border border-white/10 text-base transition-transform hover:scale-110 flex items-center justify-center shadow-sm",children:d},d))})]})]})]})}),e.jsxs("div",{className:"pt-4 border-t border-white/10 flex flex-col sm:flex-row items-stretch sm:items-center justify-end gap-3 sticky bottom-0 bg-space-900/95 py-3",children:[e.jsx("button",{type:"button",onClick:o,className:"btn-telegram-secondary py-2 px-4 justify-center text-xs",children:"CANCEL"}),e.jsxs("button",{type:"submit",disabled:x,className:"btn-telegram-primary py-2 px-6 justify-center inline-flex items-center gap-2 shadow-telegram text-xs font-bold",children:[x?e.jsx(ue,{className:"w-4 h-4 animate-spin"}):e.jsx(wt,{className:"w-4 h-4"}),e.jsx("span",{children:"SAVE MODULE SETTINGS"})]})]})]})]})})})},po=[{id:"welcome_message",name:"Welcome Message & Onboarding",category:"engagement",icon:te,version:"1.2.0",description:"Custom greeting message, dynamic placeholders ({first_name}, {bot_name}), parse mode, and inline quick-action buttons on /start.",is_installed:!0,is_enabled:!0,enable_command:!0,enable_inline_button:!0,enable_menu_button:!0,config:{welcome_text:"🌟 Welcome to our VIP Bot! Tap an option below to explore:",buttons_count:4}},{id:"force_join",name:"Force Join Channel Guard",category:"security",icon:ne,version:"1.1.0",description:"Enforces mandatory channel/group membership before unlocking bot commands. Verifies status via getChatMember.",is_installed:!0,is_enabled:!0,enable_command:!0,enable_inline_button:!0,enable_menu_button:!0,config:{channel_username:"@astraea_cloud",prompt_text:"⚠️ You must join our official Telegram channel to unlock this bot.",button_text:"📢 Join Official Channel"}},{id:"referrals",name:"Referral & Viral Growth Engine",category:"growth",icon:vt,version:"1.3.0",description:"Generates subscriber deep-link invite links (/start ref_{userId}), tracks successful signups, awards points, and calculates balances.",is_installed:!0,is_enabled:!0,enable_command:!0,enable_inline_button:!0,enable_menu_button:!0,config:{points_per_referral:10,welcome_bonus_points:5,min_payout_points:50}},{id:"redeem_codes",name:"Redeem Codes & Gift Vouchers",category:"monetization",icon:Ve,version:"1.0.0",description:"Promotional gift vouchers to award VIP subscription days, loyalty points, or cash balance. Includes anti-abuse, usage caps, and expiry dates.",is_installed:!0,is_enabled:!0,enable_command:!0,enable_inline_button:!0,enable_menu_button:!0,config:{enable_command:!0,enable_inline_button:!0,enable_menu_button:!0}},{id:"broadcasts",name:"Broadcast & Announcement Pipeline",category:"messaging",icon:_e,version:"2.0.0",description:"Token-bucket broadcasts (25 msgs/sec), audience filtering, language targeting, and /optout compliance.",is_installed:!0,is_enabled:!0,enable_command:!0,enable_inline_button:!0,enable_menu_button:!0,config:{rate_limit_per_second:25,allow_opt_out:!0}},{id:"user_management",name:"Audience & Subscriber Directory",category:"management",icon:Le,version:"1.0.0",description:"Real-time subscriber tracking, interaction count, automatic BCP 47 language preference detection, and block state auditing.",is_installed:!0,is_enabled:!0,enable_command:!0,enable_inline_button:!0,enable_menu_button:!0,config:{auto_detect_locale:!0,track_interactions:!0}},{id:"auto_filter",name:"Auto Filter & Keyword Responder",category:"automation",icon:Wt,version:"1.2.0",description:"Matches subscriber text against trigger keywords and forbidden words. Provides instantaneous auto-replies or warnings.",is_installed:!0,is_enabled:!0,enable_command:!0,enable_inline_button:!0,enable_menu_button:!0,config:{rules_count:3,blocked_words:["scam","free nitro","hack"]}},{id:"payments",name:"In-Chat Payments & Invoicing",category:"monetization",icon:et,version:"1.4.0",description:"Seamless Razorpay & Stripe in-chat payment links with cryptographic webhook verification and digital invoice dispatch.",is_installed:!0,is_enabled:!1,enable_command:!0,enable_inline_button:!0,enable_menu_button:!0,config:{currency:"INR",gateway:"razorpay"}},{id:"subscriptions",name:"VIP Subscriptions & Gated Access",category:"monetization",icon:ct,version:"1.3.0",description:"Subscription tiers, membership access duration tracking, automated renewal prompts, and grace period protection.",is_installed:!0,is_enabled:!1,enable_command:!0,enable_inline_button:!0,enable_menu_button:!0,config:{tiers_count:2,grace_period_days:3}},{id:"ai_assistant",name:"Autonomous AI Customer Concierge",category:"ai",icon:Me,version:"2.1.0",description:"Multi-turn LLM reasoning using OpenAI (GPT-4o) and Anthropic (Claude 3.5). Responds to /ai or handles conversational fallback.",is_installed:!0,is_enabled:!0,enable_command:!0,enable_inline_button:!0,enable_menu_button:!0,config:{model:"gpt-4o-mini",temperature:.5}},{id:"logs_tracker",name:"Activity Logs & Channel Audit",category:"security",icon:Fe,version:"1.5.0",description:"Real-time event logging to Telegram channel or supergroup. Pro feature: Forum Topics with unique user threads and 2-way admin chat relay.",is_installed:!0,is_enabled:!0,enable_command:!0,enable_inline_button:!0,enable_menu_button:!0,config:{log_channel_id:"-1002345678901",log_channel_type:"supergroup_forum",enable_topics:!0,topic_naming_format:"👤 {user_id} - @{username}",relay_chat_replies:!0,log_events:["new_user","command_executed","force_join_attempts","payments","broadcasts","errors"],bot_is_admin_verified:!1}},{id:"captcha_gate",name:"Anti-Spam Captcha & Human Gate",category:"security",icon:ne,version:"1.0.0",description:"Stops automated spam raids & scraper bots with an interactive human verification challenge on /start before unlocking commands.",is_installed:!0,is_enabled:!0,enable_command:!0,enable_inline_button:!0,enable_menu_button:!0,config:{captcha_type:"button",timeout_seconds:60}},{id:"file_store",name:"Digital Products & File Store",category:"monetization",icon:Kt,version:"1.0.0",description:"Securely deliver digital products, courses, videos, and PDFs upon payment, VIP subscription, or points redemption with deep-link access.",is_installed:!0,is_enabled:!0,enable_command:!0,enable_inline_button:!0,enable_menu_button:!0,config:{require_vip_for_downloads:!1,points_per_file:20}},{id:"support_tickets",name:"2-Way Live Support & Contact Admin",category:"engagement",icon:Oe,version:"1.0.0",description:"Allows subscribers to submit support inquiries. Seamlessly routes questions into dedicated admin forum topics with two-way reply relay.",is_installed:!0,is_enabled:!0,enable_command:!0,enable_inline_button:!0,enable_menu_button:!0,config:{admin_chat_id:"-1002345678901",enable_forum_topics:!0}},{id:"crypto_payments",name:"Crypto & Web3 Payment Gateway",category:"monetization",icon:Qt,version:"1.0.0",description:"Accept cryptocurrency payments (USDT TRC20, Toncoin, BTC) and Telegram Stars for VIP subscriptions and digital assets.",is_installed:!0,is_enabled:!1,enable_command:!0,enable_inline_button:!0,enable_menu_button:!0,config:{accepted_currencies:["USDT_TRC20","TON"],wallet_address:"EQD...sample_wallet"}},{id:"auto_kick",name:"VIP Channel Auto-Kick & Revoke",category:"automation",icon:Zt,version:"1.0.0",description:"Automatically kicks expired VIP subscribers from private Telegram channels/groups and invalidates single-use invite links.",is_installed:!0,is_enabled:!1,enable_command:!0,enable_inline_button:!0,enable_menu_button:!0,config:{channel_id:"-1002345678901",grace_period_hours:24}},{id:"daily_rewards",name:"Daily Check-in & Gamification",category:"growth",icon:te,version:"1.0.0",description:"Daily login bonus streak with multiplier points. Keeps subscribers engaged daily and boosts recurring retention.",is_installed:!0,is_enabled:!0,enable_command:!0,enable_inline_button:!0,enable_menu_button:!0,config:{base_points:5,streak_multiplier:1.2,max_streak_days:7}},{id:"content_protection",name:"Anti-Leak DRM & Forward Guard",category:"security",icon:Ze,version:"1.0.0",description:"Enforces Telegram content protection (protect_content). Blocks forwarding, media downloading, and screenshotting of sensitive VIP content.",is_installed:!0,is_enabled:!0,enable_command:!0,enable_inline_button:!0,enable_menu_button:!0,config:{protect_all_messages:!0,watermark_text:"CONFIDENTIAL · ASTRAEA VIP"}}],uo=({botId:t,onNavigate:s})=>{const{slug:a}=ca(),r=Ne(),{currentBot:o,selectBot:n}=ce(),i=t||a||(o==null?void 0:o.id)||"astraea-flagship";l.useEffect(()=>{a&&n(a)},[a]);const h=o||{name:"Astraea Concierge Bot",username:"astraea_flagship_bot"},[u,x]=l.useState(po),[m,b]=l.useState("modules"),[j,f]=l.useState(null),[g,v]=l.useState("{}"),[c,w]=l.useState(!1),[p,N]=l.useState(null),[k,_]=l.useState("all"),[A,C]=l.useState([]),[U,M]=l.useState(!1),[$,D]=l.useState(!1),[H,L]=l.useState(null),[se,le]=l.useState(null),[B,J]=l.useState([]),[G,pe]=l.useState(!1),[q,Y]=l.useState({code:"",title:"",reward_type:"subscription_days",reward_value:30,max_uses:1,expires_at:""});l.useEffect(()=>{async function y(){try{const d=localStorage.getItem("access_token"),E={};d&&(E.Authorization=`Bearer ${d}`);const P=await fetch(`/api/v1/bots/${i}/modules`,{headers:E});if(P.ok){const F=await P.json();if(F.data&&Array.isArray(F.data)){const V={welcome_message:te,force_join:ne,referrals:vt,redeem_codes:Ve,broadcasts:_e,user_management:Le,auto_filter:Wt,payments:et,subscriptions:ct,ai_assistant:Me,logs_tracker:Fe,captcha_gate:ne,file_store:Kt,support_tickets:Oe,crypto_payments:Qt,auto_kick:Zt,daily_rewards:te,content_protection:Ze},z=F.data.map(Z=>({id:Z.id,name:Z.name,category:Z.category,icon:V[Z.id]||je,version:Z.version,description:Z.description,is_installed:Z.is_installed,is_enabled:Z.is_enabled,enable_command:Z.enable_command!==void 0?Z.enable_command:!0,enable_inline_button:Z.enable_inline_button!==void 0?Z.enable_inline_button:!0,enable_menu_button:Z.enable_menu_button!==void 0?Z.enable_menu_button:!0,config:Z.config||{}}));x(z)}}}catch{}}y()},[i]);const fe=async()=>{M(!0);try{const y=localStorage.getItem("access_token"),d={};y&&(d.Authorization=`Bearer ${y}`);const E=await fetch(`/api/v1/bots/${i}/redeem-codes`,{headers:d});if(E.ok){const P=await E.json();C(P.data||[])}}catch(y){console.error("Failed to load redeem codes",y)}finally{M(!1)}};l.useEffect(()=>{m==="redeem_codes"&&fe()},[m,i]);const Ce=async(y,d)=>{var F,V,z,Z,ve;const E=!d,P=u.find(re=>re.id===y);if(E){if(y==="logs_tracker"&&!((F=P==null?void 0:P.config)!=null&&F.log_channel_id)){P&&f(P),N("⚠️ Please configure your Log Channel or Supergroup and verify Bot Admin before activating."),setTimeout(()=>N(null),4e3);return}if(y==="force_join"&&!((V=P==null?void 0:P.config)!=null&&V.channel_username)&&!((z=P==null?void 0:P.config)!=null&&z.channel_id)){P&&f(P),N("⚠️ Please configure your Force-Join Channel/Group before activating."),setTimeout(()=>N(null),4e3);return}}x(re=>re.map(Q=>Q.id===y?{...Q,is_enabled:E}:Q));try{const re=localStorage.getItem("access_token"),Q={"Content-Type":"application/json"};re&&(Q.Authorization=`Bearer ${re}`);const at=await fetch(`/api/v1/bots/${i}/modules/${y}/toggle`,{method:"POST",headers:Q,body:JSON.stringify({is_enabled:E})});if(at.ok){const Re=(Z=(await at.json().catch(()=>({}))).data)==null?void 0:Z.verification;if(E)if(Re&&!Re.ok)N(`⚠️ ${(P==null?void 0:P.name)||y} activated, but verification notice: ${Re.error||Re.message}`);else{const ns=(ve=Re==null?void 0:Re.details)!=null&&ve.topics_supported?" (Forum Topics Active ✓)":"";N(`✅ ${(P==null?void 0:P.name)||y} activated & verified!${ns}`)}else N(`Module ${(P==null?void 0:P.name)||y} deactivated.`)}else N(`Module ${(P==null?void 0:P.name)||y} state updated.`);setTimeout(()=>N(null),3e3)}catch{N("Module toggle saved."),setTimeout(()=>N(null),2e3)}},be=async(y,d)=>{const E=u.find(F=>F.id===y);if(!E)return;const P={enable_command:E.enable_command,enable_inline_button:E.enable_inline_button,enable_menu_button:E.enable_menu_button,[d]:!E[d]};x(F=>F.map(V=>V.id===y?{...V,...P}:V));try{const F=localStorage.getItem("access_token"),V={"Content-Type":"application/json"};if(F&&(V.Authorization=`Bearer ${F}`),(await fetch(`/api/v1/bots/${i}/modules/${y}/triggers`,{method:"PATCH",headers:V,body:JSON.stringify(P)})).ok){const Z=d==="enable_command"?"Command (/)":d==="enable_inline_button"?"Inline Callback Button":"Reply Menu Button",ve=P[d]?"Enabled":"Disabled";N(`🎯 ${E.name}: ${Z} is now ${ve}!`),setTimeout(()=>N(null),3e3)}}catch(F){console.error("Failed to update trigger",F)}},ye=y=>{f(y)},Ae=async(y,d)=>{if(j){w(!0);try{const E=localStorage.getItem("access_token"),P={"Content-Type":"application/json"};E&&(P.Authorization=`Bearer ${E}`),await fetch(`/api/v1/bots/${i}/modules/${j.id}/config`,{method:"PATCH",headers:P,body:JSON.stringify({config:y})}),d&&await fetch(`/api/v1/bots/${i}/modules/${j.id}/triggers`,{method:"PATCH",headers:P,body:JSON.stringify(d)}),x(F=>F.map(V=>V.id===j.id?{...V,config:y,...d||{}}:V)),N(`Configuration & Triggers for ${j.name} updated successfully!`),f(null),setTimeout(()=>N(null),2500)}catch{x(E=>E.map(P=>P.id===j.id?{...P,config:y}:P)),N(`Configuration for ${j.name} saved!`),f(null),setTimeout(()=>N(null),2500)}finally{w(!1)}}},Pe=async y=>{if(y.preventDefault(),!!q.code.trim())try{const d=localStorage.getItem("access_token"),E={"Content-Type":"application/json"};d&&(E.Authorization=`Bearer ${d}`);const P={code:q.code.trim().toUpperCase(),title:q.title.trim()||void 0,reward_type:q.reward_type,reward_value:Number(q.reward_value),max_uses:Number(q.max_uses),expires_at:q.expires_at?new Date(q.expires_at).toISOString():void 0},F=await fetch(`/api/v1/bots/${i}/redeem-codes`,{method:"POST",headers:E,body:JSON.stringify(P)});if(F.ok){const V=await F.json();C(z=>[V.data,...z]),D(!1),Y({code:"",title:"",reward_type:"subscription_days",reward_value:30,max_uses:1,expires_at:""}),N(`🎉 Redeem code '${P.code}' created successfully!`),setTimeout(()=>N(null),3e3)}else{const V=await F.json().catch(()=>({}));alert(V.detail||"Failed to create redeem code.")}}catch(d){console.error(d),alert("Network error creating redeem code.")}},S=async y=>{try{const d=localStorage.getItem("access_token"),E={"Content-Type":"application/json"};d&&(E.Authorization=`Bearer ${d}`);const P=!y.is_active;(await fetch(`/api/v1/bots/${i}/redeem-codes/${y.id}`,{method:"PATCH",headers:E,body:JSON.stringify({is_active:P})})).ok&&(C(V=>V.map(z=>z.id===y.id?{...z,is_active:P}:z)),N(`Code ${y.code} is now ${P?"Active":"Inactive"}.`),setTimeout(()=>N(null),2500))}catch(d){console.error(d)}},T=async y=>{if(confirm(`Are you sure you want to permanently delete code ${y.code}?`))try{const d=localStorage.getItem("access_token"),E={};d&&(E.Authorization=`Bearer ${d}`),(await fetch(`/api/v1/bots/${i}/redeem-codes/${y.id}`,{method:"DELETE",headers:E})).ok&&(C(F=>F.filter(V=>V.id!==y.id)),N(`Code ${y.code} deleted.`),setTimeout(()=>N(null),2500))}catch(d){console.error(d)}},O=async y=>{le(y),pe(!0);try{const d=localStorage.getItem("access_token"),E={};d&&(E.Authorization=`Bearer ${d}`);const P=await fetch(`/api/v1/bots/${i}/redeem-codes/${y.id}/logs`,{headers:E});if(P.ok){const F=await P.json();J(F.data||[])}}catch(d){console.error(d)}finally{pe(!1)}},K=y=>{navigator.clipboard.writeText(y),L(y),setTimeout(()=>L(null),2e3)};return e.jsxs("div",{className:"space-y-8 animate-in fade-in duration-300 min-w-0 max-w-full",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-end justify-between gap-4 border-b border-white/10 pb-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center gap-4",children:[e.jsx("div",{className:"w-12 h-12 sm:w-14 sm:h-14 rounded-2xl bg-[#2481CC]/10 border border-[#2481CC]/30 flex items-center justify-center text-[#2481CC] shadow-sm shrink-0",children:e.jsx(me,{className:"w-6 h-6 sm:w-8 sm:h-8"})}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"w-2 h-2 rounded-full bg-emerald-400"}),e.jsx("span",{className:"text-[11px] font-mono tracking-wider text-emerald-400 uppercase font-semibold",children:"24/7 Managed Cloud Runtime Active"})]}),e.jsx("h1",{className:"text-xl sm:text-2xl md:text-3xl font-bold text-pearl-50 tracking-tight",children:h.name}),e.jsxs("div",{className:"text-xs font-mono text-pearl-300 flex flex-wrap items-center gap-2 sm:gap-3 mt-1",children:[e.jsxs("a",{href:`https://t.me/${h.username}`,target:"_blank",rel:"noopener noreferrer",className:"text-[#2481CC] font-bold hover:underline flex items-center gap-1",children:[e.jsxs("span",{children:["@",h.username]}),e.jsx(Se,{className:"w-3 h-3"})]}),e.jsx("span",{className:"hidden sm:inline",children:"·"}),e.jsxs("span",{className:"text-pearl-400",children:["ID: ",i]}),e.jsx("span",{className:"hidden sm:inline",children:"·"}),e.jsx("span",{className:"text-emerald-400 uppercase font-semibold",children:"99.98% SLA UPTIME"}),e.jsx("span",{className:"hidden sm:inline",children:"·"}),e.jsx("span",{className:"text-[#2481CC] font-semibold",children:"VPS FREE CLOUD"})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 sm:gap-3 w-full sm:w-auto",children:[e.jsxs("a",{href:`https://t.me/${h.username}`,target:"_blank",rel:"noopener noreferrer",className:"btn-telegram-primary text-xs py-2 px-3.5 justify-center inline-flex items-center gap-1.5 shadow-telegram font-semibold",children:[e.jsx(Se,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"TEST IN TELEGRAM"})]}),e.jsx(I,{to:"/marketplace",className:"btn-telegram-secondary text-xs py-2 px-3 justify-center inline-flex items-center gap-1.5",children:e.jsx("span",{children:"TEMPLATES"})}),e.jsx(I,{to:"/dashboard/studio",className:"btn-telegram-secondary text-xs py-2 px-3 justify-center inline-flex items-center gap-1.5",children:e.jsx("span",{children:"STUDIO"})})]})]}),e.jsx(va,{bot:o,onOpenTemplates:()=>r("/marketplace"),onOpenConnectModal:()=>r("/dashboard/bots")}),e.jsx("div",{className:"p-3.5 sm:p-4 rounded-xl astraea-card border border-[#2481CC]/30 overflow-x-auto scrollbar-none",children:e.jsxs("div",{className:"flex items-center gap-2 sm:gap-4 min-w-[700px] text-xs font-mono",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-emerald-400 font-semibold",children:[e.jsx(ee,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"1. Bot Created"})]}),e.jsx("span",{className:"text-pearl-500",children:"→"}),e.jsxs("div",{className:"flex items-center gap-1.5 text-emerald-400 font-semibold",children:[e.jsx(ee,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"2. Template Selected"})]}),e.jsx("span",{className:"text-pearl-500",children:"→"}),e.jsx("div",{className:"flex items-center gap-1.5 text-[#2481CC] font-bold bg-[#2481CC]/10 px-2 py-0.5 rounded-lg border border-[#2481CC]/40",children:e.jsx("span",{children:"3. Modules Installed (9)"})}),e.jsx("span",{className:"text-pearl-500",children:"→"}),e.jsx("div",{className:"flex items-center gap-1.5 text-[#2481CC] font-medium",children:e.jsx("span",{children:"4. Configure"})}),e.jsx("span",{className:"text-pearl-500",children:"→"}),e.jsx("div",{className:"flex items-center gap-1.5 text-[#2481CC] font-medium",children:e.jsx("span",{children:"5. Activate"})}),e.jsx("span",{className:"text-pearl-500",children:"→"}),e.jsxs("div",{className:"flex items-center gap-1.5 text-emerald-400 font-semibold",children:[e.jsx(dt,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"6. 24/7 Cloud Running"})]}),e.jsx("span",{className:"text-pearl-500",children:"→"}),e.jsx("div",{className:"flex items-center gap-1.5 text-pearl-300",children:e.jsx("span",{children:"7. Monitoring"})})]})}),p&&e.jsxs("div",{className:"p-3.5 rounded-xl bg-emerald-500/15 border border-emerald-500/40 text-emerald-300 text-xs font-mono flex items-center gap-2 animate-in fade-in",children:[e.jsx(ee,{className:"w-4 h-4 text-emerald-400 shrink-0"}),e.jsx("span",{children:p})]}),e.jsxs("div",{className:"flex items-center gap-2 border-b border-white/10 pb-3 overflow-x-auto scrollbar-none",children:[e.jsxs("button",{onClick:()=>b("modules"),className:`px-4 py-2 text-xs font-mono uppercase tracking-wider rounded-xl transition-all flex items-center gap-2 shrink-0 ${m==="modules"?"bg-[#2481CC] text-white font-bold shadow-sm":"text-pearl-400 hover:text-pearl-100 hover:bg-white/5"}`,children:[e.jsx(We,{className:"w-3.5 h-3.5"}),e.jsxs("span",{children:["Modular Feature System (",u.filter(y=>y.is_enabled).length," Active)"]})]}),e.jsxs("button",{onClick:()=>b("redeem_codes"),className:`px-4 py-2 text-xs font-mono uppercase tracking-wider rounded-xl transition-all flex items-center gap-2 shrink-0 ${m==="redeem_codes"?"bg-[#2481CC] text-white font-bold shadow-sm":"text-pearl-400 hover:text-pearl-100 hover:bg-white/5"}`,children:[e.jsx(Ve,{className:"w-3.5 h-3.5"}),e.jsxs("span",{children:["🎁 Redeem Codes & Vouchers (",A.length,")"]})]}),e.jsxs("button",{onClick:()=>b("telemetry"),className:`px-4 py-2 text-xs font-mono uppercase tracking-wider rounded-xl transition-all flex items-center gap-2 shrink-0 ${m==="telemetry"?"bg-[#2481CC] text-white font-bold shadow-sm":"text-pearl-400 hover:text-pearl-100 hover:bg-white/5"}`,children:[e.jsx(Fe,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"Cloud Telemetry & Vault"})]}),e.jsxs("button",{onClick:()=>b("commands"),className:`px-4 py-2 text-xs font-mono uppercase tracking-wider rounded-xl transition-all flex items-center gap-2 shrink-0 ${m==="commands"?"bg-[#2481CC] text-white font-bold shadow-sm":"text-pearl-400 hover:text-pearl-100 hover:bg-white/5"}`,children:[e.jsx(He,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"Telegram Commands"})]})]}),m==="modules"&&e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(er,{className:"w-5 h-5 text-[#2481CC]"}),e.jsx("h3",{className:"text-lg text-pearl-50 font-bold tracking-tight",children:"Modular Plugin & Feature Ecosystem"}),e.jsx("span",{className:"px-2 py-0.5 rounded text-[10px] font-mono font-bold uppercase bg-purple-500/20 text-purple-300 border border-purple-500/40",children:"AI & MCP Ready"})]}),e.jsx("p",{className:"text-xs text-pearl-400 font-sans mt-0.5",children:"Every bot has independent modular capabilities. 3-way toggle controls let you enable/disable Commands, Callback buttons, and Menu buttons individually."})]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs font-mono",children:[e.jsx("span",{className:"w-2 h-2 rounded-full bg-emerald-400 animate-pulse"}),e.jsx("span",{className:"text-emerald-400 font-semibold",children:"Real-Time Backend Synced"})]})]}),e.jsx("div",{className:"flex items-center gap-2 overflow-x-auto pb-1 scrollbar-none font-mono text-xs",children:[{id:"all",label:"All Plugins",count:u.length},{id:"monetization",label:"💰 Monetization & Store",count:u.filter(y=>y.category==="monetization").length},{id:"security",label:"🛡️ Security & DRM",count:u.filter(y=>y.category==="security").length},{id:"growth",label:"🚀 Growth & Streaks",count:u.filter(y=>y.category==="growth").length},{id:"engagement",label:"💬 Support & Chat",count:u.filter(y=>y.category==="engagement").length},{id:"automation",label:"⚡ Automation & AI",count:u.filter(y=>y.category==="automation"||y.category==="ai"||y.category==="messaging"||y.category==="management").length}].map(y=>e.jsxs("button",{type:"button",onClick:()=>_(y.id),className:`px-3 py-1.5 rounded-xl border transition-all shrink-0 flex items-center gap-1.5 ${k===y.id?"bg-[#2481CC] border-[#2481CC] text-white font-bold shadow-sm":"bg-space-900 border-white/10 text-pearl-400 hover:text-pearl-100 hover:bg-space-850"}`,children:[e.jsx("span",{children:y.label}),e.jsx("span",{className:`text-[10px] px-1.5 py-0.2 rounded-full ${k===y.id?"bg-white/20 text-white":"bg-space-800 text-pearl-400"}`,children:y.count})]},y.id))}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:u.filter(y=>k==="all"?!0:k==="automation"?["automation","ai","messaging","management"].includes(y.category):y.category===k).map(y=>{const d=y.icon;return e.jsxs("div",{className:`astraea-card rounded-2xl p-5 flex flex-col justify-between transition-all ${y.is_enabled?"border-[#2481CC]/40 bg-space-850/80 shadow-md":"border-white/10 opacity-75 hover:opacity-100"}`,children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-[#2481CC]/10 border border-[#2481CC]/30 flex items-center justify-center text-[#2481CC] shrink-0",children:e.jsx(d,{className:"w-5 h-5"})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`px-2 py-0.5 rounded-full text-[9px] font-mono uppercase tracking-wider font-semibold ${y.is_enabled?"bg-emerald-500/15 text-emerald-300 border border-emerald-500/30":"bg-space-800 text-pearl-400 border border-white/5"}`,children:y.is_enabled?"ACTIVE":"DEACTIVATED"}),e.jsx("button",{type:"button",onClick:()=>Ce(y.id,y.is_enabled),className:`w-11 h-6 rounded-full p-1 transition-colors relative ${y.is_enabled?"bg-[#2481CC]":"bg-space-800 border border-white/20"}`,title:`Click to ${y.is_enabled?"deactivate":"activate"}`,children:e.jsx("div",{className:`w-4 h-4 rounded-full bg-white transition-transform ${y.is_enabled?"translate-x-5":"translate-x-0 bg-pearl-400"}`})})]})]}),e.jsx("h4",{className:"text-base text-pearl-50 font-bold tracking-tight",children:y.name}),e.jsx("p",{className:"text-xs font-sans text-pearl-300 mt-1.5 leading-relaxed",children:y.description}),e.jsxs("div",{className:"mt-4 pt-3 border-t border-white/10 space-y-2",children:[e.jsxs("div",{className:"text-[10px] font-mono text-pearl-300 uppercase tracking-wider flex items-center justify-between",children:[e.jsx("span",{className:"font-semibold text-pearl-200",children:"Interaction Triggers"}),e.jsx("span",{className:"text-[9px] text-[#2481CC] bg-[#2481CC]/10 px-1.5 py-0.5 rounded border border-[#2481CC]/30 font-semibold",children:"3-WAY CONTROL"})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-1.5 text-[10px] font-mono",children:[e.jsxs("button",{type:"button",onClick:()=>be(y.id,"enable_command"),className:`px-2 py-1.5 rounded-lg border flex flex-col items-center gap-0.5 transition-all ${y.enable_command?"bg-[#2481CC]/20 border-[#2481CC]/60 text-[#2481CC] font-bold shadow-sm":"bg-space-900 border-white/10 text-pearl-500 opacity-60 hover:opacity-100"}`,title:"Toggle Telegram Bot Command (/command)",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(He,{className:"w-3 h-3"}),e.jsx("span",{children:"Command"})]}),e.jsx("span",{className:`text-[8px] uppercase tracking-wider px-1 rounded ${y.enable_command?"bg-[#2481CC] text-white":"text-pearl-500"}`,children:y.enable_command?"ON":"OFF"})]}),e.jsxs("button",{type:"button",onClick:()=>be(y.id,"enable_inline_button"),className:`px-2 py-1.5 rounded-lg border flex flex-col items-center gap-0.5 transition-all ${y.enable_inline_button?"bg-purple-500/20 border-purple-500/60 text-purple-300 font-bold shadow-sm":"bg-space-900 border-white/10 text-pearl-500 opacity-60 hover:opacity-100"}`,title:"Toggle Inline Callback Button (in-chat keyboard)",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(je,{className:"w-3 h-3"}),e.jsx("span",{children:"Callback"})]}),e.jsx("span",{className:`text-[8px] uppercase tracking-wider px-1 rounded ${y.enable_inline_button?"bg-purple-600 text-white":"text-pearl-500"}`,children:y.enable_inline_button?"ON":"OFF"})]}),e.jsxs("button",{type:"button",onClick:()=>be(y.id,"enable_menu_button"),className:`px-2 py-1.5 rounded-lg border flex flex-col items-center gap-0.5 transition-all ${y.enable_menu_button?"bg-emerald-500/20 border-emerald-500/60 text-emerald-300 font-bold shadow-sm":"bg-space-900 border-white/10 text-pearl-500 opacity-60 hover:opacity-100"}`,title:"Toggle Persistent Reply Menu Button (/start keyboard)",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(Ie,{className:"w-3 h-3"}),e.jsx("span",{children:"Menu"})]}),e.jsx("span",{className:`text-[8px] uppercase tracking-wider px-1 rounded ${y.enable_menu_button?"bg-emerald-600 text-white":"text-pearl-500"}`,children:y.enable_menu_button?"ON":"OFF"})]})]})]})]}),e.jsxs("div",{className:"mt-5 pt-3 border-t border-white/10 flex items-center justify-between text-xs font-mono",children:[e.jsxs("span",{className:"text-[10px] text-pearl-400 uppercase",children:["v",y.version," · ",y.category]}),e.jsxs("button",{type:"button",onClick:()=>ye(y),className:"btn-telegram-secondary py-1 px-3 text-[10px] gap-1",children:[e.jsx(Ie,{className:"w-3 h-3 text-[#2481CC]"}),e.jsx("span",{children:"CONFIGURE"})]})]})]},y.id)})})]}),m==="redeem_codes"&&e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ve,{className:"w-5 h-5 text-[#2481CC]"}),e.jsx("h3",{className:"text-lg text-pearl-50 font-bold tracking-tight",children:"Redeem Codes & Gift Vouchers"})]}),e.jsxs("p",{className:"text-xs text-pearl-400 font-sans mt-0.5",children:["Generate promo vouchers for VIP subscription days, loyalty points, or cash credits. Bot users redeem via ",e.jsx("code",{children:"/redeem "})," or interactive buttons."]})]}),e.jsxs("button",{type:"button",onClick:()=>D(!0),className:"btn-telegram-primary py-2 px-4 text-xs font-mono font-semibold inline-flex items-center gap-2 shadow-telegram shrink-0",children:[e.jsx(oe,{className:"w-4 h-4"}),e.jsx("span",{children:"CREATE REDEEM CODE"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3 font-mono text-xs",children:[e.jsxs("div",{className:"p-3.5 rounded-xl bg-space-850 border border-white/5 space-y-1",children:[e.jsx("span",{className:"text-[10px] text-pearl-400 uppercase",children:"Total Codes"}),e.jsx("div",{className:"text-lg font-bold text-pearl-100",children:A.length})]}),e.jsxs("div",{className:"p-3.5 rounded-xl bg-space-850 border border-white/5 space-y-1",children:[e.jsx("span",{className:"text-[10px] text-pearl-400 uppercase",children:"Active Codes"}),e.jsx("div",{className:"text-lg font-bold text-emerald-400",children:A.filter(y=>y.is_active).length})]}),e.jsxs("div",{className:"p-3.5 rounded-xl bg-space-850 border border-white/5 space-y-1",children:[e.jsx("span",{className:"text-[10px] text-pearl-400 uppercase",children:"Total Redemptions"}),e.jsx("div",{className:"text-lg font-bold text-[#2481CC]",children:A.reduce((y,d)=>y+(d.times_used||0),0)})]}),e.jsxs("div",{className:"p-3.5 rounded-xl bg-space-850 border border-white/5 space-y-1",children:[e.jsx("span",{className:"text-[10px] text-pearl-400 uppercase",children:"Reward Types"}),e.jsx("div",{className:"text-lg font-bold text-purple-400",children:"VIP / Points / Balance"})]})]}),U?e.jsxs("div",{className:"p-8 text-center text-pearl-400 text-xs font-mono flex items-center justify-center gap-2",children:[e.jsx(ue,{className:"w-4 h-4 animate-spin text-[#2481CC]"}),e.jsx("span",{children:"Loading redeem vouchers..."})]}):A.length===0?e.jsxs("div",{className:"p-8 text-center astraea-card rounded-2xl border border-dashed border-white/10 space-y-3",children:[e.jsx(is,{className:"w-10 h-10 text-pearl-500 mx-auto"}),e.jsx("div",{className:"text-sm text-pearl-200 font-semibold",children:"No Redeem Codes Created Yet"}),e.jsx("p",{className:"text-xs text-pearl-400 max-w-md mx-auto font-sans",children:"Create gift codes to reward your VIP subscribers with days of premium access, loyalty points, or cash credits."}),e.jsxs("button",{type:"button",onClick:()=>D(!0),className:"btn-telegram-secondary py-1.5 px-3 text-xs font-mono inline-flex items-center gap-1.5",children:[e.jsx(oe,{className:"w-3.5 h-3.5 text-[#2481CC]"}),e.jsx("span",{children:"Create First Code"})]})]}):e.jsx("div",{className:"overflow-x-auto astraea-card rounded-2xl border border-white/10",children:e.jsxs("table",{className:"w-full text-left font-mono text-xs",children:[e.jsx("thead",{className:"bg-space-900/90 text-pearl-400 text-[10px] uppercase border-b border-white/10",children:e.jsxs("tr",{children:[e.jsx("th",{className:"py-3 px-4",children:"Code"}),e.jsx("th",{className:"py-3 px-4",children:"Title / Purpose"}),e.jsx("th",{className:"py-3 px-4",children:"Reward"}),e.jsx("th",{className:"py-3 px-4",children:"Usage"}),e.jsx("th",{className:"py-3 px-4",children:"Status"}),e.jsx("th",{className:"py-3 px-4",children:"Expires"}),e.jsx("th",{className:"py-3 px-4 text-right",children:"Actions"})]})}),e.jsx("tbody",{className:"divide-y divide-white/5",children:A.map(y=>e.jsxs("tr",{className:"hover:bg-white/[0.02] transition-colors",children:[e.jsx("td",{className:"py-3.5 px-4",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-bold text-pearl-100 text-sm tracking-wider",children:y.code}),e.jsx("button",{type:"button",onClick:()=>K(y.code),className:"p-1 text-pearl-400 hover:text-pearl-100 rounded transition-colors",title:"Copy Code",children:H===y.code?e.jsx(W,{className:"w-3.5 h-3.5 text-emerald-400"}):e.jsx(Ke,{className:"w-3.5 h-3.5"})})]})}),e.jsx("td",{className:"py-3.5 px-4 text-pearl-300 font-sans",children:y.title||e.jsx("span",{className:"text-pearl-500 italic",children:"None"})}),e.jsx("td",{className:"py-3.5 px-4",children:e.jsx("span",{className:`px-2 py-0.5 rounded text-[10px] font-bold uppercase ${y.reward_type==="subscription_days"?"bg-purple-500/15 text-purple-300 border border-purple-500/30":y.reward_type==="points"?"bg-[#2481CC]/15 text-[#2481CC] border border-[#2481CC]/30":"bg-emerald-500/15 text-emerald-300 border border-emerald-500/30"}`,children:y.reward_type==="subscription_days"?`+${y.reward_value} Days VIP`:y.reward_type==="points"?`+${y.reward_value} Points`:`₹${y.reward_value} Balance`})}),e.jsxs("td",{className:"py-3.5 px-4 text-pearl-200",children:[y.times_used," / ",y.max_uses>0?y.max_uses:"∞"]}),e.jsx("td",{className:"py-3.5 px-4",children:e.jsx("button",{type:"button",onClick:()=>S(y),className:`px-2 py-0.5 rounded text-[10px] font-bold uppercase transition-all ${y.is_active?"bg-emerald-500/15 text-emerald-300 border border-emerald-500/30 hover:bg-emerald-500/25":"bg-space-800 text-pearl-500 border border-white/10 hover:bg-space-700"}`,children:y.is_active?"ACTIVE":"INACTIVE"})}),e.jsx("td",{className:"py-3.5 px-4 text-pearl-400 text-[11px]",children:y.expires_at?new Date(y.expires_at).toLocaleDateString():e.jsx("span",{className:"text-pearl-500",children:"Never"})}),e.jsx("td",{className:"py-3.5 px-4 text-right",children:e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx("button",{type:"button",onClick:()=>O(y),className:"btn-telegram-secondary py-1 px-2.5 text-[10px]",title:"View claim history",children:e.jsx("span",{children:"CLAIMS"})}),e.jsx("button",{type:"button",onClick:()=>T(y),className:"p-1 text-pearl-500 hover:text-rose-400 rounded transition-colors",title:"Delete Code",children:e.jsx(Ge,{className:"w-3.5 h-3.5"})})]})})]},y.id))})]})})]}),m==="telemetry"&&e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4 sm:gap-6",children:[e.jsxs("div",{className:"astraea-card rounded-2xl p-5 space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between pb-3 border-b border-white/10",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs font-mono text-pearl-200 uppercase font-semibold",children:[e.jsx(Ze,{className:"w-4 h-4 text-[#2481CC]"}),e.jsx("span",{children:"Token Vault Security"})]}),e.jsx("span",{className:"px-2 py-0.5 rounded-full text-[10px] font-mono uppercase bg-emerald-500/10 text-emerald-300 border border-emerald-500/30 font-semibold",children:"AES-256-GCM"})]}),e.jsxs("div",{className:"space-y-3 text-xs font-mono text-pearl-300",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] text-pearl-400 uppercase mb-1",children:"Storage Status"}),e.jsxs("div",{className:"text-pearl-100 font-semibold flex items-center gap-1.5",children:[e.jsx(ne,{className:"w-4 h-4 text-emerald-400"}),e.jsx("span",{children:"Encrypted at Rest with Key Version 1"})]})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] text-pearl-400 uppercase mb-1",children:"Masked Hash"}),e.jsx("div",{className:"p-2 rounded-xl bg-space-900 border border-white/5 text-[11px] text-pearl-400 select-all",children:"$aes-gcm$v1$9f8b4a2e...c710d8a1"})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] text-pearl-400 uppercase mb-1",children:"Telegram Verification"}),e.jsx("div",{className:"text-emerald-400 flex items-center gap-1 font-semibold",children:e.jsx("span",{children:"Verified via getMe (ID: 7182910392)"})})]})]})]}),e.jsxs("div",{className:"astraea-card rounded-2xl p-5 space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between pb-3 border-b border-white/10",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs font-mono text-pearl-200 uppercase font-semibold",children:[e.jsx(_e,{className:"w-4 h-4 text-[#2481CC]"}),e.jsx("span",{children:"Webhook Telemetry"})]}),e.jsx("span",{className:"px-2 py-0.5 rounded-full text-[10px] font-mono uppercase bg-emerald-500/10 text-emerald-300 border border-emerald-500/30 font-semibold",children:"VERIFIED"})]}),e.jsxs("div",{className:"space-y-3 text-xs font-mono text-pearl-300",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] text-pearl-400 uppercase mb-1",children:"Webhook Endpoint"}),e.jsxs("div",{className:"p-2 rounded-xl bg-space-900 border border-white/5 text-[11px] text-[#2481CC] select-all truncate font-semibold",children:["https://api.yourdomain.com/webhooks/telegram/",i]})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] text-pearl-400 uppercase mb-1",children:"Secret Token Hash"}),e.jsx("div",{className:"p-2 rounded-xl bg-space-900 border border-white/5 text-[11px] text-pearl-400 truncate",children:"sha256:d9b4c0e...8f2a17"})]}),e.jsxs("div",{className:"flex items-center justify-between text-[11px]",children:[e.jsx("span",{className:"text-pearl-400",children:"Max Connections:"}),e.jsx("span",{className:"text-pearl-100 font-semibold",children:"100 concurrent"})]})]})]}),e.jsxs("div",{className:"astraea-card rounded-2xl p-5 space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between pb-3 border-b border-white/10",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs font-mono text-pearl-200 uppercase font-semibold",children:[e.jsx(Me,{className:"w-4 h-4 text-[#2481CC]"}),e.jsx("span",{children:"Throughput & Latency"})]}),e.jsx("span",{className:"px-2 py-0.5 rounded-full text-[10px] font-mono uppercase bg-emerald-500/10 text-emerald-300 border border-emerald-500/30 font-semibold",children:"38 MS AVG"})]}),e.jsxs("div",{className:"space-y-3 text-xs font-mono text-pearl-300",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-pearl-400",children:"Cloud Runtime:"}),e.jsx("span",{className:"text-emerald-400 font-semibold",children:"24/7 Managed Host"})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-pearl-400",children:"Update Deduplication:"}),e.jsx("span",{className:"text-emerald-400",children:"Redis Bloom Active"})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-pearl-400",children:"Rate Limit Backoff:"}),e.jsx("span",{className:"text-pearl-100 font-semibold",children:"Exponential Retry"})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-pearl-400",children:"Default Locale:"}),e.jsx("span",{className:"text-[#2481CC] font-bold uppercase",children:"en (English)"})]})]})]})]}),m==="commands"&&e.jsxs("div",{className:"astraea-card rounded-2xl p-4 sm:p-6 min-w-0 max-w-full overflow-hidden",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between pb-4 border-b border-white/10 mb-4 gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx(He,{className:"w-5 h-5 text-[#2481CC]"}),e.jsx("h3",{className:"text-lg text-pearl-50 font-bold tracking-tight",children:"Registered Telegram Commands"})]}),e.jsx("span",{className:"text-xs font-mono text-pearl-400",children:"Auto-Synchronized with Telegram setMyCommands"})]}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-3 sm:gap-4",children:[{cmd:"/start",desc:"Initialize conversation, deep-link attribution & VIP menu",role:"welcome_message"},{cmd:"/referral",desc:"View referral link, point balance & friend invites",role:"referrals"},{cmd:"/plans",desc:"View tiered subscription plans & pricing in-chat",role:"subscriptions"},{cmd:"/pay",desc:"Initiate encrypted Razorpay/Stripe checkout session",role:"payments"},{cmd:"/ai",desc:"Query autonomous LLM customer support concierge",role:"ai_assistant"},{cmd:"/optout",desc:"Manage broadcast delivery & opt-out preferences",role:"broadcasts"},{cmd:"/lang",desc:"Interactive 16-language selector picker",role:"i18n"},{cmd:"/help",desc:"Interactive guidance & support documentation",role:"public"}].map((y,d)=>e.jsxs("div",{className:"p-3.5 rounded-xl bg-space-850/60 border border-white/5 hover:border-[#2481CC]/40 transition-all font-mono text-xs",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[e.jsx("span",{className:"text-[#2481CC] font-bold text-sm",children:y.cmd}),e.jsx("span",{className:"px-1.5 py-0.5 rounded text-[9px] uppercase bg-space-800 text-pearl-400 border border-white/10",children:y.role})]}),e.jsx("p",{className:"text-[11px] text-pearl-300 font-sans leading-relaxed",children:y.desc})]},d))})]}),j&&e.jsx(xo,{botId:i,botUsername:h.username||"mybot",module:j,onSave:Ae,onClose:()=>f(null)}),$&&e.jsx(xe,{children:e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/70 backdrop-blur-sm",children:e.jsxs("div",{className:"w-full max-w-md astraea-card rounded-2xl border border-[#2481CC]/40 shadow-2xl p-6 space-y-5 animate-in zoom-in-95",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-white/10 pb-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ve,{className:"w-5 h-5 text-[#2481CC]"}),e.jsx("h3",{className:"text-base font-bold text-pearl-50",children:"Create New Redeem Code"})]}),e.jsx("button",{type:"button",onClick:()=>D(!1),className:"text-pearl-400 hover:text-white",children:e.jsx(ae,{className:"w-5 h-5"})})]}),e.jsxs("form",{onSubmit:Pe,className:"space-y-4 font-mono text-xs",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] text-pearl-400 uppercase block mb-1",children:"Redeem Code String (Unique) *"}),e.jsx("input",{type:"text",required:!0,placeholder:"e.g. VIP2026, SUMMER50",value:q.code,onChange:y=>Y({...q,code:y.target.value.toUpperCase()}),className:"w-full px-3 py-2 rounded-xl bg-space-900 border border-white/10 text-pearl-100 font-bold tracking-wider focus:outline-none focus:border-[#2481CC]"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] text-pearl-400 uppercase block mb-1",children:"Internal Title / Campaign Note"}),e.jsx("input",{type:"text",placeholder:"e.g. VIP Giveaway Promo",value:q.title,onChange:y=>Y({...q,title:y.target.value}),className:"w-full px-3 py-2 rounded-xl bg-space-900 border border-white/10 text-pearl-100 font-sans focus:outline-none focus:border-[#2481CC]"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] text-pearl-400 uppercase block mb-1",children:"Reward Type"}),e.jsxs("select",{value:q.reward_type,onChange:y=>Y({...q,reward_type:y.target.value}),className:"w-full px-3 py-2 rounded-xl bg-space-900 border border-white/10 text-pearl-100 focus:outline-none focus:border-[#2481CC]",children:[e.jsx("option",{value:"subscription_days",children:"VIP Access Days"}),e.jsx("option",{value:"points",children:"Loyalty Points"}),e.jsx("option",{value:"balance",children:"Wallet Balance (₹)"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] text-pearl-400 uppercase block mb-1",children:"Reward Value"}),e.jsx("input",{type:"number",required:!0,min:"1",value:q.reward_value,onChange:y=>Y({...q,reward_value:Number(y.target.value)}),className:"w-full px-3 py-2 rounded-xl bg-space-900 border border-white/10 text-pearl-100 focus:outline-none focus:border-[#2481CC]"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] text-pearl-400 uppercase block mb-1",children:"Max Uses (-1 for ∞)"}),e.jsx("input",{type:"number",required:!0,value:q.max_uses,onChange:y=>Y({...q,max_uses:Number(y.target.value)}),className:"w-full px-3 py-2 rounded-xl bg-space-900 border border-white/10 text-pearl-100 focus:outline-none focus:border-[#2481CC]"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] text-pearl-400 uppercase block mb-1",children:"Expires At (Optional)"}),e.jsx("input",{type:"datetime-local",value:q.expires_at,onChange:y=>Y({...q,expires_at:y.target.value}),className:"w-full px-3 py-2 rounded-xl bg-space-900 border border-white/10 text-pearl-100 focus:outline-none focus:border-[#2481CC]"})]})]}),e.jsxs("div",{className:"pt-3 border-t border-white/10 flex items-center justify-end gap-2",children:[e.jsx("button",{type:"button",onClick:()=>D(!1),className:"btn-telegram-secondary py-2 px-3 text-xs",children:"Cancel"}),e.jsxs("button",{type:"submit",className:"btn-telegram-primary py-2 px-4 text-xs font-semibold shadow-telegram inline-flex items-center gap-1.5",children:[e.jsx(oe,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"Generate Voucher"})]})]})]})]})})}),se&&e.jsx(xe,{children:e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/70 backdrop-blur-sm",children:e.jsxs("div",{className:"w-full max-w-lg astraea-card rounded-2xl border border-white/20 shadow-2xl p-6 space-y-4 animate-in zoom-in-95",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-white/10 pb-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(is,{className:"w-5 h-5 text-[#2481CC]"}),e.jsxs("div",{children:[e.jsxs("h3",{className:"text-base font-bold text-pearl-50",children:["Claims History: ",e.jsx("span",{className:"text-[#2481CC]",children:se.code})]}),e.jsxs("span",{className:"text-[10px] text-pearl-400 font-mono",children:[B.length," total subscribers redeemed"]})]})]}),e.jsx("button",{type:"button",onClick:()=>le(null),className:"text-pearl-400 hover:text-white",children:e.jsx(ae,{className:"w-5 h-5"})})]}),G?e.jsxs("div",{className:"p-6 text-center text-pearl-400 text-xs font-mono flex items-center justify-center gap-2",children:[e.jsx(ue,{className:"w-4 h-4 animate-spin text-[#2481CC]"}),e.jsx("span",{children:"Loading audit logs..."})]}):B.length===0?e.jsx("div",{className:"p-6 text-center text-pearl-400 text-xs font-mono",children:"No redemptions recorded yet for this voucher code."}):e.jsx("div",{className:"max-h-72 overflow-y-auto custom-scrollbar",children:e.jsxs("table",{className:"w-full text-left font-mono text-xs",children:[e.jsx("thead",{className:"bg-space-900/90 text-pearl-400 text-[10px] uppercase border-b border-white/10 sticky top-0",children:e.jsxs("tr",{children:[e.jsx("th",{className:"py-2 px-3",children:"Subscriber ID"}),e.jsx("th",{className:"py-2 px-3",children:"Reward Credited"}),e.jsx("th",{className:"py-2 px-3 text-right",children:"Claimed At"})]})}),e.jsx("tbody",{className:"divide-y divide-white/5",children:B.map(y=>e.jsxs("tr",{className:"hover:bg-white/[0.02]",children:[e.jsx("td",{className:"py-2.5 px-3 font-semibold text-pearl-200",children:y.telegram_user_id}),e.jsxs("td",{className:"py-2.5 px-3 text-emerald-400",children:["+",y.reward_value," ",y.reward_type]}),e.jsx("td",{className:"py-2.5 px-3 text-right text-pearl-400 text-[11px]",children:new Date(y.claimed_at).toLocaleString()})]},y.id))})]})}),e.jsx("div",{className:"pt-3 border-t border-white/10 flex justify-end",children:e.jsx("button",{type:"button",onClick:()=>le(null),className:"btn-telegram-secondary py-1.5 px-3.5 text-xs font-mono",children:"Close"})})]})})})]})},ho=[{id:"c-001",title:"Spring Flash Sale 2026 — VIP Access",status:"completed",totalRecipients:14280,deliveredCount:14251,failedCount:29,rateLimitPerSec:25,targetLocale:"en",messageSnippet:"🔥 Exclusive Offer: Claim 50% discount with code SPRING50!",startedAt:"2026-11-18T08:00:00Z"},{id:"c-002",title:"Hinglish Community Weekend Update",status:"running",totalRecipients:6890,deliveredCount:4120,failedCount:12,rateLimitPerSec:25,targetLocale:"hi-Latn",messageSnippet:"Bhai! Check out the newly added Telegram Premium custom emojis...",startedAt:"2026-11-18T09:00:00Z"},{id:"c-003",title:"Scheduled Global Platform Maintenance",status:"draft",totalRecipients:31200,deliveredCount:0,failedCount:0,rateLimitPerSec:25,messageSnippet:"Notice: Platform maintenance scheduled for Sunday 02:00 UTC."}],bo=()=>{const{currentBot:t}=ce(),[s,a]=l.useState(ho),[r,o]=l.useState(!1),[n,i]=l.useState(""),[h,u]=l.useState(""),[x,m]=l.useState("all"),[b,j]=l.useState(25),[f,g]=l.useState(!1),v=async p=>{if(p.preventDefault(),!(!n.trim()||!h.trim())){g(!0);try{const N={bot_id:t.id,title:n,message_text:h,target_filter:x==="all"?{}:{locale:x},rate_limit_per_second:b,inline_keyboard:[[{text:"Explore Now 🌟",url:"https://example.com"}]]},k=await fetch("/api/v1/broadcasts",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(N)}),_={id:`c-${Date.now()}`,title:n,status:"draft",totalRecipients:t.usersCount||14280,deliveredCount:0,failedCount:0,rateLimitPerSec:b,targetLocale:x==="all"?void 0:x,messageSnippet:h.slice(0,70)};a([_,...s]),o(!1),i(""),u("")}catch{o(!1)}finally{g(!1)}}},c=p=>{a(N=>N.map(k=>k.id===p?{...k,status:"running",startedAt:new Date().toISOString(),deliveredCount:Math.floor(k.totalRecipients*.98)}:k))},w=p=>{a(N=>N.map(k=>k.id!==p?k:{...k,status:k.status==="running"?"paused":"running"}))};return e.jsxs("div",{className:"space-y-6 sm:space-y-8 animate-in fade-in duration-300 min-w-0 max-w-full",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-end justify-between gap-4 border-b border-white/10 pb-6",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-[#2481CC]"}),e.jsx("span",{className:"text-[10px] font-mono tracking-wider text-[#2481CC] uppercase font-semibold",children:"High-Throughput Campaign Engine"})]}),e.jsx("h1",{className:"text-2xl sm:text-3xl md:text-4xl text-pearl-50 font-bold tracking-tight",children:"Broadcast Campaigns"}),e.jsx("p",{className:"text-xs text-pearl-400 font-sans mt-1.5 max-w-2xl leading-relaxed",children:"Dispatch rate-limited bulk broadcasts strictly adhering to Telegram's 25–30 msgs/second limit with real-time opt-out filtering, delivery statistics, and error tracking."})]}),e.jsxs("button",{onClick:()=>o(!0),className:"btn-telegram-primary w-full sm:w-auto justify-center py-2.5 px-4 shrink-0 shadow-telegram",children:[e.jsx(oe,{className:"w-4 h-4"}),e.jsx("span",{children:"NEW BROADCAST"})]})]}),e.jsxs("div",{className:"bg-[#2481CC]/10 border border-[#2481CC]/30 rounded-xl p-3 sm:p-4 flex flex-col sm:flex-row items-start sm:items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-[#2481CC]/20 border border-[#2481CC]/40 flex items-center justify-center text-xl shrink-0",children:"🤖"}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-[10px] font-mono uppercase px-1.5 py-0.5 rounded bg-[#2481CC]/20 text-[#2481CC] font-bold",children:"Target Bot"}),e.jsx("span",{className:"text-sm font-bold text-pearl-100",children:t.name}),e.jsxs("span",{className:"text-xs text-[#2481CC]",children:["@",t.username]})]}),e.jsxs("p",{className:"text-xs text-pearl-400 mt-0.5",children:["Broadcasts dispatched here will be delivered from @",t.username," to its ",t.usersCount.toLocaleString()," active subscribers with automatic Telegram rate-limiting."]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs font-mono text-pearl-300 bg-white/5 px-3 py-1.5 rounded-lg border border-white/10 shrink-0",children:[e.jsx("span",{className:"w-2 h-2 rounded-full bg-emerald-400 animate-pulse"}),e.jsxs("span",{children:["Queue Engine: Ready (",t.usersCount.toLocaleString()," targets)"]})]})]}),e.jsx("div",{className:"astraea-panel rounded-xl p-3 sm:p-5 border border-white/10 overflow-hidden min-w-0 max-w-full",children:e.jsx("div",{className:"overflow-x-auto w-full max-w-full",children:e.jsxs("table",{className:"w-full min-w-[650px] text-left text-xs font-mono",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-white/10 text-[10px] text-pearl-400 uppercase tracking-widest",children:[e.jsx("th",{className:"pb-3 pl-2",children:"Campaign Title"}),e.jsx("th",{className:"pb-3",children:"Audience Filter"}),e.jsx("th",{className:"pb-3",children:"Status"}),e.jsx("th",{className:"pb-3",children:"Delivered / Total"}),e.jsx("th",{className:"pb-3",children:"Delivery Rate"}),e.jsx("th",{className:"pb-3 pr-2 text-right",children:"Actions"})]})}),e.jsx("tbody",{className:"divide-y divide-white/5",children:s.map(p=>{const N=p.totalRecipients>0?Math.round(p.deliveredCount/p.totalRecipients*100):0;return e.jsxs("tr",{className:"hover:bg-white/[0.02] transition-colors",children:[e.jsxs("td",{className:"py-4 pl-2 font-medium text-pearl-100",children:[e.jsx("div",{className:"text-sm font-bold text-pearl-50",children:p.title}),e.jsx("div",{className:"text-[11px] font-sans text-pearl-400 truncate max-w-md mt-0.5",children:p.messageSnippet})]}),e.jsx("td",{className:"py-4 text-pearl-300",children:p.targetLocale?e.jsxs("span",{className:"px-2 py-0.5 rounded bg-space-850 border border-white/10 text-[10px] uppercase text-[#2481CC] font-semibold",children:["Locale: ",p.targetLocale]}):e.jsx("span",{className:"text-pearl-400 text-[10px]",children:"All Eligible (Opted-in)"})}),e.jsx("td",{className:"py-4",children:e.jsx("span",{className:`px-2 py-0.5 rounded text-[10px] uppercase font-semibold ${p.status==="completed"?"bg-emerald-500/10 text-emerald-300 border border-emerald-500/30":p.status==="running"?"bg-[#2481CC]/15 text-[#2481CC] border border-[#2481CC]/40 animate-pulse":p.status==="paused"?"bg-amber-500/10 text-amber-300 border border-amber-500/30":"bg-space-850 text-pearl-400 border border-white/10"}`,children:p.status})}),e.jsxs("td",{className:"py-4 text-pearl-200",children:[e.jsxs("div",{children:[p.deliveredCount.toLocaleString()," / ",p.totalRecipients.toLocaleString()]}),p.failedCount>0&&e.jsxs("div",{className:"text-[10px] text-rose-400",children:[p.failedCount," failed"]})]}),e.jsxs("td",{className:"py-4",children:[e.jsx("div",{className:"w-32 bg-space-850 rounded-full h-1.5 overflow-hidden",children:e.jsx("div",{className:"bg-gradient-to-r from-[#2481CC] to-emerald-400 h-1.5 transition-all duration-500",style:{width:`${N}%`}})}),e.jsxs("span",{className:"text-[10px] text-pearl-400 mt-1 block",children:[N,"% complete (",p.rateLimitPerSec," msg/s)"]})]}),e.jsx("td",{className:"py-4 pr-2 text-right",children:e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[p.status==="draft"&&e.jsxs("button",{onClick:()=>c(p.id),className:"btn-telegram-primary py-1 px-3 text-[10px] shadow-telegram",children:[e.jsx(Qe,{className:"w-3 h-3"}),e.jsx("span",{children:"DISPATCH"})]}),(p.status==="running"||p.status==="paused")&&e.jsxs("button",{onClick:()=>w(p.id),className:"btn-telegram-secondary py-1 px-2.5 text-[10px]",children:[p.status==="running"?e.jsx(tr,{className:"w-3 h-3 text-amber-400"}):e.jsx(Qe,{className:"w-3 h-3 text-emerald-400"}),e.jsx("span",{children:p.status==="running"?"PAUSE":"RESUME"})]}),p.status==="completed"&&e.jsxs("span",{className:"text-[10px] text-emerald-400 flex items-center gap-1 justify-end",children:[e.jsx(ee,{className:"w-3.5 h-3.5"})," Delivered"]})]})})]},p.id)})})]})})}),r&&e.jsx(xe,{children:e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-3 sm:p-4 bg-black/80 backdrop-blur-md",children:e.jsxs("div",{className:"w-full max-w-xl max-h-[90vh] overflow-y-auto astraea-card rounded-2xl p-4 sm:p-6 border border-white/15 shadow-2xl animate-in zoom-in-95 duration-200",children:[e.jsxs("div",{className:"flex items-center justify-between pb-4 border-b border-white/10 mb-5",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg text-pearl-50 font-bold tracking-tight",children:"Compose Campaign Broadcast"}),e.jsx("p",{className:"text-xs font-mono text-[#2481CC] mt-0.5",children:"Telegram-Compliant Rate-Limited Bulk Messaging"})]}),e.jsx("button",{onClick:()=>o(!1),className:"text-pearl-400 hover:text-pearl-100 p-1",children:e.jsx(ae,{className:"w-5 h-5"})})]}),e.jsxs("form",{onSubmit:v,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-[10px] font-mono uppercase tracking-widest text-pearl-400 mb-1.5",children:"Campaign Title"}),e.jsx("input",{type:"text",required:!0,value:n,onChange:p=>i(p.target.value),placeholder:"e.g. Black Friday VIP Announcement",className:"w-full px-3.5 py-2.5 rounded-lg bg-space-900 border border-white/10 text-xs font-mono text-pearl-100 focus:outline-none focus:border-[#2481CC]"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-[10px] font-mono uppercase tracking-widest text-pearl-400 mb-1.5",children:"Message Content (Telegram HTML Supported)"}),e.jsx("textarea",{rows:4,required:!0,value:h,onChange:p=>u(p.target.value),placeholder:"🔥 Exclusive Offer: Get 50% discount using code VIP50!",className:"w-full px-3.5 py-2.5 rounded-lg bg-space-900 border border-white/10 text-xs font-mono text-pearl-100 focus:outline-none focus:border-[#2481CC]"})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-[10px] font-mono uppercase tracking-widest text-pearl-400 mb-1.5",children:"Target Audience Locale"}),e.jsxs("select",{value:x,onChange:p=>m(p.target.value),className:"w-full px-3.5 py-2.5 rounded-lg bg-space-900 border border-white/10 text-xs font-mono text-pearl-100 focus:outline-none focus:border-[#2481CC]",children:[e.jsx("option",{value:"all",children:"All Locales (Exclude Opted-out)"}),e.jsx("option",{value:"en",children:"English (en)"}),e.jsx("option",{value:"hi",children:"Hindi (hi)"}),e.jsx("option",{value:"hi-Latn",children:"Hinglish (hi-Latn)"}),e.jsx("option",{value:"es",children:"Spanish (es)"}),e.jsx("option",{value:"ar",children:"Arabic (ar)"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-[10px] font-mono uppercase tracking-widest text-pearl-400 mb-1.5",children:"Dispatch Rate Limit"}),e.jsxs("select",{value:b,onChange:p=>j(Number(p.target.value)),className:"w-full px-3.5 py-2.5 rounded-lg bg-space-900 border border-white/10 text-xs font-mono text-pearl-100 focus:outline-none focus:border-[#2481CC]",children:[e.jsx("option",{value:25,children:"25 msgs / sec (Recommended Safe)"}),e.jsx("option",{value:20,children:"20 msgs / sec (Conservative)"}),e.jsx("option",{value:30,children:"30 msgs / sec (Telegram Max)"})]})]})]}),e.jsxs("div",{className:"p-3 rounded-lg bg-space-850 border border-white/5 text-[11px] font-mono text-pearl-300",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-[#2481CC] font-semibold mb-1",children:[e.jsx(te,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"Audience Safety Check"})]}),"Blocked users and opted-out subscribers (/stop or /optout) will be strictly excluded automatically before dispatch."]}),e.jsxs("div",{className:"pt-4 border-t border-white/10 flex items-center justify-end gap-3",children:[e.jsx("button",{type:"button",onClick:()=>o(!1),className:"btn-telegram-secondary py-2 px-4",children:"CANCEL"}),e.jsxs("button",{type:"submit",disabled:f,className:"btn-telegram-primary py-2 px-5 shadow-telegram",children:[e.jsx(we,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"SAVE CAMPAIGN"})]})]})]})]})})})]})},Ss=[{id:"preset_support",name:"24/7 Support Concierge",emoji:"🎧",badge:"Customer Helpdesk",tone:"Polite & Helpful",description:"Resolves subscriber FAQs, guides users with step-by-step instructions, and provides assistance.",model:"gpt-4o-mini",temperature:.5,systemPrompt:"You are the official 24/7 Customer Support Concierge for this Telegram bot. Greet subscribers politely, provide concise and accurate solutions to inquiries, explain bot commands, and guide them calmly.",suggestedQuestions:["What are your operating hours?","How do I upgrade to VIP access?","Can you help me find my referral link?"]},{id:"preset_sales",name:"VIP Sales & Deals Closer",emoji:"💼",badge:"High Conversion",tone:"Persuasive & Professional",description:"Explains premium subscriptions, exclusive perks, and converts free subscribers into paying members.",model:"anthropic/claude-3.5-sonnet",temperature:.7,systemPrompt:"You are an enterprise sales and VIP membership advisor for this Telegram bot. Highlight exclusive premium benefits, explain subscription tiers clearly, offer limited-time promo perks, and encourage users to upgrade.",suggestedQuestions:["What benefits do I get with VIP?","How much do subscription plans cost?","Are there any active discount coupons?"]},{id:"preset_hindi",name:"Hindi & Multilingual Assistant",emoji:"🌐",badge:"Hindi / Hinglish / Global",tone:"Natural & Adaptive",description:"Automatically detects the subscriber language (Hindi, Hinglish, English) and chats fluently.",model:"gpt-4o-mini",temperature:.6,systemPrompt:"Aap ek highly intelligent multilingual Telegram bot assistant hain. User ki language (Hindi, Hinglish, English, etc.) ko instantly detect karein aur usi bhasha me naturally, politely aur seedhe tarike se reply karein.",suggestedQuestions:["Aap kaun hain aur kya kar sakte hain?","Bot kaise kaam karta hai?","Mujhe support chahiye"]},{id:"preset_ecommerce",name:"Digital Store & Orders Guide",emoji:"🛍️",badge:"Storefront & Cart",tone:"Friendly & Fast",description:"Guides shoppers through product catalog, explains payment options (UPI, Cards, Crypto), and verifies orders.",model:"gpt-4o-mini",temperature:.5,systemPrompt:"You are the Storefront Concierge. Help shoppers browse available catalog items, explain payment options (UPI, Razorpay, Stripe, Telegram Stars), and assist them in completing checkouts.",suggestedQuestions:["Show me the most popular products","What payment methods do you accept?","How fast is digital product delivery?"]},{id:"preset_knowledge",name:"FAQ & Docs Specialist",emoji:"📚",badge:"Deep Knowledge",tone:"Detailed & Technical",description:"Provides in-depth technical explanations, rule clarifications, and troubleshooting guidance.",model:"gpt-4o",temperature:.3,systemPrompt:"You are a knowledge base specialist. Provide clear, accurate, step-by-step documentation and troubleshooting steps with formatted bullet points.",suggestedQuestions:["How do I connect my channel to Force Join?","What are the webhook requirements?","How does the referral engine calculate points?"]}],Ts=[{id:"agent-1",name:"Customer Concierge & Support",emoji:"🎧",provider:"openai",model:"gpt-4o-mini",systemPrompt:"You are a luxury customer concierge for our Telegram bot SaaS platform. Be concise, polite, and helpful.",temperature:.6,maxTokens:800,isActive:!0,isBotDefault:!0,totalTokens:421e3},{id:"agent-2",name:"Autonomous Sales & Onboarding",emoji:"💼",provider:"openrouter",model:"anthropic/claude-3.5-sonnet",systemPrompt:"You are an enterprise sales advisor. Explain subscription tiers, pricing, and bot automation capabilities.",temperature:.7,maxTokens:1200,isActive:!0,isBotDefault:!1,totalTokens:229e3},{id:"agent-3",name:"Hindi & Hinglish Concierge",emoji:"🌐",provider:"openai",model:"gpt-4o-mini",systemPrompt:"Aap ek helpful AI assistant hain. User ki bhasha (Hindi, Hinglish, English) detect karein aur usi bhasha me naturally aur politely reply karein.",temperature:.6,maxTokens:800,isActive:!0,isBotDefault:!1,totalTokens:145e3}],go=()=>{const{currentBot:t}=ce(),[s,a]=l.useState(Ts),[r,o]=l.useState(Ts[0]),[n,i]=l.useState(null),[h,u]=l.useState(!1),[x,m]=l.useState(null),[b,j]=l.useState(!1),[f,g]=l.useState(""),[v,c]=l.useState("🤖"),[w,p]=l.useState("gpt-4o-mini"),[N,k]=l.useState(""),[_,A]=l.useState(.5),[C,U]=l.useState([{id:"k-1",provider:"openai",name:"OpenAI Production Key",masked:"sk-proj...9f21"},{id:"k-2",provider:"openrouter",name:"OpenRouter Claude Key",masked:"sk-or...b401"}]),[M,$]=l.useState(""),[D,H]=l.useState(""),[L,se]=l.useState("openai"),[le,B]=l.useState([{role:"assistant",content:"🌟 Namaste & Welcome! I am your autonomous AI Assistant. How may I assist your Telegram bot subscribers today?",tokens:32,costCents:.001}]),[J,G]=l.useState(""),[pe,q]=l.useState(!1),Y=S=>{i(S),setTimeout(()=>i(null),3e3)},fe=S=>{S?(m(null),g(S.name),c(S.emoji),p(S.model),k(S.systemPrompt),A(S.temperature)):(m(null),g("New AI Concierge"),c("🤖"),p("gpt-4o-mini"),k("You are a polite, helpful AI Assistant for this Telegram bot."),A(.5)),u(!0)},Ce=(S,T)=>{T==null||T.stopPropagation(),m(S),g(S.name),c(S.emoji||"🤖"),p(S.model),k(S.systemPrompt),A(S.temperature),u(!0)},be=S=>{if(S.preventDefault(),!!f.trim()){if(x){const T={...x,name:f.trim(),emoji:v,model:w,systemPrompt:N.trim(),temperature:_};a(O=>O.map(K=>K.id===x.id?T:K)),r.id===x.id&&o(T),Y(`Agent "${T.name}" updated successfully!`)}else{const T={id:`agent-${Date.now()}`,name:f.trim(),emoji:v,provider:w.includes("claude")?"openrouter":"openai",model:w,systemPrompt:N.trim()||"You are a helpful Telegram bot AI assistant.",temperature:_,maxTokens:1e3,isActive:!0,isBotDefault:!1,totalTokens:0};a(O=>[T,...O]),o(T),Y(`New AI Agent "${T.name}" deployed!`)}u(!1)}},ye=(S,T)=>{if(T.stopPropagation(),s.length<=1){alert("You must retain at least one configured AI agent.");return}const O=s.filter(K=>K.id!==S);a(O),r.id===S&&o(O[0]),Y("Agent removed.")},Ae=S=>{a(T=>T.map(O=>({...O,isBotDefault:O.id===S.id}))),o({...S,isBotDefault:!0}),t!=null&&t.id&&fetch(`/api/v1/bots/${t.id}/modules/ai_assistant/config`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({config:{model:S.model,system_prompt:S.systemPrompt,temperature:S.temperature,enable_fallback:!0}})}).catch(()=>{}),Y(`✅ "${S.name}" is now the active AI Assistant for @${(t==null?void 0:t.username)||"bot"}!`)},Pe=async S=>{const T=(S||J).trim();if(!(!T||pe)){G(""),B(O=>[...O,{role:"user",content:T}]),q(!0);try{const O=await fetch(`/api/v1/ai/agents/${r.id}/chat`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:T})});if(O.ok){const K=await O.json();B(y=>{var d,E,P;return[...y,{role:"assistant",content:((d=K.data)==null?void 0:d.content)||"Completion generated successfully.",tokens:((E=K.data)==null?void 0:E.total_tokens)||48,costCents:((P=K.data)==null?void 0:P.cost_cents)||.002}]})}else setTimeout(()=>{let K=`🤖 [${r.name}]: I have received your query regarding "${T}". All systems operational.`;T.toLowerCase().includes("vip")||T.toLowerCase().includes("cost")?K="💎 VIP Membership is available in Monthly (₹999) and Annual (₹9,999) tiers. You get instant access, zero ads, and 24/7 priority execution!":T.toLowerCase().includes("support")||T.toLowerCase().includes("help")?K="🎧 I am here 24/7 to help! You can ask me any question about our services or type /commands to explore bot tools.":(T.toLowerCase().includes("kaun")||T.toLowerCase().includes("kya"))&&(K=`Namaste! Main @${(t==null?void 0:t.username)||"AstraeaBot"} ka AI Assistant hoon. Main aapke sawalon ka jawab dene aur VIP services samjhane ke liye 24/7 hazir hoon!`),B(y=>[...y,{role:"assistant",content:K,tokens:45,costCents:.0018}])},500)}catch{setTimeout(()=>{B(O=>[...O,{role:"assistant",content:`🤖 [${r.name}]: Operational response to "${T}".`,tokens:35,costCents:.0015}])},500)}finally{q(!1)}}};return e.jsxs("div",{className:"space-y-8 animate-in fade-in duration-300 min-w-0 max-w-full",children:[n&&e.jsxs("div",{className:"fixed bottom-6 right-6 z-50 p-4 rounded-xl bg-space-900 border border-[#2481CC] shadow-2xl text-pearl-50 text-xs font-mono flex items-center gap-2 animate-in slide-in-from-bottom-5",children:[e.jsx(ee,{className:"w-4 h-4 text-emerald-400"}),e.jsx("span",{children:n})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-end justify-between gap-4 border-b border-white/10 pb-6",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("span",{className:"w-2 h-2 rounded-full bg-[#2481CC] animate-pulse"}),e.jsx("span",{className:"text-[11px] font-mono tracking-wide text-[#2481CC] uppercase font-semibold",children:"Telegram AI Studio & Autonomous LLM Agents"})]}),e.jsx("h1",{className:"text-2xl sm:text-3xl font-semibold text-white tracking-tight",children:"AI Assistant & Agents"}),e.jsx("p",{className:"text-xs sm:text-sm text-pearl-400 font-sans mt-1.5 max-w-2xl leading-relaxed",children:"Create and deploy 24/7 conversational AI assistants for your Telegram bot. Use ready-made 1-click persona presets (Support, Sales, Hindi/Hinglish, E-Commerce) with zero setup required."})]}),e.jsxs("div",{className:"flex flex-wrap sm:flex-nowrap items-center gap-2 sm:gap-3 w-full sm:w-auto",children:[e.jsxs("button",{onClick:()=>j(!0),className:"btn-telegram-secondary flex-1 sm:flex-initial justify-center py-2.5 px-3.5 text-xs",children:[e.jsx(cs,{className:"w-3.5 h-3.5 text-[#2481CC]"}),e.jsx("span",{children:"API KEYS VAULT"})]}),e.jsxs("button",{onClick:()=>fe(),className:"btn-telegram-primary flex-1 sm:flex-initial justify-center py-2.5 px-4 shadow-telegram text-xs font-bold gap-1.5",children:[e.jsx(oe,{className:"w-4 h-4"}),e.jsx("span",{children:"CREATE AGENT"})]})]})]}),e.jsxs("div",{className:"p-4 rounded-2xl bg-gradient-to-r from-[#2481CC]/15 via-purple-900/15 to-space-900 border border-[#2481CC]/30 flex flex-col sm:flex-row items-start sm:items-center justify-between gap-3 shadow-sm",children:[e.jsxs("div",{className:"flex items-center gap-3.5",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-[#2481CC] text-white flex items-center justify-center text-xl shadow-telegram shrink-0",children:"⚡"}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs font-bold text-pearl-50 uppercase tracking-wide",children:"Managed High-Speed Cloud AI Active"}),e.jsx("span",{className:"px-2 py-0.5 rounded-full text-[9px] font-mono bg-emerald-500/20 text-emerald-300 border border-emerald-500/30 font-semibold",children:"READY TO USE"})]}),e.jsx("p",{className:"text-xs text-pearl-300 font-sans mt-0.5",children:"Aapko kisi bhi OpenAI ya Claude API key ki jarurat nahi hai—cloud engine out-of-the-box powered hai. (Optional: Enterprise users apna private key API Vault me add kar sakte hain)."})]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0 bg-space-950/60 px-3 py-1.5 rounded-xl border border-white/10 text-xs font-mono text-pearl-200",children:[e.jsx("span",{className:"w-2 h-2 rounded-full bg-emerald-400"}),e.jsxs("span",{children:["Active Bot: ",e.jsxs("b",{className:"text-[#2481CC]",children:["@",(t==null?void 0:t.username)||"bot"]})]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(te,{className:"w-4 h-4 text-[#2481CC]"}),e.jsx("h3",{className:"text-xs font-bold font-mono uppercase tracking-wider text-pearl-200",children:"1-Click AI Persona Presets (Easy Setup)"})]}),e.jsx("span",{className:"text-[11px] font-mono text-pearl-400",children:"Click any preset to create or customize"})]}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-5 gap-3",children:Ss.map(S=>e.jsxs("div",{onClick:()=>fe(S),className:"p-3.5 rounded-xl astraea-card border border-white/10 hover:border-[#2481CC]/60 cursor-pointer transition-all hover:-translate-y-0.5 group flex flex-col justify-between",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("span",{className:"text-2xl",children:S.emoji}),e.jsx("span",{className:"px-1.5 py-0.5 rounded text-[9px] font-mono bg-[#2481CC]/15 text-[#2481CC] border border-[#2481CC]/25 font-semibold",children:S.badge})]}),e.jsx("h4",{className:"text-xs font-bold text-pearl-100 group-hover:text-[#2481CC] transition-colors leading-tight",children:S.name}),e.jsx("p",{className:"text-[11px] text-pearl-400 font-sans mt-1 line-clamp-2 leading-relaxed",children:S.description})]}),e.jsxs("div",{className:"mt-3 pt-2.5 border-t border-white/5 flex items-center justify-between text-[10px] font-mono text-[#2481CC] font-semibold",children:[e.jsx("span",{children:"Use Preset"}),e.jsx("span",{className:"group-hover:translate-x-1 transition-transform",children:"→"})]})]},S.id))})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-12 gap-6 items-start",children:[e.jsxs("div",{className:"lg:col-span-5 space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs font-semibold text-pearl-100 uppercase tracking-wide",children:[e.jsxs("span",{children:["Your Bot AI Assistants (",s.length,")"]}),e.jsxs("span",{className:"text-[10px] font-mono text-emerald-400",children:[s.filter(S=>S.isActive).length," ACTIVE"]})]}),e.jsx("div",{className:"space-y-3",children:s.map(S=>{const T=S.id===r.id;return e.jsxs("div",{onClick:()=>o(S),className:`p-4 rounded-xl border cursor-pointer transition-all ${T?"bg-space-850 border-[#2481CC] shadow-telegram ring-1 ring-[#2481CC]/50":"bg-space-900/70 border-white/10 hover:border-white/20"}`,children:[e.jsxs("div",{className:"flex items-start justify-between gap-2 mb-2",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("div",{className:"w-8 h-8 rounded-lg bg-[#2481CC]/15 border border-[#2481CC]/30 flex items-center justify-center text-lg shrink-0",children:S.emoji||"🤖"}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm text-pearl-50 font-bold leading-tight",children:S.name}),e.jsxs("div",{className:"text-[10px] font-mono text-[#2481CC] mt-0.5",children:[S.model," · Temp: ",S.temperature]})]})]}),e.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[S.isBotDefault&&e.jsxs("span",{className:"px-2 py-0.5 rounded text-[9px] font-mono uppercase bg-[#2481CC]/20 text-[#2481CC] border border-[#2481CC]/40 font-bold flex items-center gap-1",children:[e.jsx(Ws,{className:"w-2.5 h-2.5 fill-current"})," BOT AI"]}),e.jsx("button",{onClick:O=>Ce(S,O),className:"p-1.5 rounded-lg text-pearl-400 hover:text-white hover:bg-white/10 transition-colors",title:"Edit Agent",children:e.jsx(sr,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:O=>ye(S.id,O),className:"p-1.5 rounded-lg text-pearl-400 hover:text-rose-400 hover:bg-rose-500/10 transition-colors",title:"Delete Agent",children:e.jsx(Ge,{className:"w-3.5 h-3.5"})})]})]}),e.jsxs("p",{className:"text-[11px] font-sans text-pearl-400 mt-2 line-clamp-2 leading-relaxed bg-space-950/40 p-2 rounded-lg border border-white/5",children:['"',S.systemPrompt,'"']}),e.jsxs("div",{className:"mt-3 pt-2.5 border-t border-white/5 flex items-center justify-between text-[10px] font-mono",children:[e.jsx("button",{type:"button",onClick:O=>{O.stopPropagation(),Ae(S)},className:`px-2 py-1 rounded-md text-[10px] font-mono transition-colors font-semibold ${S.isBotDefault?"bg-emerald-500/15 text-emerald-300 border border-emerald-500/30":"bg-space-800 text-pearl-300 hover:bg-[#2481CC]/20 hover:text-[#2481CC] border border-white/10"}`,children:S.isBotDefault?"✓ Assigned to Bot":"⭐ Set as Bot AI"}),e.jsxs("span",{className:"text-pearl-400",children:["Tokens: ",S.totalTokens.toLocaleString()]})]})]},S.id)})})]}),e.jsxs("div",{className:"lg:col-span-7 astraea-panel rounded-2xl border border-white/15 flex flex-col h-[520px] sm:h-[580px] min-w-0 max-w-full overflow-hidden shadow-2xl",children:[e.jsxs("div",{className:"px-5 py-3.5 border-b border-white/10 flex items-center justify-between bg-space-900/80",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 rounded-lg bg-[#2481CC]/20 border border-[#2481CC]/40 flex items-center justify-center text-lg",children:r.emoji||"🤖"}),e.jsxs("div",{children:[e.jsxs("div",{className:"text-xs text-pearl-100 font-bold flex items-center gap-2",children:[e.jsx("span",{children:r.name}),r.isBotDefault&&e.jsx("span",{className:"px-1.5 py-0.2 rounded text-[9px] font-mono bg-emerald-500/20 text-emerald-300",children:"LIVE ON BOT"})]}),e.jsxs("div",{className:"text-[10px] font-mono text-[#2481CC]",children:[r.model," · Temp: ",r.temperature]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>B([]),className:"p-1.5 text-pearl-400 hover:text-pearl-100 rounded-lg hover:bg-white/5 transition-colors",title:"Clear Chat History",children:e.jsx(qs,{className:"w-3.5 h-3.5"})}),e.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] font-mono text-emerald-400 bg-emerald-500/10 px-2.5 py-1 rounded-full border border-emerald-500/20",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-emerald-400 animate-pulse"}),e.jsx("span",{children:"Sandbox Ready"})]})]})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-4 sm:p-5 space-y-4 custom-scrollbar",children:[le.length===0?e.jsxs("div",{className:"h-full flex flex-col items-center justify-center text-center p-6 text-pearl-400 space-y-2",children:[e.jsx("div",{className:"w-12 h-12 rounded-2xl bg-space-850 flex items-center justify-center text-2xl",children:r.emoji||"🤖"}),e.jsxs("div",{className:"text-xs font-semibold text-pearl-200",children:["Ready to test ",r.name]}),e.jsx("p",{className:"text-[11px] max-w-xs text-pearl-400",children:"Click a quick test prompt below or type your own question to see how this agent responds to your Telegram subscribers."})]}):le.map((S,T)=>e.jsxs("div",{className:`flex flex-col ${S.role==="user"?"items-end":"items-start"}`,children:[e.jsx("div",{className:`max-w-[85%] rounded-2xl px-4 py-3 text-xs leading-relaxed font-sans ${S.role==="user"?"bg-[#2B5278] border border-[#6AB2F2]/30 text-white rounded-br-sm shadow-md":"bg-[#182533] border border-white/10 text-slate-100 rounded-bl-sm shadow-md"}`,children:S.content}),S.tokens!==void 0&&e.jsxs("span",{className:"text-[9px] font-mono text-pearl-400 mt-1 px-1",children:[S.tokens," tokens · $",S.costCents]})]},T)),pe&&e.jsxs("div",{className:"flex items-center gap-2 text-xs font-mono text-[#2481CC] p-2 bg-space-950/60 rounded-xl border border-white/5 w-fit",children:[e.jsx(ue,{className:"w-3.5 h-3.5 animate-spin"}),e.jsxs("span",{children:["Generating completion from ",r.model,"..."]})]})]}),e.jsxs("div",{className:"px-4 py-2 border-t border-white/10 bg-space-950/60 flex items-center gap-1.5 overflow-x-auto no-scrollbar",children:[e.jsxs("span",{className:"text-[10px] font-mono text-pearl-400 uppercase tracking-wider shrink-0 flex items-center gap-1",children:[e.jsx(je,{className:"w-3 h-3 text-[#2481CC]"})," Test:"]}),["What services do you offer?","How much is VIP access?","Aap kaun hain?","How can I get support?"].map(S=>e.jsxs("button",{type:"button",onClick:()=>Pe(S),className:"px-2.5 py-1 rounded-lg text-[11px] font-mono bg-space-900 border border-white/10 hover:border-[#2481CC] text-pearl-300 hover:text-white shrink-0 transition-colors",children:['"',S,'"']},S))]}),e.jsxs("form",{onSubmit:S=>{S.preventDefault(),Pe()},className:"p-3.5 border-t border-white/10 flex items-center gap-2 bg-space-900",children:[e.jsx("input",{type:"text",value:J,onChange:S=>G(S.target.value),placeholder:"Ask anything (e.g. How do I start my bot?)...",className:"flex-1 px-4 py-2.5 rounded-xl bg-space-950 border border-white/10 text-xs font-mono text-pearl-100 focus:outline-none focus:border-[#2481CC]"}),e.jsx("button",{type:"submit",disabled:pe||!J.trim(),className:"btn-telegram-primary py-2.5 px-4 shadow-telegram",children:e.jsx(we,{className:"w-3.5 h-3.5"})})]})]})]}),h&&e.jsx(xe,{children:e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-3 sm:p-4 bg-black/75 backdrop-blur-md",children:e.jsxs("div",{className:"w-full max-w-xl max-h-[92vh] flex flex-col astraea-card rounded-2xl border border-[#2481CC]/40 shadow-2xl animate-in zoom-in-95 duration-200 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between px-5 py-4 border-b border-white/10 bg-space-900/90 shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("div",{className:"w-9 h-9 rounded-xl bg-[#2481CC]/20 border border-[#2481CC]/40 text-[#2481CC] flex items-center justify-center",children:e.jsx(Me,{className:"w-5 h-5"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-base sm:text-lg text-pearl-50 font-bold tracking-tight",children:x?`Edit Agent: ${x.name}`:"Create New AI Agent"}),e.jsx("p",{className:"text-xs text-pearl-400",children:"Configure personality, instructions, and intelligence level."})]})]}),e.jsx("button",{onClick:()=>u(!1),className:"text-pearl-400 hover:text-pearl-100 p-1.5 rounded-lg hover:bg-white/5",children:e.jsx(ae,{className:"w-5 h-5"})})]}),e.jsxs("form",{onSubmit:be,className:"flex-1 overflow-y-auto p-5 sm:p-6 space-y-5 custom-scrollbar",children:[!x&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-[11px] font-mono text-pearl-400 uppercase font-semibold",children:"Auto-fill from Preset (Optional):"}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:Ss.map(S=>e.jsxs("button",{type:"button",onClick:()=>{g(S.name),c(S.emoji),p(S.model),k(S.systemPrompt),A(S.temperature)},className:"px-2.5 py-1.5 rounded-lg text-xs font-mono bg-space-900 border border-white/10 hover:border-[#2481CC] text-pearl-300 hover:text-white flex items-center gap-1.5 transition-colors",children:[e.jsx("span",{children:S.emoji}),e.jsx("span",{children:S.name})]},S.id))})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-4 gap-3",children:[e.jsxs("div",{className:"sm:col-span-1",children:[e.jsx("label",{className:"text-[11px] font-mono text-pearl-300 mb-1 block",children:"Emoji Icon"}),e.jsx("input",{type:"text",maxLength:2,value:v,onChange:S=>c(S.target.value),className:"w-full text-center py-2.5 rounded-xl bg-space-950 border border-white/10 text-xl font-bold"})]}),e.jsxs("div",{className:"sm:col-span-3",children:[e.jsx("label",{className:"text-[11px] font-mono text-pearl-300 mb-1 block",children:"Agent Name"}),e.jsx("input",{type:"text",required:!0,placeholder:"e.g. VIP Concierge",value:f,onChange:S=>g(S.target.value),className:"w-full px-3.5 py-2.5 rounded-xl bg-space-950 border border-white/10 text-xs font-mono text-pearl-100 focus:border-[#2481CC] focus:outline-none"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-xs font-mono font-bold uppercase text-pearl-200",children:"Intelligence & Language Model"}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-2",children:[{id:"gpt-4o-mini",label:"GPT-4o Mini",desc:"Ultra Fast & Efficient (Recommended)",badge:"⚡ FAST"},{id:"gpt-4o",label:"OpenAI GPT-4o",desc:"State of the Art Reasoning",badge:"🌟 SMART"},{id:"anthropic/claude-3.5-sonnet",label:"Claude 3.5 Sonnet",desc:"Superior Writing & Tone",badge:"🧠 REASONING"}].map(S=>e.jsxs("button",{type:"button",onClick:()=>p(S.id),className:`p-3 rounded-xl border text-left transition-all ${w===S.id?"bg-[#2481CC]/20 border-[#2481CC] text-white shadow-telegram":"bg-space-950/60 border-white/10 text-pearl-400 hover:text-pearl-200 hover:bg-space-900"}`,children:[e.jsxs("div",{className:"flex items-center justify-between text-xs font-bold font-sans",children:[e.jsx("span",{children:S.label}),e.jsx("span",{className:"text-[9px] font-mono px-1 rounded bg-[#2481CC]/20 text-[#2481CC]",children:S.badge})]}),e.jsx("div",{className:"text-[10px] text-pearl-400 mt-1",children:S.desc})]},S.id))})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-[11px] font-mono text-pearl-300 block",children:"Personality Tone Presets:"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:[{label:"🎩 Professional & Polite",addition:"Maintain a professional, polite, and refined tone."},{label:"⚡ Direct & Concise",addition:"Be extremely direct, concise, and to-the-point with zero fluff."},{label:"😊 Friendly & Casual",addition:"Be warm, friendly, approachable, and engaging."},{label:"🇮🇳 Hindi / Hinglish Friendly",addition:"User ke sath Hindi ya Hinglish me naturally communicate karein."}].map(S=>e.jsx("button",{type:"button",onClick:()=>{N.includes(S.addition)||k(T=>T?`${T}