1import{r,j as e}from"./vendor-framer-db2f12a5.js";import{d as $,H as F,l as C,o as O}from"./index-05c65494.js";import{D as G}from"./DashboardLayout-cf01d816.js";import{B as m}from"./button-bf656b36.js";import{I as p}from"./input-a895a717.js";import{h as H,F as _}from"./vendor-firebase-c0f880b0.js";import{W as E}from"./wrench-a9bee57a.js";import{T as z}from"./triangle-alert-adb603c7.js";import{G as B}from"./gift-a7986838.js";import{E as q}from"./eye-off-93771b78.js";import{E as M}from"./eye-529a7507.js";import{U as V}from"./user-plus-f46ab301.js";import{H as J}from"./hash-3c652422.js";import{C as h}from"./copy-cb8e5f90.js";import{L as W}from"./link-2c089597.js";import{C as X}from"./circle-check-big-a3c8c64f.js";import{C as Q}from"./circle-x-ff7f71bc.js";import"./vendor-react-cc5bcf5d.js";import"./vendor-pdf-5f794b66.js";import"./vendor-recharts-2adcf5ee.js";import"./vendor-i18n-6b96dd07.js";import"./vendor-radix-adc69a00.js";import"./permissions-a0882681.js";import"./badge-8e2bf9a6.js";import"./scroll-area-abadb0da.js";import"./zap-0e9fc7c7.js";import"./cloud-upload-fcdf66fc.js";import"./clock-3e76ae74.js";import"./shopping-cart-b1f13765.js";import"./settings-245d4e14.js";import"./file-check-2f45e377.js";import"./arrow-right-25fe7b74.js";const K="https://us-central1-autobidfix.cloudfunctions.net/generateCourtesyUser",Y="https://us-central1-autobidfix.cloudfunctions.net/patchCourtesyAccounts",Ue=()=>{const{toast:i}=$(),[n,k]=r.useState(""),[u,S]=r.useState(30),[g,I]=r.useState(""),[f,b]=r.useState(!1),[d,R]=r.useState(!1),[t,U]=r.useState(null),[l,j]=r.useState(!1),[N,v]=r.useState(!1),[y,A]=r.useState(!1),[c,w]=r.useState(null),L=async()=>{if(!n){i({title:"Secreto requerido",description:"Ingresa el secreto de admin.",variant:"destructive"});return}b(!0);try{const s=await C(),a=await(await fetch(K,{method:"POST",headers:s,body:JSON.stringify({adminSecret:n,expireDays:parseInt(u),label:g.trim()})})).json();if(!a.success)throw new Error(a.error||"Error desconocido");U(a.user),j(!1),i({title:"Usuario creado",description:"Cuenta de cortesÃa generada: 15 Full Reports · 20 Scans · 30 Insights."})}catch(s){i({title:"Error",description:s.message,variant:"destructive"})}finally{b(!1)}},D=async()=>{if(t){v(!0);try{const s=H(O,"users",t.uid);await _(s,{is_affiliate_approved:!l}),j(!l),i({title:l?"Afiliado Desactivado":"Afiliado Aprobado",description:"El estado de afiliado ha sido actualizado."})}catch{i({title:"Error",description:"No se pudo actualizar el estado de afiliado.",variant:"destructive"})}finally{v(!1)}}},P=async()=>{if(!n){i({title:"Secreto requerido",description:"Ingresa el secreto de admin primero.",variant:"destructive"});return}A(!0),w(null);try{const s=await C(),a=await(await fetch(Y,{method:"POST",headers:s,body:JSON.stringify({adminSecret:n})})).json();if(!a.success)throw new Error(a.error||"Error desconocido");w(a),i({title:`Parche aplicado: ${a.patched} cuentas arregladas`,description:a.errors>0?`${a.errors} errores. Revisa los resultados.`:"Todas las cuentas de cortesÃa ya pueden iniciar sesión."})}catch(s){i({title:"Error en parche",description:s.message,variant:"destructive"})}finally{A(!1)}},o=(s,x)=>{navigator.clipboard.writeText(s),i({title:"Copiado",description:`${x} copiado al portapapeles`})},T=s=>s?new Date(s).toLocaleDateString("es-MX",{year:"numeric",month:"long",day:"numeric"}):"â";return e.jsxs(G,{children:[e.jsx(F,{children:e.jsx("title",{children:"Usuarios de CortesÃa - AutoBidFix"})}),e.jsxs("div",{className:"py-8 px-6 sm:px-10 space-y-8 max-w-2xl mx-auto",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-[#1E3A8A]",children:"Usuarios de CortesÃa"}),e.jsx("p",{className:"text-gray-500 text-sm mt-1",children:"Genera cuentas de prueba con créditos gratuitos para testing."})]}),e.jsx("div",{className:"bg-red-50 border border-red-200 rounded-xl p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(E,{className:"w-5 h-5 text-red-600 flex-shrink-0 mt-0.5"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-semibold text-red-800",children:"Parche de emergencia â cuentas existentes"}),e.jsxs("p",{className:"text-xs text-red-700 mt-1",children:["Si ya enviaste invitaciones y los influencers no pueden entrar, aplica este parche. Fija ",e.jsx("code",{className:"bg-red-100 px-1 rounded",children:"emailVerified=true"})," en todas las cuentas de cortesÃa activas."]}),e.jsxs("div",{className:"flex items-center gap-3 mt-3",children:[e.jsxs(m,{size:"sm",disabled:y,onClick:P,className:"bg-red-600 hover:bg-red-700 text-white text-xs",children:[e.jsx(E,{className:"w-3.5 h-3.5 mr-1.5"}),y?"Aplicandoâ¦":"Aplicar Parche"]}),c&&e.jsxs("span",{className:"text-xs text-red-700 font-medium",children:["â
",c.patched," arregladas",c.errors>0&&` · â ï¸ ${c.errors} errores`]})]})]})]})}),e.jsxs("div",{className:"bg-blue-50 border border-blue-200 rounded-xl p-4 flex items-start gap-3",children:[e.jsx(z,{className:"w-5 h-5 text-blue-600 flex-shrink-0 mt-0.5"}),e.jsxs("div",{className:"text-sm text-blue-800",children:[e.jsx("p",{className:"font-medium",children:"Nuevo formato de cuentas"}),e.jsxs("p",{className:"mt-1",children:["Las cuentas ahora usan ",e.jsx("code",{className:"bg-blue-100 px-1 rounded",children:"[email protected]"}),", ",e.jsx("code",{className:"bg-blue-100 px-1 rounded",children:"[email protected]"}),"⦠(numeración secuencial). Al primer login el influencer verá una pantalla para registrar su correo real."]})]})]}),e.jsxs("div",{className:"bg-white rounded-2xl p-6 border border-slate-200 shadow-sm space-y-5",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx(B,{className:"w-5 h-5 text-[#1E3A8A]"}),e.jsx("h2",{className:"font-bold text-[#1E3A8A]",children:"Generar Cuenta de Prueba"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-gray-700 block mb-1.5",children:"Secreto de Admin"}),e.jsxs("div",{className:"relative",children:[e.jsx(p,{type:d?"text":"password",value:n,onChange:s=>k(s.target.value),placeholder:"Ingresa el secreto de admin",className:"pr-10 text-slate-900"}),e.jsx("button",{type:"button",onClick:()=>R(!d),className:"absolute right-3 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600",children:d?e.jsx(q,{className:"w-4 h-4"}):e.jsx(M,{className:"w-4 h-4"})})]})]}),e.jsxs("div",{className:"bg-slate-50 rounded-xl p-3 border border-slate-200",children:[e.jsx("p",{className:"text-xs font-medium text-gray-500 mb-2",children:"Créditos asignados (preconfigurado)"}),e.jsxs("div",{className:"grid grid-cols-3 gap-2 text-center",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-lg font-bold text-[#1E3A8A]",children:"15"}),e.jsx("p",{className:"text-[10px] text-gray-500",children:"Full Reports"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-lg font-bold text-[#1E3A8A]",children:"20"}
1),e.jsx("p",{className:"text-[10px] text-gray-500",children:"Quick Scans"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-lg font-bold text-[#1E3A8A]",children:"30"}),e.jsx("p",{className:"text-[10px] text-gray-500",children:"Insights"})]})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-gray-700 block mb-1.5",children:"DÃas de validez"}),e.jsx(p,{type:"number",value:u,onChange:s=>S(s.target.value),min:1,max:365,placeholder:"30",className:"text-slate-900"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-gray-700 block mb-1.5",children:"Etiqueta (opcional)"}),e.jsx(p,{type:"text",value:g,onChange:s=>I(s.target.value),placeholder:"Ej: Cliente Demo, Vendedor Prueba...",className:"text-slate-900"})]}),e.jsxs(m,{onClick:L,disabled:f,className:"w-full bg-[#1E3A8A] text-white hover:bg-[#1E3A8A]/90",children:[e.jsx(V,{className:"w-4 h-4 mr-2"}),f?"Generando...":"Generar Cuenta de CortesÃa"]})]}),t&&e.jsxs("div",{className:"bg-green-50 border border-green-200 rounded-2xl p-6 space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h2",{className:"font-bold text-green-800",children:"¡Cuenta generada exitosamente!"}),t.courtesyNumber&&e.jsxs("span",{className:"flex items-center gap-1 bg-green-200 text-green-800 text-xs font-bold px-2 py-1 rounded-full",children:[e.jsx(J,{className:"w-3 h-3"}),"courtesy",t.courtesyNumber]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between bg-white rounded-xl p-3 border border-green-100",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-gray-500",children:"Email"}),e.jsx("p",{className:"font-mono text-sm text-gray-800",children:t.email})]}),e.jsx("button",{onClick:()=>o(t.email,"Email"),className:"p-2 hover:bg-green-100 rounded-lg transition-colors",children:e.jsx(h,{className:"w-4 h-4 text-green-600"})})]}),e.jsxs("div",{className:"flex items-center justify-between bg-white rounded-xl p-3 border border-green-100",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-gray-500",children:"Contraseña temporal"}),e.jsx("p",{className:"font-mono text-sm text-gray-800",children:t.password})]}),e.jsx("button",{onClick:()=>o(t.password,"Contraseña"),className:"p-2 hover:bg-green-100 rounded-lg transition-colors",children:e.jsx(h,{className:"w-4 h-4 text-green-600"})})]}),e.jsxs("div",{className:"bg-[#1E3A8A] rounded-xl p-3 border border-blue-800",children:[e.jsx("p",{className:"text-xs text-blue-200 font-bold mb-1.5",children:"ð Link de Invitación (enviar esto)"}),e.jsx("p",{className:"font-mono text-[10px] text-white break-all leading-relaxed",children:`https://autobidfix.com/invite?e=${encodeURIComponent(t.email)}&p=${encodeURIComponent(t.password)}`}),e.jsxs("button",{onClick:()=>o(`https://autobidfix.com/invite?e=${encodeURIComponent(t.email)}&p=${encodeURIComponent(t.password)}`,"Link de Invitación"),className:"mt-2 flex items-center gap-1.5 text-xs font-bold text-yellow-400 hover:text-yellow-300 transition-colors",children:[e.jsx(h,{className:"w-3.5 h-3.5"})," Copiar Link de Invitación"]})]}),t.referralCode&&e.jsxs("div",{className:"flex items-center justify-between bg-white rounded-xl p-3 border border-green-100",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-gray-500",children:"Link de Afiliado"}),e.jsx("p",{className:"font-mono text-[10px] text-gray-800 break-all",children:`https://autobidfix.com/auth?ref=${t.referralCode}`})]}),e.jsx("button",{onClick:()=>o(`https://autobidfix.com/auth?ref=${t.referralCode}`,"Link de Afiliado"),className:"p-2 hover:bg-green-100 rounded-lg transition-colors",children:e.jsx(W,{className:"w-4 h-4 text-green-600"})})]}),e.jsxs("div",{className:"flex items-center justify-between bg-white rounded-xl p-3 border border-green-100",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:`p-1.5 rounded-full ${l?"bg-green-100":"bg-slate-100"}`,children:l?e.jsx(X,{className:"w-4 h-4 text-green-600"}):e.jsx(Q,{className:"w-4 h-4 text-slate-400"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-gray-500",children:"Estado de Afiliado"}),e.jsx("p",{className:`text-sm font-bold ${l?"text-green-700":"text-slate-500"}`,children:l?"APROBADO":"PENDIENTE"})]})]}),e.jsx(m,{size:"sm",variant:"outline",onClick:D,disabled:N,className:`border-green-200 text-green-700 hover:bg-green-50 ${l?"bg-green-50":""}`,children:N?"...":l?"Desactivar":"Aprobar"})]}),e.jsxs("div",{className:"grid grid-cols-4 gap-2",children:[e.jsxs("div",{className:"bg-white rounded-xl p-3 border border-green-100 text-center",children:[e.jsx("p",{className:"text-xs text-gray-500",children:"Full Reports"}),e.jsx("p",{className:"text-xl font-bold text-[#1E3A8A]",children:"15"})]}),e.jsxs("div",{className:"bg-white rounded-xl p-3 border border-green-100 text-center",children:[e.jsx("p",{className:"text-xs text-gray-500",children:"Scans"}),e.jsx("p",{className:"text-xl font-bold text-[#1E3A8A]",children:"20"})]}),e.jsxs("div",{className:"bg-white rounded-xl p-3 border border-green-100 text-center",children:[e.jsx("p",{className:"text-xs text-gray-500",children:"Insights"}),e.jsx("p",{className:"text-xl font-bold text-[#1E3A8A]",children:"30"})]}),e.jsxs("div",{className:"bg-white rounded-xl p-3 border border-green-100 text-center",children:[e.jsx("p",{className:"text-xs text-gray-500",children:"Vence"}),e.jsx("p",{className:"text-sm font-bold text-[#1E3A8A]",children:T(t.expiresAt)})]})]})]}),e.jsxs("p",{className:"text-xs text-green-700",children:["EnvÃa el ",e.jsx("strong",{children:"Link de Invitación"})," al influencer. Al hacer click verá sus credenciales listas para copiar y un botón de acceso directo. Al primer login se le pedirá registrar su correo real."]}),e.jsx("button",{onClick:()=>o(`https://autobidfix.com/invite?e=${encodeURIComponent(t.email)}&p=${encodeURIComponent(t.password)}`,"Link de Invitación"),className:"w-full text-center text-sm text-white font-bold py-3 bg-[#1E3A8A] rounded-xl hover:bg-[#16296C] transition-colors",children:"ð Copiar Link de Invitación"})]}),e.jsxs("div",{className:"bg-slate-50 border border-slate-200 rounded-2xl p-6 space-y-3",children:[e.jsx("h2",{className:"font-bold text-[#1E3A8A]",children:"Cómo configurar ADM
1IN_SECRET"}),e.jsxs("ol",{className:"space-y-2 text-sm text-gray-700",children:[e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"font-bold text-[#1E3A8A] w-5 flex-shrink-0",children:"1."}),e.jsxs("span",{children:["Ve a ",e.jsx("strong",{children:"Firebase Console"})," â Functions â Extensions â Manage functions"]})]}),e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"font-bold text-[#1E3A8A] w-5 flex-shrink-0",children:"2."}),e.jsxs("span",{children:["O ejecuta en terminal: ",e.jsx("code",{className:"bg-slate-100 px-2 py-0.5 rounded text-xs",children:"firebase functions:secrets:set ADMIN_SECRET"})]})]}),e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"font-bold text-[#1E3A8A] w-5 flex-shrink-0",children:"3."}),e.jsx("span",{children:"Ingresa un valor seguro cuando te lo pida (guárdalo, lo necesitas aquÃ)"})]}),e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"font-bold text-[#1E3A8A] w-5 flex-shrink-0",children:"4."}),e.jsxs("span",{children:["Redeploya las funciones: ",e.jsx("code",{className:"bg-slate-100 px-2 py-0.5 rounded text-xs",children:"firebase deploy --only functions"})]})]})]})]})]})]})};export{Ue as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.