1import{a as G}from"./chunk-73JJF2NY.js";import{c as O,e as R,h as j,m as $,n as q,o as z,r as U}from"./chunk-P4CUVN37.js";import{a as w,b as E}from"./chunk-7URW5PIY.js";import{m as P}from"./chunk-XH47QIYK.js";import"./chunk-5ZAR5CWL.js";import"./chunk-TF7BWGA3.js";import{a as T}from"./chunk-IWDFTWHJ.js";import{m as L}from"./chunk-AW3TKUV2.js";import"./chunk-J7UYNRAP.js";import{$ as m,B as M,Bb as F,Cb as I,D,Db as g,Eb as o,Fb as i,Gb as x,J as C,Mb as v,Oa as A,Rb as u,Ta as d,Tb as c,V as h,aa as p,ac as n,bc as b,fa as S,gb as k,ma as s,oc as N,xb as _,yb as y,yc as V}from"./chunk-MKV7LIBF.js";import"./chunk-W23ILHFO.js";var B=()=>["/familia"],H=(a,t)=>t.id;function J(a,t){a&1&&(o(0,"div",4),n(1,"Carregando centro de ado\xE7\xE3o..."),i())}function K(a,t){if(a&1&&(o(0,"div",5),n(1),i()),a&2){let e=c();d(),b(e.loadError())}}function Q(a,t){if(a&1){let e=v();o(0,"div",17)(1,"div",23)(2,"div",24),x(3,"img",25),i(),o(4,"div",26)(5,"h3",27),n(6),i(),o(7,"p",28),n(8),i()()(),o(9,"div",29)(10,"button",30),u("click",function(){let l=m(e).$implicit,f=c(2);return p(f.openAdoptionModal(l))}),x(11,"i",31),n(12," Adotar "),i()()()}if(a&2){let e=t.$implicit;d(3),g("src",e.profilePhoto||"/assets/default-avatar.svg",A),d(3),b(e.fullName),d(2),b(e.city||"Cidade n\xE3o informada")}}function W(a,t){a&1&&(o(0,"div",18),x(1,"i",32),o(2,"p",33),n(3,"Nenhum amigo encontrado com esse nome."),i()())}function X(a,t){if(a&1){let e=v();o(0,"div",6)(1,"div",8)(2,"div",9)(3,"h1",10),n(4,"Centro de Ado\xE7\xE3o"),i(),o(5,"p",11),n(6,"Escolha um amigo da sua lista para assumir como seu filho ou filha na \xC1rvore Geneal\xF3gica."),i()(),o(7,"div",12)(8,"div",13),x(9,"i",14),o(10,"input",15),u("ngModelChange",function(l){m(e);let f=c();return p(f.search.set(l))}),i()()(),o(11,"div",16),F(12,Q,13,3,"div",17,H,!1,W,4,0,"div",18),i()(),o(15,"div",19)(16,"div",20)(17,"h3",21),n(18,"Processos Pendentes"),i(),o(19,"p",22),n(20,"Ap\xF3s envio, o convidado precisa aceitar no modal de confirma\xE7\xE3o da p\xE1gina Fam\xEDlia."),i()()()()}if(a&2){let e=c();d(10),g("ngModel",e.search()),d(2),I(e.filteredCandidates())}}function Z(a,t){if(a&1){let e=v();o(0,"div",7)(1,"button",34),u("click",function(){m(e);let l=c();return p(l.closeAdoptionModal())}),i(),o(2,"div",35)(3,"div",36)(4,"button",37),u("click",function(){m(e);let l=c();return p(l.closeAdoptionModal())}),x(5,"i",38),i(),o(6,"div",39),n(7,"\u{1F476}"),i()(),o(8,"div",40)(9,"h3",41),n(10,"Pedido de Ado\xE7\xE3o"),i(),o(11,"p",42),n(12,"Est\xE1 prestes a convidar "),o(13,"strong",43),n(14),i(),n(15," para ser seu filho(a)."),i(),o(16,"div",44)(17,"div")(18,"label",45),n(19,"Mensagem de Convite (Opcional)"),i(),o(20,"textarea",46),u("ngModelChange",function(l){m(e);let f=c();return p(f.adoptionMessage.set(l))}),i()(),o(21,"div")(22,"label",45),n(23,"Papel Espec\xEDfico"),i(),o(24,"select",47),u("ngModelChange",function(l){m(e);let f=c();return p(f.roleLabel.set(l))}),o(25,"option",48),n(26,"Filho(a) Leg\xEDtimo(a)"),i(),o(27,"option",49),n(28,"Filho(a) Adotivo(a)"),i(),o(29,"option",50),n(30,"Filho(a) Rebelde"),i(),o(31,"option",51),n(32,"Filho(a) Preferido(a)"),i()()()(),o(33,"div",52)(34,"button",53),u("click",function(){m(e);let l=c();return p(l.closeAdoptionModal())}),n(35,"Cancelar"),i(),o(36,"button",54),u("click",function(){m(e);let l=c();return p(l.sendAdoptionRequest())}),n(37," Enviar Pedido "),i()()()()()}if(a&2){let e=c();d(14),b(t.fullName),d(6),g("ngModel",e.adoptionMessage()),d(4),g("ngModel",e.roleLabel()),d(12),g("disabled",e.actionLoading())}}var Y=class a{authSession=h(T);familyApi=h(G);destroyRef=h(S);activeProfileId$=E(this.authSession.activeProfileId);loading=s(!0);actionLoading=s(!1);loadError=s(null);canManageFamily=s(!1);candidates=s([]);familyId=s(null);search=s("");selectedCandidate=s(null);adoptionMessage=s("");roleLabel=s("Filho(a) Leg\xEDtimo(a)");modalOpen=s(!1);filteredCandidates=V(()=>{let t=this.search().trim().toLowerCase();return t?this.candidates().filter(e=>e.fullName.toLowerCase().includes(t)):this.candidates()});constructor(){this.activeProfileId$.pipe(w(this.destroyRef),C(t=>{if(!t)throw new Error("no_active_profile");return this.loading.set(!0),this.familyApi.getMyFamily(t)}),C(t=>{if(!t.family)throw this.loading.set(!1),this.loadError.set("Voc\xEA ainda n\xE3o possui fam\xEDlia ativa para ado\xE7\xE3o."),new Error("no_family");if(t.members.find(r=>r.profile.id===t.profileId)?.role!=="owner")throw this.loading.set(!1),this.loadError.set("Apenas a matriarca/patriarca pode enviar convites de ado\xE7\xE3o."),new Error("no_permission");return this.canManageFamily.set(!0),this.familyId.set(t.family.id),this.familyApi.listCandidates(t.fam
1ily.id,t.profileId,"adoption")})).subscribe({next:t=>{this.candidates.set(t.items),this.loading.set(!1)},error:()=>{this.loadError()||this.loadError.set("N\xE3o foi poss\xEDvel carregar o centro de ado\xE7\xE3o."),this.loading.set(!1)}}),E(this.search).pipe(M(250),D(),w(this.destroyRef)).subscribe(()=>this.refreshCandidates())}openAdoptionModal(t){this.selectedCandidate.set(t),this.adoptionMessage.set(""),this.roleLabel.set("Filho(a) Leg\xEDtimo(a)"),this.modalOpen.set(!0)}closeAdoptionModal(){this.modalOpen.set(!1),this.selectedCandidate.set(null)}sendAdoptionRequest(){let t=this.authSession.activeProfileId(),e=this.familyId(),r=this.selectedCandidate();!t||!e||!r||!this.canManageFamily()||(this.actionLoading.set(!0),this.familyApi.sendRequest(e,{actorProfileId:t,targetProfileId:r.id,type:"adoption",requestedRoleLabel:this.roleLabel(),message:this.adoptionMessage()}).subscribe({next:()=>{this.actionLoading.set(!1),this.closeAdoptionModal(),this.refreshCandidates()},error:()=>{this.actionLoading.set(!1)}}))}refreshCandidates(){let t=this.authSession.activeProfileId(),e=this.familyId();!t||!e||!this.canManageFamily()||this.familyApi.listCandidates(e,t,"adoption",this.search()).subscribe({next:r=>this.candidates.set(r.items)})}static \u0275fac=function(e){return new(e||a)};static \u0275cmp=k({type:a,selectors:[["app-centro-de-adocao"]],decls:9,vars:4,consts:[[1,"max-w-7xl","mx-auto","pt-24","px-4","md:px-6","mb-20","text-slate-600","antialiased"],[1,"mb-6","fade-in"],[1,"flex","items-center","gap-2","text-sm","font-bold","text-slate-500","hover:text-orkut-blue",3,"routerLink"],[1,"fa","fa-arrow-left"],[1,"bg-white","rounded-2xl","border","border-slate-100","p-6","shadow-soft"],[1,"bg-red-50","border","border-red-100","text-red-600","rounded-2xl","p-4","text-sm"],[1,"grid","grid-cols-1","lg:grid-cols-12","gap-8"],[1,"fixed","inset-0","z-[80]"],[1,"lg:col-span-6","space-y-6","fade-in"],[1,"bg-gradient-to-r","from-sky-400","via-blue-400","to-indigo-500","rounded-3xl","p-8","text-white","shadow-lg","relative","overflow-hidden"],[1,"text-3xl","font-extrabold","mb-2"],[1,"text-blue-50","text-sm","max-w-md"],[1,"bg-white","rounded-2xl","shadow-soft","p-2","flex","justify-between","items-center","border","border-slate-100","sticky","top-20","z-40"],[1,"flex-1","relative"],[1,"fa","fa-search","absolute","left-4","top-3","text-slate-400","text-sm"],["type","text","placeholder","Procurar um amigo para adotar...",1,"w-full","bg-transparent","border-none","outline-none","text-sm","pl-11","pr-4","py-2","text-slate-700",3,"ngModelChange","ngModel"],["id","friends-grid",1,"grid","grid-cols-1","sm:grid-cols-2","gap-4"],[1,"bg-white","rounded-2xl","p-4","border","border-slate-100","shadow-sm","hover:shadow-md","hover:border-orkut-blue","transition-all","flex","flex-col","group","h-full"],[1,"col-span-full","py-12","text-center","text-slate-400","bg-white","rounded-2xl","border","border-slate-100","shadow-sm"],[1,"lg:col-span-3","space-y-6","fade-in"],[1,"bg-white","rounded-2xl","shadow-soft","p-5","border","border-slate-100"],[1,"font-bold","text-slate-800","text-sm","mb-2"],[1,"text-xs","text-slate-400"],[1,"flex","gap-3","mb-4"],[1,"relative","flex-shrink-0"],[1,"w-12","h-12","rounded-xl","object-cover","border","border-slate-100","group-hover:scale-105","transition-transform",3,"src"],[1,"flex-1","min-w-0"],[1,"font-bold","text-slate-800","text-sm","truncate","group-hover:text-orkut-blue","transition-colors"],[1,"text-[10px]","text-slate-400","mt-0.5"],[1,"mt-auto"],[1,"w-full","bg-blue-50","hover:bg-orkut-blue","text-orkut-blue","hover:text-white","font-bold","py-2","rounded-xl","text-xs","transition-colors","flex","items-center","justify-center","gap-2",3,"click"],[1,"fa","fa-baby"],[1,"fa","fa-search","text-4xl","mb-3","text-slate-200"],[1,"text-sm","font-bold"],[1,"absolute","inset-0","bg-black/60","backdrop-blur-sm",3,"click"],[1,"absolute","top-1/2","left-1/2","-translate-x-1/2","-translate-y-1/2","bg-white","rounded-3xl","shadow-2xl","w-full","max-w-md","border","border-slate-100","overflow-hidden"],[1,"bg-amber-50","h-32","relative","flex","justify-center","items-end","pb-8","border-b-4","border-amber-200"],["aria-label","Fechar",1,"absolute","top-4","right-4","w-8","h-8","bg-black/10","hover:bg-black/20","text-amber-900","rounded-full","flex","items-center","justify-center",3,"click"],[1,"fa","fa-times"],[1,"absolute","-bottom-10","w-20","h-20","rounded-full","flex","items-center","justify-center","text-4xl","border-4","border-white","shadow-lg","bg-gradient-to-br","from-blue-200","to-pink-200"],[1,"pt-14","px-6","pb-6","text-center"],[1,"text-lg","font-bold","text-slate-800","mb-1"],[1,"text-sm","text-slate-500","mb-6"],[1,"text-orkut-blue"],[1,"bg-slate-50","rounded-2xl","p-4","border","border-slate-200","text-left","space-y-4"],[1,"block","text-[10px]","font-bold","text-slate-400","uppercase","tracking-wider","mb-2"],["rows","3",1,"w-full","bg-white","border","border-slate-200","rounded-xl","px-4","py-3","text-sm","focus:border-orkut-blue","outline-none","resize-none",3,"ngModelChange","ngModel"],[1,"w-full","bg-white","border","border-slate-200","rounded-xl","px-4","py-3","text-sm","font-medium","text-slate-700","outline-none","focus:border-orkut-blue",3,"ngModelChange","ngModel"],["value","Filho(a) Leg\xEDtimo(a)"],["value","Filho(a) Adotivo(a)"],["value","Filho(a) Rebelde"],["value","Filho(a) Preferido(a)"],[1,"mt-6","flex","gap-3"],[1,"flex-1","bg-slate-100","hover:bg-slate-200","text-slate-600","font-bold","py-3","rounded-xl",3,"click"],[1,"flex-1","bg-orkut-blue","hover:bg-blue-600","text-white","font-bold","py-3","rounded-xl","shadow-lg","shadow-blue-500/30",3,"click","disabled"]],template:function(e,r){if(e&1&&(o(0,"main",0)(1,"div",1)(2,"a",2),x(3,"i",3),n(4," Voltar para \xC1rvore Geneal\xF3gica "),i()(),_(5,J,2,0,"div",4)(6,K,2,1,"div",5)(7,X,21,2,"div",6),_(8,Z,38,4,"div",7),i()),e&2){let l;d(2),g("routerLink",N(3,B)),d(3),y(r.loading()?5:r.loadError()?6:7),d(3),y((l=r.modalOpen()&&r.selectedCandidate())?8:-1,l)}},dependencies:[L,U,q,z,O,$,R,j,P],styles:[".fade-in[_ngcontent-%COMP%]{animation:_ngcontent-%COMP%_fadeIn .4s ease-in-out forwards}@keyframes _ngcontent-%COMP%_fadeIn{0%{opacity:0;transform:translateY(10px)}to{opacity:1;transform:translateY(0)}}"],changeDetection:0})};export{Y as CentroDeAdocaoComponent};
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.