1import{j as e}from"./vendor-chartjs-BlT-H5dK.js";import{r,u as xe}from"./vendor-react-msX2Ez-Q.js";import{a as W,aG as pe,C as R,z as E,u as ee,b as he}from"./vendor-ui-D43Mks9_.js";import{D as ue}from"./DashboardTitle-Bao2KJ8a.js";import{c as fe,p as Y}from"./cep-promise.min-Mn9zVdp4.js";import{I as _}from"./input-BRuy6nYK.js";import{u as M,cZ as se,M as K,c_ as be,cW as U,c$ as J,cX as ge,d0 as je,cT as Ne,w as Q,j as q,d1 as ve,k as X,b_ as we,d2 as ye,cS as ke,d3 as Se}from"./index-YZYykCoL.js";import{T as ae}from"./TermsModal-DlPzfauo.js";import{i as Ce}from"./brazilian-values-BwjmfQIp.js";import{C as Z}from"./index.esm-D1jIflW3.js";import{C as Ee}from"./creditAnalysisService-DFyuKf12.js";import{R as Fe}from"./walletService-DteFx53X.js";import"./addDays-RtovZ_pw.js";import"./index-Bwd_AYnw.js";import"./vendor-apexcharts-BrWxhp4A.js";import"./vendor-i18n-BAQC3RvJ.js";import"./vendor-supabase-DVTU8ahp.js";import"./vendor-http-DhXgJQ-f.js";function Ae(){const{formState:{errors:a},register:c,setValue:x,control:o}=W(),[i,l]=r.useState(""),[d,p]=r.useState(""),[j,h]=r.useState(""),[u,g]=r.useState(""),[N,S]=r.useState(""),v=pe({control:o,name:"zip"});r.useEffect(()=>{v&&!i&&l(String(v))},[v]);async function f(m){const C=String(m).replace(/[^\d]/g,"").slice(0,8);if(l(C),x("zip",C),C.length===8){const s=await fe(C);x("address",s.street),x("city",s.city),x("neighborhood",s.neighborhood),x("state",s.state)}}function y(m){m.preventDefault();const C=m.clipboardData.getData("text");f(C)}return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 lg:gap-10",children:[e.jsxs("div",{className:"mb-5",children:[e.jsx("label",{htmlFor:"",className:"text-white text-sm mb-2 block",children:"CEP"}),e.jsx("input",{type:"hidden",...c("zip",{required:"Campo obrigatório"})}),e.jsxs("label",{className:"input input-bordered flex items-center gap-2 bg-white",children:[e.jsx("i",{className:"bi bi-crosshair"}),e.jsx("input",{type:"text",inputMode:"numeric",className:"grow",placeholder:"CEP",value:i,maxLength:8,onChange:m=>f(m.target.value),onPaste:y})]}),a.zip&&e.jsx("div",{className:"invalid-feedback",children:a.zip.message})]}),e.jsx("div",{className:"mb-5 hidden lg:block"})]}),e.jsxs("div",{className:"mb-5",children:[e.jsx("label",{htmlFor:"",className:"text-white text-sm mb-2 block",children:"Endereço"}),e.jsxs("label",{className:"input input-bordered flex items-center gap-2 bg-white",children:[e.jsx("i",{className:"bi bi-pin-map"}),e.jsx("input",{type:"text",className:"grow",placeholder:"Endereço",defaultValue:N,...c("address",{required:"Campo obrigatório",onChange:m=>S(m.target.value)})})]}),a.address&&e.jsx("div",{className:"invalid-feedback",children:a.address.message})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 lg:gap-10",children:[e.jsxs("div",{className:"mb-5",children:[e.jsx("label",{htmlFor:"",className:"text-white text-sm mb-2 block",children:"Número"}),e.jsxs("label",{className:"input input-bordered flex items-center gap-2 bg-white",children:[e.jsx("i",{className:"bi bi-pin-map"}),e.jsx("input",{type:"text",className:"grow",placeholder:"Número",...c("number",{required:"Campo obrigatório"})})]}),a.number&&e.jsx("div",{className:"invalid-feedback",children:a.number.message})]}),e.jsxs("div",{className:"mb-5",children:[e.jsx("label",{htmlFor:"",className:"text-white text-sm mb-2 block",children:"Complemento"}),e.jsxs("label",{className:"input input-bordered flex items-center gap-2 bg-white",children:[e.jsx("i",{className:"bi bi-pin-map"}),e.jsx("input",{type:"text",className:"grow",placeholder:"Complemento",...c("complement")})]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 lg:gap-10",children:[e.jsxs("div",{className:"mb-5",children:[e.jsx("label",{htmlFor:"",className:"text-white text-sm mb-2 block",children:"Bairro"}),e.jsxs("label",{className:"input input-bordered flex items-center gap-2 bg-white",children:[e.jsx("i",{className:"bi bi-pin-map"}),e.jsx("input",{type:"text",className:"grow",placeholder:"Bairro",defaultValue:u,...c("neighborhood",{required:"Campo obrigatório",onChange:m=>g(m.target.value)})})]}),a.neighborhood&&e.jsx("div",{className:"invalid-feedback",children:a.neighborhood.message})]}),e.jsxs("div",{className:"mb-5",children:[e.jsx("label",{htmlFor:"",className:"text-white text-sm mb-2 block",children:"Cidade"}),e.jsxs("label",{className:"input input-bordered flex items-center gap-2 bg-white",children:[e.jsx("i",{className:"bi bi-pin-map"}),e.jsx("input",{type:"text",className:"grow",placeholder:"Cidade",defaultValue:j,...c("city",{required:"Campo obrigatório",onChange:m=>h(m.target.value)})})]}),a.city&&e.jsx("div",{className:"invalid-feedback",children:a.city.message})]})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-10",children:[e.jsxs("div",{className:"mb-5",children:[e.jsx("label",{htmlFor:"",className:"text-white text-sm mb-2 block",children:"Estado"}),e.jsxs("label",{className:"input input-bordered flex items-center gap-2 bg-white",children:[e.jsx("i",{className:"bi bi-pin-map"}),e.jsx("input",{type:"text",className:"grow",placeholder:"Estado",defaultValue:d,...c("state",{required:"Campo obrigatório",onChange:m=>p(m.target.value)})})]}),a.state&&e.jsx("div",{className:"invalid-feedback",children:a.state.message})]}),e.jsx("div",{className:"mb-5 hidden lg:block"})]})]})}function Ie({checkControl:a,setCheckControl:c}){const{userData:x,apiKey:o}=M(),{formState:{errors:i},control:l,register:d}=W(),[p,j]=r.useState([]),[h,u]=r.useState(new Set),[g,N]=r.useState(null),[S,v]=r.useState(!1),f=p.length>1;r.useEffect(()=>{o&&se(o,"onboarding").then(j)},[o]),r.useEffect(()=>{x.document&&(c({...a,checkAccession:!0}),f&&u(new Set(p.map(s=>s.templateId))))},[x,p.length]);function y(s){N(s),v(!0)}function m(s){if(!g)return;const t=new Set(h);s.checkAccession?t.add(g.templateId):t.delete(g.templateId),u(t);const b=t.size===p.length;c({checkAccession:b,accessionError:!1})}function C(s){c(s)}return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 lg:gap-10",children:[e.jsxs("div",{className:"mb-5",children:[e.jsx("label",{htmlFor:"",className:"text-white text-sm mb-2 block",children:"Nome Completo"}),e.jsxs("label",{className:"input input-bordered flex items-center gap-2 bg-white",children:[e.jsx("i",{className:"bi bi-pers
1on"}),e.jsx("input",{type:"name",className:"grow",placeholder:"Nome Completo",...d("name",{required:"Campo obrigatório",validate:s=>s.trim().split(/\s+/).length>=2||"Informe pelo menos dois nomes"})})]}),i.name&&e.jsx("div",{className:"invalid-feedback",children:i.name.message})]}),e.jsxs("div",{className:"mb-5",children:[e.jsx("label",{htmlFor:"",className:"text-white text-sm mb-2 block",children:"CPF"}),e.jsxs("label",{className:"input input-bordered flex items-center gap-2 bg-white",children:[e.jsx("i",{className:"bi bi-person-vcard"}),e.jsx(R,{name:"documentCpfPf",control:l,rules:{required:"Campo obrigatório",validate:s=>Ce(s)||"CPF inválido"},render:({field:s,fieldState:{error:t}})=>e.jsx(_,{mask:"000.000.000-00",className:`grow ${t?"input-error":""}`,value:s.value,onAccept:b=>s.onChange(b),onBlur:s.onBlur,placeholder:"CPF"})})]}),i.documentCpfPf&&e.jsx("div",{className:"invalid-feedback",children:i.documentCpfPf.message})]})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 lg:gap-10",children:[e.jsxs("div",{className:"mb-5",children:[e.jsx("label",{htmlFor:"",className:"text-white text-sm mb-2 block",children:"Data de nascimento"}),e.jsxs("label",{className:"input input-bordered flex items-center gap-2 bg-white",children:[e.jsx("i",{className:"bi bi-calendar"}),e.jsx(R,{name:"birthdate",control:l,rules:{required:"Campo obrigatório"},render:({field:s,fieldState:{error:t}})=>e.jsx(_,{mask:"00/00/0000",className:`grow ${t?"input-error":""}`,value:s.value,onAccept:b=>s.onChange(b),placeholder:"Data de nascimento",type:"tel"})})]}),i.birthdate&&e.jsx("div",{className:"invalid-feedback",children:i.birthdate.message})]}),e.jsxs("div",{className:"mb-5",children:[e.jsx("label",{htmlFor:"",className:"text-white text-sm mb-2 block",children:"Telefone"}),e.jsxs("label",{className:"input input-bordered flex items-center gap-2 bg-white",children:[e.jsx("i",{className:"bi bi-phone"}),e.jsx(R,{name:"phone",control:l,rules:{required:"Campo obrigatório"},render:({field:s,fieldState:{error:t}})=>e.jsx(_,{mask:[{mask:"(00) 0000-0000"},{mask:"(00) 00000-0000"}],className:`grow ${t?"input-error":""}`,value:s.value,onAccept:s.onChange,placeholder:"Telefone",type:"tel"})})]}),i.phone&&e.jsx("div",{className:"invalid-feedback",children:i.phone.message})]})]}),e.jsx("div",{className:"grid grid-cols-1",children:e.jsxs("div",{className:"mb-5",children:[e.jsx("label",{htmlFor:"",className:"text-white text-sm mb-2 block",children:"E-mail"}),e.jsxs("label",{className:"input input-bordered flex items-center gap-2 bg-white",children:[e.jsx("i",{className:"bi bi-envelope"}),e.jsx("input",{type:"email",className:"grow",placeholder:"E-mail",readOnly:!0,...d("email",{required:"Campo obrigatório",pattern:{value:/^[^\s@]+@[^\s@]+$/,message:"E-mail inválido"}})})]}),i.email&&e.jsx("div",{className:"invalid-feedback",children:i.email.message})]})}),e.jsxs("div",{className:"flex flex-col gap-3 mb-5",children:[f?p.map(s=>e.jsxs("label",{className:"label cursor-pointer gap-3 justify-start w-full",children:[e.jsx("input",{type:"checkbox",className:`checkbox [--chkbg:theme(colors.second)] [--chkfg:white] ${a.accessionError&&!h.has(s.templateId)?"border-error":"border-second"}`,checked:h.has(s.templateId),onChange:()=>{const t=new Set(h);t.has(s.templateId)?t.delete(s.templateId):t.add(s.templateId),u(t);const b=t.size===p.length;c({checkAccession:b,accessionError:!1})}}),e.jsxs("span",{className:`label-text text-sm font-semibold ${a.accessionError&&!h.has(s.templateId)?"text-error":"text-white"}`,children:["Eu concordo com os"," ",e.jsx("a",{className:`underline cursor-pointer hover:!text-second ${a.accessionError&&!h.has(s.templateId)?"text-error":"text-second"}`,onClick:t=>{t.stopPropagation(),y(s)},children:s.templateName})]})]},s.templateId)):e.jsxs("label",{className:"label cursor-pointer gap-3 justify-start w-full",children:[e.jsx("input",{type:"checkbox",className:`checkbox [--chkbg:theme(colors.second)] [--chkfg:white] ${a.accessionError&&!a.checkAccession?"border-error":"border-second"}`,checked:a.checkAccession,onChange:()=>{c({...a,checkAccession:!a.checkAccession,accessionError:!1})}}),e.jsxs("span",{className:`label-text text-sm font-semibold ${a.accessionError&&!a.checkAccession?"text-error":"text-white"}`,children:["Eu concordo com os"," ",e.jsx("a",{className:`underline cursor-pointer hover:!text-second ${a.accessionError&&!a.checkAccession?"text-error":"text-second"}`,onClick:s=>{s.stopPropagation(),p.length===1?y(p[0]):(N(null),v(!0))},children:"Termos de Uso"})]})]}),!a.checkAccession&&a.accessionError&&e.jsx("div",{className:"!mt-0 invali
1d-feedback ",children:"Você precisa aceitar os termos para prosseguir"}),e.jsx("div",{className:"flex flex-col gap-3",children:e.jsxs("label",{className:"label cursor-pointer gap-3 justify-start w-full",children:[e.jsx("input",{type:"checkbox",className:"checkbox [--chkbg:theme(colors.second)] [--chkfg:white] border-second",...d("whatsappConsent")}),e.jsx("span",{className:"label-text text-sm font-semibold text-white",children:"Este telefone é WhatsApp e autorizo receber comunicações por WhatsApp"})]})})]}),e.jsx(K,{isOpen:S,onClose:()=>v(!1),title:g?.templateName??"Termos de Uso",size:g?"max-w-2xl":"max-w-xl",position:"items-center",allowClose:!0,children:e.jsx(ae,{checkState:f&&g?{checkAccession:h.has(g.templateId)}:a,setCheck:f?m:C,closeModal:()=>v(!1),dynamicTemplate:g??void 0})})]})}function Pe({checkControl:a,setCheckControl:c}){const{userData:x,apiKey:o}=M(),{formState:{errors:i},control:l,register:d}=W(),[p,j]=r.useState([]),[h,u]=r.useState(new Set),[g,N]=r.useState(null),[S,v]=r.useState(!1),f=p.length>1;r.useEffect(()=>{o&&se(o,"onboarding").then(j)},[o]),r.useEffect(()=>{x.document&&(c({...a,checkAccession:!0}),f&&u(new Set(p.map(s=>s.templateId))))},[x,p.length]);function y(s){N(s),v(!0)}function m(s){if(!g)return;const t=new Set(h);s.checkAccession?t.add(g.templateId):t.delete(g.templateId),u(t);const b=t.size===p.length;c({checkAccession:b,accessionError:!1})}function C(s){c(s)}return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 lg:gap-10",children:[e.jsxs("div",{className:"mb-5",children:[e.jsx("label",{htmlFor:"",className:"text-white text-sm mb-2 block",children:"Razão Social"}),e.jsxs("label",{className:"input input-bordered flex items-center gap-2 bg-white",children:[e.jsx("i",{className:"bi bi-buildings"}),e.jsx("input",{type:"name",className:`grow ${i.name?"input-error":""}`,placeholder:"Razão Social",...d("name",{required:"Campo obrigatório"})})]}),i.name&&e.jsx("div",{className:"invalid-feedback",children:i.name.message})]}),e.jsxs("div",{className:"mb-5",children:[e.jsx("label",{htmlFor:"",className:"text-white text-sm mb-2 block",children:"CNPJ"}),e.jsxs("label",{className:"input input-bordered flex items-center gap-2 bg-white",children:[e.jsx("i",{className:"bi bi-file-earmark-text"}),e.jsx(R,{name:"documentCpfPJ",control:l,rules:{required:"Campo obrigatório",validate:be},render:({field:s,fieldState:{error:t}})=>e.jsx(_,{mask:"00.000.000/0000-00",className:`grow ${t?"input-error":""}`,value:s.value,onAccept:b=>s.onChange(b),onBlur:s.onBlur,placeholder:"CNPJ"})})]}),i.documentCpfPJ&&e.jsx("div",{className:"invalid-feedback",children:i.documentCpfPJ.message})]})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 lg:gap-10",children:[e.jsxs("div",{className:"mb-5",children:[e.jsx("label",{htmlFor:"",className:"text-white text-sm mb-2 block",children:"Data de fundação"}),e.jsxs("label",{className:"input input-bordered flex items-center gap-2 bg-white",children:[e.jsx("i",{className:"bi bi-calendar"}),e.jsx(R,{name:"birthdate",control:l,rules:{required:"Campo obrigatório"},render:({field:s,fieldState:{error:t}})=>e.jsx(_,{mask:"00/00/0000",className:`grow ${t?"input-error":""}`,value:s.value,onAccept:b=>s.onChange(b),placeholder:"Data de fundação",type:"tel"})})]}),i.birthdate&&e.jsx("div",{className:"invalid-feedback",children:i.birthdate.message})]}),e.jsxs("div",{className:"mb-5",children:[e.jsx("label",{htmlFor:"",className:"text-white text-sm mb-2 block",children:"Telefone"}),e.jsxs("label",{className:"input input-bordered flex items-center gap-2 bg-white",children:[e.jsx("i",{className:"bi bi-phone"}),e.jsx(R,{name:"phone",control:l,rules:{required:"Campo obrigatório"},render:({field:s,fieldState:{error:t}})=>e.jsx(_,{mask:[{mask:"(00) 0000-0000"},{mask:"(00) 00000-0000"}],className:`grow ${t?"input-error":""}`,value:s.value,onAccept:s.onChange,placeholder:"Telefone",type:"tel"})})]}),i.phone&&e.jsx("div",{className:"invalid-feedback",children:i.phone.message})]})]}),e.jsxs("div",{className:"mb-5",children:[e.jsx("label",{htmlFor:"",className:"text-white text-sm mb-2 block",children:"E-mail"}),e.jsxs("label",{className:"input input-bordered flex items-center gap-2 bg-white",children:[e.jsx("i",{className:"bi bi-envelope"}),e.jsx("input",{type:"email",className:"grow",placeholder:"E-mail",readOnly:!0,...d("email",{required:"Campo obrigatório",pattern:{value:/^[^\s@]+@[^\s@]+$/,message:"E-mail inválido"}})})]}),i.email&&e.jsx("div",{className:"invalid-feedback",children:i.email.message})]}),e.jsxs("div",{className:"flex flex-col gap-1 mb-2 mt-2",children:[e.jsx("span",{className:"text-white font-semibold text-sm",children:"Sócio / Representante"}),e.jsx("span",{className:"text-white text-opacity-60 text-xs",children:"Dados do sócio ou representante legal da empresa."})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 lg:gap-10",children:[e.jsxs("div",{className:"mb-5",children:[e.jsx("label",{htmlFor:"",className:"text-white text-sm mb-2 block",children:"Nome completo"}),e.jsxs("label",{className:"input input-bordered flex items-center gap-2 bg-white",children:[e.jsx("i",{className:"bi bi-pers
1on"}),e.jsx("input",{type:"text",className:`grow ${i.partnerName?"input-error":""}`,placeholder:"Nome do sócio",...d("partnerName",{required:"Campo obrigatório"})})]}),i.partnerName&&e.jsx("div",{className:"invalid-feedback",children:i.partnerName.message})]}),e.jsxs("div",{className:"mb-5",children:[e.jsx("label",{htmlFor:"",className:"text-white text-sm mb-2 block",children:"CPF"}),e.jsxs("label",{className:"input input-bordered flex items-center gap-2 bg-white",children:[e.jsx("i",{className:"bi bi-file-earmark-person"}),e.jsx(R,{name:"partnerDocument",control:l,rules:{required:"Campo obrigatório"},render:({field:s,fieldState:{error:t}})=>e.jsx(_,{mask:"000.000.000-00",className:`grow ${t?"input-error":""}`,value:s.value,onAccept:b=>s.onChange(b),onBlur:s.onBlur,placeholder:"CPF do sócio"})})]}),i.partnerDocument&&e.jsx("div",{className:"invalid-feedback",children:i.partnerDocument.message})]})]}),e.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 lg:gap-10",children:e.jsxs("div",{className:"mb-5",children:[e.jsx("label",{htmlFor:"",className:"text-white text-sm mb-2 block",children:"Data de nascimento"}),e.jsxs("label",{className:"input input-bordered flex items-center gap-2 bg-white",children:[e.jsx("i",{className:"bi bi-calendar"}),e.jsx(R,{name:"partnerBirthdate",control:l,rules:{required:"Campo obrigatório"},render:({field:s,fieldState:{error:t}})=>e.jsx(_,{mask:"00/00/0000",className:`grow ${t?"input-error":""}`,value:s.value,onAccept:b=>s.onChange(b),placeholder:"Data de nascimento",type:"tel"})})]}),i.partnerBirthdate&&e.jsx("div",{className:"invalid-feedback",children:i.partnerBirthdate.message})]})}),e.jsxs("div",{className:"flex flex-col gap-3 mb-5",children:[f?p.map(s=>e.jsxs("label",{className:"label cursor-pointer gap-3 justify-start w-full",children:[e.jsx("input",{type:"checkbox",className:`checkbox [--chkbg:theme(colors.second)] [--chkfg:white] ${a.accessionError&&!h.has(s.templateId)?"border-error":"border-second"}`,checked:h.has(s.templateId),onChange:()=>{const t=new Set(h);t.has(s.templateId)?t.delete(s.templateId):t.add(s.templateId),u(t);const b=t.size===p.length;c({checkAccession:b,accessionError:!1})}}),e.jsxs("span",{className:`label-text text-sm font-semibold ${a.accessionError&&!h.has(s.templateId)?"text-error":"text-white"}`,children:["Eu concordo com os"," ",e.jsx("a",{className:`underline cursor-pointer hover:!text-second ${a.accessionError&&!h.has(s.templateId)?"text-error":"text-second"}`,onClick:t=>{t.stopPropagation(),y(s)},children:s.templateName})]})]},s.templateId)):e.jsxs("label",{className:"label cursor-pointer gap-3 justify-start w-full",children:[e.jsx("input",{type:"checkbox",className:`checkbox [--chkbg:theme(colors.second)] [--chkfg:white] ${a.accessionError&&!a.checkAccession?"border-error":"border-second"}`,checked:a.checkAccession,onChange:()=>{c({...a,checkAccession:!a.checkAccession,accessionError:!1})}}),e.jsxs("span",{className:`label-text text-sm font-semibold ${a.accessionError&&!a.checkAccession?"text-error":"text-white"}`,children:["Eu concordo com os"," ",e.jsx("a",{className:`underline cursor-pointer hover:!text-second ${a.accessionError&&!a.checkAccession?"text-error":"text-second"}`,onClick:s=>{s.stopPropagation(),p.length===1?y(p[0]):(N(null),v(!0))},children:"Termos de Uso"})]})]}),!a.checkAccession&&a.accessionError&&e.jsx("div",{className:"!mt-0 invalid-feedback ",children:"Você precisa aceitar os termos para prosseguir"}),e.jsx("div",{className:"flex flex-col gap-3",children:e.jsxs("label",{className:"label cursor-pointer gap-3 justify-start w-full",children:[e.jsx("input",{type:"checkbox",className:"checkbox [--chkbg:theme(colors.second)] [--chkfg:white] border-second",...d("whatsappConsent")}),e.jsx("span",{className:"label-text text-sm font-semibold text-white",children:"Este telefone é WhatsApp e autorizo receber comunicações por WhatsApp"})]})})]}),e.jsx(K,{isOpen:S,onClose:()=>v(!1),title:g?.templateName??"Termos de Uso",size:g?"max-w-2xl":"max-w-xl",position:"items-center",allowClose:!0,children:e.jsx(ae,{checkState:f&&g?{checkAccession:h.has(g.templateId)}:a,setCheck:f?m:C,closeModal:()=>v(!1),dynamicTemplate:g??void 0})})]})}function Te({active:a,apiKey:c,userData:x,refreshUserData:o}){const[i,l]=r.useState("idle"),[d,p]=r.useState(null),[j,h]=r.useState(null),[u,g]=r.useState(null);r.useRef(!1),r.useRef(!1),r.useEffect(()=>{},[a,x?.kyc,x?.kyc_level_two,x?.status_kyc,x?.kyc_reason]);const N=r.useCallback(m=>{const C=U(m);if(C==="success"){const s=J(m);return s&&g(s),h(null),l("success"),"success"}return C==="failed"?(h(m?.kycReason||m?.reason||"Seus dados não puderam ser validados. Corrija as informações e tente novamente."),l("failed"),"failed"):(h(null),l("processing"),"processing")},[]);r.useEffect(()=>{},[a,c,i,x?.status_kyc]);const S=r.useCallback(async()=>"processing",[a,c,N,o]);r.useEffect(()=>{},[a,i,S]);const v=r.useCallback(async m=>{},[a,c,N,S]),f=r.useCallback(m=>{p(m),l("error")},[]),y=r.useCallback(()=>{p(null),h(null),l("idle")},[]);
1return{status:i,error:d,failureReason:j,data:u,captured:v,fail:f,sync:S,resetToIdle:y}}function Re({isPJ:a,getValues:c,onEditPersonalData:x}){return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[e.jsxs("div",{className:"rounded-xl bg-third-400 p-3 text-white text-sm flex gap-2 items-start",children:[e.jsx("i",{className:"bi bi-buildings mt-0.5"}),e.jsxs("div",{className:"flex flex-col gap-0.5",children:[e.jsx("span",{className:"text-white text-opacity-50 text-xs",children:a?"Razão Social":"Nome"}),e.jsx("span",{className:"font-medium",children:c("name")||"â"})]})]}),e.jsxs("div",{className:"rounded-xl bg-third-400 p-3 text-white text-sm flex gap-2 items-start",children:[e.jsx("i",{className:"bi bi-person-badge mt-0.5"}),e.jsxs("div",{className:"flex flex-col gap-0.5",children:[e.jsx("span",{className:"text-white text-opacity-50 text-xs",children:a?"CNPJ":"CPF"}),e.jsx("span",{className:"font-medium",children:c(a?"documentCpfPJ":"documentCpfPf")||"â"})]})]}),e.jsxs("div",{className:"rounded-xl bg-third-400 p-3 text-white text-sm flex gap-2 items-start",children:[e.jsx("i",{className:"bi bi-calendar-check mt-0.5"}),e.jsxs("div",{className:"flex flex-col gap-0.5",children:[e.jsx("span",{className:"text-white text-opacity-50 text-xs",children:a?"Data de abertura":"Data de nascimento"}),e.jsx("span",{className:"font-medium",children:c("birthdate")||"â"})]})]}),a&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"rounded-xl bg-third-400 p-3 text-white text-sm flex gap-2 items-start",children:[e.jsx("i",{className:"bi bi-person mt-0.5"}),e.jsxs("div",{className:"flex flex-col gap-0.5",children:[e.jsx("span",{className:"text-white text-opacity-50 text-xs",children:"Nome do sócio"}),e.jsx("span",{className:"font-medium",children:c("partnerName")||"â"})]})]}),e.jsxs("div",{className:"rounded-xl bg-third-400 p-3 text-white text-sm flex gap-2 items-start",children:[e.jsx("i",{className:"bi bi-person-vcard mt-0.5"}),e.jsxs("div",{className:"flex flex-col gap-0.5",children:[e.jsx("span",{className:"text-white text-opacity-50 text-xs",children:"CPF do sócio"}),e.jsx("span",{className:"font-medium",children:c("partnerDocument")||"â"})]})]}),e.jsxs("div",{className:"rounded-xl bg-third-400 p-3 text-white text-sm flex gap-2 items-start",children:[e.jsx("i",{className:"bi bi-calendar2-check mt-0.5"}),e.jsxs("div",{className:"flex flex-col gap-0.5",children:[e.jsx("span",{className:"text-white text-opacity-50 text-xs",children:"Nascimento do sócio"}),e.jsx("span",{className:"font-medium",children:c("partnerBirthdate")||"â"})]})]})]})]}),e.jsx("button",{type:"button",className:"text-second text-xs underline underline-offset-2 text-left w-fit",onClick:x,children:"Corrigir dados pessoais"})]})}function $e({active:a,step:c,apiKey:x,userData:o,refreshUserData:i}){const[l,d]=r.useState("idle"),[p,j]=r.useState(null),[h,u]=r.useState(null),[g,N]=r.useState(null),S=r.useRef(!1),v=r.useRef(!1);r.useEffect(()=>{if(!o||l==="loading")return;const s=U(o);if(s==="failed"){d("failed"),u(o.kyc_reason||"Seus dados não puderam ser validados. Corrija as informações e tente novamente.");return}if(s==="success"){d("success"),u(null);return}if(s==="processing"){d("processing"),u(null);return}d("idle")},[a,o?.kyc,o?.kyc_level_two,o?.status_kyc,o?.kyc_reason]);const f=r.useCallback(s=>{const t=U(s);if(t==="success"){const b=J(s);return b&&N(b),u(null),d("success"),"success"}return t==="failed"?(u(s?.kycReason||s?.reason||"Seus dados não puderam ser validados. Corrija as informações e tente novamente."),d("failed"),"failed"):(u(null),d("processing"),"processing")},[]);r.useEffect(()=>{!x||l!=="success"||v.current||(v.current=!0,ge(x).then(s=>{const t=J(s?.data);if(!t)throw new Error("Limites KYC ainda não sincronizados");N(t),j(null)}).catch(s=>{j(s?.response?.data?.error||s?.message||"Não foi possÃvel carregar os limites agora.")}).finally(()=>{v.current=!1}))},[a,x,l,o?.status_kyc]);const y=r.useCallback(async()=>{if(!x||S.current)return"processing";S.current=!0;try{const s=await je(x),t=f(s?.data);return await i(),j(null),t}catch(s){return j(s?.response?.data?.error||s?.message||"Não foi possÃvel atualizar a situação agora."),"processing"}finally{S.current=!1}},[a,x,f,i]);r.useEffect(()=>{if(l!=="processing")return;const s=()=>void y();s();const t=window.setInterval(s,1e4);return()=>window.clearInterval(t)},[a,l,y]);const m=r.useCallback(async()=>
1{if(l!=="loading"&&x){j(null),u(null),d("loading");try{const s=await Ne(x);if(s?.data?.error){const b=s.data.error;u(b),d("failed"),E.error("Não foi possÃvel validar seus dados.");return}const t=f(s?.data);t==="failed"?E.error("Não foi possÃvel validar seus dados."):t==="success"?E.success("Validação concluÃda com sucesso!"):(await y(),E.success("Validação enviada. Acompanhe a análise nesta tela."))}catch(s){const t=s?.response?.data?.fields,b=Array.isArray(t)&&t.length?` Campos divergentes: ${t.join(", ")}.`:"",T=s?.response?.data?.error||s?.response?.data?.message||s?.message||"Não foi possÃvel validar seus dados. Verifique as informações cadastradas e tente novamente.";u(`${T}${b}`),d("failed"),E.error("Não foi possÃvel validar seus dados.")}}},[a,x,f,l,y]);r.useEffect(()=>{c===2&&l==="idle"&&o?.address&&(o?.status_kyc==="starting"||o?.status_kyc==="processing"||o?.status_kyc==="success"||o?.status_kyc==="failed"||o?.status_kyc==="rejected"||o?.kyc!==!0&&m())},[a,c,x,l,m,o?.address,o?.kyc,o?.status_kyc]);const C=r.useCallback(()=>{j(null),u(null),d("idle")},[]);return{status:l,error:p,failureReason:h,data:g,start:m,sync:y,resetToIdle:C}}function _e({isPJ:a,getValues:c,apiKey:x,kycL1Status:o,kycL1Error:i,kycL1FailureReason:l,kycL1Data:d,onEditPersonalData:p,onStart:j,onSync:h,formatMoney:u}){return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"font-semibold text-white text-xl",children:"Validação dos dados"}),e.jsx("span",{className:"text-white text-opacity-70 text-sm",children:"Fazemos uma checagem automática para validar seu cadastro."})]}),e.jsxs("div",{className:"rounded-2xl bg-white bg-opacity-10 border border-white border-opacity-10 p-4 flex flex-col gap-4",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("i",{className:"bi bi-shield-check text-second text-2xl"}),e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"text-white font-semibold",children:"Como funciona a validação"}),e.jsx("span",{className:"text-white text-opacity-70 text-sm",children:"Utilizamos o ItsRamp, que por sua vez consulta a Serpro, para checar a consistência das informações básicas do cadastro."})]})]}),e.jsx(Re,{isPJ:a,getValues:c,onEditPersonalData:p})]}),e.jsxs("div",{className:"rounded-2xl p-4 border border-white border-opacity-10 bg-white bg-opacity-5",children:[o==="idle"&&e.jsxs("div",{className:"flex flex-col gap-3 text-white",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("i",{className:"bi bi-shield-check text-second text-2xl"}),e.jsx("span",{className:"font-semibold",children:"Validação pronta para iniciar"})]}),e.jsx("span",{className:"text-white text-opacity-70 text-sm",children:"Confirme o envio para validar os dados já cadastrados. A página também inicia a análise automaticamente assim que a sessão segura estiver pronta."}),e.jsx("button",{type:"button",className:"btn bg-second text-black hover:bg-second-600 border-second hover:border-second-600 px-8 w-fit",onClick:j,disabled:!x,children:"Validar dados"})]}),o==="loading"&&e.jsxs("div",{className:"flex flex-col gap-3 text-white",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"loading loading-spinner loading-md"}),e.jsx("span",{className:"font-semibold",children:"Enviando dados para validação..."})]}),e.jsx("span",{className:"text-white text-opacity-70 text-sm",children:"Esse processo é assÃncrono. Assim que a solicitação for registrada, você poderá continuar."})]}),o==="success"&&e.jsxs("div",{className:"flex flex-col gap-4 text-white",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("i",{className:"bi bi-check-circle text-second text-2xl"}),e.jsx("span",{className:"font-semibold",children:"Validação de identidade concluÃda"})]}),e.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[e.jsxs("div",{className:"rounded-xl bg-third-400 p-3 flex flex-col gap-1",children:[e.jsx("span",{className:"text-white text-opacity-60 text-xs",children:"Limite para depósito"}),e.jsx("span",{className:"text-white text-sm font-semibold",children:u(d?.monthlyLimitCents)})]}),e.jsxs("div",{className:"rounded-xl bg-third-400 p-3 flex flex-col gap-1",children:[e.jsx("span",{className:"text-white text-opacity-60 text-xs",children:"Limite para saque"}),e.jsx("span",{className:"text-white text-sm font-semibold",children:u(d?.monthlySellLimitCents)})]})]}),e.jsxs("div",{className:"flex items-start gap-2 rounded-xl border border-white border-opacity-10 bg-white bg-opacity-10 p-3",children:[e.jsx("i",{className:"bi bi-info-circle mt
1-0.5 text-second"}),e.jsx("span",{className:"text-sm text-white text-opacity-70",children:"A validação cadastral deste ambiente é concluÃda nesta etapa; não há upgrade adicional de KYC no onboarding."})]})]}),o==="processing"&&e.jsxs("div",{className:"flex flex-col gap-4 text-white",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"loading loading-spinner loading-md"}),e.jsx("span",{className:"font-semibold",children:"Validação em análise"})]}),e.jsx("div",{className:"rounded-xl bg-white bg-opacity-10 border border-white border-opacity-10 p-3",children:e.jsx("span",{className:"text-white text-opacity-70 text-sm",children:"Sua solicitação foi recebida e ainda não foi aprovada pelo provedor de identidade. Esta tela será atualizada automaticamente; o investimento será liberado após a aprovação."})}),!!i&&e.jsx("span",{className:"text-yellow-200 text-sm",children:"A última atualização falhou temporariamente. Você pode tentar novamente sem reenviar a validação."}),e.jsx("button",{type:"button",className:"btn bg-white text-third hover:bg-gray-100 border-white hover:border-gray-200 px-8 w-fit",onClick:h,children:"Atualizar situação"})]}),o==="failed"&&e.jsxs("div",{className:"flex flex-col gap-4 text-white",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("i",{className:"bi bi-x-circle text-red-300 text-2xl"}),e.jsx("span",{className:"font-semibold",children:"Não foi possÃvel validar seus dados"})]}),e.jsx("div",{className:"rounded-xl bg-white bg-opacity-10 border border-white border-opacity-10 p-3",children:e.jsxs("span",{className:"text-white text-opacity-70 text-sm",children:["Motivo: ",l||"Não informado."]})}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-3",children:[e.jsx("button",{type:"button",className:"btn bg-white text-third hover:bg-gray-100 border-white hover:border-gray-200 px-8",onClick:p,children:"Voltar e revisar dados pessoais"}),e.jsx("button",{type:"button",className:"btn bg-second text-black hover:bg-second-600 border-second hover:border-second-600 px-8",onClick:j,children:"Tentar novamente"})]})]}),o==="error"&&e.jsxs("div",{className:"flex flex-col gap-3 text-white",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("i",{className:"bi bi-exclamation-triangle text-yellow-300 text-2xl"}),e.jsx("span",{className:"font-semibold",children:"Não conseguimos iniciar a validação"})]}),!!i&&e.jsx("span",{className:"text-white text-opacity-70 text-sm",children:i}),e.jsx("div",{children:e.jsx("button",{type:"button",className:"btn bg-white text-third hover:bg-gray-100 border-white hover:border-gray-200 px-8",onClick:j,children:"Tentar novamente"})})]})]})]})}function ze(a){return new Intl.NumberFormat("pt-BR",{style:"currency",currency:"BRL",minimumFractionDigits:2,maximumFractionDigits:2}).format(a)}function Ve({setPermitSubmit:a}){const{userData:c,apiKey:x,refreshUserData:o}=M(),[i,l]=r.useState(!1),[d,p]=r.useState(!1),[j,h]=r.useState(!1),[u,g]=r.useState(null),[N,S]=r.useState(null),v=r.useRef(!1),{formState:{errors:f},control:y,clearErrors:m,trigger:C,getValues:s}=ee();r.useEffect(()=>{if(!c||v.current||c.financial_investments==null||c.annual_gross_income==null)return;v.current=!0;const F=typeof c.credit_limit=="number"?c.credit_limit/100:0;S(F),a(!0)},[a,c]);async function t(){if(await C(["investorValue","incomeValue"])){if(!i){p(!0);return}p(!1),g(null),h(!0);try{const I={annualGrossIncome:s("incomeValue")*100,financialInvestments:s("investorValue")*100,id:c.uid},n=await Ee(x,I);if(!n?.data||typeof n.data.creditLimit!="number")throw new Error("Ocorreu um erro inesperado ao enviar seus dados. Tente novamente em instantes.");S(n.data.creditLimit/100),a(!0),await o()}catch(I){const n=I?.response?.data?.error||I?.response?.data?.message||I?.message||"";g(n||"Ocorreu um erro ao calcular seu perfil. Tente novamente."),E.error("Não foi possÃvel calcular seu perfil.")}finally{h(!1)}}}const b=N!==null&&N<0,T=N!==null;return e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsxs("div",{className:`grid grid-cols-1 gap-5 lg:grid-cols-2 ${T?"hidden":""}`,children:[e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx("label",{className:"text-sm text-white",children:"Investimentos financeiros *"}),e.jsxs("label",{className:"input input-bordered flex items-center gap-2 bg-white",children:[e.jsx("i",{className:"bi bi-graph-up-arrow text-gray-400"}),e.jsx(R,{name:"investorValue",control:y,rules:{required:"Campo obrigatório",validate:F=>F<=999e9||"O valor não pode exceder R$ 999.000.000.000,00"},render:({field:F})=>e.jsx(Z,{groupSeparator:".",decimalSeparator:",",placeholder:"R$ 0,00",decimalsLimit:2,decimalScale:2,prefix:"R$ ",maxLength:18,className:"grow",onValueChange:(I,n,P)=>{F.onChange(P?.float??0),m("investorValue")}})})]}),f.investorValue&&e.jsx("span",{className:"text-xs text-red-400",children:f.investorValue.message})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx("label",{className:"text-sm text-white",children:"Renda bruta anual *"}),e.jsxs("label",{className:"input input-bordered flex items-center gap-2 bg-white",children:[e.jsx("i",{className:"bi bi-cash-stack text-gray-400"}),e.jsx(R,{name:"incomeValue",control:y,rules:{required:"Campo obrigatório",validate:F=>F<=999e9||"O valor não pode exceder R$ 999.000.000.000,00"},render:({field:F})=>e.jsx(Z,{groupSeparator:".",decimalSeparator:",",placeholder:"R$ 0,00",decimalsLimit:2,decimalScale:2,prefix:"R$ ",maxLength:18,className:"grow",onValueChange:(I,n,P)=>{F.onChange(P?.float??0),m("incomeValue")}})})]}),f.incomeValue&&e.jsx("span",{className:"text-xs text-red-400",children:f.incomeValue.message})]})]}),e.jsxs("div",{className:`flex items-start gap-2 text-xs text-white text-opacity-60 ${T?"hidden":""}
1`,children:[e.jsx("i",{className:"bi bi-info-circle mt-0.5 shrink-0"}),e.jsx("span",{children:"Coletamos essas informações para definir seu limite de investimentos com base na Resolução CVM 88."})]}),e.jsxs("div",{className:`flex flex-col gap-1 ${T?"hidden":""}`,children:[e.jsxs("label",{className:"label cursor-pointer justify-start gap-3 p-0",children:[e.jsx("input",{type:"checkbox",className:`checkbox [--chkbg:theme(colors.second)] [--chkfg:white] ${d?"border-error":"border-second"}`,checked:i,onChange:F=>{l(F.target.checked),F.target.checked&&p(!1)}}),e.jsx("span",{className:`label-text text-sm font-semibold ${d?"text-error":"text-white"}`,children:"Declaro que as informações acima são verdadeiras"})]}),d&&e.jsx("span",{className:"ml-8 text-xs text-red-400",children:"Confirme que as informações são verdadeiras para continuar."})]}),!T&&e.jsx("div",{children:e.jsx("button",{type:"button",className:"btn border-second bg-second px-8 text-black hover:border-second-600 hover:bg-second-600",onClick:t,disabled:j,children:j?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"loading loading-spinner loading-sm"}),"Calculandoâ¦"]}):"Calcular perfil"})}),u&&e.jsxs("div",{className:"flex flex-col gap-3 rounded-2xl border border-red-400 border-opacity-30 bg-red-500 bg-opacity-10 p-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("i",{className:"bi bi-exclamation-triangle text-red-400"}),e.jsx("span",{className:"text-sm font-semibold text-white",children:"Não foi possÃvel calcular o perfil"})]}),e.jsx("span",{className:"text-xs text-red-300",children:u}),e.jsx("div",{children:e.jsx("button",{type:"button",className:"btn btn-sm border-second bg-second text-black hover:border-second-600 hover:bg-second-600",onClick:t,disabled:j,children:"Tentar novamente"})})]}),T&&!u&&e.jsxs("div",{className:"flex flex-col gap-3 rounded-2xl border border-green-400 border-opacity-30 bg-green-500 bg-opacity-10 p-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("i",{className:"bi bi-check-circle-fill text-lg text-green-400"}),e.jsx("span",{className:"text-sm font-semibold text-white",children:"Perfil calculado com sucesso"})]}),e.jsxs("div",{className:"flex items-center justify-between rounded-xl bg-white bg-opacity-10 px-4 py-3",children:[e.jsx("span",{className:"text-sm text-white text-opacity-70",children:"Limite para investimentos"}),e.jsx("span",{className:"text-sm font-semibold text-white",children:b?"Investidor qualificado â sem limite":ze(N)})]}),e.jsx("button",{type:"button",className:"w-fit text-xs text-white text-opacity-50 underline underline-offset-2 transition hover:text-opacity-80",onClick:()=>{S(null),a(!1),g(null)},children:"Corrigir valores e recalcular"})]})]})}const H="serpro";function as(){const{user:a,userData:c,loadingContext:x,refreshUserData:o,apiKey:i}=M(),[l,d]=r.useState(0),[p,j]=r.useState("pf"),[h,u]=r.useState(!1),[g,N]=r.useState(!1),[S,v]=r.useState(!1),[f,y]=r.useState({checkAccession:!1,accessionError:!1}),m=ee(),{trigger:C,getValues:s,reset:t}=m,b=xe(),T=r.useRef(!1),F=r.useRef(!1),I=r.useRef(!1),n=c,P=p==="pj",D=p==="pf",te=!!(n?.financial_investments&&n?.annual_gross_income),z=$e({active:H!=="idwall",step:l,apiKey:i,userData:n,refreshUserData:o});Te({active:H==="idwall",apiKey:i,userData:n,refreshUserData:o});const O=z;r.useEffect(()=>{if(!T.current&&n){T.current=!0;const k=n.phone?n.phone:"",w=n.document?n.document.toString():"",A=n.birthdate?Q(n.birthdate,!0):"",$=n?.partners?.document?n?.partners?.document?.toString():"",oe=n?.partners?.birthdate?Q(n.partners.birthdate,!0):"";try{const de=`register_profile_person_type:${n.uid}`,L=localStorage.getItem(de);if(L==="pf"||L==="pj")j(L);else{const me=q(w.toString());j(me.length===14?"pj":"pf")}}catch{j("pf")}t({name:n.name?n.name:a.user_metadata.full_name??"",email:n.email??"",documentCpfPf:w.toString(),documentCpfPJ:w.toString(),phone:k.toString(),birthdate:A,zip:n.address?.zip??"",address:n.address?.address??"",number:n.address?.number??"",complement:n.address?.complement??"",neighborhood:n.address?.neighborhood??"",city:n.address?.city??"",state:n.address?.state??"",partnerName:n?.partners?.name??"",partnerDocument:$.toString(),partnerBirthdate:oe})}},[n,t]),r.useEffect(()=>{if(n&&!F.current){if(F.current=!0,!n.document){d(0);return}if(!n.address){d(1);return}if(!te){d(2);return}}},[n]);const re=k=>typeof k!="number"?"Carregando limites...":k===0?"Aguardando sincronização":(k/100).toLocaleStr
1ing("pt-BR",{style:"currency",currency:"BRL"}),V=[{key:"basic",title:"Dados",component:e.jsxs("div",{className:"w-full bg-third rounded-2xl flex flex-col gap-6",style:{display:l===0?"flex":"none"},children:[e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"font-semibold text-white text-xl",children:D?"Dados pessoais":"Dados da empresa"}),e.jsx("span",{className:"text-white text-opacity-70 text-sm",children:"Preencha as informações básicas para liberar o restante do cadastro."})]}),e.jsxs("div",{className:"flex bg-third-400 rounded-xl p-1 w-fit",children:[e.jsx("button",{type:"button",className:`px-4 py-2 rounded-lg text-sm font-semibold transition ${D?"bg-second text-black":"text-white"}`,onClick:()=>{j("pf");try{n?.uid&&localStorage.setItem(`register_profile_person_type:${n.uid}`,"pf")}catch{}},children:"PF"}),e.jsx("button",{type:"button",className:`px-4 py-2 rounded-lg text-sm font-semibold transition ${P?"bg-second text-black":"text-white"}`,onClick:()=>{j("pj");try{n?.uid&&localStorage.setItem(`register_profile_person_type:${n.uid}`,"pj")}catch{}},children:"PJ"})]})]}),e.jsxs("div",{children:[D&&e.jsx(Ie,{checkControl:f,setCheckControl:y}),P&&e.jsx(Pe,{checkControl:f,setCheckControl:y})]})]})},{key:"address",title:"Endereço",component:e.jsx("div",{className:"w-full bg-third rounded-2xl flex flex-col gap-5",style:{display:l===1?"flex":"none"},children:e.jsxs("div",{className:"flex flex-col gap-5",children:[e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"font-semibold text-white text-xl",children:"Endereço"}),e.jsx("span",{className:"text-white text-opacity-70 text-sm",children:"Usamos esses dados para comunicação e c
1ompliance."})]}),e.jsx(Ae,{})]})})},{key:"kyc",title:"Validação",component:e.jsx("div",{className:"w-full bg-third rounded-2xl flex flex-col gap-5",style:{display:l===2?"flex":"none"},children:e.jsx("div",{className:"flex flex-col gap-5",children:e.jsx(_e,{isPJ:P,getValues:s,apiKey:i,kycL1Status:z.status,kycL1Error:z.error,kycL1FailureReason:z.failureReason,kycL1Data:z.data,onEditPersonalData:()=>d(0),onStart:z.start,onSync:()=>void z.sync(),formatMoney:re})})})},{key:"suitability",title:"Perfil",component:e.jsx("div",{className:"w-full bg-third rounded-2xl flex flex-col gap-5",style:{display:l===3?"flex":"none"},children:e.jsxs("div",{className:"lg:py-12 flex flex-col gap-5",children:[e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"font-semibold text-white text-xl",children:"Perfil do investidor"}),e.jsx("span",{className:"text-white text-opacity-70 text-sm",children:"Responda para definir seu perfil e concluir a criação da carteira."})]}),e.jsx(Ve,{setPermitSubmit:v})]})})}];async function G(k){if(!I.current){I.current=!0;try{if(k==="next"){if(l===2&&O.status!=="success")return;const w=ne();if(w){const A=await C(w);if(l===0){if(!f.checkAccession||!A){y({...f,accessionError:!f.checkAccession});return}if(!await ie())return}if(l===1){if(!A){console.error("Validation errors:",m.formState.errors);return}if(!await le())return;O.resetToIdle(),d(2);return}}d(A=>A+1)}else{if(l===0){b("/tokens");return}d(w=>Math.max(0,w-1))}}finally{I.current=!1}}}r.useEffect(()=>{l===0&&y({...f,accessionError:!1})},[l]);async function ie(){const k=E.loading("Salvando dados pessoais...");try{const w=Y(s("birthdate"),"dd/MM/yyyy",new Date),A={name:s("name"),document:P?q(s("documentCpfPJ")):q(s("documentCpfPf")),phone:q(s("phone")),whatsapp:s("whatsappConsent")?q(s("phone")):void 0,whatsappConsent:!!s("whatsappConsent"),birthdate:X(w,"yyyy-MM-dd"),personType:P?"pj":"pf",id:n.id},$=await we(i,A);return P&&await ye(i,{userUid:n.uid,name:s("partnerName"),document:q(s("partnerDocument")),birthDate:s("partnerBirthdate")?X(Y(s("partnerBirthdate"),"dd/MM/yyyy",new Date),"yyyy-MM-dd"):void 0}),$&&E.success("Dados atualizados com sucesso!"),await B(),!0}catch(w){return console.error("Falha ao salvar os dados pessoais",w),E.error("Não foi possÃvel salvar todos os dados pessoais. Revise e tente novamente."),!1}finally{E.dismiss(k)}}async function le(){try{const k={address:s("address"),number:s("number"),city:s("city"),zip:s("zip"),complement:s("complement"),neighborhood:s("neighborhood"),state:s("state"),user_id:n.uid};return await ke(i,k),B(),E.success("Endereço atualizado com sucesso!"),!0}catch{return E.error("Ocorreu um erro ao salvar endereço. Tente novamente."),!1}}const B=async()=>{await o()},ne=()=>l===0?P?["name","phone","documentCpfPJ","birthdate","partnerName","partnerDocument","partnerBirthdate"]:["name","phone","documentCpfPf","birthdate"]:l===1?["address","city","number","zip","complement","neighborhood","state"]:null,ce=async()=>{u(!0);try{N(!0);const k=E.loading("Criando uma carteira...");let w;try{w=await Fe(i)}finally{E.dismiss(k)}if(!w)throw N(!1),console.error("Ocorreu um erro ao criar a carteira. Tente novamente."),E.error("Ocorreu um erro ao criar a carteira. Tente novamente."),new Error("Ocorreu um erro ao criar a carteira. Tente novamente.");E.success("Carteira criada com sucesso!"),await Se(i),await B(),N(!1),b("/register-complete")}catch(k){console.error("Ocorreu um erro ao salvar dados",k),N(!1),E.error("Não foi possÃvel concluir o cadastro. Seus dados foram preservados para uma nova tentativa.")}finally{u(!1)}};return x||!n?e.jsx(ve,{}):e.jsxs(e.Fragment,{children:[e.jsx("section",{className:"min-h-screen relative",children:e.jsxs("div",{className:"container flex flex-col gap-10",children:[e.jsx(ue,{title:`Perfil ${n.name?`- ${n.name}`:""} `,icon:"bi bi-person"}),e.jsx("div",{className:"w-full mt-10",children:e.jsx("div",{className:"mx-auto w-full max-w-6xl overflow-hidden rounded-3xl bg-white shadow-sm ring-1 ring-black/5",children:e.jsxs("div",{className:"grid lg:grid-cols-[360px_1fr]",children:[e.jsxs("div",{className:"p-6 lg:p-8 flex flex-col gap-8",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"text-third text-lg font-semibold",children:"Seu cadastro"}),e.jsxs("span",{className:"text-gray text-sm",children:["Etapa ",Math.min(l+1,
1V.length)," de"," ",V.length]})]}),e.jsx("span",{className:"bg-second bg-opacity-20 text-third text-xs font-semibold px-3 py-1 rounded-full",children:D?"PF":"PJ"})]}),e.jsx("div",{className:"flex flex-col gap-2",children:V.map((k,w)=>{const A=l===w,$=l>w;return e.jsxs("button",{type:"button",className:`w-full text-left rounded-2xl px-4 py-3 transition flex items-center gap-3 ${A?"bg-third text-white":$?"bg-second bg-opacity-20 text-third":"bg-gray-100 text-gray-600"}`,onClick:()=>{w<=l&&d(w)},children:[e.jsx("span",{className:`w-8 h-8 rounded-xl flex items-center justify-center text-sm font-semibold ${A?"bg-white bg-opacity-15 text-white":$?"bg-second text-black":"bg-white text-gray-500"}`,children:w+1}),e.jsxs("span",{className:"flex flex-col",children:[e.jsx("span",{className:"font-semibold",children:k.title}),e.jsx("span",{className:`text-xs ${A?"text-white text-opacity-70":""}`,children:w===0?D?"Informações pessoais":"Informações da empresa":w===1?"Dados de endereço":w===2?"Checagem automática":"Suitability"})]})]},k.key)})}),e.jsxs("div",{className:"rounded-2xl bg-gray-50 p-4 flex flex-col gap-2",children:[e.jsx("span",{className:"text-third text-sm font-semibold",children:"Dica rápida"}),e.jsx("span",{className:"text-gray-600 text-sm",children:"Você pode voltar e editar qualquer etapa antes de finalizar."})]})]}),e.jsx("div",{className:"bg-white p-2 lg:p-3",children:e.jsx("div",{className:"bg-third rounded-3xl p-5 lg:p-8",children:e.jsx(he,{...m,children:e.jsxs("form",{className:"w-full max-w-full flex flex-col gap-7",children:[V.map(k=>k.component),e.jsxs("div",{className:"flex flex-col-reverse gap-3 sm:flex-row sm:justify-between sm:items-center",children:[e.jsx("button",{type:"button",className:"btn bg-white text-third hover:bg-gray-100 border-white hover:border-gray-200 px-10 w-full sm:w-max",onClick:()=>G("prev"),disabled:h,children:"Voltar"}),e.jsxs("div",{className:"flex w-full sm:w-auto gap-3",children:[e.jsx("button",{type:"button",className:`btn bg-second text-black hover:bg-second-600 border-second hover:border-second-600 px-10 w-full sm:w-max ${l===V.length-1?"hidden":""}`,onClick:()=>G("next"),disabled:h||l===2&&O.status!=="success",children:h?"Carregando...":"Continuar"}),e.jsx("button",{type:"button",className:`btn bg-second text-black hover:bg-second-600 border-second hover:border-second-600 px-10 w-full sm:w-max ${l===V.length-1?"":"hidden"}`,onClick:()=>ce(),disabled:!S||h,children:"Finalizar"})]})]})]})})})})]})})})]})}),e.jsx(K,{isOpen:g,onClose:()=>N(!1),title:"Carteira",size:"",position:"items-center",allowClose:!0,children:e.jsxs("div",{className:"flex flex-col gap-8",children:[e.jsx("div",{className:"flex justify-center",children:e.jsx("span",{className:"loading loading-infinity loading-lg"})}),e.jsx("div",{children:e.jsx("p",{className:"m-0 text-center leading-snug",children:"Estamos gerando sua carteira na blockchain. Não vai demorar..."})}),e.jsx("div",{children:e.jsx("p",{className:"m-0 text-center leading-snug",children:"Com sua carteira, você tem total controle sob seus ativos adquiridos na Capitare."})})]})})]})}export{as 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.