1/* ANPG DEVTEAM - 29/09/2026, 14:34:20 */ 2import{e as se,u as $,d as ae,j as e}from"./data-vendor-BRYI0K8G.js";import{i as te,h as re,r as m,N as z,L as K}from"./react-vendor-Bj9LQV-u.js";import{bQ as ie,w as E,b,M as ne,B as oe,F as le,O as de,bh as p,bO as ce,bN as T,bP as Q}from"./index-B5fS5HUA.js";import{P as R}from"./PageLayout-nUtosKtI.js";import{C as u,a as h,b as f,c as j}from"./card-SWKDiSm6.js";import{B as g}from"./badge-jukGcCw8.js";import{I as N}from"./input-CtWCrhgd.js";import{L as v}from"./label-ByFBDaC1.js";import{T as G}from"./textarea-DpaYHtFE.js";import{C as me}from"./checkbox-DYxG2L1i.js";import{u as pe,m as ue}from"./usePetroleumBlocks-O3Ix33qJ.js";import{A as he}from"./arrow-left-B5pHXlkl.js";import{L as xe}from"./lock-BuPS0Fev.js";import{C as fe}from"./calendar-days-4q4poLwJ.js";import{F as je}from"./file-up-BasEYrk7.js";import{P as ve}from"./paperclip-CwOjcvnZ.js";import{S as ge}from"./send-BDbszoOc.js";import"./charts-vendor-Cs07Jtv5.js";import"./motion-vendor-DMc3mo8t.js";import"./i18n-vendor-BSIZ7LIS.js";import"./PageBreadcrumb-D2posgoP.js";import"./house-B0n5Y9eN.js";import"./star-BMTUmwlW.js";import"./circle-check-BAB09i3P.js";import"./index-D6PzSG9l.js";function w(o){if(Array.isArray(o))return o.filter(l=>l&&typeof l=="object");if(typeof o=="string"&&o.trim()!=="")try{const l=JSON.parse(o);if(Array.isArray(l))return l.filter(_=>_&&typeof _=="object")}catch{return[]}return[]}function Ge(){const{user:o,roles:l,loading:_,mustChangePassword:H}=ie(),J=te(),V=se(),{slug:S}=re(),[y,F]=m.useState([]),[i,x]=m.useState({opportunity_ref_id:"",representative_name:"",representative_role:"",representative_phone:"",representative_email:"",declared_interest:"",observations:"",declaration_accepted:!1}),U=l.some(s=>s.role==="investor")||l.some(s=>s.role==="admin")||l.some(s=>s.role==="manager"),{data:k=[],isLoading:W}=pe(),{data:d}=$({queryKey:["investor-my-registration"],queryFn:()=>Q.getMyRegistration(),enabled:!!o}),{data:c}=$({queryKey:["investor-manifestation-settings"],queryFn:()=>Q.getManifestationSettings(),enabled:!!o}),{data:C}=$({queryKey:["investor-manifestations"],queryFn:()=>T.listMine(),enabled:!!o}),q=m.useMemo(()=>new Set(((C==null?void 0:C.data)||[]).map(s=>s.opportunity_ref_id)),[C]),a=m.useMemo(()=>S&&k.find(s=>ue(s.name,s.id)===S)||null,[k,S]),X=(d==null?void 0:d.status)==="approved"&&a&&a.publication_status==="published"&&a.allows_manifestation&&!q.has(a.id),L=m.useMemo(()=>w(a==null?void 0:a.public_documents),[a]),D=m.useMemo(()=>w(a==null?void 0:a.reserved_documents),[a]),O=m.useMemo(()=>w(a==null?void 0:a.opportunity_timeline),[a]),I=m.useMemo(()=>w(a==null?void 0:a.opportunity_faq),[a]),Y=(d==null?void 0:d.status)==="approved",M=ae({mutationFn:s=>T.submit(s),onSuccess:s=>{p.success(`Manifestação submetida com sucesso (${s.submission_no}).`),V.invalidateQueries({queryKey:["investor-manifestations"]}),J("/portal-investidor?tab=manifestacoes")},onError:s=>{p.error(s.message||"Não foi possÃvel submeter a manifestação.")}});if(_||W)return e.jsx("div",{className:"min-h-screen flex items-center justify-center",children:e.jsx(E,{className:"h-8 w-8 animate-spin text-primary"})});if(!o||!U)return e.jsx(z,{to:"/portal-investidor/login",replace:!0});if(H)return e.jsx(z,{to:"/portal-investidor/alterar-senha",replace:!0});if(!a)return e.jsx(R,{pageKey:"investor-portal",titleKey:"pages.investorPortal.title",subtitleKey:"pages.investorPortal.subtitle",breadcrumbs:[{label:"Portal do Investidor",href:"/portal-investidor"},{label:"Oportunidade"}],children:e.jsx(u,{children:e.jsxs(h,{className:"py-10 text-center space-y-4",children:[e.jsx("p",{className:"text-lg font-semibold",children:"Oportunidade não encontrada"}),e.jsx(b,{asChild:!0,variant:"outline",children:e.jsx(K,{to:"/portal-investidor?tab=manifestacoes",children:"Voltar à s oportunidades"})})]})})});const A=(c==null?void 0:c.manifestation_max_files)??5,P=(c==null?void 0:c.manifestation_max_file_size_mb)??10,B=(c==null?void 0:c.manifestation_allowed_mime_types)??[],Z=s=>{if(!s||s.length===0)return;const t=[...y];for(const r of Array.from(s)){if(t.length>=A){p.error(`Máximo de ${A} anexos permitido.`);break}if(r.size>P*1024*1024){p.error(`${r.name}: excede o limite de ${P} MB.`);continue}if(B.length>0&&!B.includes(r.type)){p.error(`${r.name}: tipo de ficheiro não permitido.`);continue}t.push({id:`${r.name}-${r.size}-${r.lastModified}`,file:r})}F(t)},ee=async()=>{var s;if(a){if(!i.representative_name||!i.representative_email||!i.declared_interest.trim()){p.error("Preencha os campos obrigatórios.");return}if(!i.declaration_accepted){p.error("Aceite a declaração para prosseguir.");return}try{const t=[];for(const r of y){const n=await ce.upload("investor-manifestations",r.file);t.push({file_name:n.original||n.filename,file_url:n.url,mime_type:n.mime_type,size_bytes:n.size})}M.mutate({...i,opportunity_ref_id:a.id,observations:((s=i.observations)==null?void 0:s.trim())||"",declared_interest:i.declared_interest.trim(),representative_name:i.representative_name.trim(),representative_email:i.representative_email.trim(),attachments:t})}catch(t){p.error(t instanceof Error?t.message:"Falha no upload dos anexos.")}}};return e.jsx(R,{pageKey:"investor-portal",title:"Detalhe da Oportunidade",subtitle:a.name,breadcrumbs:[{label:"Portal do Investidor",href:"/portal-investidor"},{label:"Manifestações",href:"/portal-investidor?tab=manifestacoes"},{label:a.name}],children:e.jsxs("div",{className:"space-y-6",children:[e.jsx(b,{variant:"outline",asChild:!0,children:e.jsxs(K,{to:"/portal-investidor?tab=manifestacoes",children:[e.jsx(he,{className:"h-4 w-4 mr-2"}),"Voltar à listagem"]})}),e.jsxs(u,{children:[e.jsx(f,{children:e.jsx(j,{children:a.name})}),e.jsxs(h,{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(g,{variant:"secondary",children:a.publication_status==="published"?"Publicada":"Arquivada"}),a.opportunity_code&&e.jsx(g,{variant:"outline",children:a.opportunity_code}),e.jsx(g,{variant:"outline",children:a.status}),e.jsx(g,{variant:"outline",children:a.type}),e.jsx(g,{variant:a.allows_manifestation?"default":"outline",children:a.allows_manifestation?"Permite manifestação":"Manifestação desactivada"})]}),e.jsxs("div",{className:"grid md:grid-cols-2 gap-4 text-sm text-muted-foreground",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ne,{className:"w-4 h-4"}),"Bacia: ",a.basin]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(oe,{className:"w-4 h-4"}),"Operador: ",a.operator||"ANPG"]}),e.jsxs("div",{children:["Ãrea: ",a.area_km2?`${a.area_km2.toLocaleStr
2ing("pt-AO")} km²`:"Não indicada"]}),e.jsxs("div",{children:["Profundidade: ",a.water_depth_m?`${a.water_depth_m.toLocaleString("pt-AO")} m`:"Não indicada"]})]}),a.interest_tags.length>0&&e.jsx("div",{className:"flex flex-wrap gap-2",children:a.interest_tags.map(s=>e.jsx(g,{variant:"outline",children:s},s))})]})]}),e.jsxs(u,{children:[e.jsx(f,{children:e.jsx(j,{children:"Descrição"})}),e.jsx(h,{children:e.jsx("p",{className:"text-sm leading-relaxed text-muted-foreground",children:a.description||"Descrição detalhada desta oportunidade será disponibilizada pela equipa ANPG."})})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[e.jsxs(u,{children:[e.jsx(f,{children:e.jsxs(j,{className:"flex items-center gap-2",children:[e.jsx(le,{className:"h-4 w-4"}),"Documentação Pública"]})}),e.jsx(h,{className:"space-y-2",children:L.length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"Sem documentação pública registada no CMS."}):L.map((s,t)=>{const r=String(s.title||s.name||`Documento ${t+1}`),n=String(s.url||"");return n?e.jsx("a",{href:n,target:"_blank",rel:"noopener noreferrer",className:"block text-sm text-primary hover:underline",children:r},`${r}-${t}`):e.jsx("p",{className:"text-sm",children:r},`${r}-${t}`)})})]}),e.jsxs(u,{children:[e.jsx(f,{children:e.jsxs(j,{className:"flex items-center gap-2",children:[e.jsx(xe,{className:"h-4 w-4"}),"Documentação Reservada"]})}),e.jsx(h,{className:"space-y-2",children:Y?D.length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"Sem documentação reservada registada no CMS."}):D.map((s,t)=>{const r=String(s.title||s.name||`Documento reservado ${t+1}`),n=String(s.url||"");return n?e.jsx("a",{href:n,target:"_blank",rel:"noopener noreferrer",className:"block text-sm text-primary hover:underline",children:r},`${r}-${t}`):e.jsx("p",{className:"text-sm",children:r},`${r}-${t}`)}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"A documentação reservada fica disponÃvel após aprovação da empresa no Portal do Investidor."})})]})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[e.jsxs(u,{children:[e.jsx(f,{children:e.jsxs(j,{className:"flex items-center gap-2",children:[e.jsx(fe,{className:"h-4 w-4"}),"Cronograma"]})}),e.jsx(h,{children:O.length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"Cronograma ainda não definido para esta oportunidade."}):e.jsx("div",{className:"space-y-2",children:O.map((s,t)=>e.jsxs("div",{className:"rounded-md border p-2.5 text-sm",children:[e.jsx("p",{className:"font-medium",children:String(s.label||s.title||`Marco ${t+1}`)}),s.date&&e.jsx("p",{className:"text-xs text-muted-foreground",children:String(s.date)}),s.note&&e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:String(s.note)})]},`timeline-${t}`))})})]}),e.jsxs(u,{children:[e.jsx(f,{children:e.jsxs(j,{className:"flex items-center gap-2",children:[e.jsx(de,{className:"h-4 w-4"}),"FAQ"]})}),e.jsx(h,{children:I.length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"Sem perguntas frequentes configuradas para esta oportunidade."}):e.jsx("div",{className:"space-y-3",children:I.map((s,t)=>e.jsxs("div",{className:"rounded-md border p-3",children:[e.jsx("p",{className:"text-sm font-medium",children:String(s.question||s.q||`Pergunta ${t+1}`)}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:String(s.answer||s.a||"")})]},`faq-${t}`))})})]})]}),e.jsxs(u,{children:[e.jsx(f,{children:e.jsx(j,{children:"Manifestar Interesse"})}),e.jsx(h,{className:"space-y-4",children:X?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(v,{htmlFor:"rep-name",children:"Nome completo *"}),e.jsx(N,{id:"rep-name",value:i.representative_name,onChange:s=>x(t=>({...t,representative_name:s.target.value}))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(v,{htmlFor:"rep-email",children:"Email *"}),e.jsx(N,{id:"rep-email",type:"email",value:i.representative_email,onChange:s=>x(t=>({...t,representative_email:s.target.value}))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(v,{htmlFor:"rep-role",children:"Cargo"}),e.jsx(N,{id:"rep-role",value:i.representative_role||"",onChange:s=>x(t=>({...t,representative_role:s.target.value}))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(v,{htmlFor:"rep-phone",children:"Telefone"}),e.jsx(N,{id:"rep-phone",value:i.representative_phone||"",onChange:s=>x(t=>({...t,representative_phone:s.target.value}))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(v,{htmlFor:"declared-interest",children:"Interesse declarado *"}),e.jsx(G,{id:"declared-interest",rows:5,value:i.declared_interest,onChange:s=>x(t=>({...t,declared_interest:s.target.value}))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(v,{htmlFor:"observations",children:"Observações"}),e.jsx(G,{id:"observations",rows:3,value:i.observations||"",onChange:s=>x(t=>({...t,observations:s.target.value}))})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Até ",A," ficheiros, ",P," MB por ficheiro."]}),e.jsx(b,{type:"button",variant:"outline",asChild:!0,children:e.jsxs("label",{htmlFor:"op-detail-attachments",className:"cursor-pointer",children:[e.jsx(je,{className:"w-4 h-4 mr-2"}),"Adicionar ficheiros"]})})]}),e.jsx(N,{id:"op-detail-attachments",type:"file",multiple:!0,className:"hidden",onChange:s=>{Z(s.target.files),s.currentTarget.value=""}}),y.length>0&&e.jsx("div",{className:"space-y-2 rounded-lg border p-3",children:y.map(s=>e.jsxs("div",{className:"flex items-center justify-between gap-3 text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx(ve,{className:"w-4 h-4 text-muted-foreground shrink-0"}),e.jsx("span",{className:"truncate",children:s.file.name})]}),e.jsx(b,{type:"button",variant:"ghost",size:"sm",onClick:()=>F(t=>t.filter(r=>
2r.id!==s.id)),children:"Remover"})]},s.id))})]}),e.jsxs("div",{className:"flex items-start gap-3 rounded-lg border p-3",children:[e.jsx(me,{id:"op-declaration",checked:i.declaration_accepted,onCheckedChange:s=>x(t=>({...t,declaration_accepted:s===!0}))}),e.jsx(v,{htmlFor:"op-declaration",className:"leading-6",children:"Declaro que as informações submetidas são verdadeiras."})]}),e.jsx("div",{className:"flex justify-end",children:e.jsxs(b,{onClick:ee,disabled:M.isPending,children:[M.isPending?e.jsx(E,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(ge,{className:"w-4 h-4 mr-2"}),"Submeter Manifestação"]})})]}):e.jsx("p",{className:"text-sm text-muted-foreground",children:(d==null?void 0:d.status)!=="approved"?"A conta deve estar aprovada para submeter uma manifestação.":q.has(a.id)?"Já existe uma manifestação para esta oportunidade.":a.allows_manifestation?a.publication_status!=="published"?"Esta oportunidade não está publicada para manifestação neste momento.":"A manifestação não está disponÃvel neste momento.":"Esta oportunidade está disponÃvel para consulta, mas a manifestação de interesse está desactivada pela gestão de conteúdo."})})]})]})})}export{Ge 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.