Created At: 2026-11-18T17:14:57Z Completed At: 2026-11-18T17:14:59Z Command exited with code 0. Command output: core/event_bus.py:45: def subscribe(self, event_type: type[DomainEvent], handler: EventHandler) -> None: grep: core/__pycache__/event_bus.cpython-312.pyc: binary file matches apps/frontend/src/components/pages/AIAgentsPage.tsx:74: description: 'Resolves subscriber FAQs, guides users with step-by-step instructions, and provides assistance.', apps/frontend/src/components/pages/AIAgentsPage.tsx:78: '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.', apps/frontend/src/components/pages/AIAgentsPage.tsx:91: description: 'Explains premium subscriptions, exclusive perks, and converts free subscribers into paying members.', apps/frontend/src/components/pages/AIAgentsPage.tsx:108: description: 'Automatically detects the subscriber language (Hindi, Hinglish, English) and chats fluently.', apps/frontend/src/components/pages/AIAgentsPage.tsx:231: content: '🌟 Namaste & Welcome! I am your autonomous AI Assistant. How may I assist your Telegram bot subscribers today?', apps/frontend/src/components/pages/AIAgentsPage.tsx:691: Click a quick test prompt below or type your own question to see how this agent responds to your Telegram subscribers. apps/frontend/src/components/pages/AIAgentsPage.tsx:929: placeholder="Describe how the agent should behave and answer subscriber questions..." apps/frontend/src/components/pages/LanguagesPage.tsx:132: Localized replies and multi-language strings are synced with @{currentBot.username} subscribers in 16 languages. apps/frontend/src/components/pages/UsersPage.tsx:130: Real-time subscriber directory. Inspect preferred languages, bot block states, and broadcast opt-out toggles (/stop or /optout compliance). apps/frontend/src/components/pages/UsersPage.tsx:177: Managing user profiles, locale preferences, and block states for subscribers of @{currentBot.username} ({currentBot.usersCount.toLocaleString()} total members). apps/frontend/src/components/pages/MarketplacePage.tsx:261: headline: 'Grow your Telegram channel rapidly with trackable subscriber invite links.', apps/frontend/src/components/pages/MarketplacePage.tsx:394: mcpTools: ['github.repo.subscribe', 'github.pr.merge'], apps/frontend/src/components/pages/MarketplacePage.tsx:428: mcpTools: ['blockchain.whale.subscribe'], apps/frontend/src/components/pages/BroadcastsPage.tsx:193: Broadcasts dispatched here will be delivered from @{currentBot.username} to its {currentBot.usersCount.toLocaleString()} active subscribers with automatic Telegram rate-limiting. apps/frontend/src/components/pages/BroadcastsPage.tsx:405: Blocked users and opted-out subscribers (/stop or /optout) will be strictly excluded automatically before dispatch. apps/frontend/src/components/pages/MCPProPage.tsx:111: description: 'Retrieves platform telemetry, active subscribers, and operational KPIs for the tenant.', apps/frontend/src/components/pages/BotDetailsPage.tsx:92: description: 'Generates subscriber deep-link invite links (/start ref_{userId}), tracks successful signups, awards points, and calculates balances.', apps/frontend/src/components/pages/BotDetailsPage.tsx:121: description: 'Real-time subscriber tracking, interaction count, automatic BCP 47 language preference detection, and block state auditing.', apps/frontend/src/components/pages/BotDetailsPage.tsx:135: description: 'Matches subscriber text against trigger keywords and forbidden words. Provides instantaneous auto-replies or warnings.', apps/frontend/src/components/pages/HomePage.tsx:668: desc: 'Dispatches 25 msgs/sec compliant rich announcements to thousands of subscribers with real-time delivery tracking.', apps/frontend/src/components/pages/HomePage.tsx:689: desc: 'Comprehensive subscriber directory, custom tags, ban/unban controls, activity history, and engagement analytics.', apps/frontend/src/components/pages/HomePage.tsx:1056: Large networks, unlimited subscribers, isolated databases, and 99.98% SLA. apps/frontend/src/components/modules/ModuleConfigModal.tsx:981: { label: '📚 FAQ Specialist', prompt: 'You are a concise FAQ specialist. Answer subscriber queries with clear, numbered bullet points and helpful links.' }, apps/frontend/src/components/modules/ModuleConfigModal.tsx:1007: When subscriber sends normal text (not a command), reply using AI apps/frontend/src/components/modules/ModuleConfigModal.tsx:1048:
tags"})]}),e.jsx("div",{className:"flex gap-1.5",children:["HTML","MarkdownV2"].map(w=>e.jsx("button",{type:"button",onClick:()=>N("parse_mode",w),className:`px-3 py-1.5 rounded-lg text-xs font-mono font-semibold transition-colors ${(r.parse_mode||"HTML")===w?"bg-[#2481CC] text-white shadow-telegram":"bg-space-900 text-pearl-400 hover:text-pearl-200"}`,children:w},w))})]}),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 w=r.buttons||[];N("buttons",[...w,[{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(ee,{className:"w-3.5 h-3.5"})," Add Button Row"]})]}),e.jsx("div",{className:"space-y-2",children:(r.buttons||[]).map((w,S)=>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 ",S+1]}),e.jsx("button",{type:"button",onClick:()=>{const P=[...r.buttons];P.splice(S,1),N("buttons",P)},className:"text-rose-400 hover:text-rose-300 p-1",children:e.jsx(et,{className:"w-3.5 h-3.5"})})]}),w.map((P,k)=>e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:[e.jsx("input",{type:"text",value:P.text||"",onChange:L=>{const M=[...r.buttons];M[S][k].text=L.target.value,N("buttons",M)},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:L=>{const M=[...r.buttons];L.target.value.startsWith("http")?(delete M[S][k].callback_data,M[S][k].url=L.target.value):(delete M[S][k].url,M[S][k].callback_data=L.target.value),N("buttons",M)},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"})]},k))]},S))})]})]}),n.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:r.points_per_referral??10,onChange:w=>N("points_per_referral",parseInt(w.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:r.welcome_bonus_points??5,onChange:w=>N("welcome_bonus_points",parseInt(w.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:r.min_payout_points??50,onChange:w=>N("min_payout_points",parseInt(w.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:r.invite_message||"",onChange:w=>N("invite_message",w.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(w=>e.jsx("span",{className:"px-1.5 py-0.5 rounded bg-space-900 text-pearl-300 border border-white/5",children:w},w))]})]})]}),n.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 w=r.rules||[];N("rules",[...w,{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(ee,{className:"w-3.5 h-3.5"})," Add Keyword Rule"]})]}),e.jsx("div",{className:"space-y-2.5",children:(r.rules||[]).map((w,S)=>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:w.trigger||"",onChange:P=>{const k=[...r.rules];k[S].trigger=P.target.value,N("rules",k)},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:w.match_type||"contains",onChange:P=>{const k=[...r.rules];k[S].match_type=P.target.value,N("rules",k)},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=[...r.rules];P.splice(S,1),N("rules",P)},className:"text-rose-400 hover:text-rose-300 p-1.5",children:e.jsx(et,{className:"w-4 h-4"})})]}),e.jsx("input",{type:"text",placeholder:"Auto-response message sent to user",value:w.response||"",onChange:P=>{const k=[...r.rules];k[S].response=P.target.value,N("rules",k)},className:"w-full px-3 py-1.5 rounded-lg bg-space-900 border border-white/10 text-xs font-mono text-emerald-300"})]},S))})]}),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:v,onChange:w=>h(w.target.value),onKeyDown:w=>{if(w.key==="Enter"&&(w.preventDefault(),v.trim())){const S=r.blocked_words||[];N("blocked_words",[...S,v.trim()]),h("")}},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(v.trim()){const w=r.blocked_words||[];N("blocked_words",[...w,v.trim()]),h("")}},className:"btn-telegram-secondary px-3 text-xs",children:"Add"})]}),e.jsx("div",{className:"flex flex-wrap gap-1.5 pt-1",children:(r.blocked_words||[]).map((w,S)=>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:[w,e.jsx("button",{type:"button",onClick:()=>{const P=[...r.blocked_words];P.splice(S,1),N("blocked_words",P)},className:"hover:text-rose-100",children:"×"})]},S))})]}),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:r.action_on_blocked||"warn",onChange:w=>N("action_on_blocked",w.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"})]})]})]}),n.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:r.model||"gpt-4o-mini",onChange:w=>N("model",w.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 (",r.temperature??.5,")"]}),e.jsx("input",{type:"range",min:0,max:1,step:.1,value:r.temperature??.5,onChange:w=>N("temperature",parseFloat(w.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(w=>e.jsx("button",{type:"button",onClick:()=>N("system_prompt",w.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:w.label},w.label))}),e.jsx("textarea",{rows:4,value:r.system_prompt||"",onChange:w=>N("system_prompt",w.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:r.enable_fallback??!1,onChange:w=>N("enable_fallback",w.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]"})]})]})]}),n.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:[r.rate_limit_per_second??25," msgs/sec"]})]}),e.jsx("input",{type:"range",min:5,max:30,value:r.rate_limit_per_second??25,onChange:w=>N("rate_limit_per_second",parseInt(w.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:r.allow_opt_out??!0,onChange:w=>N("allow_opt_out",w.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]"})]})]})]}),n.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:r.currency||"INR",onChange:w=>N("currency",w.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:r.gateway||"razorpay",onChange:w=>N("gateway",w.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 ⭐"})]})]})]})}),n.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:r.grace_period_days??3,onChange:w=>N("grace_period_days",parseInt(w.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"})]})}),n.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:r.auto_detect_locale??!0,onChange:w=>N("auto_detect_locale",w.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]"})]})]})}),e.jsxs("div",{className:"pt-2 border-t border-white/10",children:[e.jsxs("button",{type:"button",onClick:()=>x(!m),className:"text-[11px] font-mono text-pearl-400 hover:text-[#2481CC] flex items-center gap-1.5 transition-colors",children:[e.jsx(Fs,{className:"w-3.5 h-3.5"}),e.jsxs("span",{children:["Advanced Developer Mode: ",m?"Hide Raw JSON":"View Raw JSON"]}),m?e.jsx(Ts,{className:"w-3.5 h-3.5"}):e.jsx(Vt,{className:"w-3.5 h-3.5"})]}),m&&e.jsxs("div",{className:"mt-3 space-y-2 animate-in fade-in",children:[e.jsx("textarea",{rows:6,value:f,onChange:w=>p(w.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."})]})]}),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:l,className:"btn-telegram-secondary py-2 px-4 justify-center text-xs",children:"CANCEL"}),e.jsxs("button",{type:"submit",disabled:j,className:"btn-telegram-primary py-2 px-6 justify-center inline-flex items-center gap-2 shadow-telegram text-xs font-bold",children:[j?e.jsx(me,{className:"w-4 h-4 animate-spin"}):e.jsx(bt,{className:"w-4 h-4"}),e.jsx("span",{children:"SAVE MODULE SETTINGS"})]})]})]})]})})})},ri=[{id:"welcome_message",name:"Welcome Message & Onboarding",category:"engagement",icon:J,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,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:q,version:"1.1.0",description:"Enforces mandatory channel/group membership before unlocking bot commands. Verifies status via getChatMember.",is_installed:!0,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",icon:ut,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,config:{points_per_referral:10,welcome_bonus_points:5,min_payout_points:50}},{id:"broadcasts",name:"Broadcast & Announcement Pipeline",category:"messaging",icon:pe,version:"2.0.0",description:"Token-bucket broadcasts (25 msgs/sec), audience filtering, language targeting, and /optout compliance.",is_installed:!0,is_enabled:!0,config:{rate_limit_per_second:25,allow_opt_out:!0}},{id:"user_management",name:"Audience & Subscriber Directory",category:"management",icon:Ae,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,config:{auto_detect_locale:!0,track_interactions:!0}},{id:"auto_filter",name:"Auto Filter & Keyword Responder",category:"automation",icon:Gt,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,config:{rules_count:3,blocked_words:["scam","free nitro","hack"]}},{id:"payments",name:"In-Chat Payments & Invoicing",category:"monetization",icon:Ve,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,config:{currency:"INR",gateway:"razorpay"}},{id:"subscriptions",name:"VIP Subscriptions & Gated Access",category:"monetization",icon:rt,version:"1.3.0",description:"Subscription tiers, membership access duration tracking, automated renewal prompts, and grace period protection.",is_installed:!0,is_enabled:!1,config:{tiers_count:2,grace_period_days:3}},{id:"ai_assistant",name:"Autonomous AI Customer Concierge",category:"ai",icon:fe,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,config:{model:"gpt-4o-mini",temperature:.5}},{id:"logs_tracker",name:"Activity Logs & Channel Audit",category:"security",icon:Ie,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,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}}],ni=({botId:t,onNavigate:s})=>{const{slug:n}=aa(),a=ce(),{currentBot:l,selectBot:r}=z(),o=t||n||(l==null?void 0:l.id)||"astraea-flagship";i.useEffect(()=>{n&&r(n)},[n]);const j=l||{name:"Astraea Concierge Bot",username:"astraea_flagship_bot"},[b,m]=i.useState(ri),[x,f]=i.useState("modules"),[p,g]=i.useState(null),[u,d]=i.useState("{}"),[c,v]=i.useState(!1),[h,N]=i.useState(null);i.useEffect(()=>{async function S(){try{const P=await fetch(`/api/v1/bots/${o}/modules`);if(P.ok){const k=await P.json();if(k.data&&Array.isArray(k.data)){const L={welcome_message:J,force_join:q,referrals:ut,broadcasts:pe,user_management:Ae,auto_filter:Gt,payments:Ve,subscriptions:rt,ai_assistant:fe,logs_tracker:Ie},M=k.data.map(_=>({id:_.id,name:_.name,category:_.category,icon:L[_.id]||Ge,version:_.version,description:_.description,is_installed:_.is_installed,is_enabled:_.is_enabled,config:_.config||{}}));m(M)}}}catch{}}S()},[o]);const y=async(S,P)=>{const k=!P;m(L=>L.map(M=>M.id===S?{...M,is_enabled:k}:M));try{await fetch(`/api/v1/bots/${o}/modules/${S}/toggle`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({is_enabled:k})}),N(`Module ${S} ${k?"activated":"deactivated"} in backend runtime!`),setTimeout(()=>N(null),2500)}catch{N("Module toggle saved."),setTimeout(()=>N(null),2e3)}},E=S=>{g(S)},w=async S=>{if(p){v(!0);try{await fetch(`/api/v1/bots/${o}/modules/${p.id}/config`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({config:S})}),m(P=>P.map(k=>k.id===p.id?{...k,config:S}:k)),N(`Configuration for ${p.name} updated successfully!`),g(null),setTimeout(()=>N(null),2500)}catch{m(P=>P.map(k=>k.id===p.id?{...k,config:S}:k)),N(`Configuration for ${p.name} saved!`),g(null),setTimeout(()=>N(null),2500)}finally{v(!1)}}};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(Q,{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:j.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/${j.username}`,target:"_blank",rel:"noopener noreferrer",className:"text-[#2481CC] font-bold hover:underline flex items-center gap-1",children:[e.jsxs("span",{children:["@",j.username]}),e.jsx(ge,{className:"w-3 h-3"})]}),e.jsx("span",{className:"hidden sm:inline",children:"·"}),e.jsxs("span",{className:"text-pearl-400",children:["ID: ",o]}),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/${j.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(ge,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"TEST IN TELEGRAM"})]}),e.jsx(A,{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(A,{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(ua,{bot:l,onOpenTemplates:()=>a("/marketplace"),onOpenConnectModal:()=>a("/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(F,{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(F,{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(ht,{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"})})]})}),h&&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(F,{className:"w-4 h-4 text-emerald-400 shrink-0"}),e.jsx("span",{children:h})]}),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:()=>f("modules"),className:`px-4 py-2 text-xs font-mono uppercase tracking-wider rounded-xl transition-all flex items-center gap-2 shrink-0 ${x==="modules"?"bg-[#2481CC] text-white font-bold shadow-sm":"text-pearl-400 hover:text-pearl-100 hover:bg-white/5"}`,children:[e.jsx(Pe,{className:"w-3.5 h-3.5"}),e.jsxs("span",{children:["Modular Feature System (",b.filter(S=>S.is_enabled).length," Active)"]})]}),e.jsxs("button",{onClick:()=>f("telemetry"),className:`px-4 py-2 text-xs font-mono uppercase tracking-wider rounded-xl transition-all flex items-center gap-2 shrink-0 ${x==="telemetry"?"bg-[#2481CC] text-white font-bold shadow-sm":"text-pearl-400 hover:text-pearl-100 hover:bg-white/5"}`,children:[e.jsx(Ie,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"Cloud Telemetry & Vault"})]}),e.jsxs("button",{onClick:()=>f("commands"),className:`px-4 py-2 text-xs font-mono uppercase tracking-wider rounded-xl transition-all flex items-center gap-2 shrink-0 ${x==="commands"?"bg-[#2481CC] text-white font-bold shadow-sm":"text-pearl-400 hover:text-pearl-100 hover:bg-white/5"}`,children:[e.jsx(dt,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"Telegram Commands"})]})]}),x==="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.jsx("h3",{className:"text-lg text-pearl-50 font-bold tracking-tight",children:"Modular Bot Features"}),e.jsx("p",{className:"text-xs text-pearl-400 font-sans mt-0.5",children:"Every bot has independent modular capabilities. Toggles directly control backend webhook execution."})]}),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:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:b.map(S=>{const P=S.icon;return e.jsxs("div",{className:`astraea-card rounded-2xl p-5 flex flex-col justify-between transition-all ${S.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(P,{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 ${S.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:S.is_enabled?"ACTIVE":"DEACTIVATED"}),e.jsx("button",{type:"button",onClick:()=>y(S.id,S.is_enabled),className:`w-11 h-6 rounded-full p-1 transition-colors relative ${S.is_enabled?"bg-[#2481CC]":"bg-space-800 border border-white/20"}`,title:`Click to ${S.is_enabled?"deactivate":"activate"}`,children:e.jsx("div",{className:`w-4 h-4 rounded-full bg-white transition-transform ${S.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:S.name}),e.jsx("p",{className:"text-xs font-sans text-pearl-300 mt-1.5 leading-relaxed",children:S.description})]}),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",S.version," · ",S.category]}),e.jsxs("button",{type:"button",onClick:()=>E(S),className:"btn-telegram-secondary py-1 px-3 text-[10px] gap-1",children:[e.jsx(at,{className:"w-3 h-3 text-[#2481CC]"}),e.jsx("span",{children:"CONFIGURE"})]})]})]},S.id)})})]}),x==="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(Wt,{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(q,{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(pe,{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/",o]})]}),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(fe,{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)"})]})]})]})]}),x==="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(dt,{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((S,P)=>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:S.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:S.role})]}),e.jsx("p",{className:"text-[11px] text-pearl-300 font-sans leading-relaxed",children:S.desc})]},P))})]}),p&&e.jsx(ai,{botId:o,botUsername:j.username||"mybot",module:p,onSave:w,onClose:()=>g(null)})]})},li=[{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."}],ii=()=>{const{currentBot:t}=z(),[s,n]=i.useState(li),[a,l]=i.useState(!1),[r,o]=i.useState(""),[j,b]=i.useState(""),[m,x]=i.useState("all"),[f,p]=i.useState(25),[g,u]=i.useState(!1),d=async h=>{if(h.preventDefault(),!(!r.trim()||!j.trim())){u(!0);try{const N={bot_id:t.id,title:r,message_text:j,target_filter:m==="all"?{}:{locale:m},rate_limit_per_second:f,inline_keyboard:[[{text:"Explore Now 🌟",url:"https://example.com"}]]},y=await fetch("/api/v1/broadcasts",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(N)}),E={id:`c-${Date.now()}`,title:r,status:"draft",totalRecipients:t.usersCount||14280,deliveredCount:0,failedCount:0,rateLimitPerSec:f,targetLocale:m==="all"?void 0:m,messageSnippet:j.slice(0,70)};n([E,...s]),l(!1),o(""),b("")}catch{l(!1)}finally{u(!1)}}},c=h=>{n(N=>N.map(y=>y.id===h?{...y,status:"running",startedAt:new Date().toISOString(),deliveredCount:Math.floor(y.totalRecipients*.98)}:y))},v=h=>{n(N=>N.map(y=>y.id!==h?y:{...y,status:y.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:()=>l(!0),className:"btn-telegram-primary w-full sm:w-auto justify-center py-2.5 px-4 shrink-0 shadow-telegram",children:[e.jsx(ee,{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(h=>{const N=h.totalRecipients>0?Math.round(h.deliveredCount/h.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:h.title}),e.jsx("div",{className:"text-[11px] font-sans text-pearl-400 truncate max-w-md mt-0.5",children:h.messageSnippet})]}),e.jsx("td",{className:"py-4 text-pearl-300",children:h.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: ",h.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 ${h.status==="completed"?"bg-emerald-500/10 text-emerald-300 border border-emerald-500/30":h.status==="running"?"bg-[#2481CC]/15 text-[#2481CC] border border-[#2481CC]/40 animate-pulse":h.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:h.status})}),e.jsxs("td",{className:"py-4 text-pearl-200",children:[e.jsxs("div",{children:[h.deliveredCount.toLocaleString()," / ",h.totalRecipients.toLocaleString()]}),h.failedCount>0&&e.jsxs("div",{className:"text-[10px] text-rose-400",children:[h.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 (",h.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:[h.status==="draft"&&e.jsxs("button",{onClick:()=>c(h.id),className:"btn-telegram-primary py-1 px-3 text-[10px] shadow-telegram",children:[e.jsx($e,{className:"w-3 h-3"}),e.jsx("span",{children:"DISPATCH"})]}),(h.status==="running"||h.status==="paused")&&e.jsxs("button",{onClick:()=>v(h.id),className:"btn-telegram-secondary py-1 px-2.5 text-[10px]",children:[h.status==="running"?e.jsx(Xa,{className:"w-3 h-3 text-amber-400"}):e.jsx($e,{className:"w-3 h-3 text-emerald-400"}),e.jsx("span",{children:h.status==="running"?"PAUSE":"RESUME"})]}),h.status==="completed"&&e.jsxs("span",{className:"text-[10px] text-emerald-400 flex items-center gap-1 justify-end",children:[e.jsx(F,{className:"w-3.5 h-3.5"})," Delivered"]})]})})]},h.id)})})]})})}),a&&e.jsx(te,{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:()=>l(!1),className:"text-pearl-400 hover:text-pearl-100 p-1",children:e.jsx(H,{className:"w-5 h-5"})})]}),e.jsxs("form",{onSubmit:d,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:r,onChange:h=>o(h.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:j,onChange:h=>b(h.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:m,onChange:h=>x(h.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:f,onChange:h=>p(Number(h.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(J,{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:()=>l(!1),className:"btn-telegram-secondary py-2 px-4",children:"CANCEL"}),e.jsxs("button",{type:"submit",disabled:g,className:"btn-telegram-primary py-2 px-5 shadow-telegram",children:[e.jsx(oe,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"SAVE CAMPAIGN"})]})]})]})]})})})]})},js=[{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?"]}],vs=[{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}],oi=()=>{const{currentBot:t}=z(),[s,n]=i.useState(vs),[a,l]=i.useState(vs[0]),[r,o]=i.useState(null),[j,b]=i.useState(!1),[m,x]=i.useState(null),[f,p]=i.useState(!1),[g,u]=i.useState(""),[d,c]=i.useState("🤖"),[v,h]=i.useState("gpt-4o-mini"),[N,y]=i.useState(""),[E,w]=i.useState(.5),[S,P]=i.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"}]),[k,L]=i.useState(""),[M,_]=i.useState(""),[Y,K]=i.useState("openai"),[ne,I]=i.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}]),[$,O]=i.useState(""),[le,he]=i.useState(!1),Z=C=>{o(C),setTimeout(()=>o(null),3e3)},Se=C=>{C?(x(null),u(C.name),c(C.emoji),h(C.model),y(C.systemPrompt),w(C.temperature)):(x(null),u("New AI Concierge"),c("🤖"),h("gpt-4o-mini"),y("You are a polite, helpful AI Assistant for this Telegram bot."),w(.5)),b(!0)},_e=(C,B)=>{B==null||B.stopPropagation(),x(C),u(C.name),c(C.emoji||"🤖"),h(C.model),y(C.systemPrompt),w(C.temperature),b(!0)},Ee=C=>{if(C.preventDefault(),!!g.trim()){if(m){const B={...m,name:g.trim(),emoji:d,model:v,systemPrompt:N.trim(),temperature:E};n(R=>R.map(V=>V.id===m.id?B:V)),a.id===m.id&&l(B),Z(`Agent "${B.name}" updated successfully!`)}else{const B={id:`agent-${Date.now()}`,name:g.trim(),emoji:d,provider:v.includes("claude")?"openrouter":"openai",model:v,systemPrompt:N.trim()||"You are a helpful Telegram bot AI assistant.",temperature:E,maxTokens:1e3,isActive:!0,isBotDefault:!1,totalTokens:0};n(R=>[B,...R]),l(B),Z(`New AI Agent "${B.name}" deployed!`)}b(!1)}},Ne=(C,B)=>{if(B.stopPropagation(),s.length<=1){alert("You must retain at least one configured AI agent.");return}const R=s.filter(V=>V.id!==C);n(R),a.id===C&&l(R[0]),Z("Agent removed.")},Re=C=>{n(B=>B.map(R=>({...R,isBotDefault:R.id===C.id}))),l({...C,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:C.model,system_prompt:C.systemPrompt,temperature:C.temperature,enable_fallback:!0}})}).catch(()=>{}),Z(`✅ "${C.name}" is now the active AI Assistant for @${(t==null?void 0:t.username)||"bot"}!`)},Me=async C=>{const B=(C||$).trim();if(!(!B||le)){O(""),I(R=>[...R,{role:"user",content:B}]),he(!0);try{const R=await fetch(`/api/v1/ai/agents/${a.id}/chat`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({message:B})});if(R.ok){const V=await R.json();I(re=>{var de,xe,se;return[...re,{role:"assistant",content:((de=V.data)==null?void 0:de.content)||"Completion generated successfully.",tokens:((xe=V.data)==null?void 0:xe.total_tokens)||48,costCents:((se=V.data)==null?void 0:se.cost_cents)||.002}]})}else setTimeout(()=>{let V=`🤖 [${a.name}]: I have received your query regarding "${B}". All systems operational.`;B.toLowerCase().includes("vip")||B.toLowerCase().includes("cost")?V="💎 VIP Membership is available in Monthly (₹999) and Annual (₹9,999) tiers. You get instant access, zero ads, and 24/7 priority execution!":B.toLowerCase().includes("support")||B.toLowerCase().includes("help")?V="🎧 I am here 24/7 to help! You can ask me any question about our services or type /commands to explore bot tools.":(B.toLowerCase().includes("kaun")||B.toLowerCase().includes("kya"))&&(V=`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!`),I(re=>[...re,{role:"assistant",content:V,tokens:45,costCents:.0018}])},500)}catch{setTimeout(()=>{I(R=>[...R,{role:"assistant",content:`🤖 [${a.name}]: Operational response to "${B}".`,tokens:35,costCents:.0015}])},500)}finally{he(!1)}}};return e.jsxs("div",{className:"space-y-8 animate-in fade-in duration-300 min-w-0 max-w-full",children:[r&&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(F,{className:"w-4 h-4 text-emerald-400"}),e.jsx("span",{children:r})]}),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:()=>p(!0),className:"btn-telegram-secondary flex-1 sm:flex-initial justify-center py-2.5 px-3.5 text-xs",children:[e.jsx(es,{className:"w-3.5 h-3.5 text-[#2481CC]"}),e.jsx("span",{children:"API KEYS VAULT"})]}),e.jsxs("button",{onClick:()=>Se(),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(ee,{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(J,{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:js.map(C=>e.jsxs("div",{onClick:()=>Se(C),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:C.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:C.badge})]}),e.jsx("h4",{className:"text-xs font-bold text-pearl-100 group-hover:text-[#2481CC] transition-colors leading-tight",children:C.name}),e.jsx("p",{className:"text-[11px] text-pearl-400 font-sans mt-1 line-clamp-2 leading-relaxed",children:C.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:"→"})]})]},C.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(C=>C.isActive).length," ACTIVE"]})]}),e.jsx("div",{className:"space-y-3",children:s.map(C=>{const B=C.id===a.id;return e.jsxs("div",{onClick:()=>l(C),className:`p-4 rounded-xl border cursor-pointer transition-all ${B?"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:C.emoji||"🤖"}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm text-pearl-50 font-bold leading-tight",children:C.name}),e.jsxs("div",{className:"text-[10px] font-mono text-[#2481CC] mt-0.5",children:[C.model," · Temp: ",C.temperature]})]})]}),e.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[C.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($s,{className:"w-2.5 h-2.5 fill-current"})," BOT AI"]}),e.jsx("button",{onClick:R=>_e(C,R),className:"p-1.5 rounded-lg text-pearl-400 hover:text-white hover:bg-white/10 transition-colors",title:"Edit Agent",children:e.jsx(er,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:R=>Ne(C.id,R),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(et,{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:['"',C.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:R=>{R.stopPropagation(),Re(C)},className:`px-2 py-1 rounded-md text-[10px] font-mono transition-colors font-semibold ${C.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:C.isBotDefault?"✓ Assigned to Bot":"⭐ Set as Bot AI"}),e.jsxs("span",{className:"text-pearl-400",children:["Tokens: ",C.totalTokens.toLocaleString()]})]})]},C.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:a.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:a.name}),a.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:[a.model," · Temp: ",a.temperature]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>I([]),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(Us,{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:[ne.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:a.emoji||"🤖"}),e.jsxs("div",{className:"text-xs font-semibold text-pearl-200",children:["Ready to test ",a.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."})]}):ne.map((C,B)=>e.jsxs("div",{className:`flex flex-col ${C.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 ${C.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:C.content}),C.tokens!==void 0&&e.jsxs("span",{className:"text-[9px] font-mono text-pearl-400 mt-1 px-1",children:[C.tokens," tokens · $",C.costCents]})]},B)),le&&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(me,{className:"w-3.5 h-3.5 animate-spin"}),e.jsxs("span",{children:["Generating completion from ",a.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(Ge,{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(C=>e.jsxs("button",{type:"button",onClick:()=>Me(C),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:['"',C,'"']},C))]}),e.jsxs("form",{onSubmit:C=>{C.preventDefault(),Me()},className:"p-3.5 border-t border-white/10 flex items-center gap-2 bg-space-900",children:[e.jsx("input",{type:"text",value:$,onChange:C=>O(C.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:le||!$.trim(),className:"btn-telegram-primary py-2.5 px-4 shadow-telegram",children:e.jsx(oe,{className:"w-3.5 h-3.5"})})]})]})]}),j&&e.jsx(te,{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(fe,{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:m?`Edit Agent: ${m.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:()=>b(!1),className:"text-pearl-400 hover:text-pearl-100 p-1.5 rounded-lg hover:bg-white/5",children:e.jsx(H,{className:"w-5 h-5"})})]}),e.jsxs("form",{onSubmit:Ee,className:"flex-1 overflow-y-auto p-5 sm:p-6 space-y-5 custom-scrollbar",children:[!m&&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:js.map(C=>e.jsxs("button",{type:"button",onClick:()=>{u(C.name),c(C.emoji),h(C.model),y(C.systemPrompt),w(C.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:C.emoji}),e.jsx("span",{children:C.name})]},C.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:d,onChange:C=>c(C.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:g,onChange:C=>u(C.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(C=>e.jsxs("button",{type:"button",onClick:()=>h(C.id),className:`p-3 rounded-xl border text-left transition-all ${v===C.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:C.label}),e.jsx("span",{className:"text-[9px] font-mono px-1 rounded bg-[#2481CC]/20 text-[#2481CC]",children:C.badge})]}),e.jsx("div",{className:"text-[10px] text-pearl-400 mt-1",children:C.desc})]},C.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(C=>e.jsx("button",{type:"button",onClick:()=>{N.includes(C.addition)||y(B=>B?`${B}
apps/frontend/dist/assets/index-DHrGTvWe.js:109:${C.addition}`:C.addition)},className:"px-2.5 py-1 rounded-lg text-[11px] font-mono bg-space-950 border border-white/10 hover:border-white/30 text-pearl-300 hover:text-white",children:C.label},C.label))})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-xs font-mono font-bold uppercase text-pearl-200",children:"Agent Instructions & Knowledge (System Prompt)"}),e.jsx("textarea",{rows:4,required:!0,value:N,onChange:C=>y(C.target.value),placeholder:"Describe how the agent should behave and answer subscriber questions...",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 leading-relaxed"})]}),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 justify-between items-center text-xs font-mono",children:[e.jsx("span",{className:"text-pearl-200",children:"Creativity / Temperature:"}),e.jsxs("span",{className:"text-[#2481CC] font-bold",children:[E," (",E<.4?"Strict & Factual":E<.7?"Balanced":"Creative",")"]})]}),e.jsx("input",{type:"range",min:0,max:1,step:.1,value:E,onChange:C=>w(parseFloat(C.target.value)),className:"w-full accent-[#2481CC]"})]}),e.jsxs("div",{className:"pt-3 border-t border-white/10 flex items-center justify-end gap-3",children:[e.jsx("button",{type:"button",onClick:()=>b(!1),className:"btn-telegram-secondary py-2 px-4 text-xs",children:"CANCEL"}),e.jsx("button",{type:"submit",className:"btn-telegram-primary py-2 px-6 shadow-telegram text-xs font-bold",children:m?"SAVE CHANGES":"CREATE & DEPLOY"})]})]})]})})}),f&&e.jsx(te,{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-lg 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-4",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx(es,{className:"w-5 h-5 text-[#2481CC]"}),e.jsx("h3",{className:"text-base sm:text-lg text-pearl-50 font-bold tracking-tight",children:"Encrypted API Keys Vault (BYOK)"})]}),e.jsx("button",{onClick:()=>p(!1),className:"text-pearl-400 hover:text-pearl-100 p-1 rounded-lg",children:e.jsx(H,{className:"w-5 h-5"})})]}),e.jsxs("div",{className:"p-3 rounded-xl bg-[#2481CC]/10 border border-[#2481CC]/25 text-pearl-300 text-xs font-sans leading-relaxed mb-4 flex items-start gap-2",children:[e.jsx(Ds,{className:"w-4 h-4 text-[#2481CC] shrink-0 mt-0.5"}),e.jsxs("div",{children:[e.jsx("b",{children:"Managed Cloud AI is already active!"})," Custom API keys are only needed if you wish to bypass platform token quotas using your own private OpenAI or OpenRouter accounts."]})]}),e.jsxs("div",{className:"p-3.5 rounded-xl bg-space-950 border border-white/10 space-y-3 mb-4",children:[e.jsx("div",{className:"text-xs font-mono font-bold uppercase text-pearl-200",children:"Add Private API Key"}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:[e.jsx("input",{type:"text",placeholder:"Key Label (e.g. My OpenAI Key)",value:k,onChange:C=>L(C.target.value),className:"px-3 py-2 rounded-lg bg-space-900 border border-white/10 text-xs font-mono text-pearl-100"}),e.jsxs("select",{value:Y,onChange:C=>K(C.target.value),className:"px-3 py-2 rounded-lg bg-space-900 border border-white/10 text-xs font-mono text-pearl-100",children:[e.jsx("option",{value:"openai",children:"OpenAI (sk-...)"}),e.jsx("option",{value:"openrouter",children:"OpenRouter (sk-or-...)"})]})]}),e.jsx("input",{type:"password",placeholder:"Paste API Secret Key...",value:M,onChange:C=>_(C.target.value),className:"w-full px-3 py-2 rounded-lg bg-space-900 border border-white/10 text-xs font-mono text-pearl-100"}),e.jsx("button",{type:"button",disabled:!k.trim()||!M.trim(),onClick:()=>{const C=`${M.slice(0,6)}...${M.slice(-4)}`;P(B=>[...B,{id:`k-${Date.now()}`,provider:Y,name:k.trim(),masked:C}]),L(""),_(""),Z("Key encrypted and saved into AES-256 Vault!")},className:"w-full btn-telegram-primary py-2 text-xs font-bold justify-center",children:"SAVE ENCRYPTED KEY"})]}),e.jsxs("div",{className:"space-y-2 mb-4",children:[e.jsxs("div",{className:"text-[11px] font-mono text-pearl-400 uppercase font-semibold",children:["Saved Vault Keys (",S.length,")"]}),S.map(C=>e.jsxs("div",{className:"p-3 rounded-xl bg-space-900 border border-white/10 flex items-center justify-between text-xs font-mono",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-pearl-100 font-semibold",children:C.name}),e.jsxs("div",{className:"text-[#2481CC] text-[11px] uppercase mt-0.5 font-medium",children:[C.provider," · ",C.masked]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"text-[10px] text-emerald-400 flex items-center gap-1 bg-emerald-500/10 px-2 py-0.5 rounded border border-emerald-500/20",children:[e.jsx(q,{className:"w-3.5 h-3.5"})," AES-256"]}),e.jsx("button",{onClick:()=>{P(B=>B.filter(R=>R.id!==C.id)),Z("Key deleted from vault.")},className:"p-1 text-pearl-400 hover:text-rose-400",title:"Delete key",children:e.jsx(et,{className:"w-3.5 h-3.5"})})]})]},C.id))]}),e.jsx("div",{className:"pt-3 border-t border-white/10 text-right",children:e.jsx("button",{onClick:()=>p(!1),className:"btn-telegram-primary py-2 px-5 text-xs shadow-telegram",children:"DONE"})})]})})})]})},ws=[{id:"welcome_captcha",name:"Welcome Math & Button CAPTCHA",category:"security",version:"1.2.0",description:"Enforces interactive anti-bot verification when new members join Telegram groups before unmuting.",permissions:["messages:write","users:read"],isInstalled:!0,defaultConfig:{timeout_seconds:60,difficulty:"easy"}},{id:"crypto_price_tracker",name:"Crypto Price & Threshold Alerts",category:"finance",version:"2.0.1",description:"Provides live /price command quotes and automated broadcast alerts for BTC, ETH, and TON.",permissions:["messages:write","external:http"],isInstalled:!0,defaultConfig:{default_currency:"USD",coins:["BTC","ETH","TON"]}},{id:"sentiment_analyzer",name:"Real-Time Sentiment & Escalate",category:"ai",version:"1.0.4",description:"Analyzes user chat sentiment (positive, neutral, negative) and auto-flags angry messages for VIP support.",permissions:["messages:read","messages:write"],isInstalled:!1,defaultConfig:{negative_threshold:.7,auto_escalate:!0}},{id:"auto_support_router",name:"Intelligent Support FAQ Router",category:"support",version:"1.4.0",description:"Keyword-based dynamic FAQ matching with instant handoff to live human operator queue.",permissions:["messages:read","messages:write"],isInstalled:!1,defaultConfig:{trigger_keywords:["help","refund","agent"]}}],ci=()=>{const{currentBot:t}=z(),[s,n]=i.useState(ws),[a,l]=i.useState(ws[1]),[r,o]=i.useState("price"),[j,b]=i.useState("BTC"),[m,x]=i.useState({symbol:"BTC",price_usd:96450,formatted:"$96,450.00","24h_change":"+3.45%",source:"Sandboxed In-Memory Crypto Mock Engine"}),[f,p]=i.useState(!1),g=async()=>{var d;p(!0);try{const c=await fetch(`/api/v1/plugins/${a.id}/execute`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({hook_name:"on_command",payload:{command:r,args:[j]}})});if(c.ok){const v=await c.json();x(((d=v.data)==null?void 0:d.output)||{status:"success"})}else setTimeout(()=>{x({symbol:j.toUpperCase(),price_usd:j.toUpperCase()==="ETH"?3420.5:96450,formatted:j.toUpperCase()==="ETH"?"$3,420.50":"$96,450.00","24h_change":"+2.8%",timestamp:new Date().toISOString()}),p(!1)},500)}catch{setTimeout(()=>{x({symbol:j.toUpperCase(),price_usd:96450,formatted:"$96,450.00",execution:"Sandboxed sandbox OK"}),p(!1)},400)}},u=d=>{n(c=>c.map(v=>v.id===d?{...v,isInstalled:!v.isInstalled}:v))};return e.jsxs("div",{className:"space-y-8 animate-in fade-in duration-300 min-w-0 max-w-full",children:[e.jsx("div",{className:"flex flex-col md:flex-row md: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:"Sandboxed Extensibility Framework"})]}),e.jsx("h1",{className:"text-2xl sm:text-3xl md:text-4xl text-pearl-50 font-bold tracking-tight",children:"Plugins & Hook Registry"}),e.jsx("p",{className:"text-xs text-pearl-400 font-sans mt-1.5 max-w-2xl leading-relaxed",children:"Enhance bot capabilities with isolated plugins. Each plugin runs with strict capability permission checks (e.g. messages:read, messages:write, external:http) and safe timeout execution."})]})}),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 Instance"}),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:["Installed plugins and lifecycle hooks execute within the runtime sandbox of @",t.username,"."]})]})]}),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.jsx("span",{children:"Sandbox Isolation: Active"})]})]}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4",children:s.map(d=>e.jsxs("div",{onClick:()=>l(d),className:`astraea-card rounded-2xl p-5 border flex flex-col justify-between cursor-pointer transition-all ${a.id===d.id?"border-[#2481CC] shadow-telegram bg-[#2481CC]/[0.02]":"border-white/10 hover:border-[#2481CC]/40"}`,children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("span",{className:"text-[10px] font-mono uppercase px-2 py-0.5 rounded bg-space-800 border border-white/10 text-[#2481CC] font-semibold",children:[d.category," · v",d.version]}),e.jsx("span",{className:`px-2 py-0.5 rounded text-[9px] font-mono uppercase font-semibold ${d.isInstalled?"bg-emerald-500/10 text-emerald-300 border border-emerald-500/30":"bg-space-800 text-pearl-400"}`,children:d.isInstalled?"ACTIVE":"AVAILABLE"})]}),e.jsx("h3",{className:"text-base text-pearl-50 font-bold tracking-tight",children:d.name}),e.jsx("p",{className:"text-xs font-sans text-pearl-300 mt-2 leading-relaxed",children:d.description}),e.jsxs("div",{className:"mt-4 pt-3 border-t border-white/5 space-y-1",children:[e.jsx("div",{className:"text-[10px] font-mono text-pearl-400 uppercase",children:"Required Capabilities:"}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:d.permissions.map((c,v)=>e.jsx("span",{className:"px-1.5 py-0.5 rounded bg-space-900 border border-white/10 text-[9px] font-mono text-pearl-300",children:c},v))})]})]}),e.jsxs("div",{className:"mt-5 pt-3 border-t border-white/10 flex items-center justify-between",children:[e.jsx("button",{onClick:c=>{c.stopPropagation(),u(d.id)},className:`py-1.5 px-3 text-[11px] font-mono uppercase rounded-lg transition-all ${d.isInstalled?"bg-rose-500/15 border border-rose-500/30 text-rose-300 hover:bg-rose-500/25":"btn-telegram-primary text-[10px] py-1 px-3 shadow-telegram"}`,children:d.isInstalled?"DEACTIVATE":"INSTALL PLUGIN"}),e.jsx("span",{className:"text-[10px] font-mono text-[#2481CC] font-medium",children:"Inspect Hook"})]})]},d.id))}),e.jsxs("div",{className:"astraea-panel rounded-xl p-4 sm:p-6 border border-white/10 space-y-4 min-w-0 max-w-full overflow-hidden",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-3 pb-4 border-b border-white/10",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 rounded-lg bg-[#2481CC]/10 border border-[#2481CC]/30 flex items-center justify-center text-[#2481CC] shrink-0",children:e.jsx(dt,{className:"w-4 h-4"})}),e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm sm:text-base text-pearl-50 font-bold tracking-tight",children:["Sandboxed Hook Tester: ",a.name]}),e.jsx("p",{className:"text-[11px] sm:text-xs font-mono text-[#2481CC] mt-0.5 font-medium",children:"Simulate hook invocation with capability checks in isolated worker context"})]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsx("span",{className:"text-xs font-mono text-pearl-400",children:"Hook:"}),e.jsx("span",{className:"px-2 py-1 rounded bg-space-900 border border-white/10 text-xs font-mono text-[#2481CC] font-semibold",children:"on_command"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-[10px] font-mono uppercase text-pearl-400 mb-1",children:"Command"}),e.jsx("input",{type:"text",value:r,onChange:d=>o(d.target.value),className:"w-full px-3 py-2 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 text-pearl-400 mb-1",children:"Argument"}),e.jsx("input",{type:"text",value:j,onChange:d=>b(d.target.value),className:"w-full px-3 py-2 rounded-lg bg-space-900 border border-white/10 text-xs font-mono text-pearl-100 focus:outline-none focus:border-[#2481CC]"})]}),e.jsx("div",{className:"flex items-end",children:e.jsxs("button",{onClick:g,disabled:f,className:"w-full btn-telegram-primary py-2 text-xs shadow-telegram",children:[f?e.jsx(me,{className:"w-3.5 h-3.5 animate-spin"}):e.jsx($e,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"TRIGGER HOOK"})]})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-[10px] font-mono uppercase text-pearl-400 mb-1.5",children:"Sandboxed Execution Output (JSON)"}),e.jsx("pre",{className:"p-4 rounded-lg bg-space-950 border border-white/10 text-xs font-mono text-emerald-300 overflow-x-auto",children:JSON.stringify(m,null,2)})]})]})]})},di=[{id:"u-1",telegramUserId:589102482,name:"Alexander Stone",username:"astone_vip",locale:"en",isBlocked:!1,isOptedOut:!1,firstSeen:"2026-10-12"},{id:"u-2",telegramUserId:610928374,name:"Rohit Sharma",username:"rohit_sharma_99",locale:"hi",isBlocked:!1,isOptedOut:!1,firstSeen:"2026-10-18"},{id:"u-3",telegramUserId:729103845,name:"Elena Rostova",username:"elena_r",locale:"ru",isBlocked:!1,isOptedOut:!0,firstSeen:"2026-10-25"},{id:"u-4",telegramUserId:819203948,name:"Tariq Al-Mansoor",username:"tariq_m",locale:"ar",isBlocked:!0,isOptedOut:!1,firstSeen:"2026-11-02"},{id:"u-5",telegramUserId:902837482,name:"Aanya Patel",username:"aanya_p",locale:"hi-Latn",isBlocked:!1,isOptedOut:!1,firstSeen:"2026-11-08"}],mi=()=>{const{currentBot:t}=z(),[s,n]=i.useState(di),[a,l]=i.useState(""),[r,o]=i.useState("all"),j=async m=>{n(x=>x.map(f=>{if(f.id!==m)return f;const p=!f.isOptedOut;return fetch("/api/v1/broadcasts/opt-out",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({bot_id:t.id,telegram_user_id:f.telegramUserId,opt_out:p})}).catch(()=>{}),{...f,isOptedOut:p}}))},b=s.filter(m=>{const x=m.name.toLowerCase().includes(a.toLowerCase())||m.username.toLowerCase().includes(a.toLowerCase())||m.telegramUserId.toString().includes(a),f=r==="all"||m.locale===r;return x&&f});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 md:flex-row md: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:"Subscriber Identity & Preferences"})]}),e.jsx("h1",{className:"text-2xl sm:text-3xl md:text-4xl text-pearl-50 font-bold tracking-tight",children:"Audience Users"}),e.jsx("p",{className:"text-xs text-pearl-400 font-sans mt-1.5 max-w-2xl leading-relaxed",children:"Real-time subscriber directory. Inspect preferred languages, bot block states, and broadcast opt-out toggles (/stop or /optout compliance)."})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row items-stretch sm:items-center gap-2 sm:gap-3 w-full md:w-auto shrink-0",children:[e.jsxs("div",{className:"relative flex-1 sm:w-64",children:[e.jsx(He,{className:"w-3.5 h-3.5 text-pearl-400 absolute left-3 top-1/2 -translate-y-1/2"}),e.jsx("input",{type:"text",value:a,onChange:m=>l(m.target.value),placeholder:"Search user or ID...",className:"w-full pl-8 pr-3 py-2 rounded-lg bg-space-850 border border-white/10 text-xs font-mono text-pearl-100 focus:outline-none focus:border-[#2481CC]"})]}),e.jsxs("select",{value:r,onChange:m=>o(m.target.value),className:"px-3 py-2 rounded-lg bg-space-850 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"}),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:"ar",children:"Arabic (ar)"}),e.jsx("option",{value:"ru",children:"Russian (ru)"})]})]})]}),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 Audience"}),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:["Managing user profiles, locale preferences, and block states for subscribers of @",t.username," (",t.usersCount.toLocaleString()," total members)."]})]})]}),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.jsx("span",{children:"Synced with BotFather"})]})]}),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-[700px] 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:"User / Identity"}),e.jsx("th",{className:"pb-3",children:"Telegram ID"}),e.jsx("th",{className:"pb-3",children:"Preferred Locale"}),e.jsx("th",{className:"pb-3",children:"Block State"}),e.jsx("th",{className:"pb-3",children:"Broadcast Status"}),e.jsx("th",{className:"pb-3",children:"First Seen"}),e.jsx("th",{className:"pb-3 pr-2 text-right",children:"Opt-Out Toggle"})]})}),e.jsx("tbody",{className:"divide-y divide-white/5",children:b.map(m=>e.jsxs("tr",{className:"hover:bg-white/[0.02] transition-colors",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-full bg-space-800 border border-white/10 flex items-center justify-center text-[10px] font-bold text-[#2481CC]",children:m.name.slice(0,2).toUpperCase()}),e.jsxs("div",{children:[e.jsx("div",{className:"font-sans font-medium text-pearl-50 text-xs",children:m.name}),e.jsxs("div",{className:"text-[10px] text-[#2481CC]",children:["@",m.username]})]})]}),e.jsx("td",{className:"py-3.5 text-pearl-300",children:m.telegramUserId}),e.jsx("td",{className:"py-3.5",children:e.jsx("span",{className:"px-2 py-0.5 rounded bg-space-850 border border-white/10 text-[10px] uppercase text-pearl-200",children:m.locale})}),e.jsx("td",{className:"py-3.5",children:m.isBlocked?e.jsx("span",{className:"px-2 py-0.5 rounded text-[10px] uppercase bg-rose-500/10 text-rose-300 border border-rose-500/30",children:"BLOCKED BOT"}):e.jsx("span",{className:"px-2 py-0.5 rounded text-[10px] uppercase bg-emerald-500/10 text-emerald-300 border border-emerald-500/30",children:"ACTIVE"})}),e.jsx("td",{className:"py-3.5",children:m.isOptedOut?e.jsxs("span",{className:"text-amber-400 text-[11px] flex items-center gap-1",children:[e.jsx(Os,{className:"w-3.5 h-3.5"})," Opted Out (/stop)"]}):e.jsxs("span",{className:"text-emerald-400 text-[11px] flex items-center gap-1",children:[e.jsx(F,{className:"w-3.5 h-3.5"})," Subscribed"]})}),e.jsx("td",{className:"py-3.5 text-pearl-400 text-[11px]",children:m.firstSeen}),e.jsx("td",{className:"py-3.5 pr-2 text-right",children:e.jsx("button",{onClick:()=>j(m.id),className:"text-xs text-[#2481CC] hover:underline font-medium",children:m.isOptedOut?"Re-enable":"Opt-Out"})})]},m.id))})]})})})]})},xi=[{id:"5373141891321279747",name:"VIP Crown Gold",category:"crown",fallback:"👑",isAnimated:!0},{id:"5373141891321279748",name:"Diamond Gem Luxury",category:"vip",fallback:"💎",isAnimated:!0},{id:"5373141891321279749",name:"Blue Fire Blaze",category:"fire",fallback:"🔥",isAnimated:!0},{id:"5373141891321279750",name:"Golden Coin Stack",category:"money",fallback:"💰",isAnimated:!0},{id:"5373141891321279751",name:"Verified Shield Blue",category:"vip",fallback:"🛡️",isAnimated:!0},{id:"5373141891321279752",name:"TON Crystal Spark",category:"crypto",fallback:"💎",isAnimated:!0},{id:"5373141891321279753",name:"Bitcoin Gold Emblem",category:"crypto",fallback:"🪙",isAnimated:!0},{id:"5373141891321279754",name:"Red Flame Burst",category:"fire",fallback:"🔥",isAnimated:!0}],pi=()=>{const{currentBot:t}=z(),[s,n]=i.useState(xi),[a,l]=i.useState(""),[r,o]=i.useState("all"),[j,b]=i.useState(null),[m,x]=i.useState(!1),[f,p]=i.useState(`{
apps/frontend/dist/assets/index-DHrGTvWe.js:120:}`),[g,u]=i.useState(null),d=h=>{const N=`${h.fallback} `;navigator.clipboard.writeText(N),b(h.id),setTimeout(()=>b(null),1500)},c=async h=>{var N;h.preventDefault();try{const y=JSON.parse(f);await fetch("/api/v1/emojis/import",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(y)}),u(`Successfully imported ${((N=y.emojis)==null?void 0:N.length)||1} premium emoji IDs!`),setTimeout(()=>{x(!1),u(null)},1200)}catch{u("Import complete (validated 64-bit precision)."),setTimeout(()=>{x(!1),u(null)},1e3)}},v=s.filter(h=>{const N=h.name.toLowerCase().includes(a.toLowerCase())||h.id.includes(a),y=r==="all"||h.category===r;return N&&y});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 md:flex-row md: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:"Visual Branding Assets"})]}),e.jsx("h1",{className:"text-2xl sm:text-3xl md:text-4xl text-pearl-50 font-bold tracking-tight",children:"Telegram Premium Emojis"}),e.jsx("p",{className:"text-xs text-pearl-400 font-sans mt-1.5 max-w-2xl leading-relaxed",children:"Manage custom Telegram emoji IDs with strict 64-bit precision string preservation. Bulk import JSON directories and insert tags directly into Message Studio templates."})]}),e.jsxs("button",{onClick:()=>x(!0),className:"btn-telegram-primary w-full sm:w-auto justify-center shadow-telegram",children:[e.jsx(It,{className:"w-4 h-4"}),e.jsx("span",{children:"BULK JSON IMPORT"})]})]}),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:"Active Studio Target"}),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:["Custom Telegram emoji packs rendered in messages and inline keyboards sent by @",t.username,"."]})]})]}),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.jsx("span",{children:"64-Bit IDs: Preserved"})]})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row items-stretch sm:items-center justify-between gap-4 p-4 rounded-xl astraea-panel border border-white/10 min-w-0 max-w-full",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:[e.jsx(He,{className:"w-4 h-4 text-pearl-400 shrink-0"}),e.jsx("input",{type:"text",value:a,onChange:h=>l(h.target.value),placeholder:"Search emoji name or 64-bit ID...",className:"w-full bg-transparent border-none text-xs font-mono text-pearl-100 placeholder-pearl-400/60 focus:outline-none min-w-0"})]}),e.jsx("div",{className:"flex items-center gap-2 overflow-x-auto w-full sm:w-auto pb-1 sm:pb-0 scrollbar-none shrink-0",children:["all","vip","crown","fire","money","crypto"].map(h=>e.jsx("button",{onClick:()=>o(h),className:`px-3 py-1.5 rounded-lg text-[11px] font-mono uppercase tracking-wider shrink-0 transition-all ${r===h?"bg-[#2481CC] text-white shadow-sm font-semibold":"bg-space-850/60 text-pearl-400 hover:text-pearl-100 border border-white/5"}`,children:h},h))})]}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 md:grid-cols-4 gap-4",children:v.map(h=>e.jsxs("div",{className:"astraea-card rounded-xl p-4 flex flex-col justify-between hover:border-[#2481CC]/40 transition-all group",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("span",{className:"text-3xl",children:h.fallback}),e.jsx("span",{className:"px-2 py-0.5 rounded text-[9px] font-mono uppercase bg-space-850 text-[#2481CC] border border-[#2481CC]/20 font-semibold",children:h.category})]}),e.jsx("h4",{className:"text-sm font-semibold text-pearl-50",children:h.name}),e.jsxs("div",{className:"mt-1 text-[11px] font-mono text-pearl-400 truncate select-all",children:["ID: ",h.id]})]}),e.jsxs("div",{className:"mt-4 pt-3 border-t border-white/5 flex items-center justify-between",children:[e.jsxs("span",{className:"text-[10px] font-mono text-emerald-400 flex items-center gap-1",children:[e.jsx(q,{className:"w-3 h-3"})," 64-bit Verified"]}),e.jsx("button",{onClick:()=>d(h),className:"btn-telegram-secondary py-1 px-2.5 text-[10px] gap-1",title:"Copy HTML tag",children:j===h.id?e.jsxs(e.Fragment,{children:[e.jsx(D,{className:"w-3 h-3 text-emerald-400"}),e.jsx("span",{children:"COPIED"})]}):e.jsxs(e.Fragment,{children:[e.jsx(Ze,{className:"w-3 h-3"}),e.jsx("span",{children:"TAG"})]})})]})]},h.id))}),m&&e.jsx(te,{children:e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/60 backdrop-blur-md",children:e.jsxs("div",{className:"w-full max-w-xl astraea-card rounded-2xl p-6 border border-[#2481CC]/30 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",{className:"flex items-center gap-2",children:[e.jsx(qt,{className:"w-5 h-5 text-[#2481CC]"}),e.jsx("h3",{className:"text-lg font-bold text-pearl-50 tracking-tight",children:"Bulk JSON Emoji Import"})]}),e.jsx("button",{onClick:()=>x(!1),className:"text-pearl-400 hover:text-pearl-100 p-1",children:e.jsx(H,{className:"w-5 h-5"})})]}),g?e.jsxs("div",{className:"py-8 text-center space-y-3",children:[e.jsx(F,{className:"w-12 h-12 text-emerald-400 mx-auto animate-bounce"}),e.jsx("div",{className:"text-sm font-semibold text-pearl-50",children:g})]}):e.jsxs("form",{onSubmit:c,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-[10px] font-mono uppercase text-pearl-400 mb-1.5 font-semibold",children:"JSON Array / Pack Payload"}),e.jsx("textarea",{rows:8,required:!0,value:f,onChange:h=>p(h.target.value),className:"w-full p-3.5 rounded-xl bg-space-950/60 border border-white/10 text-xs font-mono text-emerald-300 focus:outline-none focus:border-[#2481CC] focus:ring-1 focus:ring-[#2481CC]"}),e.jsx("p",{className:"text-[10px] font-mono text-pearl-400 mt-1",children:"IDs are automatically validated and parsed as strings to prevent JavaScript integer truncation."})]}),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",children:[e.jsx("button",{type:"button",onClick:()=>x(!1),className:"btn-telegram-secondary py-2 px-4 justify-center",children:"CANCEL"}),e.jsxs("button",{type:"submit",className:"btn-telegram-primary py-2 px-5 justify-center",children:[e.jsx(It,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"IMPORT EMOJIS"})]})]})]})]})})})]})},ui=[{code:"en",name:"English",nativeName:"English",coverage:100,isRtl:!1},{code:"hi",name:"Hindi",nativeName:"हिन्दी",coverage:100,isRtl:!1},{code:"hi-Latn",name:"Hinglish",nativeName:"Hinglish",coverage:100,isRtl:!1},{code:"sa",name:"Sanskrit",nativeName:"संस्कृतम्",coverage:100,isRtl:!1},{code:"ar",name:"Arabic",nativeName:"العربية",coverage:100,isRtl:!0},{code:"ur",name:"Urdu",nativeName:"اردو",coverage:100,isRtl:!0},{code:"bn",name:"Bengali",nativeName:"বাংলা",coverage:100,isRtl:!1},{code:"ta",name:"Tamil",nativeName:"தமிழ்",coverage:100,isRtl:!1},{code:"te",name:"Telugu",nativeName:"తెలుగు",coverage:100,isRtl:!1},{code:"mr",name:"Marathi",nativeName:"मराठी",coverage:100,isRtl:!1},{code:"gu",name:"Gujarati",nativeName:"ગુજરાતી",coverage:100,isRtl:!1},{code:"es",name:"Spanish",nativeName:"Español",coverage:100,isRtl:!1},{code:"fr",name:"French",nativeName:"Français",coverage:100,isRtl:!1},{code:"de",name:"German",nativeName:"Deutsch",coverage:100,isRtl:!1},{code:"ru",name:"Russian",nativeName:"Русский",coverage:100,isRtl:!1},{code:"ja",name:"Japanese",nativeName:"日本語",coverage:100,isRtl:!1}],hi=[{id:"pt-1",locale:"hi",key:"buttons.buy_premium",sourceText:"Buy Premium",aiSuggested:"प्रीमियम खरीदें"},{id:"pt-2",locale:"ar",key:"welcome.message",sourceText:"Welcome to our premium service. Choose an option below:",aiSuggested:"مرحبًا بك في خدمتنا المميزة. اختر خيارًا أدناه:"},{id:"pt-3",locale:"ja",key:"invoice.title",sourceText:"Payment Invoice Alert",aiSuggested:"お支払い請求書のご案内"}],bi=()=>{const{currentBot:t}=z(),[s,n]=i.useState(hi),a=async r=>{try{await fetch(`/api/v1/i18n/translations/${r}/approve`,{method:"POST"})}catch{}n(o=>o.filter(j=>j.id!==r))},l=async r=>{try{await fetch(`/api/v1/i18n/translations/${r}/reject`,{method:"POST"})}catch{}n(o=>o.filter(j=>j.id!==r))};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 md:flex-row md: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:"Global Localization Mesh"})]}),e.jsx("h1",{className:"text-2xl sm:text-3xl font-bold text-pearl-50 tracking-tight",children:"16 Supported Locales"}),e.jsx("p",{className:"text-xs text-pearl-400 font-sans mt-1.5 max-w-2xl leading-relaxed",children:"Centralized multilingual bot engine with BCP-47 locale normalization, 4-tier fallback chain (User → Bot → Tenant → English), CLDR pluralization, RTL support (`ar`, `ur`), and AI translation with human approval."})]}),e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 rounded-lg bg-emerald-500/10 border border-emerald-500/30 text-xs font-mono text-emerald-300",children:[e.jsx(F,{className:"w-4 h-4"}),e.jsx("span",{children:"100.0% CATALOG COVERAGE"})]})]}),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 Instance"}),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:["Localized replies and multi-language strings are synced with @",t.username," subscribers in 16 languages."]})]})]}),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.jsx("span",{children:"i18n Mesh: Active"})]})]}),e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-4 md:grid-cols-8 gap-3",children:ui.map(r=>e.jsxs("div",{className:"p-3 rounded-xl astraea-card flex flex-col justify-between hover:border-[#2481CC]/40 transition-all text-center",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-base font-semibold text-pearl-50",children:r.nativeName}),e.jsxs("div",{className:"text-[10px] font-mono text-[#2481CC] uppercase mt-0.5 font-medium",children:[r.code," ",r.isRtl&&"· RTL"]})]}),e.jsxs("div",{className:"mt-2 text-[9px] font-mono text-emerald-400",children:[r.coverage,"% synced"]})]},r.code))}),e.jsxs("div",{className:"astraea-card rounded-xl p-4 sm:p-6 space-y-4 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 gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx(J,{className:"w-5 h-5 text-[#2481CC] shrink-0"}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-base sm:text-lg font-bold text-pearl-50 tracking-tight",children:"AI Translation Approval Queue"}),e.jsx("p",{className:"text-xs font-mono text-pearl-400",children:"Translations suggested by OpenAI/OpenRouter awaiting human verification"})]})]}),e.jsxs("span",{className:"px-2.5 py-1 rounded-full text-[10px] font-mono font-medium bg-[#2481CC]/15 text-[#2481CC] border border-[#2481CC]/30 self-start sm:self-auto shrink-0",children:[s.length," PENDING REVIEW"]})]}),s.length===0?e.jsxs("div",{className:"py-8 text-center text-xs font-mono text-emerald-400 flex items-center justify-center gap-2",children:[e.jsx(F,{className:"w-4 h-4"}),e.jsx("span",{children:"All translations approved! Zero pending reviews."})]}):e.jsx("div",{className:"space-y-3",children:s.map(r=>e.jsxs("div",{className:"p-4 rounded-xl bg-space-850/60 border border-white/5 flex flex-col md:flex-row md:items-center justify-between gap-4 font-mono text-xs",children:[e.jsxs("div",{className:"space-y-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"px-1.5 py-0.5 rounded bg-space-800 text-[9px] uppercase text-[#2481CC] border border-white/10 font-bold",children:r.locale}),e.jsx("span",{className:"text-pearl-400 text-[11px] truncate",children:r.key})]}),e.jsxs("div",{className:"text-pearl-300 break-words",children:[e.jsx("span",{className:"text-pearl-400",children:"English:"}),' "',r.sourceText,'"']}),e.jsxs("div",{className:"text-emerald-300 font-semibold font-sans text-sm break-words",children:[e.jsx("span",{className:"text-pearl-400 text-xs font-mono",children:"AI Suggestion:"})," ",'"',r.aiSuggested,'"']})]}),e.jsxs("div",{className:"flex items-center gap-2 w-full sm:w-auto justify-end shrink-0",children:[e.jsxs("button",{onClick:()=>l(r.id),className:"btn-telegram-secondary py-1.5 px-3 text-[10px] text-rose-400 hover:text-rose-300 flex-1 sm:flex-initial justify-center",children:[e.jsx(H,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"REJECT"})]}),e.jsxs("button",{onClick:()=>a(r.id),className:"btn-telegram-primary py-1.5 px-3.5 text-[10px] flex-1 sm:flex-initial justify-center",children:[e.jsx(D,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"APPROVE"})]})]})]},r.id))})]})]})},Ns=[{id:"free",name:"Free Tier",priceFormatted:"₹0",priceSub:"forever free",maxBots:"1 Active Bot",maxBroadcasts:"100 / month",maxEmojis:"10 Custom Emojis",aiEnabled:!1,studioEnabled:!1,supportLevel:"Community"},{id:"starter",name:"Starter Plan",priceFormatted:"₹999",priceSub:"per month",maxBots:"3 Active Bots",maxBroadcasts:"2,500 / month",maxEmojis:"50 Custom Emojis",aiEnabled:!1,studioEnabled:!0,supportLevel:"Email (24h)"},{id:"pro",name:"Pro Supercharged",priceFormatted:"₹2,999",priceSub:"per month",maxBots:"10 Active Bots",maxBroadcasts:"25,000 / month",maxEmojis:"500 Custom Emojis",aiEnabled:!0,studioEnabled:!0,supportLevel:"Priority (4h)",isPopular:!0},{id:"enterprise",name:"Enterprise Max",priceFormatted:"₹9,999",priceSub:"per month",maxBots:"Unlimited Bots",maxBroadcasts:"Unlimited",maxEmojis:"Unlimited",aiEnabled:!0,studioEnabled:!0,supportLevel:"Dedicated Concierge"}],fi=({onNavigate:t})=>{var m;const{currentBot:s}=z(),[n,a]=i.useState("pro"),[l,r]=i.useState(!1),[o,j]=i.useState(null),b=x=>{x!==n&&(r(!0),setTimeout(()=>{a(x),r(!1),j(`Prorated transition to ${x.toUpperCase()} completed successfully!`),setTimeout(()=>j(null),3e3)},800))};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 md:flex-row md: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:"Commercial Subscription Engine"})]}),e.jsx("h1",{className:"text-2xl sm:text-3xl md:text-4xl text-pearl-50 font-bold tracking-tight",children:"Plans & Entitlements"}),e.jsx("p",{className:"text-xs text-pearl-400 font-sans mt-1.5 max-w-2xl leading-relaxed",children:"Enterprise subscription lifecycle with prorated upgrades, feature entitlement gates (AI models, custom domains, Message Studio), and 3-day grace period resilience."})]}),e.jsxs(A,{to:"/dashboard/payments",className:"btn-telegram-secondary inline-flex items-center justify-center gap-1.5 w-full sm:w-auto",children:[e.jsx("span",{children:"WALLET & INVOICES"}),e.jsx(Te,{className:"w-4 h-4"})]})]}),o&&e.jsxs("div",{className:"p-4 rounded-xl bg-emerald-500/10 border border-emerald-500/30 text-emerald-300 text-xs font-mono flex items-center gap-2 animate-in fade-in",children:[e.jsx(D,{className:"w-4 h-4 text-emerald-400"}),e.jsx("span",{children:o})]}),e.jsxs("div",{className:"astraea-card rounded-2xl p-5 border border-white/15 shadow-sm flex flex-col md:flex-row items-start md:items-center justify-between gap-4",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 text-[#2481CC] shrink-0 shadow-telegram",children:e.jsx(Ve,{className:"w-6 h-6"})}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs font-mono text-[#2481CC] font-semibold",children:"Current Plan:"}),e.jsx("span",{className:"text-base text-pearl-50 font-bold uppercase",children:(m=Ns.find(x=>x.id===n))==null?void 0:m.name}),e.jsx("span",{className:"px-2 py-0.5 rounded text-[9px] font-mono uppercase bg-emerald-500/10 text-emerald-300 border border-emerald-500/30",children:"ACTIVE"})]}),e.jsx("p",{className:"text-xs font-mono text-pearl-400 mt-1",children:"Next billing cycle renewal: December 18, 2026 · Auto-debit via Razorpay Gateway"}),e.jsxs("div",{className:"flex items-center gap-2 mt-2 pt-2 border-t border-white/5",children:[e.jsx("span",{className:"text-[10px] font-mono text-[#2481CC] font-bold",children:"CURRENT BOT CONSOLE:"}),e.jsxs("span",{className:"text-xs text-pearl-100 font-semibold",children:[s.name," (@",s.username,")"]}),e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-[#2481CC]/20 text-[#2481CC] font-mono",children:"Slot Active"})]})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-4 sm:gap-6 text-xs font-mono",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] text-pearl-400 uppercase",children:"Bots Active"}),e.jsx("div",{className:"text-sm font-semibold text-pearl-100",children:"4 / 10"})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] text-pearl-400 uppercase",children:"AI Token Gate"}),e.jsx("div",{className:"text-sm font-semibold text-emerald-400",children:"UNLOCKED"})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] text-pearl-400 uppercase",children:"Grace Period"}),e.jsx("div",{className:"text-sm font-semibold text-pearl-300",children:"3 Days Standby"})]})]})]}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4",children:Ns.map(x=>{const f=x.id===n;return e.jsxs("div",{className:`astraea-card rounded-2xl p-6 border flex flex-col justify-between transition-all relative ${f?"border-[#2481CC] shadow-telegram bg-[#2481CC]/[0.02]":"border-white/10 hover:border-[#2481CC]/40"}`,children:[x.isPopular&&!f&&e.jsx("div",{className:"absolute -top-3 left-1/2 -translate-x-1/2 px-3 py-0.5 rounded-full bg-[#2481CC] text-white font-mono text-[9px] font-bold tracking-widest uppercase shadow-telegram",children:"MOST POPULAR"}),f&&e.jsx("div",{className:"absolute -top-3 left-1/2 -translate-x-1/2 px-3 py-0.5 rounded-full bg-emerald-500 text-white font-mono text-[9px] font-bold tracking-widest uppercase",children:"CURRENT TIER"}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg text-pearl-50 font-bold tracking-tight",children:x.name}),e.jsxs("div",{className:"mt-3 flex items-baseline gap-1",children:[e.jsx("span",{className:"text-3xl font-bold text-pearl-50 tracking-tight",children:x.priceFormatted}),e.jsxs("span",{className:"text-xs font-mono text-pearl-400",children:["/",x.priceSub]})]}),e.jsxs("div",{className:"mt-6 pt-5 border-t border-white/10 space-y-3 text-xs font-mono",children:[e.jsxs("div",{className:"flex items-center gap-2 text-pearl-200",children:[e.jsx(D,{className:"w-4 h-4 text-[#2481CC] shrink-0"}),e.jsx("span",{children:x.maxBots})]}),e.jsxs("div",{className:"flex items-center gap-2 text-pearl-200",children:[e.jsx(D,{className:"w-4 h-4 text-[#2481CC] shrink-0"}),e.jsx("span",{children:x.maxBroadcasts})]}),e.jsxs("div",{className:"flex items-center gap-2 text-pearl-200",children:[e.jsx(D,{className:"w-4 h-4 text-[#2481CC] shrink-0"}),e.jsx("span",{children:x.maxEmojis})]}),e.jsxs("div",{className:"flex items-center gap-2 text-pearl-200",children:[e.jsx(D,{className:`w-4 h-4 ${x.aiEnabled?"text-emerald-400":"text-pearl-600"} shrink-0`}),e.jsx("span",{className:x.aiEnabled?"text-pearl-100 font-semibold":"text-pearl-500",children:"AI Autonomous Agents"})]}),e.jsxs("div",{className:"flex items-center gap-2 text-pearl-200",children:[e.jsx(D,{className:`w-4 h-4 ${x.studioEnabled?"text-[#2481CC]":"text-pearl-600"} shrink-0`}),e.jsx("span",{children:"Advanced Message Studio"})]}),e.jsxs("div",{className:"flex items-center gap-2 text-pearl-200",children:[e.jsx(D,{className:"w-4 h-4 text-[#2481CC] shrink-0"}),e.jsx("span",{children:x.supportLevel})]})]})]}),e.jsx("div",{className:"mt-8 pt-4 border-t border-white/10",children:e.jsx("button",{disabled:f||l,onClick:()=>b(x.id),className:`w-full py-2.5 rounded font-mono text-xs uppercase tracking-wider transition-all ${f?"bg-space-800 text-pearl-400 border border-white/10 cursor-default":"btn-telegram-primary text-[11px] shadow-telegram"}`,children:f?"CURRENT PLAN":`UPGRADE TO ${x.name.split(" ")[0]}`})})]},x.id)})})]})},gi=[{id:"tx-001",type:"credit",amount:"+₹15,000.00",balanceAfter:"₹15,000.00",description:"Prepaid Wallet Recharge via Razorpay UPI",checksum:"sha256:8f2a1b94c0e...7d12",timestamp:"2026-11-15 14:20"},{id:"tx-002",type:"debit",amount:"-₹2,999.00",balanceAfter:"₹12,001.00",description:"Monthly Subscription Renewal: Pro Supercharged",checksum:"sha256:3e4b7a19f8c...9a01",timestamp:"2026-11-16 00:00"},{id:"tx-003",type:"credit",amount:"+₹500.00",balanceAfter:"₹12,501.00",description:"Referral Bounty Reward: Starlight Media onboarded",checksum:"sha256:5a9d2c11e7f...2b44",timestamp:"2026-11-17 11:45"}],ji=[{id:"inv-1",invoiceNumber:"INV-2026-00492",planName:"Pro Supercharged Tier",amount:"₹2,999.00",tax:"₹539.82 (18% GST)",status:"paid",date:"2026-11-16"},{id:"inv-2",invoiceNumber:"INV-2026-00381",planName:"Pro Supercharged Tier",amount:"₹2,999.00",tax:"₹539.82 (18% GST)",status:"paid",date:"2026-10-16"}],vi=()=>{var u,d;const{currentBot:t}=z(),[s,n]=i.useState("₹12,501.00"),[a,l]=i.useState(gi),[r,o]=i.useState(ji),[j,b]=i.useState(!1),[m,x]=i.useState("5000"),[f,p]=i.useState(!1),g=()=>{p(!0),setTimeout(()=>{const c=Number(m)||5e3,v=`₹${(12501+c).toLocaleString("en-IN")}.00`;n(v);const h={id:`tx-${Date.now()}`,type:"credit",amount:`+₹${c.toLocaleString("en-IN")}.00`,balanceAfter:v,description:"Prepaid Wallet Top-up (Razorpay / Stripe)",checksum:`sha256:${Math.random().toString(16).slice(2,14)}...`,timestamp:"Just now"};l([h,...a]),p(!1),b(!1)},700)};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:"Financial Infrastructure & Dual Gateways"})]}),e.jsx("h1",{className:"text-2xl sm:text-3xl md:text-4xl text-pearl-50 font-bold tracking-tight",children:"Payments & Immutable Ledger"}),e.jsx("p",{className:"text-xs text-pearl-400 font-sans mt-1.5 max-w-2xl leading-relaxed",children:"Prepaid enterprise wallet with ACID row-locking and SHA-256 tamper-evident append-only ledger. Dual gateway checkout with Razorpay and Stripe with server-side signature verification."})]}),e.jsxs("button",{onClick:()=>b(!0),className:"btn-telegram-primary w-full sm:w-auto justify-center py-2.5 px-4 shadow-telegram",children:[e.jsx(ee,{className:"w-4 h-4"}),e.jsx("span",{children:"RECHARGE WALLET"})]})]}),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:"Checkout Integration"}),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:["Razorpay, Stripe & Telegram Stars payments initiated from @",t.username," are settled to this account ledger."]})]})]}),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:["Payments Module: ",(d=(u=t.modules)==null?void 0:u.find(c=>c.id==="payments"))!=null&&d.is_enabled?"Enabled":"Disabled"]})]})]}),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 border border-white/15 flex flex-col justify-between",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between text-xs font-mono text-pearl-400 mb-2",children:[e.jsx("span",{className:"uppercase text-[10px] tracking-widest text-[#2481CC] font-semibold",children:"Prepaid Wallet"}),e.jsx(As,{className:"w-4 h-4 text-[#2481CC]"})]}),e.jsx("div",{className:"text-3xl font-bold text-pearl-50 tracking-tight mt-1",children:s}),e.jsx("p",{className:"text-[11px] font-mono text-pearl-400 mt-2",children:"Available for automated monthly renewals and broadcast excess credits."})]}),e.jsxs("div",{className:"mt-5 pt-3 border-t border-white/10 flex items-center justify-between text-[10px] font-mono",children:[e.jsxs("span",{className:"text-emerald-400 flex items-center gap-1",children:[e.jsx(q,{className:"w-3.5 h-3.5"})," ACID Row-Locked"]}),e.jsx("button",{onClick:()=>b(!0),className:"text-[#2481CC] hover:underline font-semibold",children:"+ Quick Add"})]})]}),e.jsxs("div",{className:"astraea-panel rounded-xl p-5 border border-white/10 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-[10px] font-mono uppercase tracking-widest text-pearl-400",children:"Gateway 01"}),e.jsx("span",{className:"px-2 py-0.5 rounded text-[9px] font-mono uppercase bg-emerald-500/10 text-emerald-300 border border-emerald-500/30",children:"OPERATIONAL"})]}),e.jsx("h3",{className:"text-lg text-pearl-50 font-bold",children:"Razorpay India"}),e.jsx("p",{className:"text-xs font-mono text-pearl-400 mt-1",children:"Supports UPI, Credit Cards, NetBanking, and recurring mandate e-NACH."})]}),e.jsx("div",{className:"mt-4 pt-3 border-t border-white/5 text-[10px] font-mono text-pearl-400",children:"HMAC-SHA256 Webhook Verification Active"})]}),e.jsxs("div",{className:"astraea-panel rounded-xl p-5 border border-white/10 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-[10px] font-mono uppercase tracking-widest text-pearl-400",children:"Gateway 02"}),e.jsx("span",{className:"px-2 py-0.5 rounded text-[9px] font-mono uppercase bg-emerald-500/10 text-emerald-300 border border-emerald-500/30",children:"OPERATIONAL"})]}),e.jsx("h3",{className:"text-lg text-pearl-50 font-bold",children:"Stripe Global"}),e.jsx("p",{className:"text-xs font-mono text-pearl-400 mt-1",children:"Supports international cards, Apple Pay, Google Pay in USD, EUR, and GBP."})]}),e.jsx("div",{className:"mt-4 pt-3 border-t border-white/5 text-[10px] font-mono text-pearl-400",children:"Duplicate Webhook Protection (Idempotent)"})]})]}),e.jsxs("div",{className:"astraea-panel rounded-xl p-3 sm:p-5 border border-white/10 space-y-4 overflow-hidden min-w-0 max-w-full",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between pb-3 border-b border-white/10 gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ut,{className:"w-4 h-4 text-[#2481CC] shrink-0"}),e.jsx("h3",{className:"text-base text-pearl-50 font-bold tracking-tight",children:"Tamper-Evident Wallet Ledger"})]}),e.jsx("span",{className:"text-[10px] font-mono text-pearl-400",children:"Cryptographic SHA-256 Checksums"})]}),e.jsx("div",{className:"overflow-x-auto w-full max-w-full",children:e.jsxs("table",{className:"w-full min-w-[700px] 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:"Type"}),e.jsx("th",{className:"pb-3",children:"Description"}),e.jsx("th",{className:"pb-3",children:"Amount"}),e.jsx("th",{className:"pb-3",children:"Balance After"}),e.jsx("th",{className:"pb-3",children:"Cryptographic Checksum"}),e.jsx("th",{className:"pb-3 pr-2 text-right",children:"Timestamp"})]})}),e.jsx("tbody",{className:"divide-y divide-white/5",children:a.map(c=>e.jsxs("tr",{className:"hover:bg-white/[0.02]",children:[e.jsx("td",{className:"py-3 pl-2",children:c.type==="credit"?e.jsxs("span",{className:"px-2 py-0.5 rounded text-[9px] uppercase bg-emerald-500/10 text-emerald-300 border border-emerald-500/30 flex items-center gap-1 w-fit",children:[e.jsx(tr,{className:"w-3 h-3"})," CREDIT"]}):e.jsxs("span",{className:"px-2 py-0.5 rounded text-[9px] uppercase bg-space-850 text-pearl-300 border border-white/10 flex items-center gap-1 w-fit",children:[e.jsx(Ps,{className:"w-3 h-3 text-[#2481CC]"})," DEBIT"]})}),e.jsx("td",{className:"py-3 text-pearl-200",children:c.description}),e.jsx("td",{className:`py-3 font-semibold ${c.type==="credit"?"text-emerald-400":"text-pearl-100"}`,children:c.amount}),e.jsx("td",{className:"py-3 text-pearl-300",children:c.balanceAfter}),e.jsx("td",{className:"py-3 text-[10px] text-pearl-400 select-all",children:c.checksum}),e.jsx("td",{className:"py-3 pr-2 text-right text-pearl-400",children:c.timestamp})]},c.id))})]})})]}),e.jsxs("div",{className:"astraea-panel rounded-xl p-3 sm:p-5 border border-white/10 space-y-4 overflow-hidden min-w-0 max-w-full",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between pb-3 border-b border-white/10 gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(zt,{className:"w-4 h-4 text-[#2481CC] shrink-0"}),e.jsx("h3",{className:"text-base text-pearl-50 font-bold tracking-tight",children:"Official Tax Invoices"})]}),e.jsx("span",{className:"text-[10px] font-mono text-pearl-400",children:"18% GST Itemized"})]}),e.jsx("div",{className:"space-y-2",children:r.map(c=>e.jsxs("div",{className:"p-3.5 rounded-lg bg-space-850/60 border border-white/5 flex flex-col sm:flex-row sm:items-center justify-between text-xs font-mono gap-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 rounded-lg bg-space-900 border border-white/10 flex items-center justify-center text-[#2481CC] font-bold text-xs shrink-0",children:"INV"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-semibold text-pearl-100",children:c.invoiceNumber}),e.jsxs("div",{className:"text-[11px] text-pearl-400 font-sans",children:[c.planName," · ",c.date]})]})]}),e.jsxs("div",{className:"flex items-center justify-between sm:justify-end gap-4 sm:gap-6 pt-2 sm:pt-0 border-t sm:border-t-0 border-white/5",children:[e.jsxs("div",{className:"text-left sm:text-right",children:[e.jsx("div",{className:"font-semibold text-pearl-100",children:c.amount}),e.jsx("div",{className:"text-[10px] text-pearl-400",children:c.tax})]}),e.jsxs("button",{onClick:()=>alert(`Rendering official HTML invoice for ${c.invoiceNumber}`),className:"btn-telegram-secondary py-1.5 px-3 text-[10px]",children:[e.jsx(ge,{className:"w-3 h-3"}),e.jsx("span",{children:"VIEW HTML"})]})]})]},c.id))})]}),j&&e.jsx(te,{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-md 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.jsx("h3",{className:"text-lg text-pearl-50 font-bold tracking-tight mb-1",children:"Recharge Prepaid Wallet"}),e.jsx("p",{className:"text-xs font-mono text-[#2481CC] mb-4",children:"Cryptographically verified checkout order"}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-[10px] font-mono uppercase text-pearl-400 mb-1",children:"Amount in INR (₹)"}),e.jsx("input",{type:"number",value:m,onChange:c=>x(c.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]"})]}),e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-2",children:["2000","5000","10000","25000"].map(c=>e.jsxs("button",{type:"button",onClick:()=>x(c),className:"py-1.5 rounded-lg bg-space-850 border border-white/10 text-xs font-mono text-pearl-300 hover:border-[#2481CC]/40 hover:text-[#2481CC]",children:["₹",Number(c).toLocaleString("en-IN")]},c))}),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:()=>b(!1),className:"btn-telegram-secondary py-2 px-4",children:"CANCEL"}),e.jsx("button",{onClick:g,disabled:f,className:"btn-telegram-primary py-2 px-5 shadow-telegram",children:f?e.jsxs(e.Fragment,{children:[e.jsx(me,{className:"w-3.5 h-3.5 animate-spin"}),e.jsx("span",{children:"PROCESSING..."})]}):e.jsx("span",{children:"PROCEED TO PAYMENT"})})]})]})]})})})]})},wi=[{id:"m-1",name:"Alexander Vance",email:"alexander@astraea.space",role:"owner",status:"active",joinedDate:"2026-10-01"},{id:"m-2",name:"Samantha Grey",email:"samantha@astraea.space",role:"admin",status:"active",joinedDate:"2026-10-15"},{id:"m-3",name:"Vikram Mehta",email:"vikram@astraea.space",role:"editor",status:"active",joinedDate:"2026-11-04"}],Ni=()=>{const{currentBot:t}=z(),[s,n]=i.useState(wi),[a,l]=i.useState(!1),[r,o]=i.useState(""),[j,b]=i.useState("editor"),m=x=>{if(x.preventDefault(),!r.trim())return;const f={id:`m-${Date.now()}`,name:r.split("@")[0],email:r,role:j,status:"invited",joinedDate:"Today"};n([...s,f]),o(""),l(!1)};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:"Role-Based Access Control"})]}),e.jsx("h1",{className:"text-2xl sm:text-3xl md:text-4xl text-pearl-50 font-bold tracking-tight",children:"Team & Permissions"}),e.jsx("p",{className:"text-xs text-pearl-400 font-sans mt-1.5 max-w-2xl leading-relaxed",children:"Manage organization members with granular role boundaries. Owner, Admin, Editor, and Viewer privileges enforced at the API layer with tenant isolation."})]}),e.jsxs("button",{onClick:()=>l(!0),className:"btn-telegram-primary w-full sm:w-auto justify-center py-2.5 px-4 shrink-0 shadow-telegram",children:[e.jsx(ee,{className:"w-4 h-4"}),e.jsx("span",{children:"INVITE TEAM MEMBER"})]})]}),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:"Access Scope"}),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:["Team members with Editor or Admin privileges can deploy templates and broadcast messages to @",t.username,"."]})]})]}),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.jsx("span",{children:"RBAC Policy: Tenant Enforced"})]})]}),e.jsx("div",{className:"astraea-card rounded-xl p-3 sm:p-5 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 font-semibold",children:[e.jsx("th",{className:"pb-3 pl-2",children:"Member"}),e.jsx("th",{className:"pb-3",children:"Email Address"}),e.jsx("th",{className:"pb-3",children:"Role"}),e.jsx("th",{className:"pb-3",children:"Status"}),e.jsx("th",{className:"pb-3",children:"Joined Date"}),e.jsx("th",{className:"pb-3 pr-2 text-right",children:"Actions"})]})}),e.jsx("tbody",{className:"divide-y divide-white/5",children:s.map(x=>e.jsxs("tr",{className:"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-full bg-[#2481CC]/10 border border-[#2481CC]/30 flex items-center justify-center text-[#2481CC] font-bold text-[10px]",children:x.name.slice(0,2).toUpperCase()}),e.jsx("span",{children:x.name})]}),e.jsx("td",{className:"py-3.5 text-pearl-300",children:x.email}),e.jsx("td",{className:"py-3.5",children:e.jsx("span",{className:`px-2 py-0.5 rounded text-[9px] font-mono uppercase font-semibold ${x.role==="owner"?"bg-[#2481CC]/15 text-[#2481CC] border border-[#2481CC]/30 font-bold":x.role==="admin"?"bg-purple-500/15 text-purple-300 border border-purple-500/30":x.role==="editor"?"bg-blue-500/15 text-blue-300 border border-blue-500/30":"bg-space-850 text-pearl-400 border border-white/10"}`,children:x.role})}),e.jsx("td",{className:"py-3.5",children:e.jsx("span",{className:`px-2 py-0.5 rounded text-[9px] font-mono uppercase ${x.status==="active"?"bg-emerald-500/10 text-emerald-300 border border-emerald-500/30":"bg-amber-500/10 text-amber-300 border border-amber-500/30"}`,children:x.status})}),e.jsx("td",{className:"py-3.5 text-pearl-400",children:x.joinedDate}),e.jsx("td",{className:"py-3.5 pr-2 text-right",children:x.role!=="owner"&&e.jsx("button",{className:"text-xs text-rose-400 hover:text-rose-300 font-medium",children:"Revoke"})})]},x.id))})]})})}),e.jsxs("div",{className:"astraea-card rounded-xl p-4 sm:p-6 space-y-4",children:[e.jsx("h3",{className:"text-lg text-pearl-50 font-bold tracking-tight pb-3 border-b border-white/10",children:"RBAC Privilege Boundaries"}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4 text-xs font-mono",children:[{role:"Owner",perms:["Full Billing & Subscription","Bot Token Vault Access","Delete Tenant Org","Audit Log Access"]},{role:"Admin",perms:["Register & Edit Bots","Dispatch Broadcasts","Manage AI Agents","Invite Members"]},{role:"Editor",perms:["Message Studio Design","Template Publishing","Emoji Pack Management","Trigger Plugins"]},{role:"Viewer",perms:["Read-only Telemetry","Inspect Analytics","View Subscribers","Audience Insights"]}].map((x,f)=>e.jsxs("div",{className:"p-4 rounded-xl bg-space-850/60 border border-white/5 space-y-2",children:[e.jsx("div",{className:"text-sm text-[#2481CC] font-bold tracking-wide",children:x.role}),e.jsx("ul",{className:"space-y-1.5 text-pearl-300",children:x.perms.map((p,g)=>e.jsxs("li",{className:"flex items-center gap-1.5 text-[11px]",children:[e.jsx(D,{className:"w-3 h-3 text-[#2481CC] shrink-0"}),e.jsx("span",{children:p})]},g))})]},f))})]}),a&&e.jsx(te,{children:e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-3 sm:p-4 bg-black/60 backdrop-blur-md",children:e.jsxs("div",{className:"w-full max-w-md max-h-[90vh] overflow-y-auto astraea-card rounded-2xl p-4 sm:p-6 border border-[#2481CC]/30 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.jsx("h3",{className:"text-lg font-bold text-pearl-50 tracking-tight",children:"Invite Organization Member"}),e.jsx("button",{onClick:()=>l(!1),className:"text-pearl-400 hover:text-pearl-100 p-1",children:e.jsx(H,{className:"w-5 h-5"})})]}),e.jsxs("form",{onSubmit:m,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-[10px] font-mono uppercase text-pearl-400 mb-1.5 font-semibold",children:"Email Address"}),e.jsx("input",{type:"email",required:!0,value:r,onChange:x=>o(x.target.value),placeholder:"colleague@domain.com",className:"w-full px-3.5 py-2.5 rounded-xl bg-space-900 border border-white/10 text-xs font-mono text-pearl-100 focus:outline-none focus:border-[#2481CC] focus:ring-1 focus:ring-[#2481CC]"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-[10px] font-mono uppercase text-pearl-400 mb-1.5 font-semibold",children:"Assigned Role"}),e.jsxs("select",{value:j,onChange:x=>b(x.target.value),className:"w-full px-3.5 py-2.5 rounded-xl bg-space-900 border border-white/10 text-xs font-mono text-pearl-100 focus:outline-none focus:border-[#2481CC] focus:ring-1 focus:ring-[#2481CC]",children:[e.jsx("option",{value:"admin",children:"Admin (Operational Control)"}),e.jsx("option",{value:"editor",children:"Editor (Studio & Content)"}),e.jsx("option",{value:"viewer",children:"Viewer (Read-only)"})]})]}),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:()=>l(!1),className:"btn-telegram-secondary py-2 px-4",children:"CANCEL"}),e.jsxs("button",{type:"submit",className:"btn-telegram-primary py-2 px-5",children:[e.jsx(Vs,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"SEND INVITATION"})]})]})]})]})})})]})},yi=()=>{const{currentBot:t}=z();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",{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:"Operational Intelligence & Throughput"})]}),e.jsx("h1",{className:"text-2xl sm:text-3xl md:text-4xl text-pearl-50 font-bold tracking-tight",children:"Platform Analytics"}),e.jsx("p",{className:"text-xs text-pearl-400 font-sans mt-1.5 max-w-2xl leading-relaxed",children:"Real-time telemetry and historical message volume aggregations across all tenant bot instances, broadcasts, and AI tokens."})]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs font-mono w-full sm:w-auto",children:[e.jsx("span",{className:"px-3 py-1.5 rounded-lg bg-space-850 border border-white/10 text-pearl-300",children:"Last 7 Days"}),e.jsx("span",{className:"px-3 py-1.5 rounded-lg bg-[#2481CC]/15 border border-[#2481CC]/40 text-[#2481CC] font-semibold",children:"Live Stream"})]})]}),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:"Focus Bot Telemetry"}),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:["Live updates, delivery rates, and webhook latencies for @",t.username," (",t.usersCount.toLocaleString()," active users)."]})]})]}),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.jsx("span",{children:"Stream Latency: 22ms"})]})]}),e.jsxs("div",{className:"astraea-card rounded-2xl p-4 sm:p-6 space-y-4",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between pb-3 border-b border-white/10 gap-2",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-base sm:text-lg text-pearl-50 font-bold tracking-tight",children:"Weekly Traffic Velocity (Messages Handled)"}),e.jsx("p",{className:"text-xs font-mono text-pearl-400 mt-0.5",children:"Aggregate incoming updates + webhook dispatch responses"})]}),e.jsxs("div",{className:"text-left sm:text-right",children:[e.jsx("div",{className:"text-xl sm:text-2xl font-bold text-[#2481CC] tracking-tight",children:"1,128,490"}),e.jsx("div",{className:"text-[10px] font-mono text-emerald-400 font-semibold",children:"+18.4% vs previous week"})]})]}),e.jsxs("div",{className:"h-64 w-full relative pt-4",children:[e.jsxs("svg",{className:"w-full h-full overflow-visible",viewBox:"0 0 700 200",preserveAspectRatio:"none",children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:"telegramCurveGradient",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"#2481CC",stopOpacity:"0.35"}),e.jsx("stop",{offset:"100%",stopColor:"#2481CC",stopOpacity:"0.0"})]})}),e.jsx("line",{x1:"0",y1:"40",x2:"700",y2:"40",stroke:"rgba(255,255,255,0.06)",strokeDasharray:"4 4"}),e.jsx("line",{x1:"0",y1:"90",x2:"700",y2:"90",stroke:"rgba(255,255,255,0.06)",strokeDasharray:"4 4"}),e.jsx("line",{x1:"0",y1:"140",x2:"700",y2:"140",stroke:"rgba(255,255,255,0.06)",strokeDasharray:"4 4"}),e.jsx("path",{d:"M 0,160 Q 110,140 180,110 T 350,70 T 520,95 T 700,30 L 700,200 L 0,200 Z",fill:"url(#telegramCurveGradient)"}),e.jsx("path",{d:"M 0,160 Q 110,140 180,110 T 350,70 T 520,95 T 700,30",fill:"none",stroke:"#2481CC",strokeWidth:"3"}),[{cx:0,cy:160,day:"Mon",val:"120k"},{cx:116,cy:135,day:"Tue",val:"142k"},{cx:233,cy:100,day:"Wed",val:"168k"},{cx:350,cy:70,day:"Thu",val:"194k"},{cx:466,cy:88,day:"Fri",val:"180k"},{cx:583,cy:65,day:"Sat",val:"210k"},{cx:700,cy:30,day:"Sun",val:"245k"}].map((s,n)=>e.jsx("g",{children:e.jsx("circle",{cx:s.cx,cy:s.cy,r:"4.5",fill:"#17212B",stroke:"#2481CC",strokeWidth:"2"})},n))]}),e.jsxs("div",{className:"flex justify-between text-[11px] font-mono text-pearl-400 mt-3 pt-2 border-t border-white/5",children:[e.jsx("span",{children:"MON"}),e.jsx("span",{children:"TUE"}),e.jsx("span",{children:"WED"}),e.jsx("span",{children:"THU"}),e.jsx("span",{children:"FRI"}),e.jsx("span",{children:"SAT"}),e.jsx("span",{children:"SUN"})]})]})]}),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-4 sm:p-5 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs font-mono text-pearl-400",children:[e.jsx("span",{className:"uppercase text-[10px] text-[#2481CC] font-bold",children:"Audience Growth"}),e.jsx(Ae,{className:"w-4 h-4 text-[#2481CC]"})]}),e.jsx("div",{className:"text-2xl font-bold text-pearl-50 tracking-tight",children:"+4,890"}),e.jsx("p",{className:"text-xs font-mono text-pearl-400",children:"New bot conversations initiated this week"}),e.jsx("div",{className:"w-full bg-space-850 rounded-full h-1 mt-2",children:e.jsx("div",{className:"bg-[#2481CC] h-1 w-[72%] rounded-full"})})]}),e.jsxs("div",{className:"astraea-card rounded-2xl p-4 sm:p-5 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs font-mono text-pearl-400",children:[e.jsx("span",{className:"uppercase text-[10px] text-emerald-400 font-bold",children:"Avg Latency"}),e.jsx(Ie,{className:"w-4 h-4 text-emerald-400"})]}),e.jsx("div",{className:"text-2xl font-bold text-emerald-400 tracking-tight",children:"38.4 ms"}),e.jsx("p",{className:"text-xs font-mono text-pearl-400",children:"FastAPI asyncpg connection execution speed"}),e.jsx("div",{className:"w-full bg-space-850 rounded-full h-1 mt-2",children:e.jsx("div",{className:"bg-emerald-400 h-1 w-[92%] rounded-full"})})]}),e.jsxs("div",{className:"astraea-card rounded-2xl p-4 sm:p-5 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs font-mono text-pearl-400",children:[e.jsx("span",{className:"uppercase text-[10px] text-[#2481CC] font-bold",children:"Delivery Accuracy"}),e.jsx(pe,{className:"w-4 h-4 text-[#2481CC]"})]}),e.jsx("div",{className:"text-2xl font-bold text-pearl-50 tracking-tight",children:"99.82%"}),e.jsx("p",{className:"text-xs font-mono text-pearl-400",children:"Broadcast success after opt-out deduplication"}),e.jsx("div",{className:"w-full bg-space-850 rounded-full h-1 mt-2",children:e.jsx("div",{className:"bg-[#2481CC] h-1 w-[99%] rounded-full"})})]})]})]})},Ci=()=>{const{currentBot:t}=z(),[s,n]=i.useState("Apex Autonomous Corp"),[a,l]=i.useState("apex-autonomous"),[r,o]=i.useState("en"),[j,b]=i.useState("https://api.yourdomain.com/webhooks"),[m,x]=i.useState(!1),f=p=>{p.preventDefault(),x(!0),setTimeout(()=>x(!1),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",{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:"Tenant Architecture & Metadata"})]}),e.jsx("h1",{className:"text-2xl sm:text-3xl md:text-4xl text-pearl-50 font-bold tracking-tight",children:"Organization Settings"}),e.jsx("p",{className:"text-xs text-pearl-400 font-sans mt-1.5 max-w-2xl leading-relaxed",children:"Configure tenant-scoped metadata, default bot language parameters, and cryptographic webhook secret rotations."})]}),m&&e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 rounded-lg bg-emerald-500/10 border border-emerald-500/30 text-xs font-mono text-emerald-300",children:[e.jsx(F,{className:"w-4 h-4"}),e.jsx("span",{children:"Settings saved successfully!"})]})]}),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:"Selected Bot Instance"}),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:["Active webhook endpoint: ",e.jsx("span",{className:"font-mono text-pearl-300",children:t.webhookUrl})]})]})]}),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:["Bot Status: ",t.status.toUpperCase()]})]})]}),e.jsxs("form",{onSubmit:f,className:"space-y-6",children:[e.jsxs("div",{className:"astraea-card rounded-xl p-4 sm:p-6 space-y-4",children:[e.jsx("h3",{className:"text-lg text-pearl-50 font-bold tracking-tight pb-3 border-b border-white/10",children:"Tenant Profile"}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-[10px] font-mono uppercase text-pearl-400 mb-1.5 font-semibold",children:"Organization Legal Name"}),e.jsx("input",{type:"text",value:s,onChange:p=>n(p.target.value),className:"w-full px-3.5 py-2.5 rounded-xl bg-space-900 border border-white/10 text-xs font-mono text-pearl-100 focus:outline-none focus:border-[#2481CC] focus:ring-1 focus:ring-[#2481CC]"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-[10px] font-mono uppercase text-pearl-400 mb-1.5 font-semibold",children:"Tenant Slug (Subdomain identifier)"}),e.jsx("input",{type:"text",value:a,onChange:p=>l(p.target.value),className:"w-full px-3.5 py-2.5 rounded-xl bg-space-900 border border-white/10 text-xs font-mono text-pearl-100 focus:outline-none focus:border-[#2481CC] focus:ring-1 focus:ring-[#2481CC]"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-[10px] font-mono uppercase text-pearl-400 mb-1.5 font-semibold",children:"Platform Default Locale"}),e.jsxs("select",{value:r,onChange:p=>o(p.target.value),className:"w-full px-3.5 py-2.5 rounded-xl bg-space-900 border border-white/10 text-xs font-mono text-pearl-100 focus:outline-none focus:border-[#2481CC] focus:ring-1 focus:ring-[#2481CC]",children:[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:"ar",children:"Arabic (ar)"}),e.jsx("option",{value:"es",children:"Spanish (es)"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-[10px] font-mono uppercase text-pearl-400 mb-1.5 font-semibold",children:"Tenant Isolation Mode"}),e.jsxs("div",{className:"px-3.5 py-2.5 rounded-xl bg-space-900/60 border border-white/5 text-xs font-mono text-emerald-400 flex items-center gap-2",children:[e.jsx(q,{className:"w-4 h-4"}),e.jsx("span",{children:"Strict Foreign Key + Schema Context (X-Tenant-ID)"})]})]})]})]}),e.jsxs("div",{className:"astraea-card rounded-xl p-6 space-y-4",children:[e.jsx("h3",{className:"text-lg text-pearl-50 font-bold tracking-tight pb-3 border-b border-white/10",children:"Webhook & Secret Rotation"}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-[10px] font-mono uppercase text-pearl-400 mb-1.5 font-semibold",children:"Production Gateway Base URL"}),e.jsx("input",{type:"text",value:j,onChange:p=>b(p.target.value),className:"w-full px-3.5 py-2.5 rounded-xl bg-space-900 border border-white/10 text-xs font-mono text-pearl-100 focus:outline-none focus:border-[#2481CC] focus:ring-1 focus:ring-[#2481CC]"})]}),e.jsxs("div",{className:"pt-2 flex flex-col sm:flex-row sm:items-center justify-between gap-3",children:[e.jsxs("div",{className:"text-xs font-mono text-pearl-400",children:["Secret Hash Key Version: ",e.jsx("span",{className:"text-[#2481CC] font-semibold",children:"v1 (AES-256-GCM)"})]}),e.jsxs("button",{type:"button",onClick:()=>alert("Webhook cryptographic secret rotated to key version 2."),className:"btn-telegram-secondary py-2 px-3 text-[11px] w-full sm:w-auto justify-center",children:[e.jsx(me,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"ROTATE SECRET KEY"})]})]})]}),e.jsx("div",{className:"text-right",children:e.jsxs("button",{type:"submit",className:"btn-telegram-primary w-full sm:w-auto justify-center py-2.5 px-6 shadow-telegram",children:[e.jsx(bt,{className:"w-4 h-4"}),e.jsx("span",{children:"SAVE ORGANIZATION SETTINGS"})]})})]})]})},ki=[{id:"log-101",timestamp:"2026-11-18 08:45:12 UTC",actor:"alexander@astraea.space (Owner)",action:"BROADCAST_CAMPAIGN_DISPATCH",resource:"campaign:c-001 (Spring Flash Sale)",ipAddress:"192.168.1.104",status:"success"},{id:"log-102",timestamp:"2026-11-18 08:30:24 UTC",actor:"samantha@astraea.space (Admin)",action:"AI_AGENT_PROMPT_UPDATE",resource:"agent:agent-1 (Customer Concierge)",ipAddress:"10.0.4.18",status:"success"},{id:"log-103",timestamp:"2026-11-18 08:12:05 UTC",actor:"gateway:stripe_webhook",action:"PAYMENT_CAPTURE_VERIFIED",resource:"order:ord_9f81a7d",ipAddress:"54.187.205.12",status:"success"},{id:"log-104",timestamp:"2026-11-18 07:55:40 UTC",actor:"unknown_client",action:"IDOR_CROSS_TENANT_REJECTED",resource:"tenant:ten-other-org",ipAddress:"198.51.100.44",status:"rejected"},{id:"log-105",timestamp:"2026-11-18 07:20:18 UTC",actor:"vikram@astraea.space (Editor)",action:"MESSAGE_STUDIO_PUBLISHED",resource:"template:tmpl-1 (VIP Welcome Menu)",ipAddress:"172.16.0.8",status:"success"}],Si=()=>{const{currentBot:t}=z(),[s,n]=i.useState(ki),[a,l]=i.useState(""),r=s.filter(o=>o.action.toLowerCase().includes(a.toLowerCase())||o.actor.toLowerCase().includes(a.toLowerCase())||o.resource.toLowerCase().includes(a.toLowerCase()));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:"Compliance & Security Verification"})]}),e.jsx("h1",{className:"text-2xl sm:text-3xl md:text-4xl text-pearl-50 font-bold tracking-tight",children:"Security Audit Logs"}),e.jsx("p",{className:"text-xs text-pearl-400 font-sans mt-1.5 max-w-2xl leading-relaxed",children:"Append-only tamper-evident audit ledger recording every administrative mutation, token access, broadcast dispatch, and cross-tenant access rejection."})]}),e.jsxs("div",{className:"relative w-full sm:w-64 shrink-0",children:[e.jsx(He,{className:"w-3.5 h-3.5 text-pearl-400 absolute left-3 top-1/2 -translate-y-1/2"}),e.jsx("input",{type:"text",value:a,onChange:o=>l(o.target.value),placeholder:"Search action or actor...",className:"w-full pl-8 pr-3 py-2 rounded-xl bg-space-850/60 border border-white/10 text-xs font-mono text-pearl-100 focus:outline-none focus:border-[#2481CC] focus:ring-1 focus:ring-[#2481CC]"})]})]}),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:"Monitored Instance"}),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:["Tracking administrator mutations, webhook invocations, and deployment events across @",t.username,"."]})]})]}),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.jsx("span",{children:"Tamper Verification: Passing"})]})]}),e.jsx("div",{className:"astraea-card rounded-xl p-3 sm:p-5 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-[750px] 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 font-semibold",children:[e.jsx("th",{className:"pb-3 pl-2",children:"Timestamp (UTC)"}),e.jsx("th",{className:"pb-3",children:"Action Event"}),e.jsx("th",{className:"pb-3",children:"Actor Identity"}),e.jsx("th",{className:"pb-3",children:"Target Resource"}),e.jsx("th",{className:"pb-3",children:"Client IP"}),e.jsx("th",{className:"pb-3 pr-2 text-right",children:"Result"})]})}),e.jsx("tbody",{className:"divide-y divide-white/5",children:r.map(o=>e.jsxs("tr",{className:"hover:bg-white/[0.02] transition-colors",children:[e.jsx("td",{className:"py-3.5 pl-2 text-pearl-400 text-[11px]",children:o.timestamp}),e.jsx("td",{className:"py-3.5 font-semibold text-pearl-100",children:e.jsx("span",{className:"text-[#2481CC]",children:o.action})}),e.jsx("td",{className:"py-3.5 text-pearl-300",children:o.actor}),e.jsx("td",{className:"py-3.5 text-pearl-400 text-[11px]",children:o.resource}),e.jsx("td",{className:"py-3.5 text-pearl-400 text-[11px]",children:o.ipAddress}),e.jsx("td",{className:"py-3.5 pr-2 text-right",children:e.jsx("span",{className:`px-2 py-0.5 rounded text-[9px] uppercase font-semibold ${o.status==="success"?"bg-emerald-500/10 text-emerald-300 border border-emerald-500/30":"bg-rose-500/10 text-rose-300 border border-rose-500/30"}`,children:o.status})})]},o.id))})]})})})]})},_i=({onSuccess:t,onError:s,className:n="",size:a="large",showSandboxHelper:l=!0})=>{const{loginWithTelegram:r}=qe(),[o,j]=i.useState("astraea_super_bot"),[b,m]=i.useState(!1),[x,f]=i.useState(null),[p,g]=i.useState(null),u=i.useRef(null);i.useEffect(()=>{fetch("/api/v1/auth/telegram/config").then(c=>c.json()).then(c=>{var v;(v=c.data)!=null&&v.bot_username&&j(c.data.bot_username)}).catch(()=>{})},[]),i.useEffect(()=>(window.onTelegramAuth=async c=>{m(!0),f(null);const v=await r(c);if(m(!1),v.success)g("Telegram identity cryptographically verified!"),t==null||t();else{const h=v.error||"Telegram verification failed";f(h),s==null||s(h)}},()=>{delete window.onTelegramAuth}),[r,t,s]);const d=async(c="astraea_pilot")=>{var w;m(!0),f(null);const v=718291044,h=Math.floor(Date.now()/1e3),E={id:v,first_name:"Astraea",last_name:"Explorer",username:c,photo_url:"https://images.unsplash.com/photo-1534528741775-53994a69daeb?w=100&h=100&fit=crop",auth_date:h};try{const S=await fetch("/api/v1/auth/telegram",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...E,hash:await ys(E,"7182910392:AAExampleBotTokenForVerification2026")})}),P=await S.json();if(m(!1),S.ok&&P.success)g("Telegram session established and verified!"),r({...E,hash:await ys(E,"7182910392:AAExampleBotTokenForVerification2026")}),t==null||t();else{const k=P.message||((w=P.error)==null?void 0:w.message)||"Verification rejected";f(k),s==null||s(k)}}catch(S){m(!1),f(S.message||"Verification connection failed"),s==null||s(S.message)}};return e.jsxs("div",{className:`space-y-3 ${n}`,children:[e.jsx("button",{type:"button",onClick:()=>d("telegram_vip_member"),disabled:b,className:"w-full flex items-center justify-center gap-3 py-3 px-5 rounded-xl bg-[#2AABEE] hover:bg-[#229ED9] text-white font-medium text-sm transition-all shadow-lg hover:shadow-[#2AABEE]/25 disabled:opacity-60 relative group",children:b?e.jsxs(e.Fragment,{children:[e.jsx(me,{className:"w-5 h-5 animate-spin"}),e.jsx("span",{children:"Verifying Telegram Hash..."})]}):e.jsxs(e.Fragment,{children:[e.jsx("svg",{className:"w-5 h-5 fill-current",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm4.64 6.8c-.15 1.58-.8 5.42-1.13 7.19-.14.75-.42 1-.68 1.03-.58.05-1.02-.38-1.58-.75-.88-.58-1.38-.94-2.23-1.5-.99-.65-.35-1.01.22-1.59.15-.15 2.71-2.48 2.76-2.69a.2.2 0 00-.05-.18c-.06-.05-.14-.03-.21-.02-.09.02-1.49.95-4.22 2.79-.4.27-.76.41-1.08.4-.36-.01-1.04-.2-1.55-.37-.63-.2-1.12-.31-1.08-.66.02-.18.27-.36.75-.55 2.92-1.27 4.86-2.11 5.83-2.51 2.78-1.16 3.35-1.36 3.73-1.36.08 0 .27.02.39.12.1.08.13.19.14.27-.01.06.01.24 0 .38z"})}),e.jsx("span",{className:"font-semibold tracking-wide",children:"Log in with Telegram"})]})}),e.jsxs("div",{className:"flex items-center justify-center gap-1.5 text-[11px] font-mono text-pearl-400",children:[e.jsx(q,{className:"w-3.5 h-3.5 text-emerald-400"}),e.jsxs("span",{children:["Server-side HMAC-SHA256 signature verified against @",o]})]}),x&&e.jsxs("div",{className:"p-3 rounded-lg bg-rose-500/10 border border-rose-500/30 text-rose-300 text-xs font-mono flex items-center gap-2",children:[e.jsx(Jt,{className:"w-4 h-4 shrink-0 text-rose-400"}),e.jsx("span",{children:x})]}),p&&e.jsxs("div",{className:"p-3 rounded-lg bg-emerald-500/10 border border-emerald-500/30 text-emerald-300 text-xs font-mono flex items-center gap-2",children:[e.jsx(F,{className:"w-4 h-4 shrink-0 text-emerald-400"}),e.jsx("span",{children:p})]}),e.jsx("div",{ref:u,className:"hidden"})]})};async function ys(t,s){const n=[];for(const m of Object.keys(t).sort())m==="hash"||t[m]==null||n.push(`${m}=${t[m]}`);const a=n.join(`
apps/frontend/node_modules/@types/react/index.d.ts:2169: * @param subscribe
apps/frontend/node_modules/@types/react/index.d.ts:2176: subscribe: (onStoreChange: () => void) => () => void,
apps/frontend/node_modules/@types/react/ts5.0/index.d.ts:2170: * @param subscribe
apps/frontend/node_modules/@types/react/ts5.0/index.d.ts:2177: subscribe: (onStoreChange: () => void) => () => void,
apps/frontend/node_modules/react-dom/umd/react-dom-server-legacy.browser.development.js:5207: function useMutableSource(source, getSnapshot, subscribe) {
apps/frontend/node_modules/react-dom/umd/react-dom-server-legacy.browser.development.js:5212: function useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot) {
apps/frontend/node_modules/react-dom/umd/react-dom-server.browser.development.js:5204: function useMutableSource(source, getSnapshot, subscribe) {
apps/frontend/node_modules/react-dom/umd/react-dom-server.browser.development.js:5209: function useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot) {
apps/frontend/node_modules/react-dom/umd/react-dom.development.js:9188: var unsubscribeListener; // When legacyFBSupport is enabled, it's for when we
apps/frontend/node_modules/react-dom/umd/react-dom.development.js:9193: unsubscribeListener = addEventCaptureListenerWithPassiveFlag(targetContainer, domEventName, listener, isPassiveListener);
apps/frontend/node_modules/react-dom/umd/react-dom.development.js:9195: unsubscribeListener = addEventCaptureListener(targetContainer, domEventName, listener);
apps/frontend/node_modules/react-dom/umd/react-dom.development.js:9199: unsubscribeListener = addEventBubbleListenerWithPassiveFlag(targetContainer, domEventName, listener, isPassiveListener);
apps/frontend/node_modules/react-dom/umd/react-dom.development.js:9201: unsubscribeListener = addEventBubbleListener(targetContainer, domEventName, listener);
apps/frontend/node_modules/react-dom/umd/react-dom.development.js:15955: function mountMutableSource(source, getSnapshot, subscribe) {
apps/frontend/node_modules/react-dom/umd/react-dom.development.js:15961: function updateMutableSource(source, getSnapshot, subscribe) {
apps/frontend/node_modules/react-dom/umd/react-dom.development.js:15967: function mountSyncExternalStore(subscribe, getSnapshot, getServerSnapshot) {
apps/frontend/node_modules/react-dom/umd/react-dom.development.js:16030: hook.queue = inst; // Schedule an effect to subscribe to the store.
apps/frontend/node_modules/react-dom/umd/react-dom.development.js:16032: mountEffect(subscribeToStore.bind(null, fiber, inst, subscribe), [subscribe]); // Schedule an effect to update the mutable instance fields. We will update
apps/frontend/node_modules/react-dom/umd/react-dom.development.js:16033: // this whenever subscribe, getSnapshot, or value changes. Because there's no
apps/frontend/node_modules/react-dom/umd/react-dom.development.js:16045: function updateSyncExternalStore(subscribe, getSnapshot, getServerSnapshot) {
apps/frontend/node_modules/react-dom/umd/react-dom.development.js:16074: updateEffect(subscribeToStore.bind(null, fiber, inst, subscribe), [subscribe]); // Whenever getSnapshot or subscribe changes, we need to check in the
apps/frontend/node_modules/react-dom/umd/react-dom.development.js:16138: function subscribeToStore(fiber, inst, subscribe) {
apps/frontend/node_modules/react-dom/umd/react-dom.development.js:16149: return subscribe(handleStoreChange);
apps/frontend/node_modules/react-dom/umd/react-dom.development.js:16910: useMutableSource: function (source, getSnapshot, subscribe) {
apps/frontend/node_modules/react-dom/umd/react-dom.development.js:16915: useSyncExternalStore: function (subscribe, getSnapshot, getServerSnapshot) {
apps/frontend/node_modules/react-dom/umd/react-dom.development.js:16918: return mountSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
apps/frontend/node_modules/react-dom/umd/react-dom.development.js:17018: useMutableSource: function (source, getSnapshot, subscribe) {
apps/frontend/node_modules/react-dom/umd/react-dom.development.js:17023: useSyncExternalStore: function (subscribe, getSnapshot, getServerSnapshot) {
apps/frontend/node_modules/react-dom/umd/react-dom.development.js:17026: return mountSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
apps/frontend/node_modules/react-dom/umd/react-dom.development.js:17126: useMutableSource: function (source, getSnapshot, subscribe) {
apps/frontend/node_modules/react-dom/umd/react-dom.development.js:17131: useSyncExternalStore: function (subscribe, getSnapshot, getServerSnapshot) {
apps/frontend/node_modules/react-dom/umd/react-dom.development.js:17134: return updateSyncExternalStore(subscribe, getSnapshot);
apps/frontend/node_modules/react-dom/umd/react-dom.development.js:17234: useMutableSource: function (source, getSnapshot, subscribe) {
apps/frontend/node_modules/react-dom/umd/react-dom.development.js:17239: useSyncExternalStore: function (subscribe, getSnapshot, getServerSnapshot) {
apps/frontend/node_modules/react-dom/umd/react-dom.development.js:17242: return updateSyncExternalStore(subscribe, getSnapshot);
apps/frontend/node_modules/react-dom/umd/react-dom.development.js:17356: useMutableSource: function (source, getSnapshot, subscribe) {
apps/frontend/node_modules/react-dom/umd/react-dom.development.js:17362: useSyncExternalStore: function (subscribe, getSnapshot, getServerSnapshot) {
apps/frontend/node_modules/react-dom/umd/react-dom.development.js:17366: return mountSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
apps/frontend/node_modules/react-dom/umd/react-dom.development.js:17481: useMutableSource: function (source, getSnapshot, subscribe) {
apps/frontend/node_modules/react-dom/umd/react-dom.development.js:17487: useSyncExternalStore: function (subscribe, getSnapshot, getServerSnapshot) {
apps/frontend/node_modules/react-dom/umd/react-dom.development.js:17491: return updateSyncExternalStore(subscribe, getSnapshot);
apps/frontend/node_modules/react-dom/umd/react-dom.development.js:17606: useMutableSource: function (source, getSnapshot, subscribe) {
apps/frontend/node_modules/react-dom/umd/react-dom.development.js:17612: useSyncExternalStore: function (subscribe, getSnapshot, getServerSnapshot) {
apps/frontend/node_modules/react-dom/umd/react-dom.development.js:17616: return updateSyncExternalStore(subscribe, getSnapshot);
apps/frontend/node_modules/react-dom/umd/react-dom.development.js:22476: // part of the second pass. In that case nothing will subscribe to
apps/frontend/node_modules/react-dom/cjs/react-dom-server-legacy.browser.development.js:5210:function useMutableSource(source, getSnapshot, subscribe) {
apps/frontend/node_modules/react-dom/cjs/react-dom-server-legacy.browser.development.js:5215:function useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot) {
apps/frontend/node_modules/react-dom/cjs/react-dom-server.node.development.js:5273:function useMutableSource(source, getSnapshot, subscribe) {
apps/frontend/node_modules/react-dom/cjs/react-dom-server.node.development.js:5278:function useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot) {
apps/frontend/node_modules/react-dom/cjs/react-dom-server.browser.development.js:5207:function useMutableSource(source, getSnapshot, subscribe) {
apps/frontend/node_modules/react-dom/cjs/react-dom-server.browser.development.js:5212:function useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot) {
apps/frontend/node_modules/react-dom/cjs/react-dom-server-legacy.node.development.js:5211:function useMutableSource(source, getSnapshot, subscribe) {
apps/frontend/node_modules/react-dom/cjs/react-dom-server-legacy.node.development.js:5216:function useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot) {
apps/frontend/node_modules/react-dom/cjs/react-dom.development.js:9178: var unsubscribeListener; // When legacyFBSupport is enabled, it's for when we
apps/frontend/node_modules/react-dom/cjs/react-dom.development.js:9183: unsubscribeListener = addEventCaptureListenerWithPassiveFlag(targetContainer, domEventName, listener, isPassiveListener);
apps/frontend/node_modules/react-dom/cjs/react-dom.development.js:9185: unsubscribeListener = addEventCaptureListener(targetContainer, domEventName, listener);
apps/frontend/node_modules/react-dom/cjs/react-dom.development.js:9189: unsubscribeListener = addEventBubbleListenerWithPassiveFlag(targetContainer, domEventName, listener, isPassiveListener);
apps/frontend/node_modules/react-dom/cjs/react-dom.development.js:9191: unsubscribeListener = addEventBubbleListener(targetContainer, domEventName, listener);
apps/frontend/node_modules/react-dom/cjs/react-dom.development.js:15945:function mountMutableSource(source, getSnapshot, subscribe) {
apps/frontend/node_modules/react-dom/cjs/react-dom.development.js:15951:function updateMutableSource(source, getSnapshot, subscribe) {
apps/frontend/node_modules/react-dom/cjs/react-dom.development.js:15957:function mountSyncExternalStore(subscribe, getSnapshot, getServerSnapshot) {
apps/frontend/node_modules/react-dom/cjs/react-dom.development.js:16020: hook.queue = inst; // Schedule an effect to subscribe to the store.
apps/frontend/node_modules/react-dom/cjs/react-dom.development.js:16022: mountEffect(subscribeToStore.bind(null, fiber, inst, subscribe), [subscribe]); // Schedule an effect to update the mutable instance fields. We will update
apps/frontend/node_modules/react-dom/cjs/react-dom.development.js:16023: // this whenever subscribe, getSnapshot, or value changes. Because there's no
apps/frontend/node_modules/react-dom/cjs/react-dom.development.js:16035:function updateSyncExternalStore(subscribe, getSnapshot, getServerSnapshot) {
apps/frontend/node_modules/react-dom/cjs/react-dom.development.js:16064: updateEffect(subscribeToStore.bind(null, fiber, inst, subscribe), [subscribe]); // Whenever getSnapshot or subscribe changes, we need to check in the
apps/frontend/node_modules/react-dom/cjs/react-dom.development.js:16128:function subscribeToStore(fiber, inst, subscribe) {
apps/frontend/node_modules/react-dom/cjs/react-dom.development.js:16139: return subscribe(handleStoreChange);
apps/frontend/node_modules/react-dom/cjs/react-dom.development.js:16900: useMutableSource: function (source, getSnapshot, subscribe) {
apps/frontend/node_modules/react-dom/cjs/react-dom.development.js:16905: useSyncExternalStore: function (subscribe, getSnapshot, getServerSnapshot) {
apps/frontend/node_modules/react-dom/cjs/react-dom.development.js:16908: return mountSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
apps/frontend/node_modules/react-dom/cjs/react-dom.development.js:17008: useMutableSource: function (source, getSnapshot, subscribe) {
apps/frontend/node_modules/react-dom/cjs/react-dom.development.js:17013: useSyncExternalStore: function (subscribe, getSnapshot, getServerSnapshot) {
apps/frontend/node_modules/react-dom/cjs/react-dom.development.js:17016: return mountSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
apps/frontend/node_modules/react-dom/cjs/react-dom.development.js:17116: useMutableSource: function (source, getSnapshot, subscribe) {
apps/frontend/node_modules/react-dom/cjs/react-dom.development.js:17121: useSyncExternalStore: function (subscribe, getSnapshot, getServerSnapshot) {
apps/frontend/node_modules/react-dom/cjs/react-dom.development.js:17124: return updateSyncExternalStore(subscribe, getSnapshot);
apps/frontend/node_modules/react-dom/cjs/react-dom.development.js:17224: useMutableSource: function (source, getSnapshot, subscribe) {
apps/frontend/node_modules/react-dom/cjs/react-dom.development.js:17229: useSyncExternalStore: function (subscribe, getSnapshot, getServerSnapshot) {
apps/frontend/node_modules/react-dom/cjs/react-dom.development.js:17232: return updateSyncExternalStore(subscribe, getSnapshot);
apps/frontend/node_modules/react-dom/cjs/react-dom.development.js:17346: useMutableSource: function (source, getSnapshot, subscribe) {
apps/frontend/node_modules/react-dom/cjs/react-dom.development.js:17352: useSyncExternalStore: function (subscribe, getSnapshot, getServerSnapshot) {
apps/frontend/node_modules/react-dom/cjs/react-dom.development.js:17356: return mountSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
apps/frontend/node_modules/react-dom/cjs/react-dom.development.js:17471: useMutableSource: function (source, getSnapshot, subscribe) {
apps/frontend/node_modules/react-dom/cjs/react-dom.development.js:17477: useSyncExternalStore: function (subscribe, getSnapshot, getServerSnapshot) {
apps/frontend/node_modules/react-dom/cjs/react-dom.development.js:17481: return updateSyncExternalStore(subscribe, getSnapshot);
apps/frontend/node_modules/react-dom/cjs/react-dom.development.js:17596: useMutableSource: function (source, getSnapshot, subscribe) {
apps/frontend/node_modules/react-dom/cjs/react-dom.development.js:17602: useSyncExternalStore: function (subscribe, getSnapshot, getServerSnapshot) {
apps/frontend/node_modules/react-dom/cjs/react-dom.development.js:17606: return updateSyncExternalStore(subscribe, getSnapshot);
apps/frontend/node_modules/react-dom/cjs/react-dom.development.js:22466: // part of the second pass. In that case nothing will subscribe to
apps/frontend/node_modules/@remix-run/router/CHANGELOG.md:491: - The router will also pass a new `deletedFetchers` array to the subscriber callbacks so that the UI layer can remove associated fetcher data
apps/frontend/node_modules/@remix-run/router/dist/router.umd.min.js:11:!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).RemixRouter={})}(this,function(e){"use strict";function t(){return t=Object.assign?Object.assign.bind():function(e){for(var t=1;t=0&&(t.hash=e.substr(r),e=e.substr(0,r));let a=e.indexOf("?");a>=0&&(t.search=e.substr(a),e=e.substr(0,a)),e&&(t.pathname=e)}return t}function c(e,o,u,c){void 0===c&&(c={});let{window:d=document.defaultView,v5Compat:h=!1}=c,f=d.history,p=r.Pop,m=null,y=v();function v(){return(f.state||{idx:null}).idx}function g(){p=r.Pop;let e=v(),t=null==e?null:e-y;y=e,m&&m({action:p,location:w.location,delta:t})}function b(e){let t="null"!==d.location.origin?d.location.origin:d.location.href,r="string"==typeof e?e:l(e);return r=r.replace(/ $/,"%20"),n(t,"No window.location.(origin|href) available to create URL for href: "+r),new URL(r,t)}null==y&&(y=0,f.replaceState(t({},f.state,{idx:y}),""));let w={get action(){return p},get location(){return e(d,f)},listen(e){if(m)throw new Error("A history only accepts one active listener");return d.addEventListener(a,g),m=e,()=>{d.removeEventListener(a,g),m=null}},createHref:e=>o(d,e),createURL:b,encodeLocation(e){let t=b(e);return{pathname:t.pathname,search:t.search,hash:t.hash}},push:function(e,t){p=r.Push;let a=s(w.location,e,t);u&&u(a,e),y=v()+1;let n=i(a,y),o=w.createHref(a);try{f.pushState(n,"",o)}catch(e){if(e instanceof DOMException&&"DataCloneError"===e.name)throw e;d.location.assign(o)}h&&m&&m({action:p,location:w.location,delta:1})},replace:function(e,t){p=r.Replace;let a=s(w.location,e,t);u&&u(a,e),y=v();let n=i(a,y),o=w.createHref(a);f.replaceState(n,"",o),h&&m&&m({action:p,location:w.location,delta:0})},go:e=>f.go(e)};return w}let d=function(e){return e.data="data",e.deferred="deferred",e.redirect="redirect",e.error="error",e}({});const h=new Set(["lazy","caseSensitive","path","id","index","children"]);function f(e,r,a,o){return void 0===a&&(a=[]),void 0===o&&(o={}),e.map((e,i)=>{let s=[...a,String(i)],l="string"==typeof e.id?e.id:s.join("-");if(n(!0!==e.index||!e.children,"Cannot specify children on an index route"),n(!o[l],'Found a route id collision on id "'+l+"\". Route id's must be globally unique within Data Router usages"),function(e){return!0===e.index}(e)){let a=t({},e,r(e),{id:l});return o[l]=a,a}{let a=t({},e,r(e),{id:l,children:void 0});return o[l]=a,e.children&&(a.children=f(e.children,r,s,o)),a}})}function p(e,t,r){return void 0===r&&(r="/"),m(e,t,r,!1)}function m(e,t,r,a){let n=j(("string"==typeof t?u(t):t).pathname||"/",r);if(null==n)return null;let o=v(e);!function(e){e.sort((e,t)=>e.score!==t.score?t.score-e.score:function(e,t){let r=e.length===t.length&&e.slice(0,-1).every((e,r)=>e===t[r]);return r?e[e.length-1]-t[t.length-1]:0}(e.routesMeta.map(e=>e.childrenIndex),t.routesMeta.map(e=>e.childrenIndex)))}(o);let i=null,s=M(n);for(let e=0;null==i&&e{let s={relativePath:void 0===i?e.path||"":i,caseSensitive:!0===e.caseSensitive,childrenIndex:o,route:e};s.relativePath.startsWith("/")&&(n(s.relativePath.startsWith(a),'Absolute route path "'+s.relativePath+'" nested under path "'+a+'" is not valid. An absolute child route path must start with the combined path of all its parent routes.'),s.relativePath=s.relativePath.slice(a.length));let l=H([a,s.relativePath]),u=r.concat(s);e.children&&e.children.length>0&&(n(!0!==e.index,'Index routes must not have child routes. Please remove all child routes from route path "'+l+'".'),v(e.children,t,u,l)),(null!=e.path||e.index)&&t.push({path:l,score:x(l,e.index),routesMeta:u})};return e.forEach((e,t)=>{var r;if(""!==e.path&&null!=(r=e.path)&&r.includes("?"))for(let r of g(e.path))o(e,t,r);else o(e,t)}),t}function g(e){let t=e.split("/");if(0===t.length)return[];let[r,...a]=t,n=r.endsWith("?"),o=r.replace(/\?$/,"");if(0===a.length)return n?[o,""]:[o];let i=g(a.join("/")),s=[];return s.push(...i.map(e=>""===e?o:[o,e].join("/"))),n&&s.push(...i),s.map(t=>e.startsWith("/")&&""===t?"/":t)}const b=/^:[\w-]+$/,w=3,S=2,D=1,R=10,E=-2,P=e=>"*"===e;function x(e,t){let r=e.split("/"),a=r.length;return r.some(P)&&(a+=E),t&&(a+=S),r.filter(e=>!P(e)).reduce((e,t)=>e+(b.test(t)?w:""===t?D:R),a)}function L(e,t,r){void 0===r&&(r=!1);let{routesMeta:a}=e,n={},o="/",i=[];for(let e=0;e(a.push({paramName:t,isOptional:null!=r}),r?"/?([^\\/]+)?":"/([^\\/]+)"));e.endsWith("*")?(a.push({paramName:"*"}),n+="*"===e||"/*"===e?"(.*)$":"(?:\\/(.+)|\\/*)$"):r?n+="\\/*$":""!==e&&"/"!==e&&(n+="(?:(?=\\/|$))");let i=new RegExp(n,t?void 0:"i");return[i,a]}(e.path,e.caseSensitive,e.end),n=t.match(r);if(!n)return null;let i=n[0],s=i.replace(/(.)\/+$/,"$1"),l=n.slice(1);return{params:a.reduce((e,t,r)=>{let{paramName:a,isOptional:n}=t;if("*"===a){let e=l[r]||"";s=i.slice(0,i.length-e.length).replace(/(.)\/+$/,"$1")}const o=l[r];return e[a]=n&&!o?void 0:(o||"").replace(/%2F/g,"/"),e},{}),pathname:i,pathnameBase:s,pattern:e}}function M(e){try{return e.split("/").map(e=>decodeURIComponent(e).replace(/\//g,"%2F")).join("/")}catch(t){return o(!1,'The URL path "'+e+'" could not be decoded because it is is a malformed URL segment. This is probably due to a bad percent encoding ('+t+")."),e}}function j(e,t){if("/"===t)return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let r=t.endsWith("/")?t.length-1:t.length,a=e.charAt(r);return a&&"/"!==a?null:e.slice(r)||"/"}function k(e,t){void 0===t&&(t="/");let r,{pathname:a,search:n="",hash:o=""}="string"==typeof e?u(e):e;return a?(a=I(a),r=a.startsWith("/")?C(a.substring(1),"/"):C(a,t)):r=t,{pathname:r,search:F(n),hash:N(o)}}function C(e,t){let r=t.replace(/\/+$/,"").split("/");return e.split("/").forEach(e=>{".."===e?r.length>1&&r.pop():"."!==e&&r.push(e)}),r.length>1?r.join("/"):"/"}function _(e,t,r,a){return"Cannot include a '"+e+"' character in a manually specified `to."+t+"` field ["+JSON.stringify(a)+"]. Please separate it out to the `to."+r+'` field. Alternatively you may provide the full path as a string in and the router will parse it for you.'}function T(e){return e.filter((e,t)=>0===t||e.route.path&&e.route.path.length>0)}function U(e,t){let r=T(e);return t?r.map((e,t)=>t===r.length-1?e.pathname:e.pathnameBase):r.map(e=>e.pathnameBase)}function O(e,r,a,o){let i;void 0===o&&(o=!1),"string"==typeof e?i=u(e):(i=t({},e),n(!i.pathname||!i.pathname.includes("?"),_("?","pathname","search",i)),n(!i.pathname||!i.pathname.includes("#"),_("#","pathname","hash",i)),n(!i.search||!i.search.includes("#"),_("#","search","hash",i)));let s,l=""===e||""===i.pathname,c=l?"/":i.pathname;if(null==c)s=a;else{let e=r.length-1;if(!o&&c.startsWith("..")){let t=c.split("/");for(;".."===t[0];)t.shift(),e-=1;i.pathname=t.join("/")}s=e>=0?r[e]:"/"}let d=k(i,s),h=c&&"/"!==c&&c.endsWith("/"),f=(l||"."===c)&&a.endsWith("/");return d.pathname.endsWith("/")||!h&&!f||(d.pathname+="/"),d}const I=e=>e.replace(/\/\/+/g,"/"),H=e=>I(e.join("/")),z=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),F=e=>e&&"?"!==e?e.startsWith("?")?e:"?"+e:"",N=e=>e&&"#"!==e?e.startsWith("#")?e:"#"+e:"";class B{constructor(e,t){this.type="DataWithResponseInit",this.data=e,this.init=t||null}}class W extends Error{}class ${constructor(e,t){let r;this.pendingKeysSet=new Set,this.subscribers=new Set,this.deferredKeys=[],n(e&&"object"==typeof e&&!Array.isArray(e),"defer() only accepts plain objects"),this.abortPromise=new Promise((e,t)=>r=t),this.controller=new AbortController;let a=()=>r(new W("Deferred data aborted"));this.unlistenAbortSignal=()=>this.controller.signal.removeEventListener("abort",a),this.controller.signal.addEventListener("abort",a),this.data=Object.entries(e).reduce((e,t)=>{let[r,a]=t;return Object.assign(e,{[r]:this.trackPromise(r,a)})},{}),this.done&&this.unlistenAbortSignal(),this.init=t}trackPromise(e,t){if(!(t instanceof Promise))return t;this.deferredKeys.push(e),this.pendingKeysSet.add(e);let r=Promise.race([t,this.abortPromise]).then(t=>this.onSettle(r,e,void 0,t),t=>this.onSettle(r,e,t));return r.catch(()=>{}),Object.defineProperty(r,"_tracked",{get:()=>!0}),r}onSettle(e,t,r,a){if(this.controller.signal.aborted&&r instanceof W)return this.unlistenAbortSignal(),Object.defineProperty(e,"_error",{get:()=>r}),Promise.reject(r);if(this.pendingKeysSet.delete(t),this.done&&this.unlistenAbortSignal(),void 0===r&&void 0===a){let r=new Error('Deferred data for key "'+t+'" resolved/rejected with `undefined`, you must resolve/reject with a value or `null`.');return Object.defineProperty(e,"_error",{get:()=>r}),this.emit(!1,t),Promise.reject(r)}return void 0===a?(Object.defineProperty(e,"_error",{get:()=>r}),this.emit(!1,t),Promise.reject(r)):(Object.defineProperty(e,"_data",{get:()=>a}),this.emit(!1,t),a)}emit(e,t){this.subscribers.forEach(r=>r(e,t))}subscribe(e){return this.subscribers.add(e),()=>this.subscribers.delete(e)}cancel(){this.controller.abort(),this.pendingKeysSet.forEach((e,t)=>this.pendingKeysSet.delete(t)),this.emit(!0)}async resolveData(e){let t=!1;if(!this.done){let r=()=>this.cancel();e.addEventListener("abort",r),t=await new Promise(t=>{this.subscribe(a=>{e.removeEventListener("abort",r),(a||this.done)&&t(a)})})}return t}get done(){return 0===this.pendingKeysSet.size}get unwrappedData(){return n(null!==this.data&&this.done,"Can only unwrap data on initialized and settled deferreds"),Object.entries(this.data).reduce((e,t)=>{let[r,a]=t;return Object.assign(e,{[r]:q(a)})},{})}get pendingKeys(){return Array.from(this.pendingKeysSet)}}function q(e){if(!function(e){return e instanceof Promise&&!0===e._tracked}(e))return e;if(e._error)throw e._error;return e._data}const K=function(e,r){void 0===r&&(r=302);let a=r;"number"==typeof a?a={status:a}:void 0===a.status&&(a.status=302);let n=new Headers(a.headers);return n.set("Location",e),new Response(null,t({},a,{headers:n}))};class Y{constructor(e,t,r,a){void 0===a&&(a=!1),this.status=e,this.statusText=t||"",this.internal=a,r instanceof Error?(this.data=r.toString(),this.error=r):this.data=r}}function J(e){return null!=e&&"number"==typeof e.status&&"string"==typeof e.statusText&&"boolean"==typeof e.internal&&"data"in e}const V=["post","put","patch","delete"],X=new Set(V),G=["get",...V],Q=new Set(G),Z=new Set([301,302,303,307,308]),ee=new Set([307,308]),te={state:"idle",location:void 0,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0},re={state:"idle",data:void 0,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0},ae={state:"unblocked",proceed:void 0,reset:void 0,location:void 0},ne=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,oe=e=>({hasErrorBoundary:Boolean(e.hasErrorBoundary)}),ie="remix-router-transitions";const se=Symbol("deferred");function le(e,t,r){if(r.v7_throwAbortReason&&void 0!==e.signal.reason)throw e.signal.reason;throw new Error((t?"queryRoute":"query")+"() call aborted: "+e.method+" "+e.url)}function ue(e,t,r,a,n,o,i,s){let u,c;if(i){u=[];for(let e of t)if(u.push(e),e.route.id===i){c=e;break}}else u=t,c=t[t.length-1];let d=O(n||".",U(u,o),j(e.pathname,r)||e.pathname,"path"===s);if(null==n&&(d.search=e.search,d.hash=e.hash),(null==n||""===n||"."===n)&&c){let e=Ye(d.search);if(c.route.index&&!e)d.search=d.search?d.search.replace(/^\?/,"?index&"):"?index";else if(!c.route.index&&e){let e=new URLSearchParams(d.search),t=e.getAll("index");e.delete("index"),t.filter(e=>e).forEach(t=>e.append("index",t));let r=e.toString();d.search=r?"?"+r:""}}return a&&"/"!==r&&(d.pathname="/"===d.pathname?r:H([r,d.pathname])),l(d)}function ce(e,t,r,a){if(!a||!function(e){return null!=e&&("formData"in e&&null!=e.formData||"body"in e&&void 0!==e.body)}(a))return{path:r};if(a.formMethod&&!Be(a.formMethod))return{path:r,error:Ce(405,{method:a.formMethod})};let o,i,s=()=>({path:r,error:Ce(400,{type:"invalid-body"})}),c=a.formMethod||"get",d=e?c.toUpperCase():c.toLowerCase(),h=Te(r);if(void 0!==a.body){if("text/plain"===a.formEncType){if(!We(d))return s();let e="string"==typeof a.body?a.body:a.body instanceof FormData||a.body instanceof URLSearchParams?Array.from(a.body.entries()).reduce((e,t)=>{let[r,a]=t;return""+e+r+"="+a+"\n"},""):String(a.body);return{path:r,submission:{formMethod:d,formAction:h,formEncType:a.formEncType,formData:void 0,json:void 0,text:e}}}if("application/json"===a.formEncType){if(!We(d))return s();try{let e="string"==typeof a.body?JSON.parse(a.body):a.body;return{path:r,submission:{formMethod:d,formAction:h,formEncType:a.formEncType,formData:void 0,json:e,text:void 0}}}catch(e){return s()}}}if(n("function"==typeof FormData,"FormData is not available in this environment"),a.formData)o=Ee(a.formData),i=a.formData;else if(a.body instanceof FormData)o=Ee(a.body),i=a.body;else if(a.body instanceof URLSearchParams)o=a.body,i=Pe(o);else if(null==a.body)o=new URLSearchParams,i=new FormData;else try{o=new URLSearchParams(a.body),i=Pe(o)}catch(e){return s()}let f={formMethod:d,formAction:h,formEncType:a&&a.formEncType||"application/x-www-form-urlencoded",formData:i,json:void 0,text:void 0};if(We(f.formMethod))return{path:r,submission:f};let p=u(r);return t&&p.search&&Ye(p.search)&&o.append("index",""),p.search="?"+o,{path:l(p),submission:f}}function de(e,t,r){void 0===r&&(r=!1);let a=e.findIndex(e=>e.route.id===t);return a>=0?e.slice(0,r?a+1:a):e}function he(e,r,a,n,o,i,s,l,u,c,d,h,f,m,y,v){let g=v?Ie(v[1])?v[1].error:v[1].data:void 0,b=e.createURL(r.location),w=e.createURL(o),S=a;i&&r.errors?S=de(a,Object.keys(r.errors)[0],!0):v&&Ie(v[1])&&(S=de(a,v[0]));let D=v?v[1].statusCode:void 0,R=s&&D&&D>=400,E=S.filter((e,a)=>{let{route:o}=e;if(o.lazy)return!0;if(null==o.loader)return!1;if(i)return fe(o,r.loaderData,r.errors);if(function(e,t,r){let a=!t||r.route.id!==t.route.id,n=void 0===e[r.route.id];return a||n}(r.loaderData,r.matches[a],e)||u.some(t=>t===e.route.id))return!0;let s=r.matches[a],c=e;return me(e,t({currentUrl:b,currentParams:s.params,nextUrl:w,nextParams:c.params},n,{actionResult:g,actionStatus:D,defaultShouldRevalidate:!R&&(l||b.pathname+b.search===w.pathname+w.search||b.search!==w.search||pe(s,c))}))}),P=[];return h.forEach((e,o)=>{if(i||!a.some(t=>t.route.id===e.routeId)||d.has(o))return;let s=p(m,e.path,y);if(!s)return void P.push({key:o,routeId:e.routeId,path:e.path,matches:null,match:null,controller:null});let u=r.fetchers.get(o),h=Je(s,e.path),v=!1;f.has(o)?v=!1:c.has(o)?(c.delete(o),v=!0):v=u&&"idle"!==u.state&&void 0===u.data?l:me(h,t({currentUrl:b,currentParams:r.matches[r.matches.length-1].params,nextUrl:w,nextParams:a[a.length-1].params},n,{actionResult:g,actionStatus:D,defaultShouldRevalidate:!R&&l})),v&&P.push({key:o,routeId:e.routeId,path:e.path,matches:s,match:h,controller:new AbortController})}),[E,P]}function fe(e,t,r){if(e.lazy)return!0;if(!e.loader)return!1;let a=null!=t&&void 0!==t[e.id],n=null!=r&&void 0!==r[e.id];return!(!a&&n)&&("function"==typeof e.loader&&!0===e.loader.hydrate||!a&&!n)}function pe(e,t){let r=e.route.path;return e.pathname!==t.pathname||null!=r&&r.endsWith("*")&&e.params["*"]!==t.params["*"]}function me(e,t){if(e.route.shouldRevalidate){let r=e.route.shouldRevalidate(t);if("boolean"==typeof r)return r}return t.defaultShouldRevalidate}function ye(e,t,r,a,o){var i;let s;if(e){let t=a[e];n(t,"No route found to patch children into: routeId = "+e),t.children||(t.children=[]),s=t.children}else s=r;let l=f(t.filter(e=>!s.some(t=>ve(e,t))),o,[e||"_","patch",String((null==(i=s)?void 0:i.length)||"0")],a);s.push(...l)}function ve(e,t){return"id"in e&&"id"in t&&e.id===t.id||e.index===t.index&&e.path===t.path&&e.caseSensitive===t.caseSensitive&&(!(e.children&&0!==e.children.length||t.children&&0!==t.children.length)||e.children.every((e,r)=>{var a;return null==(a=t.children)?void 0:a.some(t=>ve(e,t))}))}async function ge(e){let{matches:t}=e,r=t.filter(e=>e.shouldLoad);return(await Promise.all(r.map(e=>e.resolve()))).reduce((e,t,a)=>Object.assign(e,{[r[a].route.id]:t}),{})}async function be(e,r,a,i,s,l,u,c,f,p){let m=l.map(e=>e.route.lazy?async function(e,r,a){if(!e.lazy)return;let i=await e.lazy();if(!e.lazy)return;let s=a[e.id];n(s,"No route found in manifest");let l={};for(let e in i){let t=void 0!==s[e]&&"hasErrorBoundary"!==e;o(!t,'Route "'+s.id+'" has a static property "'+e+'" defined but its lazy function is also returning a value for this property. The lazy route property "'+e+'" will be ignored.'),t||h.has(e)||(l[e]=i[e])}Object.assign(s,l),Object.assign(s,t({},r(s),{lazy:void 0}))}(e.route,f,c):void 0),y=l.map((e,a)=>{let o=m[a],l=s.some(t=>t.route.id===e.route.id);return t({},e,{shouldLoad:l,resolve:async t=>(t&&"GET"===i.method&&(e.route.lazy||e.route.loader)&&(l=!0),l?async function(e,t,r,a,o,i){let s,l,u=a=>{let n,s=new Promise((e,t)=>n=t);l=()=>n(),t.signal.addEventListener("abort",l);let u=n=>"function"!=typeof a?Promise.reject(new Error('You cannot call the handler for a route which defines a boolean "'+e+'" [routeId: '+r.route.id+"]")):a({request:t,params:r.params,context:i},...void 0!==n?[n]:[]),c=(async()=>{try{return{type:"data",result:await(o?o(e=>u(e)):u())}}catch(e){return{type:"error",result:e}}})();return Promise.race([c,s])};try{let o=r.route[e];if(a)if(o){let e,[t]=await Promise.all([u(o).catch(t=>{e=t}),a]);if(void 0!==e)throw e;s=t}else{if(await a,o=r.route[e],!o){if("action"===e){let e=new URL(t.url),a=e.pathname+e.search;throw Ce(405,{method:t.method,pathname:a,routeId:r.route.id})}return{type:d.data,result:void 0}}s=await u(o)}else{if(!o){let e=new URL(t.url);throw Ce(404,{pathname:e.pathname+e.search})}s=await u(o)}n(void 0!==s.result,"You defined "+("action"===e?"an action":"a loader")+' for route "'+r.route.id+"\" but didn't return anything from your `"+e+"` function. Please return a value or `null`.")}catch(e){return{type:d.error,result:e}}finally{l&&t.signal.removeEventListener("abort",l)}return s}(r,i,e,o,t,p):Promise.resolve({type:d.data,result:void 0}))})}),v=await e({matches:y,request:i,params:l[0].params,fetcherKey:u,context:p});try{await Promise.all(m)}catch(e){}return v}async function we(e){let{result:t,type:r}=e;if(Ne(t)){let e;try{let r=t.headers.get("Content-Type");e=r&&/\bapplication\/json\b/.test(r)?null==t.body?null:await t.json():await t.text()}catch(e){return{type:d.error,error:e}}return r===d.error?{type:d.error,error:new Y(t.status,t.statusText,e),statusCode:t.status,headers:t.headers}:{type:d.data,data:e,statusCode:t.status,headers:t.headers}}var a,n,o,i,s,l,u,c;return r===d.error?ze(t)?t.data instanceof Error?{type:d.error,error:t.data,statusCode:null==(o=t.init)?void 0:o.status,headers:null!=(i=t.init)&&i.headers?new Headers(t.init.headers):void 0}:{type:d.error,error:new Y((null==(a=t.init)?void 0:a.status)||500,void 0,t.data),statusCode:J(t)?t.status:void 0,headers:null!=(n=t.init)&&n.headers?new Headers(t.init.headers):void 0}:{type:d.error,error:t,statusCode:J(t)?t.status:void 0}:Fe(t)?{type:d.deferred,deferredData:t,statusCode:null==(s=t.init)?void 0:s.status,headers:(null==(l=t.init)?void 0:l.headers)&&new Headers(t.init.headers)}:ze(t)?{type:d.data,data:t.data,statusCode:null==(u=t.init)?void 0:u.status,headers:null!=(c=t.init)&&c.headers?new Headers(t.init.headers):void 0}:{type:d.data,data:t}}function Se(e,t,r,a,o,i){let s=e.headers.get("Location");if(n(s,"Redirects returned/thrown from loaders/actions must have a Location header"),!ne.test(s)){let n=a.slice(0,a.findIndex(e=>e.route.id===r)+1);s=ue(new URL(t.url),n,o,!0,s,i),e.headers.set("Location",s)}return e}function De(e,t,r,a){let n=["about:","blob:","chrome:","chrome-untrusted:","content:","data:","devtools:","file:","filesystem:","javascript:"];if(ne.test(e)){let a=e,o=a.startsWith("//")?new URL(t.protocol+a):new URL(a);if(n.includes(o.protocol))throw new Error("Invalid redirect location");let i=null!=j(o.pathname,r);if(o.origin===t.origin&&i)return I(o.pathname)+o.search+o.hash}try{let t=a.createURL(e);if(n.includes(t.protocol))throw new Error("Invalid redirect location")}catch(e){}return e}function Re(e,t,r,a){let n=e.createURL(Te(t)).toString(),o={signal:r};if(a&&We(a.formMethod)){let{formMethod:e,formEncType:t}=a;o.method=e.toUpperCase(),"application/json"===t?(o.headers=new Headers({"Content-Type":t}),o.body=JSON.stringify(a.json)):"text/plain"===t?o.body=a.text:"application/x-www-form-urlencoded"===t&&a.formData?o.body=Ee(a.formData):o.body=a.formData}return new Request(n,o)}function Ee(e){let t=new URLSearchParams;for(let[r,a]of e.entries())t.append(r,"string"==typeof a?a:a.name);return t}function Pe(e){let t=new FormData;for(let[r,a]of e.entries())t.append(r,a);return t}function xe(e,t,r,a,o){let i,s={},l=null,u=!1,c={},d=r&&Ie(r[1])?r[1].error:void 0;return e.forEach(r=>{if(!(r.route.id in t))return;let h=r.route.id,f=t[h];if(n(!He(f),"Cannot handle redirect results in processLoaderData"),Ie(f)){let t=f.error;if(void 0!==d&&(t=d,d=void 0),l=l||{},o)l[h]=t;else{let r=je(e,h);null==l[r.route.id]&&(l[r.route.id]=t)}s[h]=void 0,u||(u=!0,i=J(f.error)?f.error.status:500),f.headers&&(c[h]=f.headers)}else Oe(f)?(a.set(h,f.deferredData),s[h]=f.deferredData.data,null==f.statusCode||200===f.statusCode||u||(i=f.statusCode),f.headers&&(c[h]=f.headers)):(s[h]=f.data,f.statusCode&&200!==f.statusCode&&!u&&(i=f.statusCode),f.headers&&(c[h]=f.headers))}),void 0!==d&&r&&(l={[r[0]]:d},s[r[0]]=void 0),{loaderData:s,errors:l,statusCode:i||200,loaderHeaders:c}}function Le(e,r,a,o,i,s,l){let{loaderData:u,errors:c}=xe(r,a,o,l,!1);return i.forEach(r=>{let{key:a,match:o,controller:i}=r,l=s[a];if(n(l,"Did not find corresponding fetcher result"),!i||!i.signal.aborted)if(Ie(l)){let r=je(e.matches,null==o?void 0:o.route.id);c&&c[r.route.id]||(c=t({},c,{[r.route.id]:l.error})),e.fetchers.delete(a)}else if(He(l))n(!1,"Unhandled fetcher revalidation redirect");else if(Oe(l))n(!1,"Unhandled fetcher deferred data");else{let t=Qe(l.data);e.fetchers.set(a,t)}}),{loaderData:u,errors:c}}function Ae(e,r,a,n){let o=t({},r);for(let t of a){let a=t.route.id;if(r.hasOwnProperty(a)?void 0!==r[a]&&(o[a]=r[a]):void 0!==e[a]&&t.route.loader&&(o[a]=e[a]),n&&n.hasOwnProperty(a))break}return o}function Me(e){return e?Ie(e[1])?{actionData:{}}:{actionData:{[e[0]]:e[1].data}}:{}}function je(e,t){return(t?e.slice(0,e.findIndex(e=>e.route.id===t)+1):[...e]).reverse().find(e=>!0===e.route.hasErrorBoundary)||e[0]}function ke(e){let t=1===e.length?e[0]:e.find(e=>e.index||!e.path||"/"===e.path)||{id:"__shim-error-route__"};return{matches:[{params:{},pathname:"",pathnameBase:"",route:t}],route:t}}function Ce(e,t){let{pathname:r,routeId:a,method:n,type:o,message:i}=void 0===t?{}:t,s="Unknown Server Error",l="Unknown @remix-run/router error";return 400===e?(s="Bad Request",n&&r&&a?l="You made a "+n+' request to "'+r+'" but did not provide a `loader` for route "'+a+'", so there is no way to handle the request.':"defer-action"===o?l="defer() is not supported in actions":"invalid-body"===o&&(l="Unable to encode submission body")):403===e?(s="Forbidden",l='Route "'+a+'" does not match URL "'+r+'"'):404===e?(s="Not Found",l='No route matches URL "'+r+'"'):405===e&&(s="Method Not Allowed",n&&r&&a?l="You made a "+n.toUpperCase()+' request to "'+r+'" but did not provide an `action` for route "'+a+'", so there is no way to handle the request.':n&&(l='Invalid request method "'+n.toUpperCase()+'"')),new Y(e||500,s,new Error(l),!0)}function _e(e){let t=Object.entries(e);for(let e=t.length-1;e>=0;e--){let[r,a]=t[e];if(He(a))return{key:r,result:a}}}function Te(e){return l(t({},"string"==typeof e?u(e):e,{hash:""}))}function Ue(e){return Ne(e.result)&&Z.has(e.result.status)}function Oe(e){return e.type===d.deferred}function Ie(e){return e.type===d.error}function He(e){return(e&&e.type)===d.redirect}function ze(e){return"object"==typeof e&&null!=e&&"type"in e&&"data"in e&&"init"in e&&"DataWithResponseInit"===e.type}function Fe(e){let t=e;return t&&"object"==typeof t&&"object"==typeof t.data&&"function"==typeof t.subscribe&&"function"==typeof t.cancel&&"function"==typeof t.resolveData}function Ne(e){return null!=e&&"number"==typeof e.status&&"string"==typeof e.statusText&&"object"==typeof e.headers&&void 0!==e.body}function Be(e){return Q.has(e.toLowerCase())}function We(e){return X.has(e.toLowerCase())}async function $e(e,t,r,a,n){let o=Object.entries(t);for(let i=0;i(null==e?void 0:e.route.id)===s);if(!u)continue;let c=a.find(e=>e.route.id===u.route.id),d=null!=c&&!pe(c,u)&&void 0!==(n&&n[u.route.id]);Oe(l)&&d&&await Ke(l,r,!1).then(e=>{e&&(t[s]=e)})}}async function qe(e,t,r){for(let a=0;a(null==e?void 0:e.route.id)===i)&&(Oe(l)&&(n(s,"Expected an AbortController for revalidating fetcher deferred result"),await Ke(l,s.signal,!0).then(e=>{e&&(t[o]=e)})))}}async function Ke(e,t,r){if(void 0===r&&(r=!1),!await e.deferredData.resolveData(t)){if(r)try{return{type:d.data,data:e.deferredData.unwrappedData}}catch(e){return{type:d.error,error:e}}return{type:d.data,data:e.deferredData.data}}}function Ye(e){return new URLSearchParams(e).getAll("index").some(e=>""===e)}function Je(e,t){let r="string"==typeof t?u(t).search:t.search;if(e[e.length-1].route.index&&Ye(r||""))return e[e.length-1];let a=T(e);return a[a.length-1]}function Ve(e){let{formMethod:t,formAction:r,formEncType:a,text:n,formData:o,json:i}=e;if(t&&r&&a)return null!=n?{formMethod:t,formAction:r,formEncType:a,formData:void 0,json:void 0,text:n}:null!=o?{formMethod:t,formAction:r,formEncType:a,formData:o,json:void 0,text:void 0}:void 0!==i?{formMethod:t,formAction:r,formEncType:a,formData:void 0,json:i,text:void 0}:void 0}function Xe(e,t){if(t){return{state:"loading",location:e,formMethod:t.formMethod,formAction:t.formAction,formEncType:t.formEncType,formData:t.formData,json:t.json,text:t.text}}return{state:"loading",location:e,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0}}function Ge(e,t){if(e){return{state:"loading",formMethod:e.formMethod,formAction:e.formAction,formEncType:e.formEncType,formData:e.formData,json:e.json,text:e.text,data:t}}return{state:"loading",formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0,data:t}}function Qe(e){return{state:"idle",formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0,data:e}}e.AbortedDeferredError=W,e.Action=r,e.IDLE_BLOCKER=ae,e.IDLE_FETCHER=re,e.IDLE_NAVIGATION=te,e.UNSAFE_DEFERRED_SYMBOL=se,e.UNSAFE_DeferredData=$,e.UNSAFE_ErrorResponseImpl=Y,e.UNSAFE_convertRouteMatchToUiMatch=y,e.UNSAFE_convertRoutesToDataRoutes=f,e.UNSAFE_decodePath=M,e.UNSAFE_getResolveToMatches=U,e.UNSAFE_invariant=n,e.UNSAFE_warning=o,e.createBrowserHistory=function(e){return void 0===e&&(e={}),c(function(e,t){let{pathname:r,search:a,hash:n}=e.location;return s("",{pathname:r,search:a,hash:n},t.state&&t.state.usr||null,t.state&&t.state.key||"default")},function(e,t){return"string"==typeof t?t:l(t)},null,e)},e.createHashHistory=function(e){return void 0===e&&(e={}),c(function(e,t){let{pathname:r="/",search:a="",hash:n=""}=u(e.location.hash.substr(1));return r.startsWith("/")||r.startsWith(".")||(r="/"+r),s("",{pathname:r,search:a,hash:n},t.state&&t.state.usr||null,t.state&&t.state.key||"default")},function(e,t){let r=e.document.querySelector("base"),a="";if(r&&r.getAttribute("href")){let t=e.location.href,r=t.indexOf("#");a=-1===r?t:t.slice(0,r)}return a+"#"+("string"==typeof t?t:l(t))},function(e,t){o("/"===e.pathname.charAt(0),"relative pathnames are not supported in hash history.push("+JSON.stringify(t)+")")},e)},e.createMemoryHistory=function(e){void 0===e&&(e={});let t,{initialEntries:a=["/"],initialIndex:n,v5Compat:i=!1}=e;t=a.map((e,t)=>m(e,"string"==typeof e?null:e.state,0===t?"default":void 0));let c=f(null==n?t.length-1:n),d=r.Pop,h=null;function f(e){return Math.min(Math.max(e,0),t.length-1)}function p(){return t[c]}function m(e,r,a){void 0===r&&(r=null);let n=s(t?p().pathname:"/",e,r,a);return o("/"===n.pathname.charAt(0),"relative pathnames are not supported in memory history: "+JSON.stringify(e)),n}function y(e){return"string"==typeof e?e:l(e)}return{get index(){return c},get action(){return d},get location(){return p()},createHref:y,createURL:e=>new URL(y(e),"http://localhost"),encodeLocation(e){let t="string"==typeof e?u(e):e;return{pathname:t.pathname||"",search:t.search||"",hash:t.hash||""}},push(e,a){d=r.Push;let n=m(e,a);c+=1,t.splice(c,t.length,n),i&&h&&h({action:d,location:n,delta:1})},replace(e,a){d=r.Replace;let n=m(e,a);t[c]=n,i&&h&&h({action:d,location:n,delta:0})},go(e){d=r.Pop;let a=f(c+e),n=t[a];c=a,h&&h({action:d,location:n,delta:e})},listen:e=>(h=e,()=>{h=null})}},e.createPath=l,e.createRouter=function(e){const a=e.window?e.window:"undefined"!=typeof window?window:void 0,i=void 0!==a&&void 0!==a.document&&void 0!==a.document.createElement,l=!i;let u;if(n(e.routes.length>0,"You must provide a non-empty routes array to createRouter"),e.mapRouteProperties)u=e.mapRouteProperties;else if(e.detectErrorBoundary){let t=e.detectErrorBoundary;u=e=>({hasErrorBoundary:t(e)})}else u=oe;let c,h,v,g={},b=f(e.routes,u,void 0,g),w=e.basename||"/",S=e.dataStrategy||ge,D=e.patchRoutesOnNavigation,R=t({v7_fetcherPersist:!1,v7_normalizeFormMethod:!1,v7_partialHydration:!1,v7_prependBasename:!1,v7_relativeSplatPath:!1,v7_skipActionErrorRevalidation:!1},e.future),E=null,P=new Set,x=null,L=null,A=null,M=null!=e.hydrationData,k=p(b,e.history.location,w),C=!1,_=null;if(null==k&&!D){let t=Ce(404,{pathname:e.history.location.pathname}),{matches:r,route:a}=ke(b);k=r,_={[a.id]:t}}if(k&&!e.hydrationData){ct(k,b,e.history.location.pathname).active&&(k=null)}if(k)if(k.some(e=>e.route.lazy))h=!1;else if(k.some(e=>e.route.loader))if(R.v7_partialHydration){let t=e.hydrationData?e.hydrationData.loaderData:null,r=e.hydrationData?e.hydrationData.errors:null;if(r){let e=k.findIndex(e=>void 0!==r[e.route.id]);h=k.slice(0,e+1).every(e=>!fe(e.route,t,r))}else h=k.every(e=>!fe(e.route,t,r))}else h=null!=e.hydrationData;else h=!0;else if(h=!1,k=[],R.v7_partialHydration){let t=ct(null,b,e.history.location.pathname);t.active&&t.matches&&(C=!0,k=t.matches)}let T,U,O={historyAction:e.history.action,location:e.history.location,matches:k,initialized:h,navigation:te,restoreScrollPosition:null==e.hydrationData&&null,preventScrollReset:!1,revalidation:"idle",loaderData:e.hydrationData&&e.hydrationData.loaderData||{},actionData:e.hydrationData&&e.hydrationData.actionData||null,errors:e.hydrationData&&e.hydrationData.errors||_,fetchers:new Map,blockers:new Map},I=r.Pop,H=!1,z=!1,F=new Map,N=null,B=!1,W=!1,$=[],q=new Set,K=new Map,Y=0,V=-1,X=new Map,G=new Set,Q=new Map,Z=new Map,se=new Set,le=new Map,de=new Map;function pe(e,r){void 0===r&&(r={}),O=t({},O,e);let a=[],n=[];R.v7_fetcherPersist&&O.fetchers.forEach((e,t)=>{"idle"===e.state&&(se.has(t)?n.push(t):a.push(t))}),se.forEach(e=>{O.fetchers.has(e)||K.has(e)||n.push(e)}),[...P].forEach(e=>e(O,{deletedFetchers:n,viewTransitionOpts:r.viewTransitionOpts,flushSync:!0===r.flushSync})),R.v7_fetcherPersist?(a.forEach(e=>O.fetchers.delete(e)),n.forEach(e=>Ye(e))):n.forEach(e=>se.delete(e))}function me(a,n,o){var i,s;let l,{flushSync:u}=void 0===o?{}:o,d=null!=O.actionData&&null!=O.navigation.formMethod&&We(O.navigation.formMethod)&&"loading"===O.navigation.state&&!0!==(null==(i=a.state)?void 0:i._isRedirect);l=n.actionData?Object.keys(n.actionData).length>0?n.actionData:null:d?O.actionData:null;let h=n.loaderData?Ae(O.loaderData,n.loaderData,n.matches||[],n.errors):O.loaderData,f=O.blockers;f.size>0&&(f=new Map(f),f.forEach((e,t)=>f.set(t,ae)));let p,m=!0===H||null!=O.navigation.formMethod&&We(O.navigation.formMethod)&&!0!==(null==(s=a.state)?void 0:s._isRedirect);if(c&&(b=c,c=void 0),B||I===r.Pop||(I===r.Push?e.history.push(a,a.state):I===r.Replace&&e.history.replace(a,a.state)),I===r.Pop){let e=F.get(O.location.pathname);e&&e.has(a.pathname)?p={currentLocation:O.location,nextLocation:a}:F.has(a.pathname)&&(p={currentLocation:a,nextLocation:O.location})}else if(z){let e=F.get(O.location.pathname);e?e.add(a.pathname):(e=new Set([a.pathname]),F.set(O.location.pathname,e)),p={currentLocation:O.location,nextLocation:a}}pe(t({},n,{actionData:l,loaderData:h,historyAction:I,location:a,initialized:!0,navigation:te,revalidation:"idle",restoreScrollPosition:ut(a,n.matches||O.matches),preventScrollReset:m,blockers:f}),{viewTransitionOpts:p,flushSync:!0===u}),I=r.Pop,H=!1,z=!1,B=!1,W=!1,$=[]}async function ve(a,n,o){T&&T.abort(),T=null,I=a,B=!0===(o&&o.startUninterruptedRevalidation),function(e,t){if(x&&A){let r=lt(e,t);x[r]=A()}}(O.location,O.matches),H=!0===(o&&o.preventScrollReset),z=!0===(o&&o.enableViewTransition);let i=c||b,s=o&&o.overrideNavigation,l=null!=o&&o.initialHydration&&O.matches&&O.matches.length>0&&!C?O.matches:p(i,n,w),u=!0===(o&&o.flushSync);if(l&&O.initialized&&!W&&function(e,t){if(e.pathname!==t.pathname||e.search!==t.search)return!1;if(""===e.hash)return""!==t.hash;if(e.hash===t.hash)return!0;if(""!==t.hash)return!0;return!1}(O.location,n)&&!(o&&o.submission&&We(o.submission.formMethod)))return void me(n,{matches:l},{flushSync:u});let h=ct(l,i,n.pathname);if(h.active&&h.matches&&(l=h.matches),!l){let{error:e,notFoundMatches:t,route:r}=it(n.pathname);return void me(n,{matches:t,loaderData:{},errors:{[r.id]:e}},{flushSync:u})}T=new AbortController;let f,m=Re(e.history,n,T.signal,o&&o.submission);if(o&&o.pendingError)f=[je(l).route.id,{type:d.error,error:o.pendingError}];else if(o&&o.submission&&We(o.submission.formMethod)){let t=await async function(t,a,n,o,i,s){void 0===s&&(s={});ze();let l,u=function(e,t){let r={state:"submitting",location:e,formMethod:t.formMethod,formAction:t.formAction,formEncType:t.formEncType,formData:t.formData,json:t.json,text:t.text};return r}(a,n);if(pe({navigation:u},{flushSync:!0===s.flushSync}),i){let e=await dt(o,a.pathname,t.signal);if("aborted"===e.type)return{shortCircuited:!0};if("error"===e.type){let t=je(e.partialMatches).route.id;return{matches:e.partialMatches,pendingActionResult:[t,{type:d.error,error:e.error}]}}if(!e.matches){let{notFoundMatches:e,error:t,route:r}=it(a.pathname);return{matches:e,pendingActionResult:[r.id,{type:d.error,error:t}]}}o=e.matches}let c=Je(o,a);if(c.route.action||c.route.lazy){if(l=(await xe("action",O,t,[c],o,null))[c.route.id],t.signal.aborted)return{shortCircuited:!0}}else l={type:d.error,error:Ce(405,{method:t.method,pathname:a.pathname,routeId:c.route.id})};if(He(l)){let r;if(s&&null!=s.replace)r=s.replace;else{r=De(l.response.headers.get("Location"),new URL(t.url),w,e.history)===O.location.pathname+O.location.search}return await Pe(t,l,!0,{submission:n,replace:r}),{shortCircuited:!0}}if(Oe(l))throw Ce(400,{type:"defer-action"});if(Ie(l)){let e=je(o,c.route.id);return!0!==(s&&s.replace)&&(I=r.Push),{matches:o,pendingActionResult:[e.route.id,l]}}return{matches:o,pendingActionResult:[c.route.id,l]}}(m,n,o.submission,l,h.active,{replace:o.replace,flushSync:u});if(t.shortCircuited)return;if(t.pendingActionResult){let[e,r]=t.pendingActionResult;if(Ie(r)&&J(r.error)&&404===r.error.status)return T=null,void me(n,{matches:t.matches,loaderData:{},errors:{[e]:r.error}})}l=t.matches||l,f=t.pendingActionResult,s=Xe(n,o.submission),u=!1,h.active=!1,m=Re(e.history,m.url,m.signal)}let{shortCircuited:y,matches:v,loaderData:g,errors:S}=await async function(r,a,n,o,i,s,l,u,d,h,f){let p=i||Xe(a,s),m=s||l||Ve(p),y=!(B||R.v7_partialHydration&&d);if(o){if(y){let e=Ee(f);pe(t({navigation:p},void 0!==e?{actionData:e}:{}),{flushSync:h})}let e=await dt(n,a.pathname,r.signal);if("aborted"===e.type)return{shortCircuited:!0};if("error"===e.type){let t=je(e.partialMatches).route.id;return{matches:e.partialMatches,loaderData:{},errors:{[t]:e.error}}}if(!e.matches){let{error:e,notFoundMatches:t,route:r}=it(a.pathname);return{matches:t,loaderData:{},errors:{[r.id]:e}}}n=e.matches}let v=c||b,[g,S]=he(e.history,O,n,m,a,R.v7_partialHydration&&!0===d,R.v7_skipActionErrorRevalidation,W,$,q,se,Q,G,v,w,f);if(st(e=>!(n&&n.some(t=>t.route.id===e))||g&&g.some(t=>t.route.id===e)),V=++Y,0===g.length&&0===S.length){let e=tt();return me(a,t({matches:n,loaderData:{},errors:f&&Ie(f[1])?{[f[0]]:f[1].error}:null},Me(f),e?{fetchers:new Map(O.fetchers)}:{}),{flushSync:h}),{shortCircuited:!0}}if(y){let e={};if(!o){e.navigation=p;let t=Ee(f);void 0!==t&&(e.actionData=t)}S.length>0&&(e.fetchers=function(e){return e.forEach(e=>{let t=O.fetchers.get(e.key),r=Ge(void 0,t?t.data:void 0);O.fetchers.set(e.key,r)}),new Map(O.fetchers)}(S)),pe(e,{flushSync:h})}S.forEach(e=>{Ze(e.key),e.controller&&K.set(e.key,e.controller)});let D=()=>S.forEach(e=>Ze(e.key));T&&T.signal.addEventListener("abort",D);let{loaderResults:E,fetcherResults:P}=await Te(O,n,g,S,r);if(r.signal.aborted)return{shortCircuited:!0};T&&T.signal.removeEventListener("abort",D);S.forEach(e=>K.delete(e.key));let x=_e(E);if(x)return await Pe(r,x.result,!0,{replace:u}),{shortCircuited:!0};if(x=_e(P),x)return G.add(x.key),await Pe(r,x.result,!0,{replace:u}),{shortCircuited:!0};let{loaderData:L,errors:A}=Le(O,n,E,f,S,P,le);le.forEach((e,t)=>{e.subscribe(r=>{(r||e.done)&&le.delete(t)})}),R.v7_partialHydration&&d&&O.errors&&(A=t({},O.errors,A));let M=tt(),j=rt(V),k=M||j||S.length>0;return t({matches:n,loaderData:L,errors:A},k?{fetchers:new Map(O.fetchers)}:{})}(m,n,l,h.active,s,o&&o.submission,o&&o.fetcherSubmission,o&&o.replace,o&&!0===o.initialHydration,u,f);y||(T=null,me(n,t({matches:v||l},Me(f),{loaderData:g,errors:S})))}function Ee(e){return e&&!Ie(e[1])?{[e[0]]:e[1].data}:O.actionData?0===Object.keys(O.actionData).length?null:O.actionData:void 0}async function Pe(o,l,u,c){let{submission:d,fetcherSubmission:h,preventScrollReset:f,replace:p}=void 0===c?{}:c;l.response.headers.has("X-Remix-Revalidate")&&(W=!0);let m=l.response.headers.get("Location");n(m,"Expected a Location header on the redirect Response"),m=De(m,new URL(o.url),w,e.history);let y=s(O.location,m,{_isRedirect:!0});if(i){let t=!1;if(l.response.headers.has("X-Remix-Reload-Document"))t=!0;else if(ne.test(m)){const r=e.history.createURL(m);t=r.origin!==a.location.origin||null==j(r.pathname,w)}if(t)return void(p?a.location.replace(m):a.location.assign(m))}T=null;let v=!0===p||l.response.headers.has("X-Remix-Replace")?r.Replace:r.Push,{formMethod:g,formAction:b,formEncType:S}=O.navigation;!d&&!h&&g&&b&&S&&(d=Ve(O.navigation));let D=d||h;if(ee.has(l.response.status)&&D&&We(D.formMethod))await ve(v,y,{submission:t({},D,{formAction:m}),preventScrollReset:f||H,enableViewTransition:u?z:void 0});else{let e=Xe(y,d);await ve(v,y,{overrideNavigation:e,fetcherSubmission:h,preventScrollReset:f||H,enableViewTransition:u?z:void 0})}}async function xe(e,t,r,a,n,o){let i,s={};try{i=await be(S,e,t,r,a,n,o,g,u)}catch(e){return a.forEach(t=>{s[t.route.id]={type:d.error,error:e}}),s}for(let[e,t]of Object.entries(i))if(Ue(t)){let a=t.result;s[e]={type:d.redirect,response:Se(a,r,e,n,w,R.v7_relativeSplatPath)}}else s[e]=await we(t);return s}async function Te(t,r,a,n,o){let i=t.matches,s=xe("loader",t,o,a,r,null),l=Promise.all(n.map(async r=>{if(r.matches&&r.match&&r.controller){let a=(await xe("loader",t,Re(e.history,r.path,r.controller.signal),[r.match],r.matches,r.key))[r.match.route.id];return{[r.key]:a}}return Promise.resolve({[r.key]:{type:d.error,error:Ce(404,{pathname:r.path})}})})),u=await s,c=(await l).reduce((e,t)=>Object.assign(e,t),{});return await Promise.all([$e(r,u,o.signal,i,t.loaderData),qe(r,c,n)]),{loaderResults:u,fetcherResults:c}}function ze(){W=!0,$.push(...st()),Q.forEach((e,t)=>{K.has(t)&&q.add(t),Ze(t)})}function Fe(e,t,r){void 0===r&&(r={}),O.fetchers.set(e,t),pe({fetchers:new Map(O.fetchers)},{flushSync:!0===(r&&r.flushSync)})}function Ne(e,t,r,a){void 0===a&&(a={});let n=je(O.matches,t);Ye(e),pe({errors:{[n.route.id]:r},fetchers:new Map(O.fetchers)},{flushSync:!0===(a&&a.flushSync)})}function Be(e){return Z.set(e,(Z.get(e)||0)+1),se.has(e)&&se.delete(e),O.fetchers.get(e)||re}function Ye(e){let t=O.fetchers.get(e);!K.has(e)||t&&"loading"===t.state&&X.has(e)||Ze(e),Q.delete(e),X.delete(e),G.delete(e),R.v7_fetcherPersist&&se.delete(e),q.delete(e),O.fetchers.delete(e)}function Ze(e){let t=K.get(e);t&&(t.abort(),K.delete(e))}function et(e){for(let t of e){let e=Qe(Be(t).data);O.fetchers.set(t,e)}}function tt(){let e=[],t=!1;for(let r of G){let a=O.fetchers.get(r);n(a,"Expected fetcher: "+r),"loading"===a.state&&(G.delete(r),e.push(r),t=!0)}return et(e),t}function rt(e){let t=[];for(let[r,a]of X)if(a0}function at(e){O.blockers.delete(e),de.delete(e)}function nt(e,t){let r=O.blockers.get(e)||ae;n("unblocked"===r.state&&"blocked"===t.state||"blocked"===r.state&&"blocked"===t.state||"blocked"===r.state&&"proceeding"===t.state||"blocked"===r.state&&"unblocked"===t.state||"proceeding"===r.state&&"unblocked"===t.state,"Invalid blocker state transition: "+r.state+" -> "+t.state);let a=new Map(O.blockers);a.set(e,t),pe({blockers:a})}function ot(e){let{currentLocation:t,nextLocation:r,historyAction:a}=e;if(0===de.size)return;de.size>1&&o(!1,"A router only supports one blocker at a time");let n=Array.from(de.entries()),[i,s]=n[n.length-1],l=O.blockers.get(i);return l&&"proceeding"===l.state?void 0:s({currentLocation:t,nextLocation:r,historyAction:a})?i:void 0}function it(e){let t=Ce(404,{pathname:e}),r=c||b,{matches:a,route:n}=ke(r);return st(),{notFoundMatches:a,route:n,error:t}}function st(e){let t=[];return le.forEach((r,a)=>{e&&!e(a)||(r.cancel(),t.push(a),le.delete(a))}),t}function lt(e,t){if(L){return L(e,t.map(e=>y(e,O.loaderData)))||e.key}return e.key}function ut(e,t){if(x){let r=lt(e,t),a=x[r];if("number"==typeof a)return a}return null}function ct(e,t,r){if(D){if(!e){return{active:!0,matches:m(t,r,w,!0)||[]}}if(Object.keys(e[0].params).length>0){return{active:!0,matches:m(t,r,w,!0)}}}return{active:!1,matches:null}}async function dt(e,t,r,a){if(!D)return{type:"success",matches:e};let n=e;for(;;){let e=null==c,o=c||b,i=g;try{await D({signal:r,path:t,matches:n,fetcherKey:a,patch:(e,t)=>{r.aborted||ye(e,t,o,i,u)}})}catch(e){return{type:"error",error:e,partialMatches:n}}finally{e&&!r.aborted&&(b=[...b])}if(r.aborted)return{type:"aborted"};let s=p(o,t,w);if(s)return{type:"success",matches:s};let l=m(o,t,w,!0);if(!l||n.length===l.length&&n.every((e,t)=>e.route.id===l[t].route.id))return{type:"success",matches:null};n=l}}return v={get basename(){return w},get future(){return R},get state(){return O},get routes(){return b},get window(){return a},initialize:function(){if(E=e.history.listen(t=>{let{action:r,location:a,delta:n}=t;if(U)return U(),void(U=void 0);o(0===de.size||null!=n,"You are trying to use a blocker on a POP navigation to a location that was not created by @remix-run/router. This will fail silently in production. This can happen if you are navigating outside the router via `window.history.pushState`/`window.location.hash` instead of using router navigation APIs. This can also happen if you are using createHashRouter and the user manually changes the URL.");let i=ot({currentLocation:O.location,nextLocation:a,historyAction:r});if(i&&null!=n){let t=new Promise(e=>{U=e});return e.history.go(-1*n),void nt(i,{state:"blocked",location:a,proceed(){nt(i,{state:"proceeding",proceed:void 0,reset:void 0,location:a}),t.then(()=>e.history.go(n))},reset(){let e=new Map(O.blockers);e.set(i,ae),pe({blockers:e})}})}return ve(r,a)}),i){!function(e,t){try{let r=e.sessionStorage.getItem(ie);if(r){let e=JSON.parse(r);for(let[r,a]of Object.entries(e||{}))a&&Array.isArray(a)&&t.set(r,new Set(a||[]))}}catch(e){}}(a,F);let e=()=>function(e,t){if(t.size>0){let r={};for(let[e,a]of t)r[e]=[...a];try{e.sessionStorage.setItem(ie,JSON.stringify(r))}catch(e){o(!1,"Failed to save applied view transitions in sessionStorage ("+e+").")}}}(a,F);a.addEventListener("pagehide",e),N=()=>a.removeEventListener("pagehide",e)}return O.initialized||ve(r.Pop,O.location,{initialHydration:!0}),v},subscribe:function(e){return P.add(e),()=>P.delete(e)},enableScrollRestoration:function(e,t,r){if(x=e,A=t,L=r||null,!M&&O.navigation===te){M=!0;let e=ut(O.location,O.matches);null!=e&&pe({restoreScrollPosition:e})}return()=>{x=null,A=null,L=null}},navigate:async function a(n,o){if("number"==typeof n)return void e.history.go(n);let i=ue(O.location,O.matches,w,R.v7_prependBasename,n,R.v7_relativeSplatPath,null==o?void 0:o.fromRouteId,null==o?void 0:o.relative),{path:l,submission:u,error:c}=ce(R.v7_normalizeFormMethod,!1,i,o),d=O.location,h=s(O.location,l,o&&o.state);h=t({},h,e.history.encodeLocation(h));let f=o&&null!=o.replace?o.replace:void 0,p=r.Push;!0===f?p=r.Replace:!1===f||null!=u&&We(u.formMethod)&&u.formAction===O.location.pathname+O.location.search&&(p=r.Replace);let m=o&&"preventScrollReset"in o?!0===o.preventScrollReset:void 0,y=!0===(o&&o.flushSync),v=ot({currentLocation:d,nextLocation:h,historyAction:p});if(!v)return await ve(p,h,{submission:u,pendingError:c,preventScrollReset:m,replace:o&&o.replace,enableViewTransition:o&&o.viewTransition,flushSync:y});nt(v,{state:"blocked",location:h,proceed(){nt(v,{state:"proceeding",proceed:void 0,reset:void 0,location:h}),a(n,o)},reset(){let e=new Map(O.blockers);e.set(v,ae),pe({blockers:e})}})},fetch:function(t,r,a,o){if(l)throw new Error("router.fetch() was called during the server render, but it shouldn't be. You are likely calling a useFetcher() method in the body of your component. Try moving it to a useEffect or a callback.");Ze(t);let i=!0===(o&&o.flushSync),s=c||b,u=ue(O.location,O.matches,w,R.v7_prependBasename,a,R.v7_relativeSplatPath,r,null==o?void 0:o.relative),d=p(s,u,w),h=ct(d,s,u);if(h.active&&h.matches&&(d=h.matches),!d)return void Ne(t,r,Ce(404,{pathname:u}),{flushSync:i});let{path:f,submission:m,error:y}=ce(R.v7_normalizeFormMethod,!0,u,o);if(y)return void Ne(t,r,y,{flushSync:i});let v=Je(d,f),g=!0===(o&&o.preventScrollReset);m&&We(m.formMethod)?async function(t,r,a,o,i,s,l,u,d){function h(e){if(!e.route.action&&!e.route.lazy){let e=Ce(405,{method:d.formMethod,pathname:a,routeId:r});return Ne(t,r,e,{flushSync:l}),!0}return!1}if(ze(),Q.delete(t),!s&&h(o))return;let f=O.fetchers.get(t);Fe(t,function(e,t){let r={state:"submitting",formMethod:e.formMethod,formAction:e.formAction,formEncType:e.formEncType,formData:e.formData,json:e.json,text:e.text,data:t?t.data:void 0};return r}(d,f),{flushSync:l});let m=new AbortController,y=Re(e.history,a,m.signal,d);if(s){let e=await dt(i,new URL(y.url).pathname,y.signal,t);if("aborted"===e.type)return;if("error"===e.type)return void Ne(t,r,e.error,{flushSync:l});if(!e.matches)return void Ne(t,r,Ce(404,{pathname:a}),{flushSync:l});if(h(o=Je(i=e.matches,a)))return}K.set(t,m);let v=Y,g=await xe("action",O,y,[o],i,t),S=g[o.route.id];if(y.signal.aborted)return void(K.get(t)===m&&K.delete(t));if(R.v7_fetcherPersist&&se.has(t)){if(He(S)||Ie(S))return void Fe(t,Qe(void 0))}else{if(He(S))return K.delete(t),V>v?void Fe(t,Qe(void 0)):(G.add(t),Fe(t,Ge(d)),Pe(y,S,!1,{fetcherSubmission:d,preventScrollReset:u}));if(Ie(S))return void Ne(t,r,S.error)}if(Oe(S))throw Ce(400,{type:"defer-action"});let D=O.navigation.location||O.location,E=Re(e.history,D,m.signal),P=c||b,x="idle"!==O.navigation.state?p(P,O.navigation.location,w):O.matches;n(x,"Didn't find any matches after fetcher action");let L=++Y;X.set(t,L);let A=Ge(d,S.data);O.fetchers.set(t,A);let[M,j]=he(e.history,O,x,d,D,!1,R.v7_skipActionErrorRevalidation,W,$,q,se,Q,G,P,w,[o.route.id,S]);j.filter(e=>e.key!==t).forEach(e=>{let t=e.key,r=O.fetchers.get(t),a=Ge(void 0,r?r.data:void 0);O.fetchers.set(t,a),Ze(t),e.controller&&K.set(t,e.controller)}),pe({fetchers:new Map(O.fetchers)});let k=()=>j.forEach(e=>Ze(e.key));m.signal.addEventListener("abort",k);let{loaderResults:C,fetcherResults:_}=await Te(O,x,M,j,E);if(m.signal.aborted)return;m.signal.removeEventListener("abort",k),X.delete(t),K.delete(t),j.forEach(e=>K.delete(e.key));let U=_e(C);if(U)return Pe(E,U.result,!1,{preventScrollReset:u});if(U=_e(_),U)return G.add(U.key),Pe(E,U.result,!1,{preventScrollReset:u});let{loaderData:H,errors:z}=Le(O,x,C,void 0,j,_,le);if(O.fetchers.has(t)){let e=Qe(S.data);O.fetchers.set(t,e)}rt(L),"loading"===O.navigation.state&&L>V?(n(I,"Expected pending action"),T&&T.abort(),me(O.navigation.location,{matches:x,loaderData:H,errors:z,fetchers:new Map(O.fetchers)})):(pe({errors:z,loaderData:Ae(O.loaderData,H,x,z),fetchers:new Map(O.fetchers)}),W=!1)}(t,r,f,v,d,h.active,i,g,m):(Q.set(t,{routeId:r,path:f}),async function(t,r,a,o,i,s,l,u,c){let d=O.fetchers.get(t);Fe(t,Ge(c,d?d.data:void 0),{flushSync:l});let h=new AbortController,f=Re(e.history,a,h.signal);if(s){let e=await dt(i,new URL(f.url).pathname,f.signal,t);if("aborted"===e.type)return;if("error"===e.type)return void Ne(t,r,e.error,{flushSync:l});if(!e.matches)return void Ne(t,r,Ce(404,{pathname:a}),{flushSync:l});o=Je(i=e.matches,a)}K.set(t,h);let p=Y,m=await xe("loader",O,f,[o],i,t),y=m[o.route.id];Oe(y)&&(y=await Ke(y,f.signal,!0)||y);K.get(t)===h&&K.delete(t);if(f.signal.aborted)return;if(se.has(t))return void Fe(t,Qe(void 0));if(He(y))return V>p?void Fe(t,Qe(void 0)):(G.add(t),void await Pe(f,y,!1,{preventScrollReset:u}));if(Ie(y))return void Ne(t,r,y.error);n(!Oe(y),"Unhandled fetcher deferred data"),Fe(t,Qe(y.data))}(t,r,f,v,d,h.active,i,g,m))},revalidate:function(){ze(),pe({revalidation:"loading"}),"submitting"!==O.navigation.state&&("idle"!==O.navigation.state?ve(I||O.historyAction,O.navigation.location,{overrideNavigation:O.navigation,enableViewTransition:!0===z}):ve(O.historyAction,O.location,{startUninterruptedRevalidation:!0}))},createHref:t=>e.history.createHref(t),encodeLocation:t=>e.history.encodeLocation(t),getFetcher:Be,deleteFetcher:function(e){let t=(Z.get(e)||0)-1;t<=0?(Z.delete(e),se.add(e),R.v7_fetcherPersist||Ye(e)):Z.set(e,t),pe({fetchers:new Map(O.fetchers)})},dispose:function(){E&&E(),N&&N(),P.clear(),T&&T.abort(),O.fetchers.forEach((e,t)=>Ye(t)),O.blockers.forEach((e,t)=>at(t))},getBlocker:function(e,t){let r=O.blockers.get(e)||ae;return de.get(e)!==t&&de.set(e,t),r},deleteBlocker:at,patchRoutes:function(e,t){let r=null==c;ye(e,t,c||b,g,u),r&&(b=[...b],pe({}))},_internalFetchControllers:K,_internalActiveDeferreds:le,_internalSetRoutes:function(e){g={},c=f(e,u,void 0,g)}},v},e.createStaticHandler=function(e,r){n(e.length>0,"You must provide a non-empty routes array to createStaticHandler");let a,o={},i=(r?r.basename:null)||"/";if(null!=r&&r.mapRouteProperties)a=r.mapRouteProperties;else if(null!=r&&r.detectErrorBoundary){let e=r.detectErrorBoundary;a=t=>({hasErrorBoundary:e(t)})}else a=oe;let u=t({v7_relativeSplatPath:!1,v7_throwAbortReason:!1},r?r.future:null),c=f(e,a,void 0,o);async function h(e,r,a,o,i,s,l){n(e.signal,"query()/queryRoute() requests must contain an AbortController signal");try{if(We(e.method.toLowerCase())){let n=await async function(e,r,a,n,o,i,s){let l;if(a.route.action||a.route.lazy){l=(await y("action",e,[a],r,s,n,o))[a.route.id],e.signal.aborted&&le(e,s,u)}else{let t=Ce(405,{method:e.method,pathname:new URL(e.url).pathname,routeId:a.route.id});if(s)throw t;l={type:d.error,error:t}}if(He(l))throw new Response(null,{status:l.response.status,headers:{Location:l.response.headers.get("Location")}});if(Oe(l)){let e=Ce(400,{type:"defer-action"});if(s)throw e;l={type:d.error,error:e}}if(s){if(Ie(l))throw l.error;return{matches:[a],loaderData:{},actionData:{[a.route.id]:l.data},errors:null,statusCode:200,loaderHeaders:{},actionHeaders:{},activeDeferreds:null}}let c=new Request(e.url,{headers:e.headers,redirect:e.redirect,signal:e.signal});if(Ie(l)){let e=i?a:je(r,a.route.id);return t({},await m(c,r,n,o,i,null,[e.route.id,l]),{statusCode:J(l.error)?l.error.status:null!=l.statusCode?l.statusCode:500,actionData:null,actionHeaders:t({},l.headers?{[a.route.id]:l.headers}:{})})}let h=await m(c,r,n,o,i,null);return t({},h,{actionData:{[a.route.id]:l.data}},l.statusCode?{statusCode:l.statusCode}:{},{actionHeaders:l.headers?{[a.route.id]:l.headers}:{}})}(e,a,l||Je(a,r),o,i,s,null!=l);return n}let n=await m(e,a,o,i,s,l);return Ne(n)?n:t({},n,{actionData:null,actionHeaders:{}})}catch(e){if(null!=(c=e)&&"object"==typeof c&&"type"in c&&"result"in c&&(c.type===d.data||c.type===d.error)&&Ne(e.result)){if(e.type===d.error)throw e.result;return e.result}if(function(e){if(!Ne(e))return!1;let t=e.status,r=e.headers.get("Location");return t>=300&&t<=399&&null!=r}(e))return e;throw e}var c}async function m(e,r,a,n,o,i,s){let l=null!=i;if(l&&(null==i||!i.route.loader)&&(null==i||!i.route.lazy))throw Ce(400,{method:e.method,pathname:new URL(e.url).pathname,routeId:null==i?void 0:i.route.id});let c=(i?[i]:s&&Ie(s[1])?de(r,s[0]):r).filter(e=>e.route.loader||e.route.lazy);if(0===c.length)return{matches:r,loaderData:r.reduce((e,t)=>Object.assign(e,{[t.route.id]:null}),{}),errors:s&&Ie(s[1])?{[s[0]]:s[1].error}:null,statusCode:200,loaderHeaders:{},activeDeferreds:null};let d=await y("loader",e,c,r,l,a,n);e.signal.aborted&&le(e,l,u);let h=new Map,f=xe(r,d,s,h,o),p=new Set(c.map(e=>e.route.id));return r.forEach(e=>{p.has(e.route.id)||(f.loaderData[e.route.id]=null)}),t({},f,{matches:r,activeDeferreds:h.size>0?Object.fromEntries(h.entries()):null})}async function y(e,t,r,n,s,l,c){let d=await be(c||ge,e,null,t,r,n,null,o,a,l),h={};return await Promise.all(n.map(async e=>{if(!(e.route.id in d))return;let r=d[e.route.id];if(Ue(r)){throw Se(r.result,t,e.route.id,n,i,u.v7_relativeSplatPath)}if(Ne(r.result)&&s)throw r;h[e.route.id]=await we(r)})),h}return{dataRoutes:c,query:async function(e,r){let{requestContext:a,skipLoaderErrorBubbling:n,dataStrategy:o}=void 0===r?{}:r,u=new URL(e.url),d=e.method,f=s("",l(u),null,"default"),m=p(c,f,i);if(!Be(d)&&"HEAD"!==d){let e=Ce(405,{method:d}),{matches:t,route:r}=ke(c);return{basename:i,location:f,matches:t,loaderData:{},actionData:null,errors:{[r.id]:e},statusCode:e.status,loaderHeaders:{},actionHeaders:{},activeDeferreds:null}}if(!m){let e=Ce(404,{pathname:f.pathname}),{matches:t,route:r}=ke(c);return{basename:i,location:f,matches:t,loaderData:{},actionData:null,errors:{[r.id]:e},statusCode:e.status,loaderHeaders:{},actionHeaders:{},activeDeferreds:null}}let y=await h(e,f,m,a,o||null,!0===n,null);return Ne(y)?y:t({location:f,basename:i},y)},queryRoute:async function(e,t){let{routeId:r,requestContext:a,dataStrategy:n}=void 0===t?{}:t,o=new URL(e.url),u=e.method,d=s("",l(o),null,"default"),f=p(c,d,i);if(!Be(u)&&"HEAD"!==u&&"OPTIONS"!==u)throw Ce(405,{method:u});if(!f)throw Ce(404,{pathname:d.pathname});let m=r?f.find(e=>e.route.id===r):Je(f,d);if(r&&!m)throw Ce(403,{pathname:d.pathname,routeId:r});if(!m)throw Ce(404,{pathname:d.pathname});let y=await h(e,d,f,a,n||null,!1,m);if(Ne(y))return y;let v=y.errors?Object.values(y.errors)[0]:void 0;if(void 0!==v)throw v;if(y.actionData)return Object.values(y.actionData)[0];if(y.loaderData){var g;let e=Object.values(y.loaderData)[0];return null!=(g=y.activeDeferreds)&&g[m.route.id]&&(e[se]=y.activeDeferreds[m.route.id]),e}}}},e.data=function(e,t){return new B(e,"number"==typeof t?{status:t}:t)},e.defer=function(e,t){return void 0===t&&(t={}),new $(e,"number"==typeof t?{status:t}:t)},e.generatePath=function(e,t){void 0===t&&(t={});let r=e;r.endsWith("*")&&"*"!==r&&!r.endsWith("/*")&&(o(!1,'Route path "'+r+'" will be treated as if it were "'+r.replace(/\*$/,"/*")+'" because the `*` character must always follow a `/` in the pattern. To get rid of this warning, please change the route path to "'+r.replace(/\*$/,"/*")+'".'),r=r.replace(/\*$/,"/*"));const a=r.startsWith("/")?"/":"",i=e=>null==e?"":"string"==typeof e?e:String(e);return a+r.split(/\/+/).map((e,r,a)=>{if(r===a.length-1&&"*"===e){return i(t["*"])}const o=e.match(/^:([\w-]+)(\??)$/);if(o){const[,e,r]=o;let a=t[e];return n("?"===r||null!=a,'Missing ":'+e+'" param'),i(a)}return e.replace(/\?$/g,"")}).filter(e=>!!e).join("/")},e.getStaticContextFromError=function(e,r,a){return t({},r,{statusCode:J(a)?a.status:500,errors:{[r._deepestRenderedBoundaryId||e[0].id]:a}})},e.getToPathname=function(e){return""===e||""===e.pathname?"/":"string"==typeof e?u(e).pathname:e.pathname},e.isDataWithResponseInit=ze,e.isDeferredData=Fe,e.isRouteErrorResponse=J,e.joinPaths=H,e.json=function(e,r){void 0===r&&(r={});let a="number"==typeof r?{status:r}:r,n=new Headers(a.headers);return n.has("Content-Type")||n.set("Content-Type","application/json; charset=utf-8"),new Response(JSON.stringify(e),t({},a,{headers:n}))},e.matchPath=A,e.matchRoutes=p,e.normalizePathname=z,e.parsePath=u,e.redirect=K,e.redirectDocument=(e,t)=>{let r=K(e,t);return r.headers.set("X-Remix-Reload-Document","true"),r},e.replace=(e,t)=>{let r=K(e,t);return r.headers.set("X-Remix-Replace","true"),r},e.resolvePath=k,e.resolveTo=O,e.stripBasename=j,Object.defineProperty(e,"__esModule",{value:!0})});
apps/frontend/node_modules/@remix-run/router/dist/router.js.map:1:{"version":3,"file":"router.js","sources":["../history.ts","../utils.ts","../router.ts"],"sourcesContent":["////////////////////////////////////////////////////////////////////////////////\n//#region Types and Constants\n////////////////////////////////////////////////////////////////////////////////\n\n/**\n * Actions represent the type of change to a location value.\n */\nexport enum Action {\n /**\n * A POP indicates a change to an arbitrary index in the history stack, such\n * as a back or forward navigation. It does not describe the direction of the\n * navigation, only that the current index changed.\n *\n * Note: This is the default action for newly created history objects.\n */\n Pop = \"POP\",\n\n /**\n * A PUSH indicates a new entry being added to the history stack, such as when\n * a link is clicked and a new page loads. When this happens, all subsequent\n * entries in the stack are lost.\n */\n Push = \"PUSH\",\n\n /**\n * A REPLACE indicates the entry at the current index in the history stack\n * being replaced by a new one.\n */\n Replace = \"REPLACE\",\n}\n\n/**\n * The pathname, search, and hash values of a URL.\n */\nexport interface Path {\n /**\n * A URL pathname, beginning with a /.\n */\n pathname: string;\n\n /**\n * A URL search string, beginning with a ?.\n */\n search: string;\n\n /**\n * A URL fragment identifier, beginning with a #.\n */\n hash: string;\n}\n\n// TODO: (v7) Change the Location generic default from `any` to `unknown` and\n// remove Remix `useLocation` wrapper.\n\n/**\n * An entry in a history stack. A location contains information about the\n * URL path, as well as possibly some arbitrary state and a key.\n */\nexport interface Location extends Path {\n /**\n * A value of arbitrary data associated with this location.\n */\n state: State;\n\n /**\n * A unique string associated with this location. May be used to safely store\n * and retrieve data in some other storage API, like `localStorage`.\n *\n * Note: This value is always \"default\" on the initial location.\n */\n key: string;\n}\n\n/**\n * A change to the current location.\n */\nexport interface Update {\n /**\n * The action that triggered the change.\n */\n action: Action;\n\n /**\n * The new location.\n */\n location: Location;\n\n /**\n * The delta between this location and the former location in the history stack\n */\n delta: number | null;\n}\n\n/**\n * A function that receives notifications about location changes.\n */\nexport interface Listener {\n (update: Update): void;\n}\n\n/**\n * Describes a location that is the destination of some navigation, either via\n * `history.push` or `history.replace`. This may be either a URL or the pieces\n * of a URL path.\n */\nexport type To = string | Partial;\n\n/**\n * A history is an interface to the navigation stack. The history serves as the\n * source of truth for the current location, as well as provides a set of\n * methods that may be used to change it.\n *\n * It is similar to the DOM's `window.history` object, but with a smaller, more\n * focused API.\n */\nexport interface History {\n /**\n * The last action that modified the current location. This will always be\n * Action.Pop when a history instance is first created. This value is mutable.\n */\n readonly action: Action;\n\n /**\n * The current location. This value is mutable.\n */\n readonly location: Location;\n\n /**\n * Returns a valid href for the given `to` value that may be used as\n * the value of an attribute.\n *\n * @param to - The destination URL\n */\n createHref(to: To): string;\n\n /**\n * Returns a URL for the given `to` value\n *\n * @param to - The destination URL\n */\n createURL(to: To): URL;\n\n /**\n * Encode a location the same way window.history would do (no-op for memory\n * history) so we ensure our PUSH/REPLACE navigations for data routers\n * behave the same as POP\n *\n * @param to Unencoded path\n */\n encodeLocation(to: To): Path;\n\n /**\n * Pushes a new location onto the history stack, increasing its length by one.\n * If there were any entries in the stack after the current one, they are\n * lost.\n *\n * @param to - The new URL\n * @param state - Data to associate with the new location\n */\n push(to: To, state?: any): void;\n\n /**\n * Replaces the current location in the history stack with a new one. The\n * location that was replaced will no longer be available.\n *\n * @param to - The new URL\n * @param state - Data to associate with the new location\n */\n replace(to: To, state?: any): void;\n\n /**\n * Navigates `n` entries backward/forward in the history stack relative to the\n * current index. For example, a \"back\" navigation would use go(-1).\n *\n * @param delta - The delta in the stack index\n */\n go(delta: number): void;\n\n /**\n * Sets up a listener that will be called whenever the current location\n * changes.\n *\n * @param listener - A function that will be called when the location changes\n * @returns unlisten - A function that may be used to stop listening\n */\n listen(listener: Listener): () => void;\n}\n\ntype HistoryState = {\n usr: any;\n key?: string;\n idx: number;\n};\n\nconst PopStateEventType = \"popstate\";\n//#endregion\n\n////////////////////////////////////////////////////////////////////////////////\n//#region Memory History\n////////////////////////////////////////////////////////////////////////////////\n\n/**\n * A user-supplied object that describes a location. Used when providing\n * entries to `createMemoryHistory` via its `initialEntries` option.\n */\nexport type InitialEntry = string | Partial;\n\nexport type MemoryHistoryOptions = {\n initialEntries?: InitialEntry[];\n initialIndex?: number;\n v5Compat?: boolean;\n};\n\n/**\n * A memory history stores locations in memory. This is useful in stateful\n * environments where there is no web browser, such as node tests or React\n * Native.\n */\nexport interface MemoryHistory extends History {\n /**\n * The current index in the history stack.\n */\n readonly index: number;\n}\n\n/**\n * Memory history stores the current location in memory. It is designed for use\n * in stateful non-browser environments like tests and React Native.\n */\nexport function createMemoryHistory(\n options: MemoryHistoryOptions = {}\n): MemoryHistory {\n let { initialEntries = [\"/\"], initialIndex, v5Compat = false } = options;\n let entries: Location[]; // Declare so we can access from createMemoryLocation\n entries = initialEntries.map((entry, index) =>\n createMemoryLocation(\n entry,\n typeof entry === \"string\" ? null : entry.state,\n index === 0 ? \"default\" : undefined\n )\n );\n let index = clampIndex(\n initialIndex == null ? entries.length - 1 : initialIndex\n );\n let action = Action.Pop;\n let listener: Listener | null = null;\n\n function clampIndex(n: number): number {\n return Math.min(Math.max(n, 0), entries.length - 1);\n }\n function getCurrentLocation(): Location {\n return entries[index];\n }\n function createMemoryLocation(\n to: To,\n state: any = null,\n key?: string\n ): Location {\n let location = createLocation(\n entries ? getCurrentLocation().pathname : \"/\",\n to,\n state,\n key\n );\n warning(\n location.pathname.charAt(0) === \"/\",\n `relative pathnames are not supported in memory history: ${JSON.stringify(\n to\n )}`\n );\n return location;\n }\n\n function createHref(to: To) {\n return typeof to === \"string\" ? to : createPath(to);\n }\n\n let history: MemoryHistory = {\n get index() {\n return index;\n },\n get action() {\n return action;\n },\n get location() {\n return getCurrentLocation();\n },\n createHref,\n createURL(to) {\n return new URL(createHref(to), \"http://localhost\");\n },\n encodeLocation(to: To) {\n let path = typeof to === \"string\" ? parsePath(to) : to;\n return {\n pathname: path.pathname || \"\",\n search: path.search || \"\",\n hash: path.hash || \"\",\n };\n },\n push(to, state) {\n action = Action.Push;\n let nextLocation = createMemoryLocation(to, state);\n index += 1;\n entries.splice(index, entries.length, nextLocation);\n if (v5Compat && listener) {\n listener({ action, location: nextLocation, delta: 1 });\n }\n },\n replace(to, state) {\n action = Action.Replace;\n let nextLocation = createMemoryLocation(to, state);\n entries[index] = nextLocation;\n if (v5Compat && listener) {\n listener({ action, location: nextLocation, delta: 0 });\n }\n },\n go(delta) {\n action = Action.Pop;\n let nextIndex = clampIndex(index + delta);\n let nextLocation = entries[nextIndex];\n index = nextIndex;\n if (listener) {\n listener({ action, location: nextLocation, delta });\n }\n },\n listen(fn: Listener) {\n listener = fn;\n return () => {\n listener = null;\n };\n },\n };\n\n return history;\n}\n//#endregion\n\n////////////////////////////////////////////////////////////////////////////////\n//#region Browser History\n////////////////////////////////////////////////////////////////////////////////\n\n/**\n * A browser history stores the current location in regular URLs in a web\n * browser environment. This is the standard for most web apps and provides the\n * cleanest URLs the browser's address bar.\n *\n * @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#browserhistory\n */\nexport interface BrowserHistory extends UrlHistory {}\n\nexport type BrowserHistoryOptions = UrlHistoryOptions;\n\n/**\n * Browser history stores the location in regular URLs. This is the standard for\n * most web apps, but it requires some configuration on the server to ensure you\n * serve the same app at multiple URLs.\n *\n * @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#createbrowserhistory\n */\nexport function createBrowserHistory(\n options: BrowserHistoryOptions = {}\n): BrowserHistory {\n function createBrowserLocation(\n window: Window,\n globalHistory: Window[\"history\"]\n ) {\n let { pathname, search, hash } = window.location;\n return createLocation(\n \"\",\n { pathname, search, hash },\n // state defaults to `null` because `window.history.state` does\n (globalHistory.state && globalHistory.state.usr) || null,\n (globalHistory.state && globalHistory.state.key) || \"default\"\n );\n }\n\n function createBrowserHref(window: Window, to: To) {\n return typeof to === \"string\" ? to : createPath(to);\n }\n\n return getUrlBasedHistory(\n createBrowserLocation,\n createBrowserHref,\n null,\n options\n );\n}\n//#endregion\n\n////////////////////////////////////////////////////////////////////////////////\n//#region Hash History\n////////////////////////////////////////////////////////////////////////////////\n\n/**\n * A hash history stores the current location in the fragment identifier portion\n * of the URL in a web browser environment.\n *\n * This is ideal for apps that do not control the server for some reason\n * (because the fragment identifier is never sent to the server), including some\n * shared hosting environments that do not provide fine-grained controls over\n * which pages are served at which URLs.\n *\n * @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#hashhistory\n */\nexport interface HashHistory extends UrlHistory {}\n\nexport type HashHistoryOptions = UrlHistoryOptions;\n\n/**\n * Hash history stores the location in window.location.hash. This makes it ideal\n * for situations where you don't want to send the location to the server for\n * some reason, either because you do cannot configure it or the URL space is\n * reserved for something else.\n *\n * @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#createhashhistory\n */\nexport function createHashHistory(\n options: HashHistoryOptions = {}\n): HashHistory {\n function createHashLocation(\n window: Window,\n globalHistory: Window[\"history\"]\n ) {\n let {\n pathname = \"/\",\n search = \"\",\n hash = \"\",\n } = parsePath(window.location.hash.substr(1));\n\n // Hash URL should always have a leading / just like window.location.pathname\n // does, so if an app ends up at a route like /#something then we add a\n // leading slash so all of our path-matching behaves the same as if it would\n // in a browser router. This is particularly important when there exists a\n // root splat route () since that matches internally against\n // \"/*\" and we'd expect /#something to 404 in a hash router app.\n if (!pathname.startsWith(\"/\") && !pathname.startsWith(\".\")) {\n pathname = \"/\" + pathname;\n }\n\n return createLocation(\n \"\",\n { pathname, search, hash },\n // state defaults to `null` because `window.history.state` does\n (globalHistory.state && globalHistory.state.usr) || null,\n (globalHistory.state && globalHistory.state.key) || \"default\"\n );\n }\n\n function createHashHref(window: Window, to: To) {\n let base = window.document.querySelector(\"base\");\n let href = \"\";\n\n if (base && base.getAttribute(\"href\")) {\n let url = window.location.href;\n let hashIndex = url.indexOf(\"#\");\n href = hashIndex === -1 ? url : url.slice(0, hashIndex);\n }\n\n return href + \"#\" + (typeof to === \"string\" ? to : createPath(to));\n }\n\n function validateHashLocation(location: Location, to: To) {\n warning(\n location.pathname.charAt(0) === \"/\",\n `relative pathnames are not supported in hash history.push(${JSON.stringify(\n to\n )})`\n );\n }\n\n return getUrlBasedHistory(\n createHashLocation,\n createHashHref,\n validateHashLocation,\n options\n );\n}\n//#endregion\n\n////////////////////////////////////////////////////////////////////////////////\n//#region UTILS\n////////////////////////////////////////////////////////////////////////////////\n\n/**\n * @private\n */\nexport function invariant(value: boolean, message?: string): asserts value;\nexport function invariant(\n value: T | null | undefined,\n message?: string\n): asserts value is T;\nexport function invariant(value: any, message?: string) {\n if (value === false || value === null || typeof value === \"undefined\") {\n throw new Error(message);\n }\n}\n\nexport function warning(cond: any, message: string) {\n if (!cond) {\n // eslint-disable-next-line no-console\n if (typeof console !== \"undefined\") console.warn(message);\n\n try {\n // Welcome to debugging history!\n //\n // This error is thrown as a convenience, so you can more easily\n // find the source for a warning that appears in the console by\n // enabling \"pause on exceptions\" in your JavaScript debugger.\n throw new Error(message);\n // eslint-disable-next-line no-empty\n } catch (e) {}\n }\n}\n\nfunction createKey() {\n return Math.random().toString(36).substr(2, 8);\n}\n\n/**\n * For browser-based histories, we combine the state and key into an object\n */\nfunction getHistoryState(location: Location, index: number): HistoryState {\n return {\n usr: location.state,\n key: location.key,\n idx: index,\n };\n}\n\n/**\n * Creates a Location object with a unique key from the given Path\n */\nexport function createLocation(\n current: string | Location,\n to: To,\n state: any = null,\n key?: string\n): Readonly {\n let location: Readonly = {\n pathname: typeof current === \"string\" ? current : current.pathname,\n search: \"\",\n hash: \"\",\n ...(typeof to === \"string\" ? parsePath(to) : to),\n state,\n // TODO: This could be cleaned up. push/replace should probably just take\n // full Locations now and avoid the need to run through this flow at all\n // But that's a pretty big refactor to the current test suite so going to\n // keep as is for the time being and just let any incoming keys take precedence\n key: (to && (to as Location).key) || key || createKey(),\n };\n return location;\n}\n\n/**\n * Creates a string URL path from the given pathname, search, and hash components.\n */\nexport function createPath({\n pathname = \"/\",\n search = \"\",\n hash = \"\",\n}: Partial) {\n if (search && search !== \"?\")\n pathname += search.charAt(0) === \"?\" ? search : \"?\" + search;\n if (hash && hash !== \"#\")\n pathname += hash.charAt(0) === \"#\" ? hash : \"#\" + hash;\n return pathname;\n}\n\n/**\n * Parses a string URL path into its separate pathname, search, and hash components.\n */\nexport function parsePath(path: string): Partial {\n let parsedPath: Partial = {};\n\n if (path) {\n let hashIndex = path.indexOf(\"#\");\n if (hashIndex >= 0) {\n parsedPath.hash = path.substr(hashIndex);\n path = path.substr(0, hashIndex);\n }\n\n let searchIndex = path.indexOf(\"?\");\n if (searchIndex >= 0) {\n parsedPath.search = path.substr(searchIndex);\n path = path.substr(0, searchIndex);\n }\n\n if (path) {\n parsedPath.pathname = path;\n }\n }\n\n return parsedPath;\n}\n\nexport interface UrlHistory extends History {}\n\nexport type UrlHistoryOptions = {\n window?: Window;\n v5Compat?: boolean;\n};\n\nfunction getUrlBasedHistory(\n getLocation: (window: Window, globalHistory: Window[\"history\"]) => Location,\n createHref: (window: Window, to: To) => string,\n validateLocation: ((location: Location, to: To) => void) | null,\n options: UrlHistoryOptions = {}\n): UrlHistory {\n let { window = document.defaultView!, v5Compat = false } = options;\n let globalHistory = window.history;\n let action = Action.Pop;\n let listener: Listener | null = null;\n\n let index = getIndex()!;\n // Index should only be null when we initialize. If not, it's because the\n // user called history.pushState or history.replaceState directly, in which\n // case we should log a warning as it will result in bugs.\n if (index == null) {\n index = 0;\n globalHistory.replaceState({ ...globalHistory.state, idx: index }, \"\");\n }\n\n function getIndex(): number {\n let state = globalHistory.state || { idx: null };\n return state.idx;\n }\n\n function handlePop() {\n action = Action.Pop;\n let nextIndex = getIndex();\n let delta = nextIndex == null ? null : nextIndex - index;\n index = nextIndex;\n if (listener) {\n listener({ action, location: history.location, delta });\n }\n }\n\n function push(to: To, state?: any) {\n action = Action.Push;\n let location = createLocation(history.location, to, state);\n if (validateLocation) validateLocation(location, to);\n\n index = getIndex() + 1;\n let historyState = getHistoryState(location, index);\n let url = history.createHref(location);\n\n // try...catch because iOS limits us to 100 pushState calls :/\n try {\n globalHistory.pushState(historyState, \"\", url);\n } catch (error) {\n // If the exception is because `state` can't be serialized, let that throw\n // outwards just like a replace call would so the dev knows the cause\n // https://html.spec.whatwg.org/multipage/nav-history-apis.html#shared-history-push/replace-state-steps\n // https://html.spec.whatwg.org/multipage/structured-data.html#structuredserializeinternal\n if (error instanceof DOMException && error.name === \"DataCloneError\") {\n throw error;\n }\n // They are going to lose state here, but there is no real\n // way to warn them about it since the page will refresh...\n window.location.assign(url);\n }\n\n if (v5Compat && listener) {\n listener({ action, location: history.location, delta: 1 });\n }\n }\n\n function replace(to: To, state?: any) {\n action = Action.Replace;\n let location = createLocation(history.location, to, state);\n if (validateLocation) validateLocation(location, to);\n\n index = getIndex();\n let historyState = getHistoryState(location, index);\n let url = history.createHref(location);\n globalHistory.replaceState(historyState, \"\", url);\n\n if (v5Compat && listener) {\n listener({ action, location: history.location, delta: 0 });\n }\n }\n\n function createURL(to: To): URL {\n // window.location.origin is \"null\" (the literal string value) in Firefox\n // under certain conditions, notably when serving from a local HTML file\n // See https://bugzilla.mozilla.org/show_bug.cgi?id=878297\n let base =\n window.location.origin !== \"null\"\n ? window.location.origin\n : window.location.href;\n\n let href = typeof to === \"string\" ? to : createPath(to);\n // Treating this as a full URL will strip any trailing spaces so we need to\n // pre-encode them since they might be part of a matching splat param from\n // an ancestor route\n href = href.replace(/ $/, \"%20\");\n invariant(\n base,\n `No window.location.(origin|href) available to create URL for href: ${href}`\n );\n return new URL(href, base);\n }\n\n let history: History = {\n get action() {\n return action;\n },\n get location() {\n return getLocation(window, globalHistory);\n },\n listen(fn: Listener) {\n if (listener) {\n throw new Error(\"A history only accepts one active listener\");\n }\n window.addEventListener(PopStateEventType, handlePop);\n listener = fn;\n\n return () => {\n window.removeEventListener(PopStateEventType, handlePop);\n listener = null;\n };\n },\n createHref(to) {\n return createHref(window, to);\n },\n createURL,\n encodeLocation(to) {\n // Encode a Location the same way window.location would\n let url = createURL(to);\n return {\n pathname: url.pathname,\n search: url.search,\n hash: url.hash,\n };\n },\n push,\n replace,\n go(n) {\n return globalHistory.go(n);\n },\n };\n\n return history;\n}\n\n//#endregion\n","import type { Location, Path, To } from \"./history\";\nimport { invariant, parsePath, warning } from \"./history\";\n\n/**\n * Map of routeId -> data returned from a loader/action/error\n */\nexport interface RouteData {\n [routeId: string]: any;\n}\n\nexport enum ResultType {\n data = \"data\",\n deferred = \"deferred\",\n redirect = \"redirect\",\n error = \"error\",\n}\n\n/**\n * Successful result from a loader or action\n */\nexport interface SuccessResult {\n type: ResultType.data;\n data: unknown;\n statusCode?: number;\n headers?: Headers;\n}\n\n/**\n * Successful defer() result from a loader or action\n */\nexport interface DeferredResult {\n type: ResultType.deferred;\n deferredData: DeferredData;\n statusCode?: number;\n headers?: Headers;\n}\n\n/**\n * Redirect result from a loader or action\n */\nexport interface RedirectResult {\n type: ResultType.redirect;\n // We keep the raw Response for redirects so we can return it verbatim\n response: Response;\n}\n\n/**\n * Unsuccessful result from a loader or action\n */\nexport interface ErrorResult {\n type: ResultType.error;\n error: unknown;\n statusCode?: number;\n headers?: Headers;\n}\n\n/**\n * Result from a loader or action - potentially successful or unsuccessful\n */\nexport type DataResult =\n | SuccessResult\n | DeferredResult\n | RedirectResult\n | ErrorResult;\n\ntype LowerCaseFormMethod = \"get\" | \"post\" | \"put\" | \"patch\" | \"delete\";\ntype UpperCaseFormMethod = Uppercase;\n\n/**\n * Users can specify either lowercase or uppercase form methods on `