1import{r as d,j as e}from"./index-C86y2ZZw.js";import{bb as J,bc as Ke,Q as ya,ai as ra,z as pe,aC as ge,aD as _e,aG as ca,aJ as je,B as S,an as fa,a9 as be,W as va,V as ye,ao as r,I as j,i as _,v as E,w as o,u as oa,ax as Ca,bd as Na,J as wa,be as Qe,bf as Ea,ab as Ve,aa as Sa,bg as Aa,bh as Ta,bi as Da,bj as Fa,o as Ia,D as Ye,a as Pe,b as We,c as Xe,aF as Je,ap as Ze,bk as re,bl as U,bm as ka,bn as La,bo as ce,bp as oe,bq as de,br as me,bs as x,bt as Oa,bu as za,bv as Ma,bw as qa,bx as Ra,by as Ua,aP as $a,aQ as Ba,aR as Ga,aS as Ha,aT as Ka,aU as Qa,aV as Va,aW as Ya,bz as ea,bA as aa,bB as sa,bC as ia,bD as Pa,bE as ue}from"./App-BsV2Qj_s.js";import{T as Wa,a as Xa,b as he,c as xe}from"./tabs-CCb_Hfd7.js";import{s as p}from"./client-DMrl-iUj.js";import{u as na}from"./useMutation-LFYmL0kD.js";import{C as da,s as la}from"./CiDocumentFields-Dr-zLn1q.js";import{M as Ja}from"./MemberLayout-CNk-SkpB.js";import{A as Za,b as es}from"./alert-MODGBXRs.js";import{I as as}from"./info-fnD2MFP-.js";import{P as ta}from"./plus-HguvGPAG.js";import{S as ss}from"./square-pen-DOuIsVoA.js";function is(s,i){const u=J(s),h=J(i);return u.getFullYear()-h.getFullYear()}function ns(s,i){const u=J(s),h=J(i),m=Ke(u,h),b=Math.abs(is(u,h));u.setFullYear(1584),h.setFullYear(1584);const y=Ke(u,h)===-m,f=m*(b-+y);return f===0?0:f}function ls({onSaved:s}){const{activeProfile:i,isLoading:u}=ya(),h=ra(),[m,b]=d.useState(""),[y,f]=d.useState(""),[A,B]=d.useState("1"),[k,G]=d.useState(""),[L,l]=d.useState(!1),t=A==="1"||A==="2",H=!!(((i==null?void 0:i.billing_nit)||"").trim()&&((i==null?void 0:i.billing_business_name)||"").trim());d.useEffect(()=>{b((i==null?void 0:i.billing_nit)||"");const c=[i==null?void 0:i.first_name,i==null?void 0:i.last_name].filter(Boolean).join(" ").trim()||((i==null?void 0:i.full_name)||"").trim();f((i==null?void 0:i.billing_business_name)||c),B((i==null?void 0:i.billing_doc_type)||"1"),G(((i==null?void 0:i.ci_complement)||"").toString().toUpperCase())},[i==null?void 0:i.id,i==null?void 0:i.billing_nit,i==null?void 0:i.billing_business_name,i==null?void 0:i.billing_doc_type,i==null?void 0:i.ci_complement,i==null?void 0:i.first_name,i==null?void 0:i.last_name,i==null?void 0:i.full_name]);const O=async()=>{if(i!=null&&i.id){if(m.trim()&&!y.trim()){o.error("Si registras un NIT, también debes ingresar la razón social");return}l(!0);try{const{error:c}=await p.from("family_profiles").update({billing_nit:m.trim()||null,billing_business_name:y.trim()||null,billing_doc_type:A,ci_complement:t&&k.trim()?k.trim().toUpperCase():null}).eq("id",i.id);if(c)throw c;o.success("Datos de facturación guardados"),await h.invalidateQueries({queryKey:["family-profiles-switcher"]}),s()}catch(c){o.error(c.message||"Error al guardar")}finally{l(!1)}}};return e.jsxs(pe,{children:[e.jsxs(ge,{children:[e.jsxs(_e,{className:"font-display text-lg flex items-center gap-2",children:[e.jsx(ca,{className:"h-5 w-5"}),"DATOS DE FACTURACIÃN"]}),e.jsxs(je,{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{children:"Datos fiscales de la persona seleccionada. Se usan en todas sus compras facturables."}),i&&e.jsxs(S,{variant:"secondary",children:[fa(i.full_name||"Perfil"),i.isOwner?" · Titular":""]}),i&&(H?e.jsxs(S,{className:"bg-emerald-600 hover:bg-emerald-600 text-white gap-1",children:[e.jsx(be,{className:"h-3 w-3"})," Datos guardados"]}):e.jsxs(S,{variant:"destructive",className:"gap-1",children:[e.jsx(va,{className:"h-3 w-3"})," Sin datos de facturación"]}))]})]}),e.jsxs(ye,{className:"space-y-4",children:[e.jsxs(Za,{children:[e.jsx(as,{className:"h-4 w-4"}),e.jsxs(es,{className:"text-sm",children:["Si dejas estos campos vacÃos, tus pagos generarán un ",e.jsx("strong",{children:"recibo de aportación"}),". Si los completas, podrás solicitar ",e.jsx("strong",{children:"factura legal con NIT"})," al momento de pagar. Cada perfil familiar mantiene sus propios datos de facturación."]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(r,{children:"Tipo de documento"}),e.jsxs("select",{value:A,onChange:c=>B(c.target.value),className:"w-full h-10 rounded-md border border-input bg-background px-3 text-sm sm:max-w-xs",children:[e.jsx("option",{value:"1",children:"CI - Cédula de Identidad"}),e.jsx("option",{value:"2",children:"CEX - Cédula de ExtranjerÃa"}),e.jsx("option",{value:"3",children:"Pasaporte"}),e.jsx("option",{value:"5",children:"NIT"}),e.jsx("option",{value:"4",children:"Otro Documento"})]})]}),e.jsx(da,{idPrefix:"billing",ciLabel:"Número de documento / NIT",placeholder:"Ej: 1234567890",inputMode:"numeric",showExpedition:!1,complementDisabled:!t,complementHint:"Solo si tu CI tiene sufijo alfanumérico (Libélula lo envÃa junto al documento).",ciNumber:m,onCiNumberChange:c=>b(c.replace(/\D/g,"")),complement:k,onComplementChange:G}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(r,{children:"Razón social"}),e.jsx(j,{value:y,onChange:c=>f(c.target.value),placeholder:"Ej: Empresa S.R.L."})]})]}),e.jsx("div",{className:"flex justify-end pt-2",children:e.jsxs(_,{onClick:O,disabled:L||u||!(i!=null&&i.id),children:[L&&e.jsx(E,{className:"h-4 w-4 mr-2 animate-spin"}),"Guardar datos fiscales"]})})]})]})}
1function ts(s){const i=[...new Set(s.filter(Boolean))].sort();return oa({queryKey:["family-profiles-deletable",i],enabled:i.length>0,queryFn:async()=>{const u=new Map,h=await Promise.all(i.map(async m=>{const{data:b,error:y}=await p.rpc("family_profile_is_empty",{p_family_id:m});return[m,y?!1:b===!0]}));for(const[m,b]of h)u.set(m,b);return u},staleTime:3e4,gcTime:5*6e4,refetchOnWindowFocus:!1})}const rs={spouse:"Cónyuge",child:"Hijo/a",parent:"Padre/Madre",sibling:"Hermano/a",other:"Otro"},$={first_name:"",last_name:"",relationship:"",document_number:"",ci_complement:"",birth_date:"",document_type:"CI",email:"",phone:"",gender:"",country_code:"+591",country:"BO",city:"",address:"",ci_expedition:"",avatar_url:"",billing_doc_type:"1",billing_nit:"",billing_complement:"",billing_business_name:""},I=s=>(s??"").trim().replace(/-\d+$/,"");function bs(){var De,Fe;const{profile:s,user:i,refetch:u}=Ca(),{data:h=[]}=Na(),m=ra(),[b,y]=wa(),f=b.get("tab"),A=!f||f==="profile"?"family":f,[B,k]=d.useState(A),[G,L]=d.useState(!1),[l,t]=d.useState($),[H,O]=d.useState(!1),[c,fe]=d.useState(null),[K,Z]=d.useState(!1),[T,Q]=d.useState(null),[ee,z]=d.useState(!1),ae=(l.billing_doc_type||"1")==="1"||l.billing_doc_type==="2",V=Qe(l.document_number,{excludeFamilyId:c,enabled:H}),ve=V.available===!1,[v,N]=d.useState(null),[Y,Ce]=d.useState(""),[se,Ne]=d.useState(""),[ie,we]=d.useState(""),[ne,w]=d.useState(!1),ma=((s==null?void 0:s.email)||(i==null?void 0:i.email)||"").trim().toLowerCase(),P=Y.trim().toLowerCase()!==ma,D=Ea(Y,{enabled:v==="email"&&P}),W=P&&D.registered===!0,F=Qe(se,{excludeProfileId:(s==null?void 0:s.id)??null,enabled:v==="ci"}),X=F.available===!1,ua=()=>{Ce((s==null?void 0:s.email)||(i==null?void 0:i.email)||""),N("email")},ha=()=>{Ne(I(s==null?void 0:s.ci_number)),we((s==null?void 0:s.ci_complement)||""),N("ci")},xa=async()=>{const a=Y.trim().toLowerCase();if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(a)){o.error("Correo inválido");return}if(!P){N(null);return}w(!0);const{data:n,error:C}=await p.rpc("check_email_registered",{_email:a});if(!C&&n){w(!1),o.error(re,{description:"Ingresa un correo electrónico diferente."});return}const{error:g}=await p.auth.updateUser({email:a});if(g){w(!1),o.error(/already|exists|registered/i.test(g.message)?re:g.message);return}const{error:q}=await p.from("profiles").update({email:a}).eq("id",s.id);if(w(!1),q){o.error(q.message);return}N(null),u(),o.success("Correo actualizado. Si recibes un email de confirmación, confÃrmalo para completar el cambio.")},pa=async()=>{const a=se.trim();if(!a){o.error("Ingresa tu número de carnet");return}w(!0);const{data:n,error:C}=await p.rpc("check_ci_available",{_ci:a,_exclude_profile_id:(s==null?void 0:s.id)??null,_exclude_family_id:null});if(!C&&n&&n.available===!1){w(!1),o.error(U);return}const{error:g}=await p.from("profiles").update({ci_number:a,ci_complement:ie?ie.toUpperCase():null}).eq("id",s.id);if(w(!1),g){o.error(ea(g)?U:g.message);return}N(null),u(),o.success("Carnet actualizado")},ga=a=>{k(a),y({tab:a})},{data:Ee,isLoading:_a}=oa({queryKey:["family-profiles",s==null?void 0:s.id],queryFn:async()=>{if(!(s!=null&&s.id))return[];const{data:a,error:n}=await p.from("family_profiles").select("*").eq("owner_profile_id",s.id).is("deleted_at",null).order("is_titular",{ascending:!1}).order("created_at");if(n)throw n;return a},enabled:!!(s!=null&&s.id)}),M=d.useMemo(()=>Ee??[],[Ee]),{data:le}=ts(M.filter(a=>!a.is_titular).map(a=>a.id)),te=na({mutationFn:async({id:a,data:n})=>{var q,Ie,ke,Le,Oe,ze,Me,qe,Re,Ue,$e,Be,Ge;if(!(s!=null&&s.id))throw new Error("No profile");const C=n.first_name.trim(),g=n.last_name.trim();if(a){const{error:R}=await p.rpc("update_family_profile_full",{p_family_id:a,p_payload:{first_name:C,last_name:g,relationship:n.relationship,ci_number:I(n.document_number),ci_expedition:n.ci_expedition||"",ci_complement:(n.ci_complement||n.billing_complement||"").toUpperCase(),birth_date:n.birth_date||"",avatar_url:n.avatar_url||"",document_type:n.document_type||"CI",gender:n.gender||"",country_code:n.country_code||"",country:n.country||"",city:((q=n.city)==null?void 0:q.trim())||"",address:((Ie=n.address)==null?void 0:Ie.trim())||"",phone:((ke=n.phone)==null?void 0:ke.trim())||"",email:((Le=n.email)==null?void 0:Le.trim())||"",billing_doc_type:n.billing_doc_type||"1",billing_nit:((Oe=n.billing_nit)==null?void 0:Oe.trim())||"",billing_business_name:((ze=n.billing_business_name)==null?void 0:ze.trim())||""}});if(R)throw R}else{const{data:R,error:He}=await p.rpc("create_family_profile",{p_owner_profile_id:s.id,p_first_name:C,p_last_name:g,p_relationship:n.relationship,p_document_type:n.document_type||"CI",p_document_number:I(n.document_number)||null,p_birth_date:n.birth_date||null,p_email:((Me=n.email)==null?void 0:Me.trim())||null,p_gender:n.gender||null,p_country_code:n.country_code||null,p_country:n.country||null,p_city:((qe=n.city)==null?void 0:qe.trim())||null,p_address:((Re=n.address)==null?void 0:Re.trim())||null,p_phone:((Ue=n.phone)==null?void 0:Ue.trim())||null,p_ci_expedition:n.ci_expedition||null,p_ci_complement:(n.ci_complement||n.billing_complement||"").toUpperCase()||null,p_billing_doc_type:n.billing_doc_type||null,p_billing_nit:(($e=n.billing_nit)==null?void 0:$e.trim())||null,p_billing_business_name:((Be=n.billing_business_name)==null?void 0:Be.trim())||null});if(He)throw He;R&&((Ge=n.avatar_url)!=null&&Ge.trim())&&await p.rpc("update_family_profile_full",{p_family_id:R,p_payload:{avatar_url:n.avatar_url.trim()}})}},onSuccess:()=>{o.success(c?"Perfil actualizado":"Familiar agregado"),Te(),m.invali
1dateQueries({queryKey:["family-profiles"]}),m.invalidateQueries({queryKey:["family-profiles-switcher"]})},onError:a=>o.error(ea(a)?U:(a==null?void 0:a.message)||"Error al guardar familiar")}),Se=na({mutationFn:async a=>{const{error:n}=await p.rpc("delete_family_profile",{p_family_id:a});if(n)throw n},onSuccess:()=>{o.success("Familiar eliminado"),Q(null),m.invalidateQueries({queryKey:["family-profiles"]}),m.invalidateQueries({queryKey:["family-profiles-switcher"]}),m.invalidateQueries({queryKey:["family-profiles-deletable"]})},onError:a=>{const n=String((a==null?void 0:a.message)??"");n.includes("PROFILE_HAS_RECORDS")?o.error("Este perfil tiene membresÃas, entradas u operaciones asociadas y no puede eliminarse"):n.includes("PROFILE_IS_TITULAR")?o.error("El titular de la cuenta no puede eliminarse"):o.error("Error al eliminar familiar"),Q(null)}}),ja=a=>{fe(a.id),Z(!!a.is_titular);const n=aa(a.city);t({first_name:a.first_name||"",last_name:a.last_name||"",ci_expedition:a.ci_expedition||sa(n),ci_complement:a.ci_complement||"",avatar_url:a.avatar_url||"",relationship:a.is_titular?"self":a.relationship,document_number:I(a.ci_number||a.document_number),birth_date:a.birth_date||"",document_type:a.document_type||"CI",email:a.email||(s==null?void 0:s.email)||"",phone:ia(a.phone||(s==null?void 0:s.phone)||"",a.country_code||(s==null?void 0:s.country_code)),gender:Pa(a.gender),country_code:a.country_code||(s==null?void 0:s.country_code)||"+591",country:ue(a.country,h)||ue(s==null?void 0:s.country,h)||"BO",city:n,address:a.address||"",billing_doc_type:a.billing_doc_type||"1",billing_nit:a.billing_nit||"",billing_complement:(a.ci_complement||"").toString().toUpperCase(),billing_business_name:a.billing_business_name||""}),z(!!(a.ci_complement||"").toString().trim()),O(!0)},Ae=()=>{Z(!1);const a=aa(s==null?void 0:s.city);t({...$,email:(s==null?void 0:s.email)||"",phone:ia((s==null?void 0:s.phone)||"",s==null?void 0:s.country_code),country_code:(s==null?void 0:s.country_code)||$.country_code,country:ue(s==null?void 0:s.country,h)||$.country,city:a,ci_expedition:sa(a),address:(s==null?void 0:s.address)||""}),z(!1),O(!0)},Te=()=>{O(!1),fe(null),Z(!1),t($),z(!1)},ba=a=>a?ns(new Date,new Date(a)):null;return e.jsx(Ja,{children:e.jsxs("div",{className:"space-y-6 max-w-4xl mx-auto",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"font-display text-2xl md:text-3xl font-bold",children:"MI CUENTA"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"Gestiona tu información personal y perfiles familiares."})]}),e.jsxs(Wa,{value:B,onValueChange:ga,className:"space-y-6",children:[e.jsxs(Xa,{className:"w-full grid grid-cols-3 h-auto bg-muted/30 border border-border rounded-lg p-1",children:[e.jsxs(he,{value:"family",className:"gap-1.5 text-xs sm:text-sm rounded-md data-[state=active]:bg-background data-[state=active]:shadow-sm py-2",children:[e.jsx(Ve,{className:"h-3.5 w-3.5 sm:h-4 sm:w-4"}),e.jsx("span",{className:"truncate",children:"Perfiles"})]}),e.jsxs(he,{value:"billing",className:"gap-1.5 text-xs sm:text-sm rounded-md data-[state=active]:bg-background data-[state=active]:shadow-sm py-2",children:[e.jsx(ca,{className:"h-3.5 w-3.5 sm:h-4 sm:w-4"}),e.jsx("span",{className:"truncate",children:"Facturación"})]}),e.jsxs(he,{value:"security",className:"gap-1.5 text-xs sm:text-sm rounded-md data-[state=active]:bg-background data-[state=active]:shadow-sm py-2",children:[e.jsx(Sa,{className:"h-3.5 w-3.5 sm:h-4 sm:w-4"}),e.jsx("span",{className:"truncate",children:"Seguridad"})]})]}),e.jsx(xe,{value:"billing",children:e.jsx(ls,{profile:s,onSaved:u})}),e.jsx(xe,{value:"family",children:e.jsxs(pe,{children:[e.jsxs(ge,{className:"flex flex-row items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(_e,{className:"font-display text-lg flex items-center gap-2",children:["PERFILES FAMILIARES",M.length>0&&e.jsx(S,{variant:"secondary",children:M.length})]}),e.jsx(je,{children:"Tu perfil principal y los perfiles de tu grupo familiar."})]}),e.jsxs(_,{size:"sm",onClick:Ae,children:[e.jsx(ta,{className:"h-4 w-4 mr-2"}),"Agregar"]})]}),e.jsx(ye,{children:_a?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(E,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):M.length?e.jsx("div",{className:"space-y-3",children:M.map(a=>{const n=`${a.first_name} ${a.last_name}`.trim(),C=ba(a.birth_date);return e.jsxs("div",{className:"flex items-center gap-3 sm:gap-4 p-3 sm:p-4 roun
1ded-lg border bg-card hover:bg-muted/50 transition-colors group",children:[e.jsxs(Aa,{className:"w-10 h-10 sm:w-12 sm:h-12",children:[a.avatar_url&&e.jsx(Ta,{src:a.avatar_url,alt:n}),e.jsx(Da,{className:"bg-primary/10 text-primary font-bold text-sm",children:n.split(" ").map(g=>g[0]).join("").toUpperCase().slice(0,2)})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm sm:text-base truncate",children:n}),a.is_titular&&e.jsx(S,{variant:"secondary",className:"shrink-0 text-[10px]",children:"Titular"})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-0.5 text-xs text-muted-foreground mt-0.5",children:[(a.is_titular||(a.relationship??"").trim())&&e.jsx("span",{children:a.is_titular?"Titular de la cuenta":rs[a.relationship]||a.relationship}),C!==null&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"·"}),e.jsxs("span",{children:[C," años"]})]}),a.ci_number&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"·"}),e.jsx("span",{children:`${I(a.ci_number)}${a.ci_complement?`-${a.ci_complement}`:""}${a.ci_expedition?` ${a.ci_expedition}`:""}`})]})]})]}),e.jsxs("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 sm:opacity-100 transition-opacity",children:[e.jsx(_,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>a.synthetic?L(!0):ja(a),children:e.jsx(ss,{className:"h-3.5 w-3.5"})}),!a.is_titular&&(le==null?void 0:le.get(a.id))===!0&&e.jsx(_,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive hover:bg-destructive/10",onClick:()=>Q({id:a.id,name:n}),children:e.jsx(Fa,{className:"h-3.5 w-3.5"})})]})]},a.id)})}):e.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[e.jsx("div",{className:"p-4 rounded-full bg-muted inline-block mb-3",children:e.jsx(Ve,{className:"h-8 w-8 opacity-40"})}),e.jsx("p",{className:"font-medium mb-1",children:"No tienes perfiles familiares"}),e.jsx("p",{className:"text-sm max-w-xs mx-auto mb-4",children:"Agrega familiares a tu cuenta para gestionar sus membresÃas de forma centralizada."}),e.jsxs(_,{variant:"outline",size:"sm",onClick:Ae,children:[e.jsx(ta,{className:"h-4 w-4 mr-2"}),"Agregar familiar"]})]})})]})}),e.jsx(xe,{value:"security",children:e.jsxs(pe,{children:[e.jsxs(ge,{children:[e.jsx(_e,{className:"font-display text-lg",children:"DATOS DE LA CUENTA Y SEGURIDAD"}),e.jsx(je,{children:"Gestiona tu correo, carnet, contraseña y acceso"})]}),e.jsxs(ye,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 p-4 rounded-lg border",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-medium",children:"Correo electrónico"}),e.jsx("p",{className:"text-sm text-muted-foreground break-all",children:(s==null?void 0:s.email)||(i==null?void 0:i.email)})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsx(S,{variant:"outline",className:"text-emerald-400 border-emerald-500",children:"Verificado"}),e.jsx(_,{variant:"outline",size:"sm",onClick:ua,children:"Editar"})]})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3 p-4 rounded-lg border",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-medium",children:"Carnet de identidad (CI)"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s!=null&&s.ci_number?`${I(s.ci_number)}${s.ci_complement?`-${s.ci_complement}`:""}${s.ci_expedition?` ${s.ci_expedition}`:""}`:"No registrado"})]}),e.jsx(_,{variant:"outline",size:"sm",className:"shrink-0",onClick:ha,children:"Editar"})]}),e.jsxs("div",{className:"flex items-center justify-between p-4 rounded-lg border",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Contraseña"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"â¢â¢â¢â¢â¢â¢â¢â¢"})]}),e.jsx(_,{variant:"outline",size:"sm",onClick:async()=>{const a=(s==null?void 0:s.email)||(i==null?void 0:i.email);if(!a)return;const{error:n}=await p.functions.invoke("send-password-reset",{body:{email:a.trim().toLowerCase(),redirectTo:`${window.location.origin}/reset-password`}});n?o.error("Error al enviar email"):o.success("Email de recuperación enviado")},children:"Cambiar"})]}),e.jsxs("div",{className:"flex items-center justify-between p-4 rounded-lg border border-destructive/40",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Eliminar mi cuenta"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Solicita la eliminación definitiva de tu cuenta y datos personales."})]}),e.jsx(_,{asChild:!0,variant:"outline",size:"sm",className:"shrink-0 border-destructive/50 text-destructive hover:bg-destructive/10",children:e.jsx(Ia,{to:"/eliminar-cuenta",children:"Solicitar"})})]})]})]})})]}),e.jsx(Ye,{open:v!==null,onOpenChange:a=>{a||N(null)},children:e.jsxs(Pe,{children:[e.jsxs(We,{children:[e.jsx(Xe,{children:v==="ci"?"Editar carnet de la cuenta":"Editar correo de la cuenta"}),e.jsx(Je,{children:v==="ci"?"Validamos que el carnet no esté asociad
1o a otra cuenta antes de guardar.":"Validamos que el correo no esté asociado a otra cuenta antes de guardar."})]}),v==="email"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(r,{htmlFor:"account_email",children:"Correo electrónico"}),e.jsxs("div",{className:"relative",children:[e.jsx(j,{id:"account_email",type:"email",value:Y,onChange:a=>Ce(a.target.value),className:W?"border-destructive pr-10":"pr-10"}),e.jsxs("div",{className:"absolute right-3 top-1/2 -translate-y-1/2",children:[D.checking&&e.jsx(E,{className:"w-4 h-4 animate-spin text-muted-foreground"}),!D.checking&&P&&D.registered===!1&&e.jsx(be,{className:"w-4 h-4 text-emerald-500"}),!D.checking&&W&&e.jsx(Ze,{className:"w-4 h-4 text-destructive"})]})]}),W&&e.jsxs("p",{className:"text-xs text-destructive",children:[re," Ingresa un correo electrónico diferente."]})]}),v==="ci"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(r,{htmlFor:"account_ci",children:"Número de carnet (CI)"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(j,{id:"account_ci",value:se,onChange:a=>Ne(a.target.value.replace(/[^\dA-Za-z]/g,"")),className:X?"border-destructive pr-10":"pr-10"}),e.jsxs("div",{className:"absolute right-3 top-1/2 -translate-y-1/2",children:[F.checking&&e.jsx(E,{className:"w-4 h-4 animate-spin text-muted-foreground"}),!F.checking&&F.available===!0&&e.jsx(be,{className:"w-4 h-4 text-emerald-500"}),!F.checking&&X&&e.jsx(Ze,{className:"w-4 h-4 text-destructive"})]})]}),e.jsx(j,{value:ie,onChange:a=>we(la(a.target.value)),placeholder:"Comp.",maxLength:5,className:"w-20 uppercase text-center"})]}),X&&e.jsx("p",{className:"text-xs text-destructive",children:U})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(_,{variant:"outline",onClick:()=>N(null),disabled:ne,children:"Cancelar"}),e.jsx(_,{onClick:v==="ci"?pa:xa,disabled:ne||(v==="email"?W||D.checking:X||F.checking),children:ne?e.jsx(E,{className:"w-4 h-4 animate-spin"}):"Guardar"})]})]})}),G&&e.jsx(ka,{forceOpen:!0,onClose:()=>{L(!1),u()}}),e.jsx(Ye,{open:H,onOpenChange:a=>{a||Te()},children:e.jsx(Pe,{className:"max-h-[90vh] overflow-y-auto p-0",children:e.jsxs("div",{className:"p-6",children:[e.jsxs(We,{children:[e.jsx(Xe,{children:c?K?"Editar Perfil Titular":"Editar Perfil Familiar":"Agregar Familiar"}),e.jsx(Je,{children:c?K?"Modifica los datos del titular de la cuenta.":"Modifica los datos del perfil familiar.":"Agrega un nuevo perfil a tu cuenta."})]}),e.jsxs("div",{className:"space-y-4 pt-2",children:[e.jsx(La,{value:l.avatar_url||"",onChange:a=>t(n=>({...n,avatar_url:a})),profileId:c,initials:`${((De=l.first_name)==null?void 0:De[0])??""}${((Fe=l.last_name)==null?void 0:Fe[0])??""}`.toUpperCase()}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(r,{children:"Nombre *"}),e.jsx(j,{value:l.first_name,onChange:a=>t({...l,first_name:a.target.value}),placeholder:"Nombre"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(r,{children:"Apellido *"}),e.jsx(j,{value:l.last_name,onChange:a=>t({...l,last_name:a.target.value}),placeholder:"Apellido"})]})]}),K?e.jsxs("div",{className:"space-y-2",children:[e.jsx(r,{children:"Tipo de perfil"}),e.jsxs("div",{className:"flex items-center gap-2 rounded-md border border-border bg-muted/40 px-3 py-2",children:[e.jsx(S,{variant:"secondary",className:"text-[10px]",children:"Titular"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"Titular de la cuenta"})]})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsx(r,{children:"Parentesco *"}),e.jsxs(ce,{value:l.relationship,onValueChange:a=>t({...l,relationship:a}),children:[e.jsx(oe,{children:e.jsx(de,{placeholder:"Seleccionar parentesco"})}),e.jsxs(me,{children:[e.jsx(x,{value:"spouse",children:"Cónyuge"}),e.jsx(x,{value:"child",children:"Hijo/a"}),e.jsx(x,{value:"parent",children:"Padre/Madre"}),e.jsx(x,{value:"sibling",children:"Hermano/a"}),e.jsx(x,{value:"other",children:"Otro"})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(r,{children:"Fecha de nacimiento"}),e.jsx(Oa,{value:l.birth_date,onChange:a=>t({...l,birth_date:a})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(r,{children:"Género"}),e.jsxs(ce,{value:l.gender||void 0,onValueChange:a=>t({...l,gender:a}),children:[e.jsx(oe,{children:e.jsx(de,{placeholder:"Selecciona"})}),e.jsxs(me,{children:[e.jsx(x,{value:"male",children:"Hombre"}),e.jsx(x,{value:"female",children:"Mujer"}),e.jsx(x,{value:"other",children:"Otro"}),e.jsx(x,{value:"prefer_not_to_say",children:"Prefiero no decirlo"})]})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(r,{children:"PaÃs de residencia"}),e.jsx(za,{value:l.country,onChange:a=>t({...l,country:a,...a!==l.country?{city:""}:{}})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(r,{children:!l.country||l.country==="BO"?"Ciudad / Departamento":"Ciudad"}),e.jsx(Ma,{country:l.country,value:l.city,onChange:a=>t({...l,city:a})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(r,{children:"Correo electrónico"}),e.jsx(j,{type:"email",value:l.email,onChange:a=>t({...l,email:a.target.value}),placeholder:"[email protected]"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Prellenado con tu correo. Puedes camb
1iarlo si el familiar tiene el suyo."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(r,{children:"Dirección"}),e.jsx(j,{value:l.address,onChange:a=>t({...l,address:a.target.value}),placeholder:"Calle, número, zona"})]}),e.jsxs("div",{className:"grid grid-cols-[140px_1fr] gap-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(r,{children:"Cód. tel."}),e.jsx(qa,{value:l.country_code,onChange:a=>t({...l,country_code:a})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(r,{children:"Celular"}),e.jsx(Ra,{value:l.phone,onChange:a=>t({...l,phone:a}),placeholder:"70000000"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Prellenado con tu teléfono. Puedes cambiarlo si el familiar tiene el suyo."})]})]}),e.jsx(da,{idPrefix:"family_ci",ciLabel:"N° de Carnet",ciNumber:l.document_number,onCiNumberChange:a=>t({...l,document_number:a}),complement:l.ci_complement||"",onComplementChange:a=>t({...l,ci_complement:a}),expedition:l.ci_expedition,onExpeditionChange:a=>t({...l,ci_expedition:a}),checking:V.checking,available:V.available,taken:ve,takenMessage:U}),e.jsxs("section",{className:"space-y-3 rounded-lg border border-border/60 p-3",children:[e.jsxs("div",{children:[e.jsx(r,{className:"text-sm font-semibold",children:"Datos de facturación"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:"Opcional. Si los completas podrás solicitar factura legal con NIT; si los dejas vacÃos tus pagos generarán un recibo de aportación."})]}),ae&&e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-lg border border-border/60 bg-muted/30 px-3 py-2",children:[e.jsx(r,{htmlFor:"fam_billing_has_complement",className:"text-xs font-normal text-muted-foreground",children:"Mi documento de facturación tiene complemento (ej. 1E, 2K)"}),e.jsx(Ua,{id:"fam_billing_has_complement",checked:ee,onCheckedChange:a=>{z(a),a||t(n=>({...n,billing_complement:""}))}})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(r,{htmlFor:"fam_billing_doc_type",children:"Tipo de documento"}),e.jsxs(ce,{value:l.billing_doc_type||"1",onValueChange:a=>{t(n=>({...n,billing_doc_type:a,...a!=="1"&&a!=="2"?{billing_complement:""}:{}})),a!=="1"&&a!=="2"&&z(!1)},children:[e.jsx(oe,{id:"fam_billing_doc_type",children:e.jsx(de,{placeholder:"Selecciona"})}),e.jsxs(me,{children:[e.jsx(x,{value:"1",children:"CI - Cédula de Identidad"}),e.jsx(x,{value:"2",children:"CEX - Cédula de ExtranjerÃa"}),e.jsx(x,{value:"3",children:"Pasaporte"}),e.jsx(x,{value:"5",children:"NIT"}),e.jsx(x,{value:"4",children:"Otro Documento"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(r,{htmlFor:"fam_billing_nit",children:"Número de documento / NIT"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(j,{id:"fam_billing_nit",value:l.billing_nit||"",onChange:a=>t(n=>({...n,billing_nit:a.target.value.replace(/\D/g,"")})),inputMode:"numeric",placeholder:"Ej: 1234567890",className:"flex-1"}),ae&&ee&&e.jsx(j,{id:"fam_billing_complement",value:l.billing_complement||"",onChange:a=>t(n=>({...n,billing_complement:la(a.target.value)})),placeholder:"Comp.",maxLength:5,className:"w-20 uppercase text-center"})]}),ae&&ee&&e.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Complemento de tu CI/CEX (ej. 1E, 2K)."})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(r,{htmlFor:"fam_billing_name",children:"Razón social"}),e.jsx(j,{id:"fam_billing_name",value:l.billing_business_name||"",onChange:a=>t(n=>({...n,billing_business_name:a.target.value})),placeholder:"Ej: Empresa S.R.L."})]})]}),e.jsxs(_,{className:"w-full",onClick:()=>te.mutate({id:c,data:l}),disabled:!l.first_name.trim()||!l.last_name.trim()||!K&&!l.relationship||te.isPending||ve||V.checking,children:[te.isPending&&e.jsx(E,{className:"h-4 w-4 mr-2 animate-spin"}),c?"Guardar Cambios":"Agregar Familiar"]})]})]})})}),e.jsx($a,{open:!!T,onOpenChange:a=>{a||Q(null)},children:e.jsxs(Ba,{children:[e.jsxs(Ga,{children:[e.jsx(Ha,{children:"¿Eliminar perfil familiar?"}),e.jsxs(Ka,{children:["Se eliminará el perfil de ",e.jsx("strong",{children:T==null?void 0:T.name}),". Esta acción no se puede deshacer."]}
1)]}),e.jsxs(Qa,{children:[e.jsx(Va,{children:"Cancelar"}),e.jsxs(Ya,{className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",onClick:()=>T&&Se.mutate(T.id),children:[Se.isPending&&e.jsx(E,{className:"h-4 w-4 mr-2 animate-spin"}),"Eliminar"]})]})]})})]})})}export{bs 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.