PageSourceSearch

https://snew.ai/assets/NuvemshopProductsSandboxPage-BPPRIfl2.js

js snew.ai collected 2026-10-05 15:08:52 UTC 54,120 bytes, 1 lines download raw bytes

1import{r as n,u as ae,j as e}from"./index-L9AYrVUw.js";import{P as _e}from"./ProductCmoProposal-DUJv8Qz-.js";import{p as he,cW as fe,aC as x,R as d,C as I,a as B,s as F,aB as oe,a3 as X,u as Ee}from"./PlanAccessModal-P_W2GThH.js";import{m as ke}from"./ArrowsClockwise.es-CX8V1pij.js";import{p as te}from"./ChartLineUp.es-Cj6aI3xb.js";import{n as xe}from"./Eye.es-UdlNEHEy.js";import{m as ye}from"./MagicWand.es-CAihBnXI.js";import{c as Ie}from"./Megaphone.es-CpcQHM6H.js";import{h as Pe}from"./ShieldCheck.es-DSaGknie.js";import{r as le,s as ve}from"./sanitized-commercial-metrics-Ctrrpq63.js";import{c as be,d as Me}from"./sheet-CL9mA1Sp.js";import{S as R}from"./skeleton-CthpmC5T.js";import{s as He}from"./productFunnel-DiJFcMU2.js";import{a as We,r as Oe,d as De,b as je,p as ie,e as $e,f as Ne}from"./sandboxCommercialOpportunities-BqgeVlPa.js";import{d as Se}from"./useCampaigns-Bxox62wz.js";import{c as Ze}from"./connectedStoreCompiler-B6HBdZ2d.js";import"./FloatingTopMenu-CIhwk2RR.js";import"./locale-Cctu0V3Y.js";import"./SnewLogo-Cg53XTnQ.js";import"./loadRecommendationContext-eK4jCmh4.js";import"./snewDefault-bcI9V4vY.js";import"./privateMedia-B7Po080i.js";import"./quickActions-Bt6kGa-B.js";import"./christmasCreativeDirections-Ceo-u5n5.js";import"./recipes-CtHnj9D9.js";import"./antiStock-CfefI4TX.js";import"./eligibility-B5UjMwH6.js";import"./overrides-DxGb-X-q.js";import"./types-YVLQw7aQ.js";import"./scoring-Oj4SgCwH.js";import"./generationHistory-D4RTxXIf.js";import"./historyKey-GcKgTVWl.js";import"./KnowledgeBasePage-DJT9Fkps.js";import"./ChatCircle.es-ys8V5LKI.js";import"./FloppyDisk.es-DCGe340Q.js";import"./Globe.es-5iBT42E4.js";import"./Image.es-BLTC_PgL.js";import"./Package.es-CyLjTX4J.js";import"./Palette.es-Dd5ZEM4v.js";import"./Target.es-Ds7XP-fd.js";import"./WarningCircle.es-CHfqKWRY.js";import"./hydrateStoreContext-CnRDd9GD.js";import"./sceneCovers-B-dE7_Ce.js";import"./stagingComposerPrompt-ut90SPpr.js";import"./cmoGenerationContext-Bbeq5hi5.js";const Ve=new Map([["bold",n.createElement(n.Fragment,null,n.createElement("path",{d:"M196,35.52C177.62,25.51,153.48,20,128,20S78.38,25.51,60,35.52C39.37,46.79,28,62.58,28,80v96c0,17.42,11.37,33.21,32,44.48,18.35,10,42.49,15.52,68,15.52s49.62-5.51,68-15.52c20.66-11.27,32-27.06,32-44.48V80C228,62.58,216.63,46.79,196,35.52ZM204,128c0,17-31.21,36-76,36s-76-19-76-36v-8.46a88.9,88.9,0,0,0,8,4.94c18.35,10,42.49,15.52,68,15.52s49.62-5.51,68-15.52a88.9,88.9,0,0,0,8-4.94ZM128,44c44.79,0,76,19,76,36s-31.21,36-76,36S52,97,52,80,83.21,44,128,44Zm0,168c-44.79,0-76-19-76-36v-8.46a88.9,88.9,0,0,0,8,4.94c18.35,10,42.49,15.52,68,15.52s49.62-5.51,68-15.52a88.9,88.9,0,0,0,8-4.94V176C204,193,172.79,212,128,212Z"}))],["duotone",n.createElement(n.Fragment,null,n.createElement("path",{d:"M216,80c0,26.51-39.4,48-88,48S40,106.51,40,80s39.4-48,88-48S216,53.49,216,80Z",opacity:"0.2"}),n.createElement("path",{d:"M128,24C74.17,24,32,48.6,32,80v96c0,31.4,42.17,56,96,56s96-24.6,96-56V80C224,48.6,181.83,24,128,24Zm80,104c0,9.62-7.88,19.43-21.61,26.92C170.93,163.35,150.19,168,128,168s-42.93-4.65-58.39-13.08C55.88,147.43,48,137.62,48,128V111.36c17.06,15,46.23,24.64,80,24.64s62.94-9.68,80-24.64ZM69.61,53.08C85.07,44.65,105.81,40,128,40s42.93,4.65,58.39,13.08C200.12,60.57,208,70.38,208,80s-7.88,19.43-21.61,26.92C170.93,115.35,150.19,120,128,120s-42.93-4.65-58.39-13.08C55.88,99.43,48,89.62,48,80S55.88,60.57,69.61,53.08ZM186.39,202.92C170.93,211.35,150.19,216,128,216s-42.93-4.65-58.39-13.08C55.88,195.43,48,185.62,48,176V159.36c17.06,15,46.23,24.64,80,24.64s62.94-9.68,80-24.64V176C208,185.62,200.12,195.43,186.39,202.92Z"}))],["fill",n.createElement(n.Fragment,null,n.createElement("path",{d:"M128,24C74.17,24,32,48.6,32,80v96c0,31.4,42.17,56,96,56s96-24.6,96-56V80C224,48.6,181.83,24,128,24Zm80,104c0,9.62-7.88,19.43-21.61,26.92C170.93,163.35,150.19,168,128,168s-42.93-4.65-58.39-13.08C55.88,147.43,48,137.62,48,128V111.36c17.06,15,46.23,24.64,80,24.64s62.94-9.68,80-24.64Zm-21.61,74.92C170.93,211.35,150.19,216,128,216s-42.93-4.65-58.39-13.08C55.88,195.43,48,185.62,48,176V159.36c17.06,15,46.23,24.64,80,24.64s62.94-9.68,80-24.64V176C208,185.62,200.12,195.43,186.39,202.92Z"}))],["light",n.createElement(n.Fragment,null,n.createElement("path",{d:"M128,26C75.29,26,34,49.72,34,80v96c0,30.28,41.29,54,94,54s94-23.72,94-54V80C222,49.72,180.71,26,128,26Zm0,12c44.45,0,82,19.23,82,42s-37.55,42-82,42S46,102.77,46,80,83.55,38,128,38Zm82,138c0,22.77-37.55,42-82,42s-82-19.23-82-42V154.79C62,171.16,92.37,182,128,182
1s66-10.84,82-27.21Zm0-48c0,22.77-37.55,42-82,42s-82-19.23-82-42V106.79C62,123.16,92.37,134,128,134s66-10.84,82-27.21Z"}))],["regular",n.createElement(n.Fragment,null,n.createElement("path",{d:"M128,24C74.17,24,32,48.6,32,80v96c0,31.4,42.17,56,96,56s96-24.6,96-56V80C224,48.6,181.83,24,128,24Zm80,104c0,9.62-7.88,19.43-21.61,26.92C170.93,163.35,150.19,168,128,168s-42.93-4.65-58.39-13.08C55.88,147.43,48,137.62,48,128V111.36c17.06,15,46.23,24.64,80,24.64s62.94-9.68,80-24.64ZM69.61,53.08C85.07,44.65,105.81,40,128,40s42.93,4.65,58.39,13.08C200.12,60.57,208,70.38,208,80s-7.88,19.43-21.61,26.92C170.93,115.35,150.19,120,128,120s-42.93-4.65-58.39-13.08C55.88,99.43,48,89.62,48,80S55.88,60.57,69.61,53.08ZM186.39,202.92C170.93,211.35,150.19,216,128,216s-42.93-4.65-58.39-13.08C55.88,195.43,48,185.62,48,176V159.36c17.06,15,46.23,24.64,80,24.64s62.94-9.68,80-24.64V176C208,185.62,200.12,195.43,186.39,202.92Z"}))],["thin",n.createElement(n.Fragment,null,n.createElement("path",{d:"M192.14,42.55C174.94,33.17,152.16,28,128,28S81.06,33.17,63.86,42.55C45.89,52.35,36,65.65,36,80v96c0,14.35,9.89,27.65,27.86,37.45,17.2,9.38,40,14.55,64.14,14.55s46.94-5.17,64.14-14.55c18-9.8,27.86-23.1,27.86-37.45V80C220,65.65,210.11,52.35,192.14,42.55ZM212,176c0,11.29-8.41,22.1-23.69,30.43C172.27,215.18,150.85,220,128,220s-44.27-4.82-60.31-13.57C52.41,198.1,44,187.29,44,176V149.48c4.69,5.93,11.37,11.34,19.86,16,17.2,9.38,40,14.55,64.14,14.55s46.94-5.17,64.14-14.55c8.49-4.63,15.17-10,19.86-16Zm0-48c0,11.29-8.41,22.1-23.69,30.43C172.27,167.18,150.85,172,128,172s-44.27-4.82-60.31-13.57C52.41,150.1,44,139.29,44,128V101.48c4.69,5.93,11.37,11.34,19.86,16,17.2,9.38,40,14.55,64.14,14.55s46.94-5.17,64.14-14.55c8.49-4.63,15.17-10,19.86-16Zm-23.69-17.57C172.27,119.18,150.85,124,128,124s-44.27-4.82-60.31-13.57C52.41,102.1,44,91.29,44,80s8.41-22.1,23.69-30.43C83.73,40.82,105.15,36,128,36s44.27,4.82,60.31,13.57C203.59,57.9,212,68.71,212,80S203.59,102.1,188.31,110.43Z"}))]]),qe=new Map([["bold",n.createElement(n.Fragment,null,n.createElement("path",{d:"M180,232a12,12,0,0,1-12,12H88a12,12,0,0,1,0-24h80A12,12,0,0,1,180,232Zm40-128a91.51,91.51,0,0,1-35.17,72.35A12.26,12.26,0,0,0,180,186v2a20,20,0,0,1-20,20H96a20,20,0,0,1-20-20v-2a12,12,0,0,0-4.7-9.51A91.57,91.57,0,0,1,36,104.52C35.73,54.69,76,13.2,125.79,12A92,92,0,0,1,220,104Zm-24,0a68,68,0,0,0-69.65-68C89.56,36.88,59.8,67.55,60,104.38a67.71,67.71,0,0,0,26.1,53.19A35.87,35.87,0,0,1,100,184h56.1A36.13,36.13,0,0,1,170,157.49,67.68,67.68,0,0,0,196,104Zm-20.07-5.32a48.5,48.5,0,0,0-31.91-40,12,12,0,0,0-8,22.62,24.31,24.31,0,0,1,16.09,20,12,12,0,0,0,23.86-2.64Z"}))],["duotone",n.createElement(n.Fragment,null,n.createElement("path",{d:"M208,104a79.86,79.86,0,0,1-30.59,62.92A24.29,24.29,0,0,0,168,186v6a8,8,0,0,1-8,8H96a8,8,0,0,1-8-8v-6a24.11,24.11,0,0,0-9.3-19A79.87,79.87,0,0,1,48,104.45C47.76,61.09,82.72,25,126.07,24A80,80,0,0,1,208,104Z",opacity:"0.2"}),n.createElement("path",{d:"M176,232a8,8,0,0,1-8,8H88a8,8,0,0,1,0-16h80A8,8,0,0,1,176,232Zm40-128a87.55,87.55,0,0,1-33.64,69.21A16.24,16.24,0,0,0,176,186v6a16,16,0,0,1-16,16H96a16,16,0,0,1-16-16v-6a16,16,0,0,0-6.23-12.66A87.59,87.59,0,0,1,40,104.49C39.74,56.83,78.26,17.14,125.88,16A88,88,0,0,1,216,104Zm-16,0a72,72,0,0,0-73.74-72c-39,.92-70.47,33.39-70.26,72.39a71.65,71.65,0,0,0,27.64,56.3A32,32,0,0,1,96,186v6h64v-6a32.15,32.15,0,0,1,12.47-25.35A71.65,71.65,0,0,0,200,104Zm-16.11-9.34a57.6,57.6,0,0,0-46.56-46.55,8,8,0,0,0-2.66,15.78c16.57,2.79,30.63,16.85,33.44,33.45A8,8,0,0,0,176,104a9,9,0,0,0,1.35-.11A8,8,0,0,0,183.89,94.66Z"}))],["fill",n.createElement(n.Fragment,null,n.createElement("path",{d:"M176,232a8,8,0,0,1-8,8H88a8,8,0,0,1,0-16h80A8,8,0,0,1,176,232Zm40-128a87.55,87.55,0,0,1-33.64,69.21A16.24,16.24,0,0,0,176,186v6a16,16,0,0,1-16,16H96a16,16,0,0,1-16-16v-6a16,16,0,0,0-6.23-12.66A87.59,87.59,0,0,1,40,104.49C39.74,56.83,78.26,17.14,125.88,16A88,88,0,0,1,216,104Zm-32.11-9.34a57.6,57.6,0,0,0-46.56-46.55,8,8,0,0,0-2.66,15.78c16.57,2.79,30.63,16.85,33.44,33.45A8,8,0,0,0,176,104a9,9,0,0,0,1.35-.11A8,8,0,0,0,183.89,94.66Z"}))],["light",n.createElement(n.Fragment,null,n.createElement("path",{d:"M174,232a6,6,0,0,1-6,6H88a6,6,0,0,1,0-12h80A6,6,0,0,1,174,232Zm40-128a85.56,85.56,0,0,1-32.88,67.64A18.23,18.23,0,0,0,174,186v6a14,14,0,0,1-14,14H96a14,14,0,0,1-14-14v-6a18,18,0,0,0-7-14.23h0a85.59,85.59,0,0,1-33-67.24C41.74,57.91,79.39,19.12,125.93,18A86,86,0,0,1,214,104Zm-12,0a74,74,0,0,0-75.79-74C86.17,31,53.78,64.34,54,104.42a73.67,73.67,0,0,0,28.4,57.87A29.92,29.92,0,0,1,94,186v6a2,2,0,0,0,2,2h64a2,2,0,0,0,2-2v-6a30.18,30.18,0,0,1,11.7-23.78A73.59,73.59,0,0,0,202,104Zm-20.08-9A55.58,55.58,0,0,0,137,50.08a6,6,0,1,0-2,11.84C152.38,64.84,167.13,79.6,170.08,97a6,6,0,0,0,5.91,5,6.87,6.87,0,0,0,1-.08A6,6,0,0,0,181.92,95Z"}))],["regular",n.createElement(n.Fragment,null,n.createElement("path",{d:"M176,232a8,8,0,0,1-8,8H88a8,8,0,0,1,0-16h80A8,8,0,0,1,176,232Zm40-128a87.55,87.55,0,0,1-33.64,69.21A16.24,16.24,0,0,0,176,186v6a16,16,0,0,1-16,16H96a16,16,0,0,1-16-16v-6a16,16,0,0,0-6.23-12.66A87.59,87.59,0,0,1,40,104.49C39.74,56.83,78.26,17.14,125.88,16A88,88,0,0,1,216,104Zm-16,0a72,72,0,0,0-73.74-72c-39,.92-70.47,33.39-70.26,72.39a71.65,71.65,0,0,0,27.64,56.3A32,32,0,0,1,96,186v6h64v-6a32.15,32.15,0,0,1,12.47-25.35A71.65,71.65,0,0,0,200,104Zm-16.11-9.34a57.6,57.6,0,0,0-46.56-46.55,8,8,0,0,0-2.66,15.78c16.57,2.79,30.63,16.85,33.44,33.45A8,8,0,0,0,176,104a9,9,0,0,0,1.35-.11A8,8,0,0,0,183.89,94.66Z"}))],["thin",n.createElement(n.Fragment,null,n.createElement("path",{d:"M172,232a4,4,0,0,1-4,4H88a4,4,0,0,1,0-8h80A4,4,0,0,1,172,232Zm40-128a83.59,83.59,0,0,1-32.11,66.06A20.2,20.2,0,0,0,172,186v6a12,12,0,0,1-12,12H96a12,12,0,0,1-12-12v-6a20,20,0,0,0-7.76-15.81A83.58,83.58,0,0,1,44,104.47C43.75,59,80.52,21.09,126,20a84,84,0,0,1,86,84Zm-8,0a76,76,0,0,0-77.83-76C85,29,51.77,63.27,52,104.43a75.62,75.62,0,0,0,29.17,59.43A28,28,0,0,1,92,186v6a4,4,0,0,0,4,4h64a4,4,0,0,0,4-4v-6a28.14,28.14,0,0,1,10.94-22.2A75.62,75.62,0,0,0,204,104ZM136.66,52.06a4,4,0,0,0-1.32,7.88C153.53,63,169,78.45,172.06,96.67A4,4,0,0,0,176,100a3.88,3.88,0,0,0,.67-.06,4,4,0,0,0,3.27-4.61A53.51,53.51,0,0,0,136.66,52.06Z"}))]]),we=n.forwardRef((t,i)=>n.createElement(he,{ref:i,...t,weights:Ve}));
1we.displayName="DatabaseIcon";const Be=we,Ce=n.forwardRef((t,i)=>n.createElement(he,{ref:i,...t,weights:qe}));Ce.displayName="LightbulbIcon";const Fe=Ce;function Le(t){var p;const i=typeof t.stock_quantity=="number"&&Number.isFinite(t.stock_quantity)?t.stock_quantity:null,r=typeof t.unit_price=="number"&&Number.isFinite(t.unit_price)?t.unit_price:null,l=[`Produto: ${t.name}.`,i===null?"Estoque não informado.":`Estoque informado: ${i} un.`,...r===null?[]:[`Preço informado: ${new Intl.NumberFormat("pt-BR",{style:"currency",currency:"BRL"}).format(r)}.`]].join(" "),s=["Vendas por produto não disponíveis nesta análise."];(p=t.description)!=null&&p.trim()||s.push("Conferir a descrição na loja antes de afirmar material, medidas ou público."),i===null&&s.push("Confirmar disponibilidade antes de publicar.");const u=/pompom/i.test(t.name)?"o pompom indicado no nome":"um detalhe que esteja visível na foto original";return i!==null&&i<=0?{title:"Confirmar reposição antes de divulgar",evidence:l,action:`Para ${t.name}, revisar a disponibilidade na loja e confirmar reposição antes de iniciar uma campanha.`,deliverable:"Checklist de disponibilidade e critério de retomada: estoque positivo confirmado na loja.",missing:s}:i!==null&&i<=3?{title:"Divulgação pontual para o estoque disponível",evidence:l,action:`Preparar um post orgânico de ${t.name}, com a foto completa e um recorte mostrando ${u}. Conferir o estoque antes da publicação; não escalar mídia sem verificar reposição.`,deliverable:"Um post de duas imagens e legenda com nome, preço informado e link do produto. Não anunciar escassez sem confirmar o saldo atual.",missing:s}:{title:"Explicar o produto antes de ampliar a divulgação",evidence:l,action:`Preparar um carrossel de ${t.name}: foto completa, recorte mostrando ${u} e informações de compra verificadas na página do produto.`,deliverable:"Um carrossel de três quadros com link para o produto. Avaliar cliques e pedidos quando esses dados estiverem disponíveis, sem presumir desempenho atual.",missing:s}}const T={...le,productPairs:le.productPairs.map(t=>{if(t.product_ids.length!==2||t.product_ids.some(i=>typeof i!="string"||!i))throw new Error("INVALID_COMMERCIAL_PRODUCT_PAIR");return{...t,product_ids:[t.product_ids[0],t.product_ids[1]]}})},Y=new Map;function Ue(t){if(!t||typeof t!="object")return!1;const i=t;return typeof i.overview=="string"&&!!i.campaign&&typeof i.campaign.title=="string"&&typeof i.campaign.concept=="string"}function O(t){return Array.isArray(t)?t.filter(i=>typeof i=="string"&&i.trim().length>0):[]}function Ge(t){if(!Ue(t))return null;const i=t.vision&&typeof t.vision=="object"?t.vision:{},r=t.campaign;return{...t,vision:{category:typeof i.category=="string"?i.category:"Produto",materials:O(i.materials),palette:O(i.palette),audience:typeof i.audience=="string"?i.audience:"",usage:typeof i.usage=="string"?i.usage:"",strengths:O(i.strengths)},commercialDiagnosis:typeof t.commercialDiagnosis=="string"?t.commercialDiagnosis:"",campaign:{title:r.title,objective:typeof r.objective=="string"?r.objective:"",style:typeof r.style=="string"?r.style:"",concept:r.concept,rationale:typeof r.rationale=="string"?r.rationale:"",deliverables:O(r.deliverables)},alternatives:Array.isArray(t.alternatives)?t.alternatives:[],confidence:typeof t.confidence=="number"?t.confidence:0,missingSignals:O(t.missingSignals)}}function Je(t){const[i,r]=n.useState(0),[l,s]=n.useState({status:"idle",result:null,error:null}),o=JSON.stringify(t);n.useEffect(()=>{var j,z,C,b,y;if(!t){s({status:"idle",result:null,error:null});return}const p=o,g=Y.get(p);if(!t.connectedStore&&g&&i===0){s({status:"success",result:g,error:null});return}const v=new AbortController,f=t.connectedStore?null:fe(),k=f?{brandName:f.brandName,visualThesis:((j=f.dna.visual_profile)==null?void 0:j.visualThesis)??f.dna.conceito??"",palette:((z=f.dna.visual_profile)==null?void 0:z.palette.instruction)??f.dna.paleta_luz??"",photography:((C=f.dna.visual_profile)==null?void 0:C.photography)??null,recurringMotifs:((b=f.dna.visual_profile)==null?void 0:b.recurringMotifs)??[],negativeRules:((y=f.dna.visual_profile)==null?void 0:y.negativeRules)??[],styles:f.styles.filter(h=>h.status==="approved").slice(0,8).map(h=>({id:h.id,name:h.name,role:h.role,description:h.description,prompt:h.prompt,negativeRules:h.negativeRules}))}:null;return s({status:"loading",result:null,error:null}),(t.connectedStore?He.functions.invoke("cmo-product-analysis",{body:{productId:t.id},signal:v.signal}).then(({data:h,error:S})=>{if(S)throw new Error("analysis_unavailable");return h}):fetch("/__sandbox/product-vision",{method:"POST",headers:{"Content-Type":"application/json"},signal:v.signal,body:JSON.stringify({productName:t.name,imageUrl:t.imageUrl,brandContext:k,productC
1ontext:t})}).then(async h=>{const S=await h.json();if(!h.ok)throw new Error(typeof S.error=="string"?S.error:`vision_${h.status}`);return S})).then(h=>{if(v.signal.aborted)return;const S=Ge(h.result);if(!S)throw new Error("invalid_vision_response");t.connectedStore||Y.set(p,S),s({status:"success",result:S,error:null})}).catch(h=>{v.signal.aborted||s({status:"error",result:null,error:h instanceof Error?h.message:"vision_failed"})}),()=>v.abort()},[o,i]);const u=n.useCallback(()=>{t&&Y.delete(o),r(p=>p+1)},[t]);return{...l,refresh:u}}const L="snew:sandbox-store-recommendations:v6:",Ke=24*60*60*1e3,V=new Map;function Qe(t){const i=t.map(l=>`${l.id}:${l.name}:${l.imageUrl}:${l.description??""}`).join("|");let r=2166136261;for(let l=0;l<i.length;l+=1)r^=i.charCodeAt(l),r=Math.imul(r,16777619);return(r>>>0).toString(36)}function ze(t){if(!t||typeof t!="object")return!1;const i=t;return typeof i.overview=="string"&&Array.isArray(i.recommendations)&&Array.isArray(i.products)}function Xe(t){if(typeof window>"u")return null;try{const i=window.localStorage.getItem(`${L}${t}`);if(!i)return null;const r=JSON.parse(i);return typeof r.savedAt!="number"||Date.now()-r.savedAt>Ke?(window.localStorage.removeItem(`${L}${t}`),null):ze(r.result)?r.result:null}catch{return null}}function Ye(t,i){if(V.set(t,i),!(typeof window>"u"))try{window.localStorage.setItem(`${L}${t}`,JSON.stringify({savedAt:Date.now(),result:i}))}catch{}}function et(t){const i=n.useMemo(()=>Qe(t),[t]),[r,l]=n.useState(0),[s,o]=n.useState({status:"idle",result:null,error:null});n.useEffect(()=>{if(!t.length){o({status:"idle",result:null,error:null});return}const p=r===0?V.get(i)??Xe(i):null;if(p){V.set(i,p),o({status:"success",result:p,error:null});return}const g=new AbortController;return o({status:"loading",result:null,error:null}),fetch("/__sandbox/store-recommendations",{method:"POST",headers:{"Content-Type":"application/json"},signal:g.signal,body:JSON.stringify({products:t})}).then(async v=>{const f=await v.json();if(!v.ok)throw new Error(typeof f.error=="string"?f.error:`recommendations_${v.status}`);if(!ze(f.result))throw new Error("invalid_recommendations_response");Ye(i,f.result),o({status:"success",result:f.result,error:null})}).catch(v=>{g.signal.aborted||o({status:"error",result:null,error:v instanceof Error?v.message:"recommendations_failed"})}),()=>g.abort()},[t,r,i]);const u=n.useCallback(()=>{if(V.delete(i),typeof window<"u")try{window.localStorage.removeItem(`${L}${i}`)}catch{}l(p=>p+1)},[i]);return{...s,refresh:u}}const ee=new Map;function tt(t){if(!t||typeof t!="object")return!1;const i=t;return typeof i.problem=="string"&&typeof i.proposal=="string"&&Array.isArray(i.artifacts)&&Array.isArray(i.validationChecklist)}function it(t){var u;const[i,r]=n.useState({status:"idle",result:null,error:null}),l=t?`${t.recommendationId}:${((u=t.product)==null?void 0:u.id)??"store"}`:"";n.useEffect(()=>{if(!t){r({status:"idle",result:null,error:null});return}const p=ee.get(l);r(p?{status:"success",result:p,error:null}:{status:"idle",result:null,error:null})},[l,t==null?void 0:t.recommendationId]);const s=n.useCallback(async()=>{if(t){r({status:"loading",result:null,error:null});try{const p=await fetch("/__sandbox/recommendation-draft",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),g=await p.json();if(!p.ok)throw new Error(typeof g.error=="string"?g.error:`draft_${p.status}`);if(!tt(g.result))throw new Error("invalid_draft_response");ee.set(l,g.result),r({status:"success",result:g.result,error:null})}catch(p){r({status:"error",result:null,error:p instanceof Error?p.message:"draft_failed"})}}},[l,t]),o=n.useCallback(()=>{l&&ee.delete(l),r({status:"idle",result:null,error:null})},[l]);return{...i,generate:s,reset:o}}const at=new Set(["azul","bege","body","bebe","bebes","bordado","calca","claro","comfy","crianca","criancas","especial","infantil","jacard","menina","menino","personalizado","personalizada","rosa","sueter","tricot","trico","unissex"]),nt=new Set(["acao","ajudar","aumentar","cliente","clientes","conteudo","criar","destacar","loja","melhorar","produto","produtos","recomenda","recomendacao","sugestao","venda","vendas"]),st=/\b(campanha|carrossel|sequencia de (?:foto|fotos|
1imagem|imagens)|video|email|newsletter|landing page|pagina de produto|pagina da categoria|colecao|kit|combo|bundle|lookbook|guia de presentes?|anuncio|criativo|roteiro|ensaio|shooting|vitrine|teste a\/?b|experimento|meta ?title|meta ?description|titulo seo|taxonomia|cross[ -]?sell|upsell|regua de relacionamento|segmentacao|oferta|cupom|whatsapp)\b/i,rt=[/\bdescri(?:cao|coes)\b.{0,65}\b(atraente|clara|envolvente|personalizada|informativa|detalhada|completa|otimizada|persuasiva|cativante)\b/i,/\b(atraente|clara|envolvente|personalizada|informativa|detalhada|completa|otimizada|persuasiva|cativante)\b.{0,65}\bdescri(?:cao|coes)\b/i,/\b(melhorar|revisar|otimizar|aprimorar|fortalecer|adicionar|reescrever|enriquecer)\b.{0,50}\bdescri(?:cao|coes)\b/i,/\b(destacar|reforcar|comunicar)\b.{0,45}\b(conforto|qualidade|personalizacao|beneficios?|diferenciais?|apelo emocional)\b/i,/\b(criar|produzir)\b.{0,35}\bconteudo (?:atraente|envolvente|cativante|de qualidade)\b/i,/\b(atrair|chamar) (?:mais )?atencao\b/i,/\bproduto (?:ideal|perfeito|especial|unico)\b/i],ot=[/^descri(?:cao|coes) (?:atual |do produto )?(?:esta |estao )?(?:clara|claras|informativa|informativas|detalhada|detalhadas|disponivel|disponiveis)/i,/^o produto (?:e|parece|possui) (?:atraente|bonito|interessante|personalizado|confortavel)/i,/^a imagem (?:e|esta|mostra) (?:atraente|clara|bonita|o produto)/i,/^produto com (?:descricao|imagem) /i];function P(t){return t.normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase().replace(/[^a-z0-9\s/-]/g," ").replace(/\s+/g," ").trim()}function lt(t){return[...new Set(P(t).split(/[\s/-]+/).filter(i=>i.length>=4&&!at.has(i)))]}function de(t,i){const r=P(t);return lt(i).some(s=>r.includes(s))}function dt(t){const i=P(t);return i.length<24?!0:ot.some(r=>r.test(i))}function ct(t){const i=P([t.headline,t.suggestion,t.summary,t.nextAction].filter(Boolean).join(" "));return new Set(i.split(/[\s/-]+/).filter(r=>r.length>=5&&!nt.has(r)))}function ut(t,i){if(!t.size||!i.size)return 0;let r=0;return t.forEach(l=>{i.has(l)&&(r+=1)}),r/Math.min(t.size,i.size)}function pt(t,i){var g;const r=[],l=P([t.headline,t.suggestion,t.summary,t.nextAction,t.objective].filter(Boolean).join(" ")),s=P(t.currentState??"");(!l||l.length<45)&&r.push("ação insuficientemente detalhada"),st.test(l)||r.push("não propõe um entregável concreto"),rt.some(v=>v.test(l))&&r.push("usa uma formulação genérica de marketing ou copy");const o=de(P(t.headline??""),i.name),u=!dt(s)&&de(s,i.name);return o||r.push("o título não identifica a oportunidade específica do produto"),u||r.push("a evidência não está ancorada em um sinal específico do produto"),((g=t.missingSignals)==null?void 0:g.length)===1&&t.missingSignals[0]==="descriptions"&&/\bdescri(?:cao|coes)\b/i.test(l)&&r.push("depende apenas de uma descrição ausente"),{actionable:r.length===0,reasons:r}}function mt(t,i){return pt(t,i).actionable}function gt(t,i){const r=new Map(i.map(o=>[o.id,o])),l=[],s=[];return t.slice().sort((o,u)=>(Number(u.confidence)||0)-(Number(o.confidence)||0)).forEach(o=>{const u=r.get(o.productId);if(!u||!mt(o,u))return;const p=ct(o);s.some(g=>ut(g,p)>=.82)||(l.push(o),s.push(p))}),l}const Ae=ve.products;new Intl.DateTimeFormat("pt-BR",{day:"numeric",month:"short",year:"numeric"}).format(new Date(T.asOf));const ce=new Intl.NumberFormat("pt-BR",{style:"currency",currency:T.currency||"BRL",maximumFractionDigits:0}),ue=Ae.map(t=>({id:t.product_id,name:t.name,imageUrl:t.image_url,sku:t.sku,description:t.description??""})),Te={campaign:"Campanha",seo:"SEO",copy:"Copy",performance:"Performance",merchandising:"Merchandising",insight:"Insight"},a={page:`hsl(${I.bg.secondary})`,surface:`hsl(${I.bg.primary})`,text:`hsl(${I.text.primary})`,muted:`hsl(${I.text.secondary})`,subtle:`hsl(${I.text.tertiary})`},ht=t=>`snew:brand-dna-compiler-approved:${t}`;function pi(){var b,y;ae();const[t,i]=n.useState(null),[r,l]=n.useState(null),[s,o]=n.useState(!1),[u,p]=n.useState("all"),[g,v]=n.useState(new Set),f=n.useMemo(()=>Ze({platform:"nuvemshop",catalog:ve,commercial:T}),[]),[k,M]=n.useState(()=>{try{return window.localStorage.getItem(ht(f.storeId))==="1"}catch{return!1}}),j=et(ue),z=n.useMemo(()=>We(Ae,T,3),[]);n.useMemo(()=>{var h;return{overview:T.isSimulated?"Três decisões priorizadas por impacto, confiança, urgência e esforço. Os sinais comerciais desta demonstração são simulados; o catálogo permanece sanitizado.":"Três decisões priorizadas a partir de vendas, velocidade, estoque e conteúdo do catálogo.",recommendations:z,products:((h=j.result)==null?void 0:h.products)??[],missingSignals:T.isSimulated?["live_commercial_data"]:[],generatedAt:T.generatedAt}},[z,(b=j.result)==null?void 0:b.products]),Je(t?{id:t.product_id,name:t.name,imageUrl:t.image_url}:null);const C=n.useMemo(()=>{var h;return new Map(gt(((h=j.result)==null?void 0:h.products)??[],ue).map(S=>[S.productId,S]))},[(y=j.result)==null?void 0:y.products]);return t&&C.get(t.product_id),null}function mi({recommendation:t,product:i}){var W,c,w,J,ne,se,re;const r=ae(),l=n.useMemo(()=>({recommendationId:t.id,kind:t.kind,title:t.title,summary:t.summary,rationale:t.rationale,action:t.action,missingSignals:t.missingSignals,c
1ommercial:t.commercial??null,product:i?{id:i.product_id,name:i.name,sku:i.sku,imageUrl:i.image_url,description:i.description??""}:null}),[i,t]),s=it(l),[o,u]=n.useState([]),[p,g]=n.useState(null),[v,f]=n.useState(null),k=!!p;n.useEffect(()=>{g(null),f(null),u([])},[t.id]),n.useEffect(()=>{s.result&&u(s.result.artifacts)},[s.result]),n.useEffect(()=>{s.status==="idle"&&s.generate()},[s.generate,s.status]);const M=(m,Z)=>{g(null),f(null),u(K=>K.map(Q=>Q.id===m?{...Q,value:Z}:Q))},j=()=>{if(!s.result)return;const m=$e({recommendation:t,draft:s.result,artifacts:o,product:i?{id:i.product_id,name:i.name,sku:i.sku,imageUrl:i.image_url,description:i.description??""}:null,dataAsOf:T.asOf});g(m),f(null)},z=()=>{if(!p)return;const m=Ne(p);ie(m),f(m)},C=()=>{if(!p)return;const m=je(p);Se(m.campaign),ie(m),r("/board",{state:m.boardState})},b=((W=s.result)==null?void 0:W.problem)||t.rationale,y=((c=s.result)==null?void 0:c.evidence)||"",h=((w=s.result)==null?void 0:w.proposal)||t.summary,S=t.action,H=((J=s.result)==null?void 0:J.expectedImpact)||"",U=/não disponível no snapshot sanitizado/i.test(y),G=!!y&&!U&&!q(b,y),$=!!S&&!q(h,S),N=!!H&&!q(h,H);return e.jsxs("div",{style:{minHeight:"100%"},children:[e.jsx("div",{style:{padding:24,borderBottom:x.default},children:e.jsxs("div",{style:{paddingRight:38},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7,marginBottom:10,color:a.muted,fontSize:11,fontWeight:600},children:[e.jsx("span",{style:{padding:"5px 8px",borderRadius:d.pill,background:a.text,color:a.surface,fontSize:9,letterSpacing:"0.04em",textTransform:"uppercase"},children:Te[t.kind]}),t.commercial?e.jsxs(e.Fragment,{children:[e.jsxs("span",{style:{padding:"5px 8px",borderRadius:d.pill,background:a.page,color:a.muted,fontSize:9,fontWeight:650},children:[t.commercial.role," · ",t.commercial.lever]}),e.jsxs("span",{style:{color:a.subtle,fontSize:9,fontWeight:650},children:[t.commercial.score,"/100"]})]}):null]}),e.jsx(be,{style:{margin:0,fontSize:22,lineHeight:1.25,letterSpacing:"-0.028em",fontWeight:600},children:t.title})]})}),e.jsxs("div",{style:{display:"grid",gap:22,padding:24},children:[i?e.jsxs("div",{"aria-label":"Produto relacionado",style:{display:"flex",alignItems:"center",gap:12,padding:10,borderRadius:d.lg,border:x.default},children:[e.jsx("img",{src:i.image_url,alt:"",style:{width:48,height:48,flex:"0 0 auto",objectFit:"cover",borderRadius:d.md}}),e.jsxs("div",{style:{minWidth:0},children:[e.jsx("div",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:12,lineHeight:1.4,fontWeight:600},children:i.name}),e.jsx("div",{style:{marginTop:4,color:a.subtle,fontSize:9},children:i.sku})]})]}):e.jsxs("div",{style:{display:"inline-flex",width:"fit-content",alignItems:"center",gap:7,padding:"8px 10px",borderRadius:d.pill,background:a.page,color:a.muted,fontSize:10},children:[e.jsx(oe,{size:13,weight:"fill"})," Recomendação para toda a loja"]}),t.commercial?e.jsxs("section",{"data-testid":"recommendation-commercial-evidence",children:[e.jsx(A,{icon:e.jsx(te,{size:16,weight:"fill"}),children:"Por que entrou no Top 3"}),e.jsxs("div",{style:{padding:14,borderRadius:d.xl,background:a.page},children:[e.jsx("div",{style:{fontSize:13,lineHeight:1.55,fontWeight:560},children:t.rationale}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:7,marginTop:11},children:t.commercial.evidence.map(m=>e.jsx("span",{style:{padding:"7px 9px",borderRadius:d.pill,background:a.surface,color:a.muted,border:x.default,fontSize:9,fontWeight:600},children:m},m))}),e.jsx("div",{style:{marginTop:10,color:a.subtle,fontSize:9},children:t.commercial.source==="simulation"?"Sinal comercial simulado para validar a experiência":"Sinal calculado a partir de pedidos agregados e sanitizados"})]})]}):null,s.status==="loading"?e.jsx(ft,{kind:t.kind}):null,s.status==="error"?e.jsxs("div",{style:{padding:16,borderRadius:d.lg,border:x.default,background:a.page},children:[e.jsx("div",{style:{fontSize:13,fontWeight:600},children:"Não foi possível gerar a proposta."}),e.jsx("div",{style:{marginTop:6,color:a.subtle,fontSize:10},children:s.error}),e.jsx("button",{type:"button",onClick:()=>void s.generate(),style:{...D,width:"auto",marginTop:12,padding:"8px 12px"},children:"Tentar novamente"})]}
1):null,s.result?e.jsxs(e.Fragment,{children:[e.jsxs("section",{children:[e.jsx(A,{icon:e.jsx(xe,{size:16,weight:"fill"}),children:"Diagnóstico"}),e.jsxs("div",{style:{padding:16,borderRadius:d.xl,background:a.page},children:[e.jsx("div",{style:{fontSize:14,lineHeight:1.55,fontWeight:560},children:b}),G?e.jsxs("div",{style:{marginTop:11,color:a.subtle,fontSize:11,lineHeight:1.5},children:[e.jsx("strong",{style:{color:a.muted,fontWeight:600},children:"Base do diagnóstico:"})," ",y]}):null]})]}),e.jsxs("section",{children:[e.jsx(A,{icon:e.jsx(ye,{size:16,weight:"fill"}),children:"Recomendação"}),e.jsxs("div",{style:{padding:16,borderRadius:d.xl,border:x.default},children:[e.jsx("div",{style:{fontSize:14,lineHeight:1.6},children:h}),$?e.jsxs("div",{style:{marginTop:12,color:a.muted,fontSize:11,lineHeight:1.45},children:[e.jsx("strong",{style:{color:a.text,fontWeight:600},children:"Primeiro entregável:"})," ",S]}):null,N?e.jsxs("div",{style:{marginTop:12,paddingTop:12,borderTop:x.default,color:a.subtle,fontSize:11,lineHeight:1.45},children:[e.jsx("strong",{style:{color:a.muted,fontWeight:600},children:"Hipótese:"})," ",H]}):null]})]})]}):null,(ne=s.result)!=null&&ne.experiment?e.jsxs("section",{"data-testid":"recommendation-experiment-plan",children:[e.jsx(A,{icon:e.jsx(te,{size:16,weight:"fill"}),children:"Plano do teste A/B"}),e.jsxs("div",{style:{display:"grid",gap:10},children:[e.jsx(_,{label:"Hipótese",value:s.result.experiment.hypothesis}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:10},children:[e.jsx(_,{label:"Controle A",value:s.result.experiment.control}),e.jsx(_,{label:"Variante B",value:s.result.experiment.variant})]}),e.jsx(_,{label:"Métrica principal",value:s.result.experiment.primaryMetric}),e.jsx(_,{label:"Audiência",value:s.result.experiment.audience}),e.jsx(_,{label:"Amostra mínima",value:s.result.experiment.minimumSampleRule}),e.jsx(_,{label:"Quando encerrar",value:s.result.experiment.durationRule}),e.jsx(_,{label:"Regra de decisão",value:s.result.experiment.decisionRule})]})]}):null,s.result&&o.length?e.jsxs("section",{"data-testid":"recommendation-editable-draft",children:[e.jsx(A,{icon:e.jsx(ke,{size:16,weight:"fill"}),children:"Minha sugestão"}),e.jsx("div",{style:{display:"grid",gap:14},children:o.map(m=>{const Z=Re(m.currentValue);return e.jsxs("article",{style:{padding:14,border:x.default,borderRadius:d.xl},children:[e.jsx("div",{style:{marginBottom:10,color:a.text,fontSize:11,fontWeight:650},children:m.label}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:Z?"minmax(0, 1fr) minmax(0, 1fr)":"minmax(0, 1fr)",gap:10},children:[Z?e.jsxs("div",{style:{padding:12,borderRadius:d.lg,background:a.page},children:[e.jsx("div",{style:{color:a.subtle,fontSize:8,fontWeight:700,letterSpacing:"0.065em",textTransform:"uppercase"},children:"Como está"}),e.jsx("div",{style:{marginTop:8,color:a.muted,fontSize:11,lineHeight:1.5,whiteSpace:"pre-wrap"},children:m.currentValue})]}):null,e.jsxs("label",{style:{display:"grid",minWidth:0,gap:7},children:[e.jsx("span",{style:{color:a.subtle,fontSize:8,fontWeight:700,letterSpacing:"0.065em",textTransform:"uppercase"},children:"Minha sugestão"}),e.jsx("textarea",{value:m.value,onChange:K=>M(m.id,K.target.value),rows:m.value.length>180?6:4,style:{width:"100%",minHeight:88,resize:"vertical",padding:11,border:x.default,borderRadius:d.lg,background:a.surface,color:a.text,font:"inherit",fontSize:11,lineHeight:1.5,outline:"none"}})]})]}),m.helper?e.jsx("div",{style:{marginTop:9,color:a.subtle,fontSize:9,lineHeight:1.4},children:m.helper}):null]},m.id)})})]}):null,(se=s.result)!=null&&se.validationChecklist.length?e.jsxs("section",{children:[e.jsx(A,{icon:e.jsx(Pe,{size:16,weight:"fill"}),children:"Antes de aplicar"}),e.jsx("div",{style:{display:"grid",gap:8},children:s.result.validationChecklist.map(m=>e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:8,color:a.muted,fontSize:11,lineHeight:1.45},children:[e.jsx(X,{size:13,weight:"bold",style:{flex:"0 0 auto",marginTop:2}}),m]},m))})]}):null,(re=s.result)!=null&&re.missingSignals.length?e.jsxs("section",{children:[e.jsx(A,{icon:e.jsx(Be,{size:16,weight:"fill"}),children:"Dados necessários para validar"}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:7},children:s.result.missingSignals.map(m=>e.jsx("span",{style:{padding:"7px 9px",borderRadius:d.pill,background:a.page,color:a.muted,fontSize:9,fontWeight:600},children:m},m))})]}
1):null,s.status==="success"?e.jsxs("section",{style:{display:"grid",gap:9,paddingTop:4},children:[k?e.jsxs(e.Fragment,{children:[e.jsxs("div",{"data-testid":"recommendation-approved",style:{display:"flex",alignItems:"center",gap:8,padding:13,borderRadius:d.lg,background:`hsl(${I.bg.success})`,color:`hsl(${I.text.success})`,fontSize:12,fontWeight:600},children:[e.jsx(X,{size:15,weight:"bold"})," Proposta aprovada. Escolha o próximo passo."]}),v?e.jsxs("div",{"data-testid":"nuvemshop-change-plan",style:{display:"grid",gap:10,padding:14,border:x.default,borderRadius:d.xl},children:[e.jsxs("div",{children:[e.jsx("div",{style:{color:a.text,fontSize:12,fontWeight:650},children:"Plano de atualização preparado"}),e.jsx("div",{style:{marginTop:5,color:a.subtle,fontSize:10,lineHeight:1.45},children:"Nada foi alterado na loja. Cada item ainda passa pela confirmação final."})]}),e.jsx("div",{style:{display:"grid",gap:7},children:v.operations.map(m=>e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:10,padding:"9px 10px",borderRadius:d.lg,background:a.page},children:[e.jsx("span",{style:{minWidth:0,overflow:"hidden",color:a.muted,fontSize:10,fontWeight:560,textOverflow:"ellipsis",whiteSpace:"nowrap"},children:m.label}),e.jsx("span",{style:{flex:"0 0 auto",padding:"4px 7px",borderRadius:d.pill,background:a.surface,border:x.default,color:a.subtle,fontSize:8,fontWeight:650},children:m.readiness==="ready"?"Pronto para revisar":m.readiness==="needs-asset"?"Gerar asset primeiro":"Revisão necessária"})]},m.id))}),e.jsx("div",{style:{padding:11,borderRadius:d.lg,background:a.page,color:a.subtle,fontSize:9,lineHeight:1.5},children:"O executor de produção deverá rodar no servidor, reler o produto, comparar os valores e usar este plano como chave idempotente. O token da loja nunca vai para o navegador."}),e.jsx("button",{type:"button",disabled:!0,title:"Disponível quando o executor de escrita da Nuvemshop for conectado",style:{...ge,o
1pacity:.4,cursor:"not-allowed"},children:"Confirmar e atualizar · conectar executor"}),e.jsx("button",{type:"button",onClick:()=>f(null),style:D,children:"Escolher outro caminho"})]}):e.jsxs("div",{"data-testid":"cmo-execution-destinations",style:{display:"grid",gap:10,marginTop:4},children:[e.jsxs("button",{type:"button",onClick:z,"data-testid":"prepare-nuvemshop-update",style:pe,children:[e.jsx("span",{style:me,children:e.jsx(oe,{size:18,weight:"fill"})}),e.jsxs("span",{style:{minWidth:0},children:[e.jsx("strong",{style:{display:"block",color:a.text,fontSize:12,fontWeight:650},children:"Atualizar minha Nuvemshop"}),e.jsx("span",{style:{display:"block",marginTop:4,color:a.subtle,fontSize:10,lineHeight:1.45},children:"Preparar as mudanças da loja para revisar e confirmar antes de publicar."})]}),e.jsx(F,{size:15,weight:"bold",style:{flex:"0 0 auto",color:a.muted}})]}),e.jsxs("button",{type:"button",onClick:C,"data-testid":"start-cmo-campaign",style:pe,children:[e.jsx("span",{style:me,children:e.jsx(Ie,{size:18,weight:"fill"})}),e.jsxs("span",{style:{minWidth:0},children:[e.jsx("strong",{style:{display:"block",color:a.text,fontSize:12,fontWeight:650},children:"Gerar campanha no board"}),e.jsx("span",{style:{display:"block",marginTop:4,color:a.subtle,fontSize:10,lineHeight:1.45},children:"Abrir o briefing do CMO e gerar Hero, Produto em uso e Detalhe do produto."})]}),e.jsx(F,{size:15,weight:"bold",style:{flex:"0 0 auto",color:a.muted}})]})]})]}):e.jsxs("button",{type:"button",onClick:j,style:ge,children:[e.jsx(X,{size:15,weight:"bold"})," Aprovar proposta"]}),e.jsx("button",{type:"button",onClick:()=>{u([]),g(null),f(null),s.reset()},style:D,children:"Gerar outra versão"})]}):null]})]})}const pe={display:"grid",gridTemplateColumns:"36px minmax(0, 1fr) auto",alignItems:"center",gap:11,width:"100%",padding:12,textAlign:"left",border:x.default,borderRadius:d.xl,background:a.surface,font:"inherit",cursor:"pointer"},me={display:"grid",width:36,height:36,placeItems:"center",borderRadius:d.lg,background:a.page,color:a.text};function q(t,i){const r=g=>g.normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase().replace(/[^a-z0-9\s]/g," ").replace(/\s+/g," ").trim(),l=r(t),s=r(i);if(!s||l===s||Math.min(l.length,s.length)>36&&(l.includes(s)||s.includes(l)))return!0;const o=new Set(l.split(" ").filter(g=>g.length>3)),u=new Set(s.split(" ").filter(g=>g.length>3));return!o.size||!u.size?!1:[...o].filter(g=>u.has(g)).length/Math.min(o.size,u.size)>=.8}function Re(t){const i=t.trim();return!!i&&!/não disponível no snapshot sanitizado/i.test(i)}function _({label:t,value:i}){return e.jsxs("div",{style:{padding:13,borderRadius:d.lg,border:x.default,background:a.page},children:[e.jsx("div",{style:{color:a.subtle,fontSize:9,fontWeight:650,letterSpacing:"0.055em",textTransform:"uppercase"},children:t}),e.jsx("div",{style:{marginTop:7,color:a.muted,fontSize:11,lineHeight:1.5},children:i})]})}function ft({kind:t}){return e.jsxs("div",{"data-testid":"recommendation-draft-skeleton",style:{display:"grid",gap:12,padding:18,borderRadius:d.xl,border:x.default},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,color:a.muted,fontSize:12},children:[e.jsx(B,{size:14,weight:"fill"}),t==="performance"?"Montando o relatório, controle e variante…":"Montando o relatório comparativo completo…"]}),e.jsx(R,{style:{height:12,width:"88%"}}),e.jsx(R,{style:{height:12,width:"72%"}}),e.jsx(R,{style:{height:72,width:"100%"}})]})}function gi({product:t,result:i,status:r,error:l,onRefresh:s,backgroundRecommendation:o,commercialData:u,dataAsOf:p}){var $,N,W;const g=ae(),[v,f]=n.useState(!1),[k,M]=n.useState(null),j=(i==null?void 0:i.campaign)??null,z=Le(t),C=n.useMemo(()=>{if(!i)return null;const c=u===null?null:fe();return Oe({draft:i.creativeDirection,campaignTitle:i.campaign.title,campaignConcept:i.campaign.concept,campaignObjective:i.campaign.objective,productName:t.name,productDescription:t.description??"",productCategory:i.vision.category,brandName:(c==null?void 0:c.brandName)??null,brandProfile:(c==null?void 0:c.dna.visual_profile)??null,brandStyles:(c==null?void 0:c.styles)??[]})},[u,t.description,t.name,i]),b=u===void 0?T:u,y=(b==null?void 0:b.products.find(c=>c.product_id===t.product_id))??null,h=r==="idle"||r==="loading",S=(($=o==null?void 0:o.currentState)==null?void 0:$.trim())??"",H=o?o.suggestion||o.desiredState||o.summary:"",U=o?[...Re(S)?[{label:"Como está",content:S}]:[],{label:"Minha sugestão",content:H}]:[],G=()=>{if(!(!i||v)){f(!0),M(null);try{const c=De({product:{id:t.product_id,name:t.name,sku:t.sku,imageUrl:t.image_url,description:t.description??"",commercialSnapshot:y?{source:b.source,isSimulated:b.
1isSimulated,dataAsOf:b.asOf,currency:b.currency,units7d:y.units_7d,units30d:y.units_30d,revenue30d:y.revenue_30d,orders30d:y.orders_30d,stockQuantity:y.stock_quantity,unitPrice:y.unit_price,lastSaleAt:y.last_sale_at}:void 0},vision:i,backgroundRecommendation:o,dataAsOf:p??(b==null?void 0:b.asOf)??new Date(0).toISOString()}),w=je(c,void 0,{allowLocalBrandContext:u!==null});if((Array.isArray(w.boardState.autoSubmitAssetId)?w.boardState.autoSubmitAssetId:w.boardState.autoSubmitAssetId?[w.boardState.autoSubmitAssetId]:[]).length===0)throw new Error("O compilador não criou os quadros da campanha.");Se(w.campaign),ie(w),g("/board",{state:{...w.boardState,_ts:Date.now()}})}catch(c){const w=c instanceof Error?c.message:"Não foi possível preparar a campanha.";console.error("[cmo-campaign-handoff]",c),M(w),f(!1),Ee.error("A campanha não pôde ser aberta",{description:w})}}};return u===null?e.jsx(_e,{product:t},t.product_id):e.jsxs("div",{style:{minHeight:"100%"},children:[e.jsx("div",{style:{padding:24,borderBottom:x.default},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:16,paddingRight:36},children:[e.jsx("img",{src:t.image_url,alt:"",style:{width:76,height:76,flex:"0 0 auto",objectFit:"cover",borderRadius:d.lg}}),e.jsxs("div",{style:{minWidth:0},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:7,color:a.muted,fontSize:12,fontWeight:500},children:[e.jsx(B,{size:15,weight:"fill"}),"Snew CMO · Análise do produto"]}),e.jsx(be,{style:{margin:0,fontSize:17,lineHeight:1.35,letterSpacing:"-0.02em",fontWeight:600},children:t.name}),e.jsx(Me,{className:"sr-only",children:"Análise visual do produto e recomendação de campanha geradas no sandbox local."}),e.jsx("div",{style:{marginTop:7,color:a.subtle,fontSize:11},children:t.sku})]})]})}),e.jsxs("div",{style:{display:"grid",gap:28,padding:24},children:[e.jsxs("section",{children:[e.jsx(A,{icon:e.jsx(xe,{size:16,weight:"fill"}),children:"Leitura do produto"}),h?e.jsx(xt,{}):l?e.jsx(vt,{product:t,error:l,onRetry:s}):e.jsxs("div",{"data-testid":"agent-product-overview",style:{padding:16,borderRadius:d.lg,background:a.page,fontSize:14,lineHeight:1.55},children:[e.jsx("div",{children:(i==null?void 0:i.overview)||"O agente reconheceu o produto e preparou uma direção adequada ao seu contexto."}),i!=null&&i.vision?e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:6,marginTop:12},children:[i.vision.category,...i.vision.palette,...i.vision.strengths].filter(Boolean).slice(0,6).map(c=>e.jsx("span",{style:{padding:"5px 8px",borderRadius:d.pill,border:x.default,background:a.surface,color:a.muted,fontSize:10},children:c},c))}):null]})]}),o&&u!==null?e.jsxs("section",{"data-testid":"background-product-recommendation",children:[e.jsx(A,{icon:e.jsx(Fe,{size:16,weight:"fill"}),children:u===null?"Orientação com base no catálogo":"Oportunidade detectada em background"}),e.jsxs("div",{style:{padding:16,borderRadius:d.xl,border:x.default,background:a.page},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:10},children:[e.jsx("span",{style:{color:a.subtle,fontSize:10,fontWeight:650,letterSpacing:"0.055em",textTransform:"uppercase"},children:Te[o.kind]}),o.vibeLabel?e.jsx("span",{style:{padding:"5px 8px",borderRadius:d.pill,border:x.default,background:a.surface,color:a.muted,fontSize:9,fontWeight:600},children:o.vibeLabel}):null]}),e.jsx("h3",{style:{margin:"11px 0 0",fontSize:16,lineHeight:1.35,letterSpacing:"-0.018em",fontWeight:600},children:o.headline}),e.jsx("div",{style:{display:"grid",gap:10,marginTop:14},children:U.map(c=>e.jsxs("div",{style:{padding:"10px 12px",borderRadius:d.md,background:a.surface,border:x.default},children:[e.jsx("div",{style:{color:a.subtle,fontSize:9,fontWeight:650,letterSpacing:"0.055em",textTransform:"uppercase"},children:c.label}),e.jsx("div",{style:{marginTop:4,color:a.muted,fontSize:12,lineHeight:1.5},children:c.content})]},c.label))}),o.objective?e.jsxs("div",{style:{marginTop:12,color:a.subtle,fontSize:10},children:["Objetivo: ",o.objective]}):null,o.nextAction&&!q(H,o.nextAction)?e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",ga
1p:7,marginTop:13,color:a.muted,fontSize:11,lineHeight:1.45},children:[e.jsx(F,{size:12,weight:"bold",style:{flex:"0 0 auto",marginTop:2}}),o.nextAction]}):null]})]}):null,e.jsxs("section",{children:[e.jsx(A,{icon:e.jsx(te,{size:16,weight:"fill"}),children:"Sinais comerciais"}),y?e.jsxs("div",{"data-testid":"product-commercial-signals",style:{display:"grid",gridTemplateColumns:"repeat(3, 1fr)",gap:10},children:[e.jsx(E,{label:"Vendas · 30 dias",value:`${y.units_30d} un.`}),e.jsx(E,{label:"Receita · 30 dias",value:ce.format(y.revenue_30d)}),e.jsx(E,{label:"Estoque",value:y.stock_quantity==null?"Não informado":`${y.stock_quantity} un.`})]}):e.jsxs("div",{"data-testid":"product-commercial-signals",style:{display:"grid",gridTemplateColumns:"repeat(3, 1fr)",gap:10},children:[e.jsx(E,{label:"Preço",value:t.unit_price==null?"Não informado":ce.format(t.unit_price)}),e.jsx(E,{label:"Estoque",value:t.stock_quantity==null?"Não informado":`${t.stock_quantity} un.`}),e.jsx(E,{label:"Vendas · 30 dias",value:"Não disponíveis"})]}),e.jsx("p",{style:{margin:"10px 0 0",color:a.subtle,fontSize:11,lineHeight:1.45},children:y?`Dados reais sincronizados da Nuvemshop até ${new Intl.DateTimeFormat("pt-BR",{day:"2-digit",month:"2-digit",year:"numeric"}).format(new Date(b.asOf))}. Acessos não são estimados.`:"Preço e estoque conforme o catálogo sincronizado. As vendas por produto não estão disponíveis nesta análise."}),i!=null&&i.commercialDiagnosis?e.jsx("div",{style:{marginTop:12,padding:14,borderRadius:d.lg,background:a.page,color:a.muted,fontSize:12,lineHeight:1.5},children:i.commercialDiagnosis}):null]}),e.jsxs("section",{children:[e.jsx(A,{icon:e.jsx(ye,{size:16,weight:"fill"}),children:"Ação recomendada"}),e.jsxs("div",{"data-testid":"catalog-product-action",style:{padding:16,border:x.default,borderRadius:d.lg,marginBottom:16,fontSize:12,lineHeight:1.55},children:[e.jsx("strong",{children:z.title}),e.jsx("p",{children:z.evidence}),e.jsx("p",{children:z.action}),e.jsxs("p",{children:[e.jsx("strong",{children:"Entregável: "}),z.deliverable]}),e.jsx("div",{style:{color:a.subtle},children:z.missing.join(" ")})]}),h?e.jsx(yt,{}):l?null:j?e.jsxs("div",{"data-testid":"agent-campaign-recommendation",style:{border:x.default,borderRadius:d.xl,overflow:"hidden"},children:[e.jsxs("div",{style:{padding:18,background:a.page},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:12},children:[e.jsxs("div",{children:[e.jsx("h3",{style:{margin:0,fontSize:18,lineHeight:1.25,letterSpacing:"-0.02em",fontWeight:600},children:j.title}),e.jsxs("div",{style:{marginTop:8,color:a.muted,fontSize:12},children:[j.style||"Direção editorial"," · ",j.objective||"Conversão"]})]}),e.jsx("span",{style:{padding:"5px 8px",borderRadius:d.pill,background:a.surface,border:x.default,color:a.muted,fontSize:10,fontWeight:600},children:"RECOMENDADO"})]}),e.jsx("p",{style:{margin:"16px 0 0",color:a.muted,fontSize:14,lineHeight:1.6},children:j.concept}),j.rationale?e.jsx("p",{style:{margin:"12px 0 0",color:a.subtle,fontSize:12,lineHeight:1.55},children:j.rationale}):null,C?e.jsxs("div",{"data-testid":"cmo-creative-language",style:{display:"grid",gap:14,marginTop:18,padding:16,borderRadius:d.lg,border:x.default,background:a.surface},children:[e.jsxs("div",{children:[e.jsxs("div",{style:{color:a.subtle,fontSize:9,fontWeight:650,letterSpacing:"0.055em",textTransform:"uppercase"},children:["Linguagem criativa · ",C.vibeName]}),e.jsx("div",{style:{marginTop:7,color:a.muted,fontSize:12,lineHeight:1.55},children:C.thesis})]}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:10},children:[["Fotografia",C.photography],["Luz",C.lighting],["Textura",C.texture],["Assinatura",C.signatureMotif]].map(([c,w])=>e.jsxs("div",{style:{minWidth:0,padding:"10px 11px",borderRadius:d.md,background:a.page},children:[e.jsx("div",{style:{color:a.subtle,fontSize:8,fontWeight:650,letterSpacing:"0.055em",textTransform:"uppercase"},children:c}),e.jsx("div",{style:{marginTop:5,color:a.muted,fontSize:10,lineHeight:1.45},children:w})]},c))}),e.jsx("div",{style:{display:"grid",gap:7},children:C.shotArc.map((c,w)=>e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"18px 1fr",gap:8,color:a.muted,fontSize:10,lineHeight:1.45},children:[e.jsx("span",{style:{color:a.subtle},children:w+1}),e.jsxs("span",{children:[e.jsxs("strong",{style:{color:a.text,fontWeight:600},children:[c.title,"."]})," ",c.narrativeBeat]})]},c.role))})]}):null,(N=j.deliverables)!=null&&N.length?e.jsx("div",{style:{display:"grid",gap:7,marginTop:16},children:j.deliverables.slice(0,3).map(c=>
1e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:8,color:a.muted,fontSize:11,lineHeight:1.4},children:[e.jsx(F,{size:12,weight:"bold",style:{flex:"0 0 auto",marginTop:2}}),c]},c))}):null]}),e.jsxs("div",{style:{display:"grid",gap:8,padding:12},children:[e.jsx("button",{type:"button",onClick:G,disabled:v,"data-testid":"create-product-campaign",style:{...bt,opacity:v?.68:1,cursor:v?"wait":"pointer"},children:v?"Preparando campanha…":"Gerar campanha no board"}),k?e.jsx("div",{role:"alert",style:{color:"#B42318",fontSize:10,lineHeight:1.45,textAlign:"center"},children:k}):null,e.jsx("button",{type:"button",onClick:s,style:D,children:"Gerar outra direção"})]})]}):null]}),!h&&!l&&(((W=i==null?void 0:i.alternatives)==null?void 0:W.length)??0)>0?e.jsxs("section",{children:[e.jsx(A,{icon:e.jsx(B,{size:16,weight:"fill"}),children:"Outras direções"}),e.jsx("div",{style:{display:"grid",gap:8},children:i.alternatives.slice(0,2).map(c=>e.jsxs("div",{style:{padding:14,borderRadius:d.lg,border:x.default},children:[e.jsx("div",{style:{fontSize:13,fontWeight:600},children:c.title}),e.jsx("div",{style:{marginTop:5,color:a.subtle,fontSize:11},children:c.style||"Direção criativa"})]},`${c.title}-${c.style}`))})]}):null]})]})}function A({icon:t,children:i}){return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:12,color:a.muted,fontSize:12,fontWeight:600},children:[t,i]})}function E({label:t,value:i}){return e.jsxs("div",{style:{padding:14,borderRadius:d.lg,border:x.default,background:a.page},children:[e.jsx("div",{style:{color:a.subtle,fontSize:10,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.06em"},children:t}),e.jsx("div",{style:{marginTop:7,color:a.muted,fontSize:12,lineHeight:1.35},children:i})]})}function xt(){return e.jsxs("div",{"data-testid":"agent-analysis-skeleton",style:{display:"grid",gap:10,padding:16,borderRadius:d.lg,background:a.page},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,color:a.muted,fontSize:12},children:[e.jsx(B,{size:14,weight:"fill"})," Analisando imagem e contexto do produto…"]}),e.jsx(R,{style:{height:12,width:"92%"}}),e.jsx(R,{style:{height:12,width:"74%"}})]})}function yt(){return e.jsxs("div",{style:{display:"grid",gap:12,padding:18,borderRadius:d.xl,border:x.default},children:[e.jsx(R,{style:{height:18,width:"48%"}}),e.jsx(R,{style:{height:12,width:"86%"}}),e.jsx(R,{style:{height:12,width:"70%"}}),e.jsx(R,{style:{height:40,width:"100%",marginTop:6}})]})}function vt({product:t,error:i,onRetry:r}){var o;const l=(t.gallery_urls??[]).filter(Boolean).length,s=[t.category,t.subcategory,t.product_form,...t.traits??[]].filter(Boolean).slice(0,6);return e.jsxs("div",{"data-testid":"agent-product-catalog-reading",style:{padding:16,borderRadius:d.lg,border:x.default,background:a.page},children:[e.jsx("div",{style:{fontSize:13,fontWeight:600},children:"Conteúdo do catálogo disponível"}),e.jsx("div",{style:{marginTop:6,color:a.muted,fontSize:12,lineHeight:1.5},children:"A análise visual avançada está indisponível, mas isso não bloqueia os dados recebidos da Nuvemshop."}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(2, minmax(0, 1fr))",gap:8,marginTop:14},children:[e.jsx(E,{label:"Imagens",value:`${l}`}),e.jsx(E,{label:"Variantes",value:`${t.variant_count??0}`})]}),(o=t.description)!=null&&o.trim()?e.jsx("div",{style:{marginTop:12,color:a.muted,fontSize:11,lineHeight:1.5},children:t.description}):e.jsx("div",{style:{marginTop:12,color:a.subtle,fontSize:11},children:"Descrição não recebida nesta leitura. Isso não significa que esteja ausente na loja."}),s.length?e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:6,marginTop:12},children:s.map(u=>e.jsx("span",{style:{padding:"5px 8px",borderRadius:d.pill,border:x.default,background:a.surface,color:a.muted,fontSize:10},children:u},u))}):null,e.jsx("div",{style:{marginTop:12,color:a.subtle,fontSize:10,lineHeight:1.45},children:"O enriquecimento visual está indisponível. A orientação abaixo usa os dados do catálogo."}),e.jsx("button",{type:"button",onClick:r,style:{...D,width:"auto",marginTop:12,padding:"8px 12px"},children:"Tentar enriquecer com Vision"})]})}const bt={width:"100%",minHeight:42,display:"inline-flex",alignItems:"center",justifyContent:"center",gap:8,border:0,borderRadius:d.md,background:a.text,color:a.surface,fontSize:13,fontWeight:600,cursor:"pointer",opacity:1},ge={width:"100%",minHeight:42,display:"inline-flex",alignItems:"center",justifyContent:"center",gap:8,border:0,borderRadius:d.md,background:a.text,color:a.surface,fontSize:12,fontWeight:650,cursor:"pointer"},D={width:"100%",minHeight:40,display:"inline-flex",alignItems:"center",justifyContent:"center",border:x.default,borderRadius:d.md,background:a.surface,color:a.muted,fontSize:12,fontWeight:600,cursor:"pointer"};export{gi as ProductAgentDrawer,mi as RecommendationReviewDrawer,pi 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.