1import{r as d,j as e}from"./react-vendor-pafHdoJx.js";import{b as C,d as g,u as z,l as B}from"./index-Db0fDLGN.js";import{L as v,R as O,as as y,o as R,ae as x,s as E,l as F,aO as A}from"./ui-vendor-DLXJn6s3.js";import"./map-vendor-Dr8zbd0c.js";import"./firebase-vendor-D3UzkAhn.js";const n={background:"var(--surface-secondary)",border:"1px solid var(--border-primary)",borderRadius:12,padding:16};function o(r){return r==null?"#94A3B8":r>=21?"#EF4444":r>=7?"#F59E0B":"#3B82F6"}function T(){const[r,j]=d.useState(!1),[m,p]=d.useState(null),[l,f]=d.useState(null),{data:t,loading:b,error:u,refetch:i}=C(()=>g.adminActivation(r),[r]),{toast:N}=z(),k=async a=>{p(a);try{await g.adminRefreshActivation(a),await i(),B("activation_refresh_org",{})}catch(s){N({title:(s==null?void 0:s.message)||"Falha ao reapurar",kind:"error"})}finally{p(null)}};if(b&&!t)return e.jsxs("div",{className:"flex items-center gap-2 p-8",style:{color:"var(--page-text-secondary)"},children:[e.jsx(v,{className:"animate-spin",size:18})," Apurando marcos de ativaçãoâ¦"]});if(u||!t)return e.jsxs("div",{style:{...n,borderColor:"#EF4444"},children:[e.jsx("p",{className:"text-sm font-semibold",style:{color:"#EF4444"},children:"Não consegui carregar a ativação."}),e.jsx("p",{className:"text-xs mt-1",style:{color:"var(--page-text-secondary)"},children:u||"resposta vazia"}),e.jsx("button",{onClick:i,className:"mt-2 text-sm underline",style:{color:"var(--page-text-secondary)"},children:"Tentar de novo"})]});const h=t.blockers||[],c=t.orgs||[],w=c.filter(a=>!a.activated);return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{style:n,children:[e.jsxs("div",{className:"flex items-start justify-between gap-4 flex-wrap",children:[e.jsxs("div",{children:[e.jsxs("p",{className:"text-sm font-semibold flex items-center gap-1.5",style:{color:"var(--page-text)"},children:[e.jsx(O,{size:15,style:{color:"#3B82F6"}})," Ativação da base"]}),e.jsx("p",{className:"text-xs mt-1",style:{color:"var(--page-text-secondary)"},children:"Marcos apurados dos dados reais â ninguém marca nada à mão."})]}),e.jsxs("div",{className:"flex items-end gap-6",children:[e.jsxs("div",{className:"text-right",children:[e.jsx("p",{className:"text-3xl font-bold tabular-nums leading-none",style:{color:"#10B981"},children:t.activationRate==null?"â":`${t.activationRate}%`}),e.jsxs("p",{className:"text-[11px] mt-1",style:{color:"var(--page-text-muted)"},children:[t.activated," de ",t.total," no momento aha"]})]}),e.jsxs("div",{className:"text-right",children:[e.jsx("p",{className:"text-3xl font-bold tabular-nums leading-none",style:{color:"#F59E0B"},children:w.length}),e.jsx("p",{className:"text-[11px] mt-1",style:{color:"var(--page-text-muted)"},children:"ainda em onboarding"})]})]})]}),e.jsxs("div",{className:"flex items-center gap-3 mt-3 flex-wrap",children:[e.jsxs("label",{className:"flex items-center gap-1.5 text-xs cursor-pointer",style:{color:"var(--page-text-secondary)"},children:[e.jsx("input",{type:"checkbox",checked:r,onChange:a=>j(a.target.checked)}),"incluir orgs demo"]}),e.jsxs("button",{onClick:i,className:"text-xs flex items-center gap-1 underline",style:{color:"var(--page-text-secondary)"},children:[e.jsx(y,{size:11})," reapurar"]}),t.stale>0&&e.jsxs("span",{className:"text-[11px] flex items-center gap-1",style:{color:"#F59E0B"},children:[e.jsx(R,{size:11}),t.stale," org(s) com apuração antiga â reapure de novo pra atualizar o resto"]})]})]}),e.jsxs("div",{style:n,children:[e.jsx("p",{className:"text-xs font-semibold uppercase tracking-wide mb-3",style:{color:"var(--page-text-secondary)"},children:"Onde a base está travada"}),h.length===0?e.jsxs("p",{className:"text-sm flex items-center gap-1.5",style:{color:"#10B981"},children:[e.jsx(x,{size:15})," Ninguém travado â toda a base chegou no momento aha."]}):e.jsx("div",{className:"space-y-2",children:h.map(a=>e.jsxs("div",{children:[e.jsxs("button",{onClick:()=>f(l===a.blockedOn?null:a.blockedOn),className:"w-full rounded-lg border p-3 flex items-center justify-between gap-3 text-left hover-surface",style:{borderColor:"var(--border-primary)",background:"var(--surface-primary)"},"aria-expanded":l===a.blockedOn,children:[e.jsxs("div",{className:"flex items-center gap-2.5 min-w-0",children:[e.jsx("span",{className:"text-lg font-bold tabular-nums shrink-0",style:{color:o(a.maxStalledDays)},children:a.count}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",style:{color:"var(--page-text)"},children:a.label}),e.jsxs("p",{className:"text-[11px]",style:{color:"var(--page-text-muted)"},children:["travado há até ",a.maxStalledDays," dia(s)"]})]})]}),e.jsx(E,{size:15,className:"shrink-0",style:{color:"var(--page-text-muted)",transform:l===a.blockedOn?"rotate(90deg)":void 0}})]}),l===a.blockedOn&&e.jsx("div",{className:"mt-1 ml-4 space-y-1",children:a.orgs.map(s=>e.jsxs("p",{className:"text-xs flex items-center justify-between gap-2 py-1",style:{color:"var(--page-text-secondary)"},children:[e.jsx("span",{className:"truncate",children:s.orgName}),e.jsxs("span",{className:"tabular-nums shrink-0",style:{color:o(s.stalledDays)},children:[s.stalledDays,"d"]})]},s.orgId))})]},a.blockedOn))})]}),e.jsxs("div",{style:n,children:[e.jsxs("p",{className:"text-xs font-semibold uppercase tracking-wide mb-3",style:{color:"var(--page-text-secondary)"},children:["Checklist por organização (",c.length,")"]}),c.length===0?e.jsxs("p",{className:"text-sm",style:{color:"var(--page-text-secondary)"},children:["Nenhuma organização ativa na base",r?"":" (fora as demo)","."]}):e.jsx("div",{className:"space-y-2",children:c.map(a=>e.jsxs("div",{className:"rounded-lg border p-3",style:{borderColor:"var(--border-primary)",background:"var(--surface-primary)"},children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 flex-wrap",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("p",{className:"text-sm font-semibold flex items-center gap-1.5",style:{color:"var(--page-text)"},children:[a.activated?e.jsx(x,{size:13,style:{color:"#10B981"}}):e.jsx(F,{size:13,style:{color:o(a.stalledDays)}}),e.jsx("span",{className:"truncate",children:a.orgName})]}),e.jsxs("p",{className:"text-[11px] mt-0.5",style:{color:"var(--page-text-muted)"},children:[a.blueprintId||"sem blueprint"," · ",a.doneCount,"/",a.total," marcos",a.activated?" · ativada":a.blockedLabel?` · travada em "${a.blockedLabel}" há ${a.stalledDays}d`:""]})]}),e.jsxs("button",{onClick:()=>k(a.orgId),disabled:m===a.orgId,className:"text-[11px] flex items-center gap-1 px-2 py-1 rounded disabled:opacity-50 hover-surface",style:{color:"var(--page-text-secondary)"},"aria-label":`Reapurar ${a.orgName}`,children:[m===a.orgId?e.jsx(v,{size:11,className:"animate-spin"}):e.jsx(y,{size:11})," reapurar"]})]}),e.jsx("div",{className:"h-1.5 rounded-full mt-2 overflow-hidden",style:{background:"var(--border-primary)"},children:e.jsx("div",{className:"h-full rounded-full",style:{width:`${a.percent}%`,background:a.activated?"#10B981":o(a.stalledDays)}})}),e.jsx("div",{className:"flex flex-wrap gap-x-3 gap-y-1 mt-2",children:(a.milestones||[]).map(s=>e.jsxs("span",{className:"text-[11px] flex items-center gap-1",title:s.done?s.label:s.hint,style:{color:s.done?"#10B981":"var(--page-text-muted)"},children:[s.done?e.jsx(x,{size:10}):e.jsx(A,{size:10}),s.label,s.id===a.aha&&e.jsx("span",{className:"font-bold",style:{color:"#3B82F6"},children:"â
"})]},s.id))}),!a.activated&&a.blockedHint&&e.jsxs("p",{className:"text-[11px] mt-2",style:{color:"var(--page-text-secondary)"},children:["â ",a.blockedHint]})]},a.orgId))}),e.jsx("p",{className:"text-[10px] mt-3",style:{color:"var(--page-text-muted)"},children:"â
= momento aha do blueprint (o marco que fecha o onboarding). Ativação e checklist 100% são coisas diferentes: dá pra ativar com marco intermediário ainda aberto."})]})]})}export{T as AtivacaoPanel};
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.