PageSourceSearch

https://irpa2026colombia.org/assets/PortalParticipante-y2KIyGbB.js

js irpa2026colombia.org collected 2026-10-08 03:16:43 UTC 82,216 bytes, 31 lines download raw bytes

1import{c as Ce,r as u,s as j,i as Ge,d as ze,j as e,B as S,b as K,X as ss,k as ws,g as as,u as Cs}from"./index-DnVm687U.js";import{H as He,F as We}from"./Footer-Bvqa_r8G.js";import{C as q,b as ee,c as se,a as T,d as Ye}from"./card-CRFaJYNz.js";import{B as b}from"./badge-BLNB1n0H.js";import{D as Es,b as Ps,c as Ss,d as Fs}from"./dialog-BQOPzVNo.js";import{S as be,a as Ne,b as _e,c as ye,d as we}from"./select-BBeLgipb.js";import{T as Ds}from"./textarea-wowC9C90.js";import{L as h}from"./label-BWZGrcrB.js";import{R as De,a as pe}from"./radio-group-CcBF0RkW.js";import{S as ks}from"./separator-Cey6I7pC.js";import{A as I,a as z}from"./alert-CuNsnv7-.js";import{I as E}from"./input-D4ugazI8.js";import{D as As}from"./date-of-birth-input-jW_WuZ-N.js";import{c as Ze}from"./countries-CCyu059Z.js";import{U as rs}from"./dropdown-menu-elZyZctl.js";import{S as Is}from"./square-pen-VVKvgBd-.js";import{S as zs}from"./save-N9WwdXh1.js";import{C as Q}from"./circle-check-big-hO1idMQN.js";import{C as de}from"./circle-x-DIo5bdqO.js";import{C as te}from"./clock-CIC8GvrU.js";import{L as Ie}from"./lock-BySUVuJ_.js";import{C as qs}from"./checkbox-DQGP46Z3.js";import{T as xe}from"./triangle-alert-DrFwYdXz.js";import{F as ge}from"./file-text-BU0yiu-Q.js";import{S as ke}from"./shield-alert-csZ0oKw4.js";import{I as Xe}from"./info-zLLFQJ0e.js";import{D as fe}from"./download-Cln34tJJ.js";import{U as oe}from"./upload-0ilaCe4N.js";import{C as je}from"./circle-check-CEudxvXQ.js";import{R as Ts}from"./receipt-CQodndI6.js";import{C as Je}from"./circle-alert-DRJhAiAk.js";import{B as Ke}from"./building-2-CVxC9Ilf.js";import{D as Qe}from"./dollar-sign-Cy0oYWFk.js";import{T as Us}from"./ticket-3Vb_l25F.js";import{T as Rs}from"./tag-DJh0gazI.js";import{C as Os}from"./credit-card-BLsRK1Y1.js";import{T as Ls}from"./trash-2-mVbNQiFx.js";import"./shield-BN1RiLGr.js";import"./log-out-CtUQRbPX.js";import"./Combination-D1NCdNup.js";import"./search-BNZJvCG8.js";import"./mail-BBtFmBsn.js";import"./index-yRo4nqrX.js";import"./index-B-Wc5f3e.js";import"./index-Cue5PJE5.js";import"./chevron-up-46FaISor.js";import"./index-C7OIboLl.js";/**
2 * @license lucide-react v0.462.0 - ISC
3 *
4 * This source code is licensed under the ISC license.
5 * See the LICENSE file in the root directory of this source tree.
6 */const Ms=Ce("CloudUpload",[["path",{d:"M12 13v8",key:"1l5pq0"}],["path",{d:"M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242",key:"1pljnt"}],["path",{d:"m8 17 4-4 4 4",key:"1quai1"}]]);/**
7 * @license lucide-react v0.462.0 - ISC
8 *
9 * This source code is licensed under the ISC license.
10 * See the LICENSE file in the root directory of this source tree.
11 */const $s=Ce("List",[["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 18h.01",key:"1tta3j"}],["path",{d:"M3 6h.01",key:"1rqtza"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 18h13",key:"1lx6n3"}],["path",{d:"M8 6h13",key:"ik3vkj"}]]);/**
12 * @license lucide-react v0.462.0 - ISC
13 *
14 * This source code is licensed under the ISC license.
15 * See the LICENSE file in the root directory of this source tree.
16 */const es=Ce("Paperclip",[["path",{d:"m21.44 11.05-9.19 9.19a6 6 0 0 1-8.49-8.49l8.57-8.57A4 4 0 1 1 18 8.84l-8.59 8.57a2 2 0 0 1-2.83-2.83l8.49-8.48",key:"1u3ebp"}]]);/**
17 * @license lucide-react v0.462.0 - ISC
18 *
19 * This source code is licensed under the ISC license.
20 * See the LICENSE file in the root directory of this source tree.
21 */const Bs=Ce("Percent",[["line",{x1:"19",x2:"5",y1:"5",y2:"19",key:"1x9vlm"}],["circle",{cx:"6.5",cy:"6.5",r:"2.5",key:"4mh3h7"}],["circle",{cx:"17.5",cy:"17.5",r:"2.5",key:"1mdrzq"}]]),Vs=(r,ie="COP")=>{const[D,d]=u.useState(null),[a,U]=u.useState(!0),[t,g]=u.useState(ie),M=async H=>{if(!r){U(!1);return}try{U(!0);const R=new Intl.DateTimeFormat("en-CA",{timeZone:"America/Bogota"}).format(new Date),{data:$,error:W}=await j.from("registration_fees").select("*").eq("category",r).eq("is_active",!0).lte("valid_from",R).gte("valid_until",R).order("valid_from",{ascending:!0}).limit(1);if(W){console.error("Error fetching fee:",W),Ge.error("Error al obtener la tarifa actual"),d(null);return}if($&&$.length>0){const N=$[0];d({fee_id:N.id,fee_name:N.fee_name,fee_type:N.fee_type,amount:H==="USD"?N.amount_usd:N.amount_cop,amount_cop:N.amount_cop,amount_usd:N.amount_usd,currency:H,valid_until:N.valid_until})}else d(null)}catch(R){console.error("Error fetching fee:",R),Ge.error("Error al calcular la tarifa"),d(null)}finally{U(!1)}};return u.useEffect(()=>{M(t)},[r,t]),{fee:D,loading:a,currency:t,setCurrency:g,refetch:()=>M(t)}},Gs=({registration:r,userId:ie,onUpdate:D})=>{const{toast:d}=ze(),[a,U]=u.useState(!1),[t,g]=u.useState({}),[M,H]=u.useState(!1),R=()=>{g({first_name:r.first_name,second_name:r.second_name,first_surname:r.first_surname,second_surname:r.second_surname,birth_date:r.birth_date,birth_country:r.birth_country,residence_country:r.residence_country,contact_phone:r.contact_phone,alternative_email:r.alternative_email,profession:r.profession,academic_degree:r.academic_degree,primary_institution:r.primary_institution,secondary_institution:r.secondary_institution,position:r.position,study_institution:r.study_institution,career:r.career,is_author:r.is_author,requires_funding:r.requires_funding}),U(!0)},$=()=>{U(!1),g({})},W=async()=>{var n,V,ne,me,ce,Y,Z,l,c,v,x,_,O,F,y,B;if(!((n=t.first_name)!=null&&n.trim())||t.first_name.trim().length<2){d({title:"Error de validación",description:"El primer nombre debe tener al menos 2 caracteres",variant:"destructive"});return}if(!((V=t.first_surname)!=null&&V.trim())||t.first_surname.trim().length<2){d({title:"Error de validación",description:"El primer apellido debe tener al menos 2 caracteres",variant:"destructive"});return}if((ne=t.alternative_email)!=null&&ne.trim()&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t.alternative_email.trim())){d({title:"Error de validación",description:"El email alternativo no tiene un formato válido",variant:"destructive"});return}H(!0);try{const k={first_name:t.first_name.trim().toUpperCase(),second_name:((me=t.second_name)==null?void 0:me.trim().toUpperCase())||null,first_surname:t.first_surname.trim().toUpperCase(),second_surname:((ce=t.second_surname)==null?void 0:ce.trim().toUpperCase())||null,full_name:`${t.first_name.trim()} ${((Y=t.second_name)==null?void 0:Y.trim())||""} ${t.first_surname.trim()} ${((Z=t.second_surname)==null?void 0:Z.trim())||""}`.replace(/\s+/g," ").trim().toUpperCase(),birth_date:t.birth_date,birth_country:t.birth_country,residence_country:t.residence_country,contact_phone:((l=t.contact_phone)==null?void 0:l.trim())||null,alternative_email:((c=t.alternative_email)==null?void 0:c.trim())||null,profession:((v=t.profession)==null?void 0:v.trim().toUpperCase())||null,academic_degree:((x=t.academic_degree)==null?void 0:x.trim())||null,primary_institution:((_=t.primary_institution)==null?void 0:_.trim().toUpperCase())||null,secondary_institution:((O=t.
21secondary_institution)==null?void 0:O.trim().toUpperCase())||null,position:((F=t.position)==null?void 0:F.trim().toUpperCase())||null,study_institution:((y=t.study_institution)==null?void 0:y.trim().toUpperCase())||null,career:((B=t.career)==null?void 0:B.trim().toUpperCase())||null,is_author:t.is_author,requires_funding:t.requires_funding},{error:X}=await j.from("registrations").update(k).eq("id",r.id).eq("user_id",ie);if(X)throw X;d({title:"Información actualizada",description:"Tus datos se han guardado correctamente"}),U(!1),D()}catch(k){console.error("Error updating registration:",k),d({title:"Error",description:"No se pudo actualizar la información",variant:"destructive"})}finally{H(!1)}},N=({label:n,value:V})=>e.jsxs("div",{className:"relative",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(Ie,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:n})]}),e.jsx("p",{className:"font-medium text-muted-foreground",children:V}),a&&e.jsxs("div",{className:"mt-2 p-3 bg-amber-50 border border-amber-200 rounded-lg text-xs",children:[e.jsx("p",{className:"text-amber-800 font-medium",children:"Para modificar este campo, contacta a soporte:"}),e.jsx("a",{href:"mailto:[email protected]",className:"flex items-center gap-1 text-primary font-semibold mt-1 hover:underline break-all",children:"[email protected]"}),e.jsx("p",{className:"text-amber-700 mt-1",children:"Lun-Vie 8am-4pm (hora Colombia)"})]})]});return e.jsxs(q,{id:"mi-informacion",children:[e.jsx(ee,{children:e.jsxs(se,{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(rs,{className:"h-5 w-5"}),e.jsx("span",{children:"Mi Información"})]}),a?e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(S,{size:"sm",onClick:W,disabled:M,className:"gap-2",children:[M?e.jsx(K,{className:"h-4 w-4 animate-spin"}):e.jsx(zs,{className:"h-4 w-4"}),"Guardar"]}),e.jsx(S,{variant:"outline",size:"sm",onClick:$,disabled:M,children:e.jsx(ss,{className:"h-4 w-4"})})]}):e.jsxs(S,{variant:"outline",size:"sm",onClick:R,className:"gap-2",children:[e.jsx(Is,{className:"h-4 w-4"}),"Editar"]})]})}),e.jsx(T,{children:r?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold mb-4 text-primary",children:"Datos Personales"}),e.jsxs("div",{className:"grid md:grid-cols-2 gap-4",children:[a?e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx(h,{htmlFor:"first_name",children:"Primer Nombre *"}),e.jsx(E,{id:"first_name",value:t.first_name||"",onChange:n=>g({...t,first_name:n.target.value}),className:"mt-1"})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:"second_name",children:"Segundo Nombre"}),e.jsx(E,{id:"second_name",value:t.second_name||"",onChange:n=>g({...t,second_name:n.target.value}),className:"mt-1"})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:"first_surname",children:"Primer Apellido *"}),e.jsx(E,{id:"first_surname",value:t.first_surname||"",onChange:n=>g({...t,first_surname:n.target.value}),className:"mt-1"})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:"second_surname",children:"Segundo Apellido"}),e.jsx(E,{id:"second_surname",value:t.second_surname||"",onChange:n=>g({...t,second_surname:n.target.value}),className:"mt-1"})]})]}):e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Nombre Completo"}),e.jsx("p",{className:"font-medium",children:r.full_name})]}),e.jsx(N,{label:"Documento",value:`${r.document_type}: ${r.identification_number}`}),a?e.jsxs(e.Fragment,{children:[e.jsx("div",{children:e.jsx(As,{value:t.birth_date||"",onChange:n=>g({...t,birth_date:n})})}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:"birth_country",children:"País de Nacimiento *"}),e.jsxs(be,{value:t.birth_country||"",onValueChange:n=>g({...t,birth_country:n}),children:[e.jsx(Ne,{className:"mt-1",children:e.jsx(_e,{})}),e.jsx(ye,{children:Ze.map(n=>e.jsx(we,{value:n.label,children:n.label},n.value))})]})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:"residence_country",children:"País de Residencia"}),e.jsxs(be,{value:t.residence_country||"",onValueChange:n=>g({...t,residence_country:n}),children:[e.jsx(Ne,{className:"mt-1",children:e.jsx(_e,{})}),e.jsx(ye,{children:Ze.map(n=>e.jsx(we,{value:n.label,children:n.label},n.value))})]})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Fecha de Nacim
21iento"}),e.jsx("p",{className:"font-medium",children:ws(r.birth_date)})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"País de Nacimiento"}),e.jsx("p",{className:"font-medium",children:r.birth_country})]}),r.residence_country&&e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"País de Residencia"}),e.jsx("p",{className:"font-medium",children:r.residence_country})]})]})]})]}),e.jsxs("div",{className:"border-t pt-6",children:[e.jsx("h3",{className:"text-lg font-semibold mb-4 text-primary",children:"Información de Contacto"}),e.jsxs("div",{className:"grid md:grid-cols-2 gap-4",children:[e.jsx(N,{label:"Email Principal",value:r.primary_email}),a?e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx(h,{htmlFor:"alternative_email",children:"Email Alternativo"}),e.jsx(E,{id:"alternative_email",type:"email",value:t.alternative_email||"",onChange:n=>g({...t,alternative_email:n.target.value}),className:"mt-1"})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:"contact_phone",children:"Teléfono"}),e.jsx(E,{id:"contact_phone",value:t.contact_phone||"",onChange:n=>g({...t,contact_phone:n.target.value}),className:"mt-1"})]})]}):e.jsxs(e.Fragment,{children:[r.alternative_email&&e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Email Alternativo"}),e.jsx("p",{className:"font-medium",children:r.alternative_email})]}),r.contact_phone&&e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Teléfono"}),e.jsx("p",{className:"font-medium",children:r.contact_phone})]})]})]})]}),e.jsxs("div",{className:"border-t pt-6",children:[e.jsx("h3",{className:"text-lg font-semibold mb-4 text-primary",children:r.category==="profesional_tecnico"?"Información Profesional":"Información Académica"}),e.jsx("div",{className:"grid md:grid-cols-2 gap-4",children:r.category==="profesional_tecnico"?e.jsx(e.Fragment,{children:a?e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx(h,{htmlFor:"profession",children:"Profesión"}),e.jsx(E,{id:"profession",value:t.profession||"",onChange:n=>g({...t,profession:n.target.value}),className:"mt-1"})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:"academic_degree",children:"Grado Académico"}),e.jsx(E,{id:"academic_degree",value:t.academic_degree||"",onChange:n=>g({...t,academic_degree:n.target.value}),className:"mt-1"})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:"primary_institution",children:"Institución Principal"}),e.jsx(E,{id:"primary_institution",value:t.primary_institution||"",onChange:n=>g({...t,primary_institution:n.target.value}),className:"mt-1"})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:"secondary_institution",children:"Institución Secundaria"}),e.jsx(E,{id:"secondary_institution",value:t.secondary_institution||"",onChange:n=>g({...t,secondary_institution:n.target.value}),className:"mt-1"})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:"position",children:"Cargo"}),e.jsx(E,{id:"position",value:t.position||"",onChange:n=>g({...t,position:n.target.value}),className:"mt-1"})]})]}):e.jsxs(e.Fragment,{children:[r.profession&&e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Profesión"}),e.jsx("p",{className:"font-medium",children:r.profession})]}),r.academic_degree&&e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Grado Académico"}),e.jsx("p",{className:"font-medium",children:r.academic_degree})]}),r.primary_institution&&e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Institución Principal"}),e.jsx("p",{className:"font-medium",children:r.primary_institution})]}),r.secondary_institution&&e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Institución Secundaria"}),e.jsx("p",{className:"font-medium",children:r.secondary_institution})]}),r.position&&e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Cargo"}),e.jsx("p",{className:"font-medium",children:r.position})]})]})}):e.jsxs(e.Fragment,{children:[a?e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx(h,{htmlFor:"study_institution",children:"Institución de Estudio"}),e.jsx(E,{id:"study_institution",value:t.study_institution||"",onChange:n=>g({...t,study_institution:n.target.value}),className:"mt-1"})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:"career",children:"Carrera"}),e.jsx(E,{id:"career",value:t.career||"",onChange:n=>g({...t,career:n.target.value}),className:"mt-1"})]})]}):e.jsxs(e.Fragment,{children:[r.study_institution&&e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Institución de Estudio"}),e.jsx("p",{className:"font-medium",children:r.study_institution})]}),r.career&&e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Carrera"}),e.jsx("p",{className:"font-medium",children:r.career})]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Certificado Estudiantil"}),e.jsx("p",{className:"font-medium",children:r.certificate_validated===!0?e.jsxs(b,{className:"bg-green-500",children:[e.jsx(Q,{className:"h-3 w-3 mr-1"}),"Aprobado"]}):r.certificate_validated===!1?e.jsxs(b,{variant:"destructive",children:[e.jsx(de,{className:"h-3 w-3 mr-1"}),"Rechazado"]}):e.jsxs(b,{variant:"outline",children:[e.jsx(te,{className:"h-3 w-3 mr-1"}),"Pendiente de Validación"]})})]})]})})]}),e.jsxs("div",{className:"border-t pt-6",children:[e.jsx("h3",{className:"text-lg font-semibold mb-4 text-primary",children:"Estado del Registro"}),e.jsxs("div",{className:"grid md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Categoría"}),e.jsx("p",{className:"font-medium",children:r.category==="profesional_tecnico"?"Profesional/Técnico":"Estudiante de Pregrado"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Tipo de Registro"}),e.jsx("p",{className:"font-medium",children:r.registration_type==="code_based"?"Código de Cupo":"Pago Directo"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Estado de Pago"}),e.jsxs("p",{className:"font-medium",children:[r.payment_status==="completed"&&e.jsxs(b,{className:"bg-green-500",children:[e.jsx(Q,{className:"h-3 w-3 mr-1"}),"Completado"]}),r.payment_status==="pending"&&e.jsxs(b,{variant:"outline",className:"text-orange-600 border-orange-600",children:[e.jsx(te,{className:"h-3 w-3 mr-1"}),"Pendiente"]}),r.payment_status==="exempt"&&e.jsxs(b,{className:"bg-blue-500",children:[e.jsx(Q,{className:"h-3 w-3 mr-1"}),"Exento"]})]})]}),a?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",id:"is_author",checked:t.is_author||!1,onChange:n=>g({...t,is_author:n.target.checked}),className:"h-4 w-4"}),e.jsx(h,{htmlFor:"is_author",className:"cursor-pointer",children:"Autor de Trabajos"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",id:"requires_funding",checked:t.requires_funding||!1,onChange:n=>g({...t,requires_funding:n.target.checked}),className:"h-4 w-4"}),e.jsx(h,{htmlFor:"requires_funding",className:"cursor-pointer",children:"Solicita Financiamiento"})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Autor de Trabajos"}),e.jsx("p",{className:"font-medium",children:r.is_author?"Sí":"No"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Solicita Financiamiento"}),e.jsx("p",{className:"font-medium",children:r.requires_funding?"Sí":"No"})]})]})]})]})]}):e.jsx("div",{className:"text-center py-8",children:e.jsx("p",{className:"text-muted-foreground",children:"No se encontró información de registro"})})})]})},Hs=new Date("2026-10-13T04:59:00Z"),Ae=()=>new Date>=Hs,Ws=()=>{const{user:r,userRole:ie}=as(),{toast:D}=ze(),[d,a]=u.useState([]),[U,t]=u.useState({}),[g,M]=u.useState(!0),[H,R]=u.useState(null),[$,W]=u.useState({}),N=u.useMemo(()=>Ae(),[]),n=ie==="super_admin",V=N&&!n;u.useEffect(()=>{r&&ne()},[r]);const ne=async()=>
21{if(r)try{M(!0);const{data:l,error:c}=await j.from("abstracts").select(`
22          id,
23          title,
24          authors,
25          status,
26          presentation_type,
27          created_at
28        `).eq("user_id",r.id).eq("is_latest_version",!0);if(c)throw c;if(!l||l.length===0){a([]),M(!1);return}const v=l.map(x=>{let _="oral";return x.status==="approved_poster"?_="poster":x.status==="approved_oral"&&(_="oral"),{...x,final_format:_}});if(a(v),v.length>0){const{data:x,error:_}=await j.from("final_submissions").select("*").in("abstract_id",v.map(F=>F.id)).eq("is_latest_version",!0);if(_)throw _;const O={};x==null||x.forEach(F=>{O[F.abstract_id]=F}),t(O)}}catch(l){console.error("Error fetching approved abstracts:",l),D({title:"Error",description:"No se pudieron cargar los resúmenes aprobados",variant:"destructive"})}finally{M(!1)}},me=async(l,c)=>{if(r){if(Ae()&&!n){D({title:"Plazo finalizado",description:"La fecha límite para carga de trabajos finales ha expirado.",variant:"destructive"});return}if(!$[l]){D({title:"Confirmación requerida",description:"Debes confirmar que tu trabajo no incluye publicidad de la(s) empresa(s) para las que trabajas antes de subir el archivo.",variant:"destructive"});return}if(c.type!=="application/pdf"){D({title:"Formato inválido",description:"Solo se aceptan archivos PDF",variant:"destructive"});return}if(c.size>10*1024*1024){D({title:"Archivo muy grande",description:"El archivo no debe superar los 10 MB",variant:"destructive"});return}try{R(l);const v=U[l],x=v?v.version_number+1:1;if(x>5){D({title:"Límite de iteraciones alcanzado",description:"Has alcanzado el máximo de 5 intentos para este trabajo. No puedes enviar más versiones.",variant:"destructive"}),R(null);return}const _=`${r.id}/${l}_v${x}_${Date.now()}.pdf`,{error:O}=await j.storage.from("final-works").upload(_,c);if(O)throw O;v!=null&&v.file_path&&await j.storage.from("final-works").remove([v.file_path]),v&&await j.from("final_submissions").update({is_latest_version:!1}).eq("id",v.id);const F=Ae(),{data:y,error:B}=await j.from("final_submissions").insert({abstract_id:l,user_id:r.id,file_path:_,file_size:c.size,version_number:x,submission_status:"pending",submitted_after_deadline:F,no_advertising_confirmed:!0,no_advertising_confirmed_at:new Date().toISOString()}).select("id").single();if(B)throw B;y!=null&&y.id&&j.functions.invoke("backup-final-work-to-drive",{body:{submission_id:y.id}}).catch(k=>{console.warn("Drive backup invocation failed:",k)}),D({title:"Trabajo enviado",description:F?"Trabajo cargado después del cierre oficial (excepción de superadministrador)":"Tu trabajo final ha sido enviado exitosamente para revisión"}),ne()}catch(v){console.error("Error uploading file:",v),D({title:"Error al subir archivo",description:v.message||"No se pudo subir el archivo",variant:"destructive"})}finally{R(null)}}},ce=l=>{const x=`https://czennzkcwtyvuhayills.supabase.co/storage/v1/object/public/congress-templates/${l==="oral"?"Plantilla_Presentaciones_Orales.pptx":"Plantilla_Presentacion_Poster.pptx"}`;window.open(x,"_blank")},Y=l=>l==="oral"?"Presentación Oral":"Póster",Z=l=>{switch(l){case"pending":return e.jsxs(b,{variant:"secondary",className:"flex items-center gap-1",children:[e.jsx(te,{className:"h-3 w-3"}),"Pendiente de revisión"]});case"under_review":return e.jsxs(b,{variant:"default",className:"flex items-center gap-1",children:[e.jsx(te,{className:"h-3 w-3"}),"En revisión"]});case"approved":return e.jsxs(b,{variant:"default",className:"flex items-center gap-1 bg-green-600 hover:bg-green-700",children:[e.jsx(je,{className:"h-3 w-3"}),"Aprobado"]});case"rejected":return e.jsxs(b,{variant:"destructive",className:"flex items-center gap-1",children:[e.jsx(de,{className:"h-3 w-3"}),"Requiere correcciones"]});default:return e.jsx(b,{variant:"outline",children:l})}};return g?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(K,{className:"h-8 w-8 animate-spin text-primary"})}):d.length===0?e.jsx(q,{children:e.jsxs(T,{className:"flex flex-col items-center justify-center py-12",children:[e.jsx(xe,{className:"h-12 w-12 text-muted-foreground mb-4"}),e.jsxs("p",{className:"text-muted-foreground text-center",children:["No tienes resúmenes aprobados aún.",e.jsx("br",{}),"Una vez que tus resúmenes sean evaluados y aprobados, podrás enviar tus trabajos finales aquí."]})]})}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs(I,{children:[e.jsx(ge,{className:"h-4 w-4"}),e.jsxs(z,{children:[e.jsx("strong",{children:"Instrucciones:"})," Una vez que tu resumen sea aprobado por el comité científico, deberás enviar tu trabajo final completo en formato PDF. Descarga la plantilla correspondiente según el formato de tu presentación (oral o póster)."]})]}),e.jsxs(I,{className:"border-primary/50 bg-primary/5",children:[e.jsx(te,{className:"h-4 w-4 text-primary"}),e.jsxs(z,{className:"text-foreground",children:[e.jsx("strong",{children:"Fecha límite de carga de trabajos finales:"})," 12 de octubre a las 11:59 PM (hora Colombia)."]})]}),N&&!n&&e.jsxs(I,{variant:"destructive",children:[e.jsx(xe,{className:"h-4 w-4"}),e.jsxs(z,{children:[e.jsx("strong",{children:"Plazo finalizado:"})," La fecha límite para la carga de trabajos finales ha expirado. Ya no es posible subir ni reemplazar archivos."]})]}),N&&n&&e.jsxs(I,{className:"border-amber-400 bg-amber-50 dark:bg-amber-950/30",children:[e.jsx(ke,{className:"h-4 w-4 text-amber-600"}),e.jsxs(z,{className:"text-amber-800 dark:text-amber-300",children:[e.jsx("strong",{children:"Modo superadministrador:"}),' La fecha límite de carga ha expirado, pero como superadministrador puedes cargar y reemplazar archivos de forma excepcional. Los archivos cargados serán marcados como "Carga posterior al cierre".']})]}),d.map(l=>{const c=U[l.id],v=H===l.id,x=l.status==="approved_oral"||l.status==="approved_poster",_=l.status==="rejected",O=!V&&(!c||c.submission_status==="rejected"&&c.version_number<5),F=!V&&c&&c.submission_status!=="rejected"&&c.submission_status!=="approved";return e.jsxs(q,{className:"border-2",children:[e.jsx(ee,{children:e.jsxs("div",{className:"flex justify-between items-start gap-4",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx(se,{className:"text-xl mb-2",children:l.title}),e.jsxs(Ye,{children:[e.jsx("span",{className:"font-semibold",children:"Autores:"})," ",l.authors]})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[x&&e.jsx(b,{variant:"outline",className:l.final_format==="oral"?"border-green-500 text-green-700 dark:text-green-400 bg-green-50 dark:bg-green-950":"border-blue-500 text-blue-700 dark:text-blue-400 bg-blue-50 dark:bg-blue-950",children:Y(l.final_format)}),_&&e.jsxs(b,{variant:"destructive",className:"flex items-center gap-1",children:[e.jsx(de,{className:"h-3 w-3"}),"Rechazado"]}),!x&&!_&&e.jsxs(b,{variant:"secondary",className:"flex items-center gap-1",children:[e.jsx(te,{className:"h-3 w-3"}),"En evaluación"]}),c&&Z(c.submission_status),(c==null?void 0:c.submitted_after_deadline)&&e.jsxs(b,{className:"flex items-center gap-1 bg-amber-500 hover:bg-amber-600 text-white",children:[e.jsx(ke,{className:"h-3 w-3"}),"Carga posterior al cierre"]})]})]})}),e.jsxs(T,{className:"space-y-4",children:[_&&e.jsxs(I,{variant:"destructive",children:[e.jsx(xe,{className:"h-4 w-4"}),e.jsx(z,{children:"Este trabajo fue rechazado por el comité evaluador. No es posible cargar un trabajo final para este resumen. Le invitamos a revisar las observaciones y enviar nuevamente su resumen."})]}),!x&&!_&&e.jsxs(I,{children:[e.jsx(te,{className:"h-4 w-4"}),e.jsx(z,{children:"Tu resumen está en proceso de evaluación. Una vez aprobado, podrás descargar la plantilla y subir tu trabajo final aquí."})]}),x&&e.jsxs(e.Fragment,{children:[(c==null?void 0:c.submission_status)==="rejected"&&c.admin_comments&&e.jsxs(I,{variant:"destructive",children:[e.jsx(xe,{className:"h-4 w-4"}),e.jsx(z,{children:e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{children:[e.jsx("strong",{children:"Comentarios del revisor:"}),e.jsx("p",{className:"mt-2",children:c.admin_comments})]}),e.jsxs("div",{className:"text-sm",children:[e.jsx("strong",{children:"Versión actual:"})," ",c.version_number," de 5",c.version_number>=4&&e.jsxs("span",{className:"text-destructive font-semibold ml-2",children:["(¡Solo ",5-c.version_number," intento(s) restante(s)!)"]})]})]})})]}),c&&c.version_number>=3&&c.submission_status!=="approved"&&e.jsxs(I,{children:[e.jsx(xe,{className:"h-4 w-4"}),e.jsxs(z,{children:["Has usado ",c.version_number," de 5 intentos permitidos para este trabajo.",c.version_number===5&&c.submission_status==="rejected"&&e.jsx("span",{className:"font-semibold text-destructive ml-1",children:"Este fue tu último intento."})]})]}),l.final_format==="poster"&&e.jsxs(I,{className:"border-blue-300 bg-blue-50 dark:bg-blue-950/30",children:[e.jsx(Xe,{className:"h-4 w-4 text-blue-600"}),e.jsxs(z,{className:"text-blue-800 dark:text-blue-300",children:[e.jsx("strong",{children:"Nota:"})," Póster. El participante debe enviar el diseño del mismo, pero la producción está a cargo de la organización del congreso."]})]}),e.jsxs("div",{children:[e.jsxs(S,{variant:"outline",onClick:()=>ce(l.final_format),className:"w-full sm:w-auto",children:[e.jsx(fe,{className:"h-4 w-4 mr-2"}),"Descargar Plantilla ",l.final_format==="oral"?"Oral":"Póster"]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Descarga la plantilla oficial en formato PowerPoint (.pptx)"})]}),l.final_format==="poster"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs(q,{className:"border-blue-200 bg-blue-50/50 dark:bg-blue-950/20",children:[e.jsx(ee,{className:"pb-2",children:e.jsxs(se,{className:"text-base text-blue-800 dark:text-blue-300 flex items-center gap-2",children:[e.jsx(Xe,{className:"h-4 w-4"}),"Guía para la Elaboración del Póster Científico"]})}),e.jsxs(T,{className:"space-y-4 text-sm text-blue-900 dark:text-blue-200",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold mb-1",children:"1. Descarga y Configuración"}),e.jsx("p",{children:"No es necesario configurar las medidas manualmente. Descargue la diapositiva de muestra directamente desde nuestra aplicación."}),e.jsxs("p",{children:[e.jsx("strong",{children:"Formato:"})," Vertical. ",e.jsx("strong",{children:"Medidas:"}
28)," 56 cm de ancho x 122 cm de alto (ya preconfiguradas en la plantilla)."]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold mb-1",children:"2. Espacio Exclusivo para su Investigación"}),e.jsx("p",{children:"El área total del póster debe ser utilizada únicamente para el contenido científico de su trabajo."}),e.jsxs("p",{children:[e.jsx("strong",{children:"Importante:"})," No incluya encabezados ni pies de página con información o logos del Congreso."]}),e.jsx("p",{className:"text-xs italic",children:"Nota: Esa información institucional será incorporada por la organización durante la impresión final."})]}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold mb-1",children:"3. Tipografía y Tamaños Sugeridos"}),e.jsx("p",{className:"mb-1",children:"Recomendamos fuentes legibles de tipo Sans Serif (ej. Arial, Helvetica o Calibri):"}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-xs border-collapse",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-blue-300",children:[e.jsx("th",{className:"text-left py-1 px-2",children:"Elemento"}),e.jsx("th",{className:"text-left py-1 px-2",children:"Tamaño Sugerido"})]})}),e.jsxs("tbody",{children:[e.jsxs("tr",{className:"border-b border-blue-200",children:[e.jsx("td",{className:"py-1 px-2",children:"Título"}),e.jsx("td",{className:"py-1 px-2",children:"72 - 90 pt (Negrita)"})]}),e.jsxs("tr",{className:"border-b border-blue-200",children:[e.jsx("td",{className:"py-1 px-2",children:"Autores y Filiación"}),e.jsx("td",{className:"py-1 px-2",children:"40 - 48 pt"})]}),e.jsxs("tr",{className:"border-b border-blue-200",children:[e.jsx("td",{className:"py-1 px-2",children:"Cuerpo del Texto"}),e.jsx("td",{className:"py-1 px-2",children:"28 - 32 pt"})]}),e.jsxs("tr",{children:[e.jsx("td",{className:"py-1 px-2",children:"Referencias y Pies de Foto"}),e.jsx("td",{className:"py-1 px-2",children:"20 - 24 pt"})]})]})]})})]}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold mb-1",children:"4. Calidad de Imágenes y Gráficas"}),e.jsx("p",{children:"Utilice una resolución mínima de 300 dpi para evitar imágenes pixeladas. Asegúrese de que las gráficas sean nítidas y los ejes de lectura sean claros."})]}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold mb-1",children:"5. Formato de Envío"}),e.jsx("p",{children:"Una vez finalizado su diseño, guarde el archivo exclusivamente en formato PDF."}),e.jsxs("p",{children:[e.jsx("strong",{children:"Ruta:"})," Archivo → Guardar como → Tipo: PDF (*.pdf)."]}),e.jsx("p",{children:"Confirme que el archivo generado mantenga las proporciones de la plantilla original."}),e.jsx("p",{className:"text-xs italic mt-1",children:"Nota: El uso de la plantilla descargable es obligatorio para garantizar que su trabajo se imprima correctamente en el espacio asignado."})]})]})]}),e.jsxs(q,{className:"border-blue-200",children:[e.jsxs(ee,{className:"pb-2",children:[e.jsxs(se,{className:"text-base flex items-center gap-2",children:[e.jsx(ge,{className:"h-4 w-4"}),"Ejemplo de póster final (solo referencia)"]}),e.jsx(Ye,{children:"Así lucirá tu póster una vez que la organización incorpore la información institucional del congreso."})]}),e.jsx(T,{children:e.jsx("iframe",{src:"/poster-ejemplo.pdf#toolbar=0&navpanes=0&scrollbar=0",className:"w-full h-[500px] border rounded-lg",title:"Ejemplo de póster final"})})]})]}),(O||F)&&e.jsxs("div",{className:`border-2 border-dashed rounded-lg p-6 text-center space-y-4 ${N&&n?"border-amber-400 bg-amber-50/50 dark:bg-amber-950/20":""}`,children:[e.jsx(oe,{className:"h-12 w-12 mx-auto text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:(c==null?void 0:c.submission_status)==="rejected"?"Envía una versión corregida de tu trabajo":F?`Reemplaza tu archivo actual de ${Y(l.final_format)} (solo se conservará la última versión)`:`Sube tu trabajo final de ${Y(l.final_format)} en formato PDF`}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Máximo 10 MB • Solo archivos PDF"}),N&&n&&e.jsx("p",{className:"text-xs text-amber-600 font-semibold mt-1",children:"⚠ Carga excepcional posterior al cierre (superadministrador)"})]}),e.jsxs("div",{className:"flex items-start gap-3 text-left bg-amber-50 dark:bg-amber-950/20 border border-amber-300 dark:border-amber-800 rounded-md p-3",children:[e.jsx(qs,{id:`no-ads-${l.id}`,checked:!!$[l.id],onCheckedChange:y=>W(B=>({...B,[l.id]:y===!0})),className:"mt-0.5"}),e.jsxs("label",{htmlFor:`no-ads-${l.id}`,className:"text-xs text-amber-900 dark:text-amber-200 leading-relaxed cursor-pointer select-none",children:[e.jsx("strong",{children:"Declaración obligatoria:"})," Confirmo que el contenido de mi trabajo",l.final_format==="poster"?" (póster)":" (oral)"," ",e.jsx("strong",{children:"no incluye publicidad ni promoción comercial"})," de la(s) empresa(s) o institución(es) para la(s) que trabajo. El material presentado es estrictamente científico/académico."]})]}),e.jsx(S,{onClick:()=>{const y=document.createElement("input");y.type="file",y.accept="application/pdf",y.onchange=B=>{var X;const k=(X=B.target.files)==null?void 0:X[0];k&&me(l.id,k)},y.click()},disabled:v||!$[l.id],className:N&&n?"bg-amber-500 hover:bg-amber-600":"bg-gradient-to-r from-primary to-accent",children:v?e.jsxs(e.Fragment,{children:[e.jsx(K,{className:"h-4 w-4 mr-2 animate-spin"}),"Subiendo..."]}):e.jsxs(e.Fragment,{children:[e.jsx(oe,{className:"h-4 w-4 mr-2"}),(c==null?void 0:c.submission_status)==="rejected"?"Subir Nueva Versión":F?"Reemplazar Archivo":"Subir Trabajo Final"]})})]}),V&&!c&&e.jsxs(I,{variant:"destructive",children:[e.jsx(xe,{className:"h-4 w-4"}),e.jsx(z,{children:"El plazo para subir tu trabajo final ha expirado. No es posible cargar ar
28chivos."})]}),c&&c.submission_status!=="rejected"&&e.jsxs("div",{className:`rounded-lg p-4 space-y-2 ${c.submitted_after_deadline?"bg-amber-50 dark:bg-amber-950/30 border border-amber-300":"bg-muted/50"}`,children:[c.submitted_after_deadline&&e.jsxs("div",{className:"flex items-center gap-2 text-amber-700 dark:text-amber-400 text-xs font-semibold mb-2",children:[e.jsx(ke,{className:"h-3 w-3"}),"Carga posterior al cierre"]}),e.jsxs("div",{className:"flex justify-between items-center text-sm",children:[e.jsx("span",{className:"font-semibold",children:"Versión:"}),e.jsxs("span",{children:["v",c.version_number]})]}),e.jsxs("div",{className:"flex justify-between items-center text-sm",children:[e.jsx("span",{className:"font-semibold",children:"Fecha de envío:"}),e.jsx("span",{children:new Date(c.submitted_at).toLocaleDateString("es-ES")})]}),e.jsxs("div",{className:"flex justify-between items-center text-sm",children:[e.jsx("span",{className:"font-semibold",children:"Tamaño:"}),e.jsxs("span",{children:[(c.file_size/1024/1024).toFixed(2)," MB"]})]}),c.reviewed_at&&e.jsxs("div",{className:"flex justify-between items-center text-sm",children:[e.jsx("span",{className:"font-semibold",children:"Revisado:"}),e.jsx("span",{children:new Date(c.reviewed_at).toLocaleDateString("es-ES")})]})]})]})]})]},l.id)})]})},Ma=()=>{const{user:r,signOut:ie}=as(),D=Cs(),{toast:d}=ze(),[a,U]=u.useState(null),[t,g]=u.useState([]),[M,H]=u.useState([]),[R,$]=u.useState(!0),[W,N]=u.useState(!1),[n,V]=u.useState([]),[ne,me]=u.useState(!1),[ce,Y]=u.useState(!1),[Z,l]=u.useState(""),[c,v]=u.useState(""),[x,_]=u.useState(null),[O,F]=u.useState(!1),[y,B]=u.useState(null),[k,X]=u.useState(""),[J,ae]=u.useState("idle"),[o,le]=u.useState(null),[qe,Te]=u.useState(!1),[A,Ee]=u.useState(null),[f,re]=u.useState({document_type:"",document_number:"",legal_name:"",email:"",phone:"",address:"",city:""}),[Ue,Re]=u.useState(!1),[w,Oe]=u.useState({}),ts=[{value:"NIT",label:"NIT"},{value:"CC",label:"CC - Cédula de Ciudadanía"},{value:"NIT_OTRO_PAIS",label:"NIT de otro país"},{value:"PP",label:"PP - Pasaporte"},{value:"PEP",label:"PEP - Permiso Especial de Permanencia"},{value:"DIE",label:"DIE - Documento de Identidad Extranjero"},{value:"CE",label:"CE - Cédula de Extranjería"},{value:"TE",label:"TE - Tarjeta de Extranjería"},{value:"TI",label:"TI - Tarjeta de Identidad"},{value:"RC",label:"RC - Registro Civil"},{value:"NUIP",label:"NUIP"}],Le={"application/pdf":".pdf","application/msword":".doc","application/vnd.openxmlformats-officedocument.wordprocessingml.document":".docx","application/vnd.oasis.opendocument.text":".odt","application/rtf":".rtf","text/plain":".txt","application/vnd.ms-powerpoint":".ppt","application/vnd.openxmlformats-officedocument.presentationml.presentation":".pptx","application/vnd.oasis.opendocument.presentation":".odp","image/jpeg":".jpg/.jpeg","image/png":".png","image/gif":".gif","image/webp":".webp","image/svg+xml":".svg","application/vnd.ms-excel":".xls","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":".xlsx","application/vnd.oasis.opendocument.spreadsheet":".ods","text/csv":".csv","application/zip":".zip"},Me=[{value:"certificado",label:"📜 Certificado",description:"Certificados académicos/profesionales"},{value:"carta_respaldo",label:"✉️ Carta de Respaldo",description:"Cartas de recomendación/apoyo"},{value:"permiso",label:"📋 Permiso",description:"Autorizaciones, permisos de participación"},{value:"comprobante_pago",label:"💳 Comprobante de Pago",description:"Recibos, transferencias"},{value:"logo_institucional",label:"🏛️ Logo Institucional",description:"Logos para presentaciones"},{value:"documento_financiamiento",label:"💰 Documento de Financiamiento",description:"Solicitudes OIEA/OMS/OPS"},{value:"presupuesto",label:"📊 Presupuesto",description:"Presupuestos de viaje/participación"},{value:"plantilla",label:"📑 Plantilla",description:"Plantillas personalizadas"},{value:"otro",label:"📄 Otro",description:"Documentos varios"}],is=15*1024*1024,Pe=20,ns=(a==null?void 0:a.category)==="estudiante_pregrado"&&(a==null?void 0:a.certificate_validated)===!0,cs=(a==null?void 0:a.category)==="estudiante_pregrado"&&(a==null?void 0:a.certificate_validated)===!1,ls=(a==null?void 0:a.category)==="estudiante_pregrado"&&(a==null?void 0:a.certificate_validated)===null,os=()=>a?a.category==="estudiante_pregrado"?a.certificate_validated===!0?"estudiante_pregrado":a.certificate_validated===!1?"general":null:y:null,{fee:P,loading:$e,currency:ue,setCurrency:ds}=Vs(os());u.useEffect(()=>{if(!k||k.trim().length===0){ae("idle"),le(null);return}if(k.trim().length<3){ae("idle"),le(null);return}const s=setTimeout(async()=>{ae("checking");try{const{data:i,error:p}=await j.rpc("verify_registration_code",{p_code:k}),m=Array.isArray(i)?i[0]:null;if(p||!m||m.status!=="valid"){ae("invalid"),le(null);return}ae("valid"),le({sponsor_name:m.sponsor_name,discount_percentage:m.discount_percentage,available_slots:m.available_slots,total_slots:m.total_slots,expiry_date:m.expiry_date,code_id:m.code_id})}catch(i){console.error("Error validating code:",i),ae("invalid"),le(null)}},500);return()=>clearTimeout(s)},[k]);const ms=async()=>
28{if(!(!o||!a)){if(o.discount_percentage<100&&A===null){d({title:"Información requerida",description:"Por favor indique si requiere facturación electrónica antes de continuar",variant:"destructive"});return}Te(!0);try{const s=o.discount_percentage===100;s&&A===null&&Ee(!1);const{error:i}=await j.rpc("link_code_to_registration",{p_registration_id:a.id,p_code_id:o.code_id});if(i)throw i;const{error:p}=await j.from("registrations").update({payment_status:s?"exempt":"pending",status:s?"registrado":"pre_registrado"}).eq("id",a.id);if(p)throw p;if(s)try{const{data:m,error:C}=await j.functions.invoke("send-registration-certificate",{body:{registration_id:a.id,payment_amount:0,payment_currency:"COP"}});C?console.error("Error enviando comprobante:",C):console.log("Comprobante enviado exitosamente:",m)}catch(m){console.error("Error invocando función de comprobante:",m)}d({title:s?"¡Inscripción Completada!":"Código Aplicado",description:s?`Inscripción gratuita gracias a ${o.sponsor_name}. Se ha enviado el comprobante a tu correo.`:`Descuento de ${o.discount_percentage}% aplicado`}),ve(),X(""),le(null),ae("idle")}catch(s){console.error("Error applying discount code:",s),d({title:"Error",description:"No se pudo aplicar el código de descuento",variant:"destructive"})}finally{Te(!1)}}},Se=async()=>{try{const{data:s,error:i}=await j.from("participant_attachments").select("*").eq("user_id",r==null?void 0:r.id).order("uploaded_at",{ascending:!1});if(i)throw i;V(s||[])}catch(s){console.error("Error fetching attachments:",s)}},us=s=>{var p;const i=(p=s.target.files)==null?void 0:p[0];i&&Be(i)},ps=s=>{s.preventDefault(),F(!1);const i=s.dataTransfer.files[0];i&&Be(i)},Be=s=>{if(!Object.keys(Le).includes(s.type)){d({title:"Formato no permitido",description:"Por favor selecciona un archivo válido (PDF, Word, PowerPoint, Excel, imagen o ZIP)",variant:"destructive"});return}if(s.size>is){d({title:"Archivo muy grande",description:"El tamaño máximo permitido es 15 MB",variant:"destructive"});return}if(n.length>=Pe){d({title:"Límite alcanzado",description:`Solo puedes subir hasta ${Pe} archivos`,variant:"destructive"});return}_(s)},xs=async()=>{if(!x||!Z||!a){d({title:"Campos requeridos",description:"Selecciona un archivo y el tipo de documento",variant:"destructive"});return}Y(!0);try{const s=x.name.split(".").pop(),i=`${r==null?void 0:r.id}/${Date.now()}.${s}`,{error:p}=await j.storage.from("participant-attachments").upload(i,x);if(p)throw p;const{error:m}=await j.from("participant_attachments").insert({user_id:r==null?void 0:r.id,registration_id:a.id,file_name:x.name,file_path:i,file_size:x.size,file_type:x.type,document_type:Z,description:c||null});if(m)throw m;d({title:"Archivo subido",description:"El documento se ha guardado correctamente"}),_(null),l(""),v(""),Se()}catch(s){console.error("Error uploading file:",s),d({title:"Error",description:"No se pudo subir el archivo",variant:"destructive"})}finally{Y(!1)}},hs=async s=>{try{const{data:i,error:p}=await j.storage.from("participant-attachments").createSignedUrl(s.file_path,60);if(p)throw p;const m=document.createElement("a");m.href=i.signedUrl,m.download=s.file_name,document.body.appendChild(m),m.click(),document.body.removeChild(m)}catch(i){console.error("Error downloading file:",i),d({title:"Error",description:"No se pudo descargar el archivo",variant:"destructive"})}},fs=async s=>{if(confirm("¿Estás seguro de eliminar este archivo?"))try{const{error:i}=await j.storage.from("participant-attachments").remove([s.file_path]);if(i)throw i;const{error:p}=await j.from("participant_attachments").delete().eq("id",s.id);if(p)throw p;d({title:"Archivo eliminado",description:"El documento se ha eliminado correctamente"}),Se()}catch(i){console.error("Error deleting file:",i),d({title:"Error",description:"No se pudo eliminar el archivo",variant:"destructive"})}},js=s=>s.includes("pdf")?"📄":s.includes("word")||s.includes("document")?"📝":s.includes("powerpoint")||s.includes("presentation")?"📊":s.includes("excel")||s.includes("spreadsheet")?"📈":s.includes("image")?"🖼️":s.includes("zip")?"🗜️":"📎",Ve=s=>{if(s===0)return"0 Bytes";const i=1024,p=["Bytes","KB","MB"],m=Math.floor(Math.log(s)/Math.log(i));return Math.round(s/Math.pow(i,m)*100)/100+" "+p[m]},gs=async()=>{try{const{data:s,error:i}=await j.from("congress_templates").select("*").eq("is_active",!0).order("display_order",{ascending:!0});if(i)throw i;H(s||[])}catch(s){console.error("Error fetching templates:",s)}};u.useEffect(()=>{r&&(ve(),Se(),gs())},[r]);const ve=async()=>{try{const{data:s,error:i}=await j.from("registrations").select("*").eq("user_id",r==null?void 0:r.id).maybeSingle();if(i)throw i;U(s),s&&(s.requires_electronic_invoice!==null&&Ee(s.requires_electronic_invoice),s.requires_electronic_invoice&&re({document_type:s.invoice_document_type||"",document_number:s.invoice_document_number||"",legal_name:s.invoice_legal_name||"",email:s.invoice_email||"",phone:s.invoice_phone||"",address:s.invoice_address||"",city:s.invoice_city||""}));const{data:p,error:m}=await j.from("abstracts").select(`
29       *,
30       abstract_evaluations(is_accepted, final_format)
31     `).eq("user_id",r==null?void 0:r.id).order("created_at",{ascending:!1});if(m)throw m;const C=(p||[]).map(L=>{var he;const G=(he=L.abstract_evaluations)==null?void 0:he[0];return(G==null?void 0:G.is_accepted)===!0&&!["approved_oral","approved_poster"].includes(L.status)?{...L,status:G.final_format==="poster"?"approved_poster":"approved_oral"}:(G==null?void 0:G.is_accepted)===!1&&L.status==="pending"?{...L,status:"rejected"}:L});g(C)}catch(s){console.error("Error fetching data:",s),d({title:"Error",description:"No se pudo cargar la 
31información",variant:"destructive"})}finally{$(!1)}},vs=s=>{switch(s){case"approved_oral":case"approved_poster":return e.jsxs(b,{className:"bg-green-500",children:[e.jsx(Q,{className:"h-3 w-3 mr-1"}),"Aprobado"]});case"pending":return e.jsxs(b,{variant:"outline",children:[e.jsx(te,{className:"h-3 w-3 mr-1"}),"En Evaluación"]});case"rejected":return e.jsxs(b,{variant:"destructive",children:[e.jsx(de,{className:"h-3 w-3 mr-1"}),"Rechazado"]});default:return e.jsx(b,{variant:"secondary",children:s})}},Fe=()=>P?o?P.amount*(1-o.discount_percentage/100):P.amount:0,bs=()=>{const s={};return f.document_type||(s.document_type="Seleccione el tipo de documento"),f.document_number.trim()||(s.document_number="Ingrese el número de documento"),f.legal_name.trim()||(s.legal_name="Ingrese el nombre o razón social"),f.email.trim()?/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(f.email)||(s.email="Ingrese un email válido"):s.email="Ingrese el email de facturación",f.phone.trim()||(s.phone="Ingrese el teléfono"),f.address.trim()||(s.address="Ingrese la dirección"),f.city.trim()||(s.city="Ingrese la ciudad"),Oe(s),Object.keys(s).length===0},Ns=async()=>{if(a){if(A&&!bs()){d({title:"Campos incompletos",description:"Por favor complete todos los campos de facturación",variant:"destructive"});return}Re(!0);try{const s={requires_electronic_invoice:A};A?(s.invoice_document_type=f.document_type,s.invoice_document_number=f.document_number,s.invoice_legal_name=f.legal_name,s.invoice_email=f.email,s.invoice_phone=f.phone,s.invoice_address=f.address,s.invoice_city=f.city):(s.invoice_document_type=null,s.invoice_document_number=null,s.invoice_legal_name=null,s.invoice_email=null,s.invoice_phone=null,s.invoice_address=null,s.invoice_city=null);const{error:i}=await j.from("registrations").update(s).eq("id",a.id);if(i)throw i;d({title:"Información guardada",description:A?"Los datos de facturación han sido guardados":"Se ha registrado que no requiere facturación electrónica"}),ve()}catch(s){console.error("Error saving invoice data:",s),d({title:"Error",description:"No se pudo guardar la información de facturación",variant:"destructive"})}finally{Re(!1)}}},_s=()=>A===null?!1:A?f.document_type&&f.document_number.trim()&&f.legal_name.trim()&&f.email.trim()&&/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(f.email)&&f.phone.trim()&&f.address.trim()&&f.city.trim():!0,ys=async()=>{if(!(!a||!P)){if(A===null){d({title:"Información requerida",description:"Por favor indique si requiere facturación electrónica",variant:"destructive"});return}if(A&&!_s()){d({title:"Datos de facturación incompletos",description:"Por favor complete y guarde los datos de facturación antes de continuar",variant:"destructive"});return}
31if(N(!0),y==="asociado_convenio"&&o&&!a.registration_code_id)try{const{error:s}=await j.rpc("link_code_to_registration",{p_registration_id:a.id,p_code_id:o.code_id});if(s)throw s}catch(s){console.error("Error auto-applying code before payment:",s),d({title:"Error",description:"No se pudo vincular el código al registro",variant:"destructive"}),N(!1);return}try{const{data:{session:s}}=await j.auth.getSession();if(!s){d({title:"Error",description:"Debe iniciar sesión para realizar el pago",variant:"destructive"});return}const i=Fe(),p=!0,m=p?await j.functions.invoke("create-bold-payment-link",{body:{registration_id:a.id,amount:P.amount,currency:ue,payer_email:a.primary_email,payer_name:a.full_name,discount_percentage:(o==null?void 0:o.discount_percentage)||0}}):await j.functions.invoke("create-payment-preference",{body:{registration_id:a.id,amount:P.amount,currency:ue,payer_email:a.primary_email,payer_name:a.full_name,discount_percentage:(o==null?void 0:o.discount_percentage)||0}});if(m.error)throw new Error(m.error.message||"Error al crear la preferencia de pago");const C=m.data;if(!C.success){d({title:"Error",description:C.error||"No se pudo crear la preferencia de pago",variant:"destructive"});return}const L=p?C.payment_url:C.init_point;L?window.location.href=L:d({title:"Error",description:"No se recibió la URL de pago",variant:"destructive"})}catch(s){console.error("Error initiating payment:",s),d({title:"Error",description:s.message||"No se pudo iniciar el proceso de pago",variant:"destructive"})}finally{N(!1)}}};return R?e.jsx("div",{className:"min-h-screen flex items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"animate-spin h-8 w-8 border-4 border-primary border-t-transparent rounded-full mx-auto mb-4"}),e.jsx("p",{className:"text-muted-foreground",children:"Cargando portal..."})]})}):a?e.jsxs("div",{className:"min-h-screen",children:[e.jsx(He,{}),e.jsxs("main",{className:"pt-20 pb-20",children:[e.jsx("section",{className:"py-12 gradient-hero text-white",children:e.jsx("div",{className:"container mx-auto px-4",children:e.jsxs("div",{className:"max-w-6xl mx-auto text-center",children:[e.jsx("h1",{className:"text-4xl md:text-5xl font-bold mb-4",children:"Portal del Participante"}),e.jsxs("p",{className:"text-xl text-white/90",children:["Bienvenido, ",(a==null?void 0:a.full_name)||(r==null?void 0:r.email)]}),a&&e.jsx("div",{className:"mt-4",children:e.jsx("span",{className:`px-4 py-2 rounded-full text-sm font-semibold ${a.status==="registrado"?"bg-green-500 text-white":"bg-orange-500 text-white"}`,children:a.status==="registrado"?"✓ Registrado":"⚠ Pre-registrado"})})]})})}),e.jsx("section",{className:"py-12 bg-background",children:e.jsx("div",{className:"container mx-auto px-4",children:e.jsxs("div",{className:"max-w-6xl mx-auto space-y-8",children:[e.jsxs(q,{children:[e.jsx(ee,{children:e.jsxs(se,{className:"flex items-center space-x-2",children:[e.jsx(ge,{className:"h-5 w-5"}),e.jsx("span",{children:"Seguimiento del proceso de evaluación"})]})}),e.jsx(T,{children:e.jsxs("div",{className:"grid md:grid-cols-3 gap-6",children:[e.jsxs("div",{className:"text-center p-4 bg-primary/5 rounded-lg",children:[e.jsx("div",{className:"text-3xl font-bold text-primary mb-2",children:t.length}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Resúmenes Enviados"})]}),e.jsxs("div",{className:"text-center p-4 bg-green-500/5 rounded-lg",children:[e.jsx("div",{className:"text-3xl font-bold text-green-600 mb-2",children:t.filter(s=>s.status==="approved_oral"||s.status==="approved_poster").length}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Aprobados"})]}),e.jsxs("div",{className:"text-center p-4 bg-orange-500/5 rounded-lg",children:[e.jsx("div",{className:"text-3xl font-bold text-orange-600 mb-2",children:t.filter(s=>s.status==="pending").length}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"En Evaluación"})]})]})})]}),e.jsxs("div",{className:"grid md:grid-cols-2 gap-6",children:[e.jsx(q,{className:"hover-lift cursor-pointer",onClick:()=>{const s=document.getElementById("mi-informacion");s==null||s.scrollIntoView({behavior:"smooth"})},children:e.jsxs(T,{className:"p-6 text-center",children:[e.jsx(rs,{className:"h-12 w-12 mx-auto mb-4 text-primary"}),e.jsx("h3",{className:"font-semibold mb-2",children:"Mi Información"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Ver Datos Personales"})]})}),e.jsx(q,{className:"hover-lift cursor-pointer",onClick:()=>D("/enviar-resumen"),children:e.jsxs(T,{className:"p-6 text-center",children:[e.jsx(oe,{className:"h-12 w-12 mx-auto mb-4 text-primary"}),e.jsx("h3",{className:"font-semibold mb-2",children:"Envío de Resúmenes"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Formulario en Línea"})]})}),e.jsx(q,{className:"hover-lift",children:e.jsxs(T,{className:"p-6 text-center",children:[e.jsx(fe,{className:"h-12 w-12 mx-auto mb-4 text-primary"}),e.jsx("h3",{className:"font-semibold mb-2",children:"Plantillas"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Descarga Planillas Oficiales"}),(()=>{const s=t.filter(C=>C.status==="approved_oral"||C.status==="approved_poster"),i=s.some(C=>C.status==="approved_oral"),p=s.some(C=>C.status==="approved_poster");return s.length>0?e.jsxs("div",{className:"space-y-2",children:[i&&e.jsxs(S,{variant:"outline",size:"sm",className:"w-full justify-start",onClick:()=>{window.open("https://czennzkcwtyvuhayills.supabase.co/storage/v1/object/public/congress-templates/Plantilla_Presentaciones_Orales.pptx","_blank")},children:[e.jsx(fe,{className:"h-4 w-4 mr-2"}),"Plantilla Presentación Oral (.pptx)"]}),p&&e.jsxs(S,{variant:"outline",size:"sm",className:"w-full justify-start",onClick:()=>{window.open("https://czennzkcwtyvuhayills.supabase.co/storage/v1/object/public/congress-templates/Plantilla_Presentacion_Poster.pptx","_blank")},children:[e.jsx(fe,{className:"h-4 w-4 mr-2"}
31),"Plantilla Póster (.pptx)"]})]}):e.jsxs("div",{className:"text-sm text-muted-foreground bg-orange-50 p-3 rounded-lg border border-orange-200",children:[e.jsx(Ie,{className:"h-4 w-4 inline mr-1 text-orange-500"}),"Las plantillas estarán disponibles cuando tu trabajo sea aprobado"]})})()]})})]}),t.filter(s=>s.status==="approved_oral"||s.status==="approved_poster").length>0&&e.jsxs(q,{id:"cargar-trabajos",className:"border-green-200 bg-green-50/30",children:[e.jsx(ee,{children:e.jsxs(se,{className:"flex items-center gap-2 text-green-800",children:[e.jsx(oe,{className:"h-5 w-5"}),"Cargar Trabajos Finales"]})}),e.jsxs(T,{children:[e.jsxs(I,{className:"bg-green-100 border-green-300 mb-4",children:[e.jsx(Q,{className:"h-4 w-4 text-green-600"}),e.jsxs(z,{className:"text-green-800",children:["¡Felicitaciones! Tienes ",t.filter(s=>s.status==="approved_oral"||s.status==="approved_poster").length," trabajo(s) aprobado(s). Descarga la plantilla correspondiente y sube tu presentación final."]})]}),e.jsx(Ws,{})]})]}),e.jsxs(q,{children:[e.jsx(ee,{children:e.jsxs(se,{className:"flex items-center space-x-2",children:[e.jsx($s,{className:"h-5 w-5"}),e.jsx("span",{children:"Mis Resúmenes"})]})}),e.jsx(T,{children:t.length===0?e.jsxs("div",{className:"text-center py-12",children:[e.jsx(ge,{className:"h-16 w-16 mx-auto mb-4 text-muted-foreground/50"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"Aun no has enviado ningún resumen"}),e.jsx(S,{onClick:()=>D("/enviar-resumen"),children:"Enviar Primer Resumen"})]}):e.jsx("div",{className:"space-y-4",children:t.map(s=>{var i;return e.jsxs("div",{className:"border rounded-lg p-4 hover:shadow-md transition-shadow",children:[e.jsxs("div",{className:"flex justify-between items-start mb-2",children:[e.jsx("h4",{className:"font-semibold",children:s.title}),vs(s.status)]}),e.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:s.presentation_type==="oral"?"Presentación Oral":"Póster"}),e.jsx("div",{className:"flex flex-wrap gap-2 mb-2",children:(i=s.thematic_areas)==null?void 0:i.slice(0,3).map((p,m)=>e.jsx(b,{variant:"secondary",className:"text-xs",children:p},m))}),(s.status==="approved_oral"||s.status==="approved_poster")&&e.jsxs(S,{variant:"outline",size:"sm",className:"mt-2 border-green-500 text-green-700 hover:bg-green-50",onClick:()=>{const p=document.getElementById("cargar-trabajos");p==null||p.scrollIntoView({behavior:"smooth"})},children:[e.jsx(oe,{className:"h-4 w-4 mr-1"}),"Cargar trabajo final"]})]},s.id)})})})]}),e.jsx(Gs,{registration:a,userId:r==null?void 0:r.id,onUpdate:ve}),(a==null?void 0:a.payment_status)==="pending"&&(o==null?void 0:o.discount_percentage)!==100&&e.jsxs(q,{className:"border-blue-200 bg-blue-50/50",children:[e.jsx(ee,{children:e.jsxs(se,{className:"flex items-center gap-2 text-blue-900",children:[e.jsx(Ts,{className:"h-5 w-5"}),"Facturación Electrónica ",e.jsx("span",{className:"text-destructive",children:"* (obligatorio)"})]})}),e.jsxs(T,{className:"space-y-4",children:[e.jsx("p",{className:"text-sm text-blue-700 mb-4",children:"Antes de continuar con el pago, indique si requiere facturación electrónica."}),A===null&&e.jsxs(I,{variant:"destructive",className:"mb-4",children:[e.jsx(Je,{className:"h-4 w-4"}),e.jsx(z,{children:"Debe responder esta pregunta antes de proceder al pago."})]}),e.jsxs("div",{className:"bg-white rounded-lg p-4 border border-blue-200",children:[e.jsx(h,{className:"text-sm font-medium text-blue-900 mb-3 block",children:"¿Requiere facturación electrónica?"}),e.jsxs(De,{value:A===null?"":A?"yes":"no",onValueChange:s=>{Ee(s==="yes"),s==="no"&&Oe({})},className:"flex gap-6",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(pe,{value:"no",id:"invoice-no"}),e.jsx(h,{htmlFor:"invoice-no",className:"cursor-pointer",children:"No"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(pe,{value:"yes",id:"invoice-yes"}),e.jsx(h,{htmlFor:"invoice-yes",className:"cursor-pointer",children:"Sí"})]})]})]}),A&&e.jsxs("div",{className:"bg-white rounded-lg p-4 border border-blue-200 space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(Ke,{className:"h-5 w-5 text-blue-600"}),e.jsx("span",{className:"font-medium text-blue-900",children:"Datos de Facturación"})]}),e.jsxs("div",{className:"grid md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(h,{htmlFor:"invoice-doc-type",className:"text-sm font-medium",children:["Tipo de Documento ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsxs(be,{value:f.document_type,onValueChange:s=>re(i=>({...i,document_type:s})),children:[e.jsx(Ne,{id:"invoice-doc-type",className:w.document_type?"border-destructive":"",children:e.jsx(_e,{placeholder:"Seleccione..."})}),e.jsx(ye,{children:ts.map(s=>e.jsx(we,{value:s.value,children:s.label},s.value))})]}),w.document_type&&e.jsx("p",{className:"text-xs text-destructive",children:w.document_type})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(h,{htmlFor:"invoice-doc-number",className:"text-sm font-medium",children:["Número de Documento ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(E,{id:"invoice-doc-number",placeholder:"Ingrese el número",value:f.document_number,onChange:s=>re(i=>({...i,document_number:s.target.value})),className:w.document_number?"border-destructive":""}),w.document_number&&e.jsx("p",{className:"text-xs text-destructive",children:w.document_number})]}),e.jsxs("div",{className:"space-y-2 md:col-span-2",children:[e.jsxs(h,{htmlFor:"invoice-legal-name",className:"text-sm font-medium",children:["Nombre o Razón Social ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(E,{id:"invoice-legal-name",placeholder:"Ingrese el nombre o razón social",value:f.legal_name,onChange:s=>re(i=>({...i,legal_name:s.target.value})),className:w.legal_name?"border-destructive":""}),w.legal_name&&e.jsx("p",{className:"text-xs text-destructive",children:w.legal_name})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(h,{htmlFor:"invoice-email",className:"text-sm font-medium",children:["Email de Facturación ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(E,{id:"invoice-email",type:"email",placeholder:"[email protected]",value:f.email,onChange:s=>re(i=>({...i,email:s.target.value})),className:w.email?"border-destructive":""}),w.email&&e.jsx("p",{className:"text-xs text-destructive",children:w.email})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(h,{htmlFor:"invoice-phone",className:"text-sm font-medium",children:["Teléfono ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(E,{id:"invoice-phone",placeholder:"Ingrese el teléfono",value:f.phone,onChange:s=>re(i=>({...i,phone:s.target.value})),className:w.phone?"border-destructive":""}),w.phone&&e.jsx("p",{className:"text-xs text-destructive",children:w.phone})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(h,{htmlFor:"invoice-address",className:"text-sm font-medium",children:["Dirección ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(E,{id:"invoice-address",placeholder:"Ingrese la dirección",value:f.address,onChange:s=>re(i=>({...i,address:s.target.value})),className:w.address?"border-destructive":""}),w.address&&e.jsx("p",{className:"text-xs text-destructive",children:w.address})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(h,{htmlFor:"invoice-city",className:"text-sm font-medium",children:["Ciudad ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(E,{id:"invoice-city",placeholder:"Ingrese la ciudad",value:f.city,onChange:s=>re(i=>({...i,city:s.target.value})),className:w.city?"border-destructive":""}),w.city&&e.jsx("p",{className:"text-xs text-destructive",children:w.
31city})]})]})]}),A!==null&&e.jsx(S,{onClick:Ns,disabled:Ue,className:"w-full bg-blue-600 hover:bg-blue-700",children:Ue?e.jsxs(e.Fragment,{children:[e.jsx(K,{className:"mr-2 h-4 w-4 animate-spin"}),"Guardando..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Q,{className:"mr-2 h-4 w-4"}),"Guardar Información de Facturación"]})}),(a==null?void 0:a.requires_electronic_invoice)!==null&&e.jsxs(I,{className:a!=null&&a.requires_electronic_invoice?"bg-blue-100 border-blue-300":"bg-gray-100 border-gray-300",children:[e.jsx(je,{className:`h-4 w-4 ${a!=null&&a.requires_electronic_invoice?"text-blue-600":"text-gray-600"}`}),e.jsx(z,{className:a!=null&&a.requires_electronic_invoice?"text-blue-800":"text-gray-800",children:a!=null&&a.requires_electronic_invoice?"Datos de facturación electrónica guardados":"No requiere facturación electrónica"})]})]})]}),(a==null?void 0:a.payment_status)==="pending"&&e.jsxs(q,{className:"border-orange-200 bg-orange-50/50",children:[e.jsx(ee,{children:e.jsxs(se,{className:"flex items-center gap-2 text-orange-900",children:[e.jsx(Qe,{className:"h-5 w-5"}),"Pago Pendiente"]})}),e.jsxs(T,{className:"space-y-4",children:[e.jsx("p",{className:"text-sm text-orange-700 mb-4",children:"Complete su inscripción realizando el pago correspondiente"}),ls&&e.jsxs(I,{className:"bg-orange-100 border-orange-300",children:[e.jsx(Ie,{className:"h-4 w-4 text-orange-600"}),e.jsxs(z,{className:"text-orange-800",children:[e.jsx("strong",{children:"Certificado pendiente de validación"}),e.jsx("p",{className:"text-sm mt-1",children:"Su certificado de estudiante aún no ha sido revisado por el organizador. No puede realizar el pago hasta que se valide su documento."})]})]}),cs&&e.jsxs(e.Fragment,{children:[e.jsxs(I,{className:"bg-red-50 border-red-300",children:[e.jsx(de,{className:"h-4 w-4 text-red-600"}),e.jsxs(z,{className:"text-red-800",children:[e.jsx("strong",{children:"Certificado de estudiante rechazado"}),e.jsxs("p",{className:"text-sm mt-1",children:["Su certificado no cumplió con los requisitos de validación. Puede cargar un nuevo certificado para ser revisado nuevamente, o continuar con la ",e.jsx("strong",{children:"tarifa general"}),"."]})]})]}),e.jsxs("div",{className:"bg-white rounded-lg p-4 border border-orange-200 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(oe,{className:"h-5 w-5 text-orange-600"}),e.jsx("span",{className:"font-medium text-orange-900",children:"Cargar nuevo certificado de estudiante"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"El certificado debe contener: documento de identidad, nombre completo, hoja membrete y estudio que está realizando. (JPG, PNG o PDF, máx. 5MB)"}),e.jsx("input",{type:"file",accept:".jpg,.jpeg,.png,.pdf",onChange:async s=>{var p;const i=(p=s.target.files)==null?void 0:p[0];if(i){if(i.size>5*1024*1024){d({title:"Error",description:"El archivo debe ser menor a 5MB",variant:"destructive"});return}try{const m=i.name.split(".").pop(),C=`${a.user_id}/${Date.now()}.${m}`,{error:L}=await j.storage.from("student-certificates").upload(C,i);if(L)throw L;const{error:G}=await j.from("registrations").update({student_certificate_url:C,certificate_validated:null}).eq("id",a.id);if(G)throw G;d({title:"Certificado cargado",description:"Su nuevo certificado ha sido enviado para revisión."});const{data:he}=await j.from("registrations").select("*").eq("id",a.id).single();he&&U(he)}catch(m){console.error("Error uploading certificate:",m),d({title:"Error",description:"No se pudo cargar el certificado",variant:"destructive"})}}},className:"block w-full text-sm text-muted-foreground file:mr-4 file:py-2 file:px-4 file:rounded-md file:border-0 file:text-sm file:font-medium file:bg-primary file:text-primary-foreground hover:file:bg-primary/90"})]})]}),ns&&e.jsxs(I,{className:"bg-green-50 border-green-300",children:[e.jsx(Q,{className:"h-4 w-4 text-green-600"}),e.jsxs(z,{className:"text-green-800",children:[e.jsx("strong",{children:"Certificado aprobado"})," — Puede pagar con tarifa de estudiante."]})]}),(a==null?void 0:a.category)==="profesional_tecnico"&&e.jsxs("div",{className:"bg-white rounded-lg p-4 border border-orange-200",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(Qe,{className:"h-5 w-5 text-orange-600"}),e.jsx("span",{className:"font-medium text-orange-900",children:"Seleccione su tipo de tarifa:"})]}),e.jsxs(De,{value:y||"",onValueChange:s=>{B(s),X(""),ae("idle"),le(null)},className:"space-y-3",children:[e.jsxs("div",{className:"flex items-start space-x-3 border rounded-lg p-3 hover:bg-orange-50 transition-colors cursor-pointer",children:[e.jsx(pe,{value:"general",id:"fee-general",className:"mt-0.5"}),e.jsxs("label",{htmlFor:"fee-general",className:"cursor-pointer flex-1",children:[e.jsx("span",{className:"font-medium",children:"Tarifa General"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Tarifa estándar sin convenio institucional"})]})]}),e.jsxs("div",{className:"flex items-start space-x-3 border rounded-lg p-3 hover:bg-orange-50 transition-colors cursor-pointer",children:[e.jsx(pe,{value:"asociad
31o_convenio",id:"fee-convenio",className:"mt-0.5"}),e.jsxs("label",{htmlFor:"fee-convenio",className:"cursor-pointer flex-1",children:[e.jsx("span",{className:"font-medium",children:"Convenios y Asociados"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Tarifa para instituciones con convenio o asociaciones aliadas"})]})]})]})]}),(a==null?void 0:a.category)==="profesional_tecnico"&&y==="asociado_convenio"&&e.jsxs("div",{className:"bg-white rounded-lg p-4 border border-orange-200",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(Us,{className:"h-5 w-5 text-orange-600"}),e.jsx("span",{className:"font-medium text-orange-900",children:"Código de Descuento (Opcional)"})]}),e.jsxs("div",{className:"flex-1 relative",children:[e.jsx(E,{placeholder:"Ingrese su código",value:k,onChange:s=>X(s.target.value.toUpperCase()),maxLength:20,disabled:!!a.registration_code_id,className:J==="valid"?"border-green-500 focus:border-green-500 pr-10":J==="invalid"?"border-destructive focus:border-destructive pr-10":"pr-10"}),e.jsxs("div",{className:"absolute right-3 top-1/2 -translate-y-1/2",children:[J==="checking"&&e.jsx(K,{className:"h-4 w-4 animate-spin text-muted-foreground"}),J==="valid"&&e.jsx(je,{className:"h-4 w-4 text-green-500"}),J==="invalid"&&e.jsx(de,{className:"h-4 w-4 text-destructive"})]})]}),J==="invalid"&&k.length>=3&&e.jsxs("p",{className:"text-sm text-destructive flex items-center gap-1 mt-2",children:[e.jsx(de,{className:"h-4 w-4"}),"Código inválido, vencido o sin cupos disponibles"]}),a.registration_code_id&&e.jsxs("p",{className:"text-sm text-green-600 flex items-center gap-1 mt-2",children:[e.jsx(je,{className:"h-4 w-4"}),"Ya tiene un código de descuento aplicado"]}),!a.registration_code_id&&J==="idle"&&e.jsx("p",{className:"text-xs text-muted-foreground mt-2",children:"Si tiene un código proporcionado por patrocinadores, ingréselo aquí."})]}),J==="valid"&&o&&e.jsxs("div",{className:"bg-green-50 border border-green-200 rounded-lg p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(je,{className:"h-5 w-5 text-green-600"}),e.jsx("span",{className:"font-semibold text-green-800",children:"Código Válido"})]}),e.jsxs("div",{className:"space-y-2 text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ke,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"text-muted-foreground",children:"Aliado:"}),e.jsx("span",{className:"font-medium",children:o.sponsor_name})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Bs,{className:"h-4 w-4 text-muted-foreground"}),o.discount_percentage===0?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-muted-foreground",children:"Tipo:"}),e.jsx(b,{className:"bg-green-600",children:"Tarifa especial para aliados"})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-muted-foreground",children:"Descuento:"}),e.jsxs(b,{className:"bg-green-600",children:[o.discount_percentage,"%"]}),o.discount_percentage===100&&e.jsx("span",{className:"text-green-600 font-medium",children:"¡Inscripción Gratuita!"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Rs,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"text-muted-foreground",children:"Cupos disponibles:"}),e.jsxs("span",{className:"font-medium",children:[o.available_slots," de ",o.total_slots]})]})]})]}),((a==null?void 0:a.category)==="profesional_tecnico"&&y==="general"||(a==null?void 0:a.category)==="profesional_tecnico"&&y==="asociad
31o_convenio"&&J==="valid"||(a==null?void 0:a.category)==="estudiante_pregrado"&&(a==null?void 0:a.certificate_validated)===!0||(a==null?void 0:a.category)==="estudiante_pregrado"&&(a==null?void 0:a.certificate_validated)===!1)&&e.jsxs(e.Fragment,{children:[e.jsx(ks,{}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(h,{className:"text-sm font-medium text-orange-900",children:"Seleccione la moneda:"}),e.jsxs(De,{value:ue,onValueChange:s=>ds(s),className:"flex gap-4",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(pe,{value:"COP",id:"cop"}),e.jsx(h,{htmlFor:"cop",className:"cursor-pointer",children:"Pesos Colombianos (COP)"})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(pe,{value:"USD",id:"usd"}),e.jsx(h,{htmlFor:"usd",className:"cursor-pointer",children:"Dólares (USD)"})]})]})]}),$e?e.jsxs("div",{className:"text-center py-4",children:[e.jsx(K,{className:"h-6 w-6 animate-spin text-orange-600 mx-auto"}),e.jsx("p",{className:"text-sm text-orange-700 mt-2",children:"Calculando tarifa..."})]}):P?e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm font-medium text-orange-900",children:"Tipo de Tarifa:"}),e.jsx(b,{variant:P.fee_type==="early_bird"?"default":P.fee_type==="regular"?"secondary":"outline",children:P.fee_type==="early_bird"?"🎉 Tarifa Temprana":P.fee_type==="regular"?"Tarifa Regular":"Tarifa Onsite"})]}),e.jsxs("div",{className:"bg-white rounded-lg p-4 border-2 border-orange-300",children:[e.jsx("p",{className:"text-sm text-orange-700 mb-1",children:P.fee_name}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"Tarifa base:"}),e.jsx("span",{className:o&&o.discount_percentage>0?"line-through text-muted-foreground":"font-medium",children:ue==="COP"?new Intl.NumberFormat("es-CO",{style:"currency",currency:"COP",maximumFractionDigits:0}).format(P.amount):new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"}).format(P.amount)})]}),o&&o.discount_percentage>0&&e.jsxs("div",{className:"flex justify-between items-center text-green-600",children:[e.jsxs("span",{className:"text-sm",children:["Descuento (",o.discount_percentage,"%):"]}),e.jsxs("span",{children:["-",ue==="COP"?new Intl.NumberFormat("es-CO",{style:"currency",currency:"COP",maximumFractionDigits:0}).format(P.amount*o.discount_percentage/100):new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"}).format(P.amount*o.discount_percentage/100)]})]}),e.jsx("div",{className:"border-t pt-2 mt-2",children:e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx("span",{className:"font-bold text-lg",children:"TOTAL A PAGAR:"}),e.jsx("span",{className:`text-2xl font-bold ${(o==null?void 0:o.discount_percentage)===100?"text-green-600":"text-orange-900"}`,children:(o==null?void 0:o.discount_percentage)===100?"GRATIS":ue==="COP"?new Intl.NumberFormat("es-CO",{style:"currency",currency:"COP",maximumFractionDigits:0}).format(Fe()):new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"}).format(Fe())})]})}),e.jsxs("p",{className:"text-xs text-orange-600 mt-2",children:["Válida hasta: ",new Date(P.valid_until).toLocaleDateString("es-CO",{year:"numeric",month:"long",day:"numeric"})]})]}),P.fee_type==="early_bird"&&e.jsxs("div",{className:"flex items-start gap-2 bg-green-50 border border-green-200 rounded-lg p-3",children:[e.jsx(Q,{className:"h-4 w-4 text-green-600 mt-0.5 flex-shrink-0"}),e.jsx("p",{className:"text-xs text-green-800",children:"¡Está aprovechando la tarifa con descuento! No pierda esta oportunidad."})]})]}):e.jsxs("div",{className:"text-center py-4",children:[e.jsx(Je,{className:"h-8 w-8 text-orange-400 mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-orange-700",children:"No hay tarifas disponibles actualmente para su categoría."}),e.jsx("p",{className:"text-xs text-orange-600 mt-1",children:"Por favor contacte al administrador."})]}),(o==null?void 0:o.discount_percentage)===100?e.jsx(S,{className:"w-full bg-green-600 hover:bg-green-700",onClick:ms,disabled:qe,children:qe?e.jsxs(e.Fragment,{children:[e.jsx(K,{className:"mr-2 h-4 w-4 animate-spin"}),"Procesando..."]}):"Completar Inscripción Gratuita"}):e.jsxs(e.Fragment,{children:[e.jsx(S,{className:"w-full bg-orange-600 hover:bg-orange-700",disabled:!P||$e||W||A===null,onClick:ys,children:W?e.jsxs(e.Fragment,{children:[e.jsx(K,{className:"mr-2 h-4 w-4 animate-spin"}),"Conectando con Mercado Pago..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Os,{className:"mr-2 h-4 w-4"}),"Ir a Pagar"]})}),A===null&&e.jsx("p",{className:"text-destructive text-xs text-center mt-2",children:"Debe completar la sección de facturación electrónica para continuar."})]})]})]})]})]})})})]}),e.jsx(We,{}),e.jsx(Es,{open:ne,onOpenChange:me,children:e.jsxs(Ps,{className:"max-w-4xl max-h-[90vh] overflow-y-auto",children:[e.jsx(Ss,{children:e.jsxs(Fs,{className:"flex items-center gap-2",children:[e.jsx(es,{className:"h-5 w-5"}),"Gestión de Anexos"]})}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"border-2 border-dashed rounded-lg p-6",children:[e.jsxs("div",{className:`text-center ${O?"bg-primary/5":""}`,onDragOver:s=>{s.preventDefault(),F(!0)},onDragLeave:()=>F(!1),onDrop:ps,children:[e.jsx("input",{type:"file",id:"file-upload",className:"hidden",onChange:us,accept:Object.values(Le).join(",")}),e.jsxs("label",{htmlFor:"file-upload",className:"cursor-pointer",children:[e.jsx(Ms,{className:"h-16 w-16 mx-auto mb-4 text-primary/50"}),e.jsx("p",{className:"text-lg font-semibold mb-2",children:x?x.name:"Arrastra un archivo o haz clic para seleccionar"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"PDF, Word, PowerPoint, Excel, imágenes o ZIP (máx. 15 MB)"}),x&&e.jsxs("div",{className:"flex items-center justify-center gap-2 text-sm text-primary",children:[e.jsx(Q,{className:"h-4 w-4"}),Ve(x.size)]})]})]}),x&&e.jsxs("div",{className:"mt-6 space-y-4",children:[e.jsxs("div",{children:[e.jsxs(h,{htmlFor:"document-type",className:"mb-2 block",children:["Tipo de Documento ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsxs(be,{value:Z,onValueChange:l,children:[e.jsx(Ne,{id:"document-type",children:e.jsx(_e,{placeholder:"Selecciona el tipo de documento"})}),e.jsx(ye,{children:Me.map(s=>e.jsx(we,{value:s.value,children:e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:s.label}),e.jsx("div",{className:"text-xs text-muted-foreground",children:s.description})]})},s.value))})]})]}),e.jsxs("div",{children:[e.jsx(h,{htmlFor:"description",className:"mb-2 block",children:"Descripción (opcional)"}),e.jsx(Ds,{id:"description",placeholder:"Agrega una descripción...",value:c,onChange:s=>v(s.target.value),rows:2})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(S,{variant:"outline",onClick:()=>{_(null),l(""),v("")},children:[e.jsx(ss,{className:"h-4 w-4 mr-2"}),"Cancelar"]}),e.jsx(S,{onClick:xs,disabled:ce||!Z,children:ce?e.jsxs(e.Fragment,{children:[e.jsx(K,{className:"h-4 w-4 mr-2 animate-spin"}),"Subiendo..."]}):e.jsxs(e.Fragment,{children:[e.jsx(oe,{className:"h-4 w-4 mr-2"}),"Subir Archivo"]})})]})]})]}),e.jsxs("div",{children:[e.jsxs("h4",{className:"font-semibold mb-3",children:["Mis Archivos (",n.length,"/",Pe,")"]}),n.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(es,{className:"h-12 w-12 mx-auto mb-2 opacity-50"}),e.jsx("p",{children:"No tienes archivos adjuntos"})]}):e.jsx("div",{className:"space-y-2",children:n.map(s=>{var i;return e.jsxs("div",{className:"flex items-center justify-between p-3 bg-muted/50 rounded-lg",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-2xl",children:js(s.file_type)}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm",children:s.file_name}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx("span",{children:Ve(s.file_size)}),e.jsx("span",{children:"•"}),e.jsx("span",{children:((i=Me.find(p=>p.value===s.document_type))==null?void 0:i.label)||s.document_type})]})]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(S,{variant:"ghost",size:"sm",onClick:()=>hs(s),children:e.jsx(fe,{className:"h-4 w-4"})}),e.jsx(S,{variant:"ghost",size:"sm",onClick:()=>fs(s),className:"text-destructive hover:text-destructive",children:e.jsx(Ls,{className:"h-4 w-4"})})]})]},s.id)})})]})]})]})})]}):e.jsxs("div",{className:"min-h-screen flex flex-col",children:[e.jsx(He,{}),e.jsx("main",{className:"flex-1 flex items-center justify-center pt-20 pb-20 bg-gradient-subtle",children:e.jsx("div",{className:"w-full max-w-lg px-4",children:e.jsx(q,{className:"shadow-elegant border-border/50",children:e.jsxs(T,{className:"pt-8 pb-6 px-6 text-center",children:[e.jsx("div",{className:"w-16 h-16 bg-primary/10 rounded-full flex items-center justify-center mx-auto mb-4",children:e.jsx(ge,{className:"h-8 w-8 text-primary"})}),e.jsx("h2",{className:"text-2xl font-bold text-foreground mb-2",children:"Aún no te has inscrito al congreso"}),e.jsxs("p",{className:"text-muted-foreground mb-2",children:["Tu cuenta ",e.jsx("strong",{children:r==null?void 0:r.email})," tiene perfil de participante, pero no has completado el formulario de inscripción."]}),e.jsx("p",{className:"text-sm text-muted-foreground mb-6",children:"Para acceder a todas las funcionalidades del portal (envío de resúmenes, pagos, certificados), primero debes completar tu inscripción."}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(S,{className:"w-full",size:"lg",onClick:()=>D("/inscribirme"),children:"Completar mi inscripción"}),e.jsx(S,{variant:"secondary",className:"w-full",onClick:()=>D("/seleccionar-perfil"),children:"Cambiar de perfil"}),e.jsx(S,{variant:"outline",className:"w-full",onClick:()=>ie(),children:"Cerrar sesión"})]})]})})})}),e.jsx(We,{})]})};export{Ma 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.