PageSourceSearch

https://realastrology.ai/assets/AdminUnitEconomics-C_94uJGg.js

js realastrology.ai collected 2026-10-05 15:14:04 UTC 15,304 bytes, 5 lines download raw bytes

1
2!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="34cabee1-3f56-55ba-981b-4023137a8f43")}catch(e){}}();
3import{j as e}from"./radix-Dv40WeBR.js";import{r as m}from"./react-vendor-DMCBMKwH.js";import{E as A,cz as C,cH as $,B as R,R as E,A as N,a1 as L,C as u,d as x,e as p,g as _}from"./index-DY-XyNlk.js";import{A as B,a as F}from"./alert-BNJPzo3Z.js";import{A as D}from"./alert-circle-gCOO3Nso.js";import"./i18n-CRxfqRtU.js";import"./charts-D11ksbhN.js";function q(s){const o=s.trim();if(!o)return;const l=o.replace(/\./g,"").replace(",","."),c=Number(l);if(!(!Number.isFinite(c)||c<0))return Math.round(c*100)}const O="/api/v1/admin/unit-economics",z={getSummary(s=30,o){const l=new URLSearchParams({days:String(s)});return o!==void 0&&o>0&&l.set("spend_cents",String(o)),A.get(`${O}/summary?${l.toString()}`)}},I=[7,30,90];function t(s){return(s/100).toLocaleString("pt-BR",{style:"currency",currency:"BRL",minimumFractionDigits:2})}function h(s){return s===null?"—":`${(s*100).toFixed(1)}%`}function i(s,o){return s===null?"—":o(s)}function T(s){switch(s.spend_status){case"not_configured":return"Verba não informada. Digite o valor do período acima, ou configure a leitura automática da conta de anúncios.";case"expired":return"O token da Meta expirou — gere um novo com escopo ads_read. Até lá, informe a verba à mão acima.";case"unauthorized":return"O token da Meta não tem permissão de leitura na conta de anúncios (ads_read). Informe a verba à mão acima.";case"error":return`Não foi possível ler o gasto da Meta${s.spend_detail?`: ${s.spend_detail}`:""}. Informe a verba à mão acima.`;default:return"Informe a verba do período acima para ver o que sobra depois da mídia."}}function P(s){const o=[];return s.llm_cost_real_share!==null&&s.llm_cost_real_share<.9&&o.push(`medido em ${h(s.llm_cost_real_share)} das linhas — custo subestimado`),s.llm_measuring_from&&o.push(`medindo desde ${new Date(s.llm_measuring_from).toLocaleDateString("pt-BR")}`),o.length?o.join(" · "):void 0}function U(s){if(s.llm_cost_real_share===null)return"nenhuma venda na janela";const o=s.llm_cost_lines-s.lines_missing_llm_cost;if(s.llm_cost_real_share>=.9){const l=s.llm_cost_ambiguous_cents>0?` · ${t(s.llm_cost_ambiguous_cents)} de mapa com mais de um produto`:"";return`${o} de ${s.llm_cost_lines} linhas${l} · mapa anterior à instrumentação tem custo parcial`}return"custo subestimado — margem otimista"}function H(s){if(s!==null)return s>=.9?"good":s>=.5?void 0:"bad"}function r({label:s,value:o,hint:l,tone:c}){return e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:s}),e.jsx("p",{className:N("text-2xl font-semibold tabular-nums",c==="good"&&"text-green-600 dark:text-green-500",c==="bad"&&"text-destructive"),children:o}),l&&e.jsx("p",{className:"text-xs text-muted-foreground",children:l})]})}function Y(){const[s,o]=m.useState(null),[l,c]=m.useState(30),[j,k]=m.useState(""),[g,y]=m.useState(!0),[w,S]=m.useState(null),f=m.useRef(0),v=m.useCallback(async()=>{const a=++f.current;y(!0),S(null);try{const b=q(j),M=await z.getSummary(l,b);a===f.current&&o(M)}catch(b){a===f.current&&S(C(b))}finally{a===f.current&&y(!1)}},[l,j]);m.useEffect(()=>{v()},[v]);const n=s==null?void 0:s.totals,d=s==null?void 0:s.break_even;return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx($,{className:"h-5 w-5 text-primary"}),e.jsx("h1",{className:"text-2xl font-semibold",children:"Margem de contribuição"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[I.map(a=>e.jsxs(R,{size:"sm",variant:l===a?"default":"outline",onClick:()=>c(a),children:[a,"d"]},a)),e.jsx(R,{size:"sm",variant:"outline",onClick:()=>void v(),disabled:g,children:e.jsx(E,{className:N("h-4 w-4",g&&"animate-spin")})})]})]}),w&&e.jsxs(B,{variant:"destructive",children:[e.jsx(D,{className:"h-4 w-4"}),e.jsx(F,{children:w})]}),g&&!s&&e.jsx(L,{className:"h-64 w-full"}),n&&d&&s&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs(u,{children:[e.jsx(x,{children:e.jsx(p,{className:"text-base",children:"Break-even de contribuição"})}),e.jsxs(_,{className:"space-y-3",children:[e.jsx(r,{label:"ROAS mínimo",value:i(d.contribution.roas,a=>a.toFixed(2)),hint:"Abaixo disto a campanha queima caixa em cada venda. É piso, não alvo."}),e.jsx(r,{label:"CPA máximo",value:i(d.contribution.max_cpa_cents,t),hint:"O mesmo piso, na unidade que se compra."})]})]}),e.jsxs(u,{children:[e.jsx(x,{children:e.jsx(p,{className:"text-base",children:"Break-even total (MER)"})}),e.jsxs(_,{className:"space-y-3",children:[d.total.suppressed_reason?e.jsx("p",{className:"text-sm text-muted-foreground",children:d.total.suppressed_reason}):e.jsx(r,{label:"MER mínimo",value:i(d.total.mer,a=>a.toFixed(2)),hint:"Inclui o custo fixo. Cai conforme a verba sobe."}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-xs text-muted-foreground",htmlFor:"spend",children:"Verba do período (R$)"}),e.jsx("input",{id:"spend",inputMode:"decimal",value:j,onChange:a=>k(a.target.value),placeholder:"ex: 3150,00",className:"w-full rounded-md border border-border bg-background px-3 py-2 text-sm"})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[e.jsx("strong",{children:"É MER, não ROAS."})," Sem atribuição por pedido este número inclui receita orgânica, que campanha nenhuma comprou — enquanto o ROAS de campanha da Meta a exclui. Comparar os dois faz uma campanha lucrativa parecer prejuízo."]})]})]})]}),e.jsxs(u,{children:[e.jsx(x,{children:e.jsx(p,{className:"text-base",children:"Depois dos anúncios"})}),e.jsx(_,{className:"space-y-4",children:s.after_ads.spend_cents===null?e.jsx("p",{className:"text-sm text-muted-foreground",children:T(s.after_ads)}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-4 sm:grid-cols-3",children:[e.jsx(r,{label:"Verba do período",value:t(s.after_ads.spend_cents),hint:s.after_ads.spend_source==="meta"?"Lido da conta de anúncios":"Informado à mão"}),e.jsx(r,{label:"Lucro após marketing",value:i(s.after_ads.profit_after_ads_cents,t),hint:"Margem de contribuição menos a verba.",tone:s.after_ads.profit_after_ads_cents===null?void 0:s.after_ads.profit_after_ads_cents>=0?"good":"bad"}),e.jsx(r,{label:"Lucro líquido",value:i(s.after_ads.net_profit_cents,t),hint:"Descontado também o custo fixo do período.",tone:s.after_ads.net_profit_cents===null?void 0:s.after_ads.net_profit_cents>=0?"good":"bad"})]}),e.jsxs("div",{className:"flex flex-wrap items-baseline gap-x-6 gap-y-1 border-t border-border pt-3",children:[e.jsxs("span",{className:"text-sm",children:["MER realizado"," ",e.jsx("strong",{className:"tabular-nums",children:i(s.after_ads.realized_mer,a=>a.toFixed(2))})]}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:["break-even"," ",d.total.suppressed_reason?"—":i(d.total.mer,a=>a.toFixed(2))]}),s.after_ads.beats_break_even!==null&&e.jsx("span",{className:N("text-sm font-semibold",s.after_ads.beats_break_even?"text-green-600 dark:text-green-500":"text-destructive"),children:s.after_ads.beats_break_even?"acima do break-even":"abaixo"})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[e.jsx("strong",{children:"O MER realizado é blended."})," A receita aqui inclui vendas orgânicas, que a verba não comprou. Ele responde “a operação inteira paga a mídia?”, não “e
3sta campanha é lucrativa?”."]})]})})]}),e.jsxs(u,{children:[e.jsx(x,{children:e.jsxs(p,{className:"text-base",children:["Da receita à margem — ",s.start_date," a ",s.end_date]})}),e.jsxs(_,{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-4",children:[e.jsx(r,{label:"Receita bruta",value:t(n.gross_revenue_cents)}),e.jsx(r,{label:"Reembolsos",value:t(-n.refunds_cents),hint:"A taxa não volta: o gateway fica com ela.",tone:n.refunds_cents>0?"bad":void 0}),e.jsx(r,{label:"Taxa de gateway",value:t(-n.gateway_fee_cents)}),e.jsx(r,{label:"Imposto",value:t(-n.tax_cents)}),e.jsx(r,{label:"Custo de LLM",value:t(-n.llm_cost_cents),hint:P(s.data_quality)}),e.jsx(r,{label:"Margem de contribuição",value:t(n.contribution_margin_cents),hint:h(n.contribution_margin_rate),tone:n.contribution_margin_cents>=0?"good":"bad"}),e.jsx(r,{label:"Custo fixo do período",value:t(-n.fixed_cost_cents),hint:n.fixed_cost_credits_cents!==null&&n.fixed_cost_credits_cents>0?"bruto — é este que decide":void 0}),n.fixed_cost_credits_cents!==null&&n.fixed_cost_credits_cents>0&&n.fixed_cost_after_credits_cents!==null&&e.jsx(r,{label:"↳ com crédito aplicado",value:t(-n.fixed_cost_after_credits_cents),hint:`${t(n.fixed_cost_credits_cents)} abatidos — só informativo, não entra no lucro abaixo`}),e.jsx(r,{label:"Lucro operacional",value:t(n.operating_profit_cents),tone:n.operating_profit_cents>=0?"good":"bad"})]})]}),e.jsxs(u,{children:[e.jsx(x,{children:e.jsx(p,{className:"text-base",children:"Por produto"})}),e.jsx(_,{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-border text-left text-xs text-muted-foreground",children:[e.jsx("th",{className:"py-2 pr-4",children:"Produto"}),e.jsx("th",{className:"py-2 pr-4 text-right",children:"Unid."}),e.jsx("th",{className:"py-2 pr-4 text-right",children:"Receita"}),e.jsx("th",{className:"py-2 pr-4 text-right",children:"LLM"}),e.jsx("th",{className:"py-2 pr-4 text-right",children:"Margem"}),e.jsx("th",{className:"py-2 pr-4 text-right",children:"%"}),e.jsx("th",{className:"py-2 text-right",children:"BE ROAS"})]})}),e.jsx("tbody",{children:s.by_product.map(a=>e.jsxs("tr",{className:"border-b border-border/50",children:[e.jsx("td",{className:"py-2 pr-4",children:a.product_type}),e.jsx("td",{className:"py-2 pr-4 text-right tabular-nums",children:a.units}),e.jsx("td",{className:"py-2 pr-4 text-right tabular-nums",children:t(a.net_revenue_cents)}),e.jsx("td",{className:"py-2 pr-4 text-right tabular-nums text-muted-foreground",children:t(a.llm_cost_cents)}),e.jsx("td",{className:"py-2 pr-4 text-right tabular-nums",children:t(a.contribution_margin_cents)}),e.jsx("td",{className:"py-2 pr-4 text-right tabular-nums",children:h(a.contribution_margin_rate)}),e.jsx("td",{className:"py-2 text-right tabular-nums",children:i(a.break_even_roas,b=>b.toFixed(2))})]},a.product_type))})]})})]}),e.jsxs(u,{children:[e.jsx(x,{children:e.jsx(p,{className:"text-base",children:"Impacto do order bump"})}),e.jsxs(_,{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-4",children:[e.jsx(r,{label:"Attach rate",value:h(s.bump_impact.attach_rate)}),e.jsx(r,{label:"Margem com bump",value:t(s.bump_impact.cm_with_bump_cents)}),e.jsx(r,{label:"Margem sem bump",value:t(s.bump_impact.cm_without_bump_cents),hint:"A taxa não encolhe: é por pedido, e o pedido continua existindo."}),e.jsx(r,{label:"BE ROAS sem bump",value:i(s.bump_impact.break_even_roas_without_bump,a=>a.toFixed(2))})]})]}),e.jsxs(u,{children:[e.jsx(x,{children:e.jsx(p,{className:"text-base",children:"O que é medido e o que é premissa"})}),e.jsxs(_,{className:"space-y-4 text-sm",children:[e.jsxs("div",{className:"grid gap-4 sm:grid-cols-3",children:[e.jsx(r,{label:"Taxa de gateway real",value:h(s.data_quality.gateway_fee_real_share),hint:"% do valor; o resto é taxa fixa publicada"}),e.jsx(r,{label:"Custo de LLM real",value:h(s.data_quality.llm_cost_real_share),hint:U(s.data_quality),tone:H(s.data_quality.llm_cost_real_share)}),e.jsx(r,{label:"Pedidos sem trilho",value:String(s.data_quality.orders_missing_payment_method),hint:"não dá para escolher a taxa certa"})]}),s.data_quality.fee_by_rail.length>0&&e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-border text-left text-muted-foreground",children:[e.jsx("th",{className:"py-1.5 pr-3",children:"Trilho"}),e.jsx("th",{className:"py-1.5 pr-3 text-right",children:"Pedidos"}),e.jsx("th",{className:"py-1.5 pr-3 text-right",children:"Taxa"}),e.jsx("th",{className:"py-1.5 text-right",children:"Medida"})]})}),e.jsx("tbody",{children:s.data_quality.fee_by_rail.map(a=>e.jsxs("tr",{className:"border-b border-border/40",children:[e.jsxs("td",{className:"py-1.5 pr-3",children:[a.provider," · ",a.rail]}),e.jsx("td",{className:"py-1.5 pr-3 text-right tabular-nums",children:a.orders}),e.jsx("td",{className:"py-1.5 pr-3 text-right tabular-nums",children:t(a.fee_cents)}),e.jsx("td",{className:"py-1.5 text-right tabular-nums text-muted-foreground",children:a.orders_with_real_fee===a.orders?"toda":a.orders_with_real_fee===0?"tabela":`${a.orders_with_real_fee} de ${a.orders}`})]},`${a.provider}-${a.rail}`))})]}),e.jsxs("div",{className:"space-y-1 text-muted-foreground",children:[e.jsxs("p",{children:["Imposto: Simples Anexo ",s.assumptions.annex,", alíquota efetiva"," ",h(s.assumptions.tax_effective_rate)," sobre RBT12 de"," ",t(s.assumptions.rbt12_cents),"."]}),e.jsxs("p",{children:["Câmbio: ",i(s.assumptions.fx_usd_brl,a=>a.toFixed(2))," BRL/USD."]}),e.jsx("p",{children:s.assumptions.fallback_gateway_note})]}),e.jsxs("div",{children:[e.jsx("p",{className:"mb-2 text-xs text-muted-foreground",children:"Custo fixo mensal"}),e.jsx("ul",{className:"space-y-1",children:s.assumptions.fixed_costs.map(a=>e.jsxs("li",{className:"flex flex-wrap justify-between gap-2",children:[e.jsxs("span",{children:[a.label," ",e.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",a.source_note," — ",a.as_of,")"]})]}),e.jsx("span",{className:"tabular-nums",children:a.currency==="USD"?`US$ ${(a.monthly_cents/100).toFixed(2)}`:t(a.monthly_cents)})]},a.key))}),s.assumptions.cost_offsets.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("ul",{className:"mt-2 space-y-1 border-t pt-2",children:s.assumptions.cost_offsets.map(a=>e.jsxs("li",{className:"flex flex-wrap justify-between gap-2",children:[e.jsxs("span",{children:[a.label," ",e.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",a.source_note," — ",a.as_of,")"]})]}),e.jsxs("span",{className:"tabular-nums text-emerald-600 dark:text-emerald-400",children:["−",t(a.applied_monthly_cents_brl)]})]},a.key))}),e.jsxs("div",{className:"mt-2 flex flex-wrap justify-between gap-2 border-t pt-2 font-medium",children:[e.jsx("span",{children:"Desembolso mensal hoje"}),e.jsx("span",{className:"tabular-nums",children:s.assumptions.fixed_cost_net_monthly_total_cents!==null?t(s.assumptions.fixed_cost_net_monthly_total_cents):"—"})]}),e.jsxs("p",{className:"mt-2 text-xs text-muted-foreground",children:["Break-even e lucro operacional usam o custo ",e.jsx("strong",{children:"bruto"})," (",t(s.assumptions.fixed_cost_monthly_total_cents??0),"), não este. O abatimento acaba em"," ",s.assumptions.cost_offsets.map(a=>
3a.effective_to).filter(Boolean).sort()[0]??"data não declarada","."]})]})]})]})]})]})]})}export{Y as AdminUnitEconomics};
4
5//# debugId=34cabee1-3f56-55ba-981b-4023137a8f43

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.