1import{r as f,j as e,L as I}from"./react-vendor-Cvme-g6x.js";import{c as be,as as ve,y as l,t as b,m as _,L as je,B as j,g as G,r as A,j as te,q as w}from"./index-BJjQW3BE.js";import{S as re}from"./switch-C_uePLoX.js";import{r as Ne}from"./supportTicketAttachment-BKU2TDJU.js";import{C as ae}from"./circle-check-CauAGcIi.js";import{S as we}from"./search-YQr2vLbu.js";import{R as ne}from"./refresh-cw-DJOLxwhX.js";import{T as ye}from"./trash-2-BEB0qm-Y.js";import{I as Se}from"./image-plus-UC9GVPQ_.js";import{E as ke}from"./external-link-hulnOIDb.js";/** 2 * @license lucide-react v0.453.0 - ISC 3 * 4 * This source code is licensed under the ISC license. 5 * See the LICENSE file in the root directory of this source tree. 6 */const Me=be("ShieldAlert",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]]),Ie=/ltwebstatic\.com|sheinsz\.com/i;function ie(t){let r=String(t??"").trim();if(!r)return null;r.startsWith("//")&&(r=`https:${r}`);const n=r.match(/((?:img\.)?ltwebstatic\.com\/[^\s"'<>\\]+)/i);if(n?.[1])return`https://${n[1].replace(/\\u002F/gi,"/").replace(/\\\//g,"/").split(/[?#]/)[0]}`;const a=r.match(/(sheinsz\.com\/[^\s"'<>\\]+)/i);return a?.[1]?`https://${a[1].split(/[?#]/)[0]}`:r}function Ae(t){const r=ie(t),n=String(r??"").trim();if(!n)return null;if(!Ie.test(n))return n;let a=n;try{const i=new URL(n.startsWith("//")?`https:${n}`:n);i.search="",i.hash="",a=i.toString()}catch{a=n.split("?")[0]?.split("#")[0]||n}return a=ie(a)||a,/_thumbnail_\d+x\d+\.avif$/i.test(a)?a.replace(/\.avif$/i,".jpg"):/_square_thumbnail_\d+x\d+\.avif$/i.test(a)?a.replace(/\.avif$/i,".jpg"):/_square\.(avif|webp)$/i.test(a)&&!/thumbnail/i.test(a)?a.replace(/_square\.(avif|webp)$/i,"_thumbnail_405x552.jpg"):/\/(?:v4|images3_spmp|gspCenter)\//i.test(a)&&/\.avif$/i.test(a)?a.replace(/\.avif$/i,".jpg"):/\/v4\/[pj]\/ccc\/|images3_ccc|images3_ac[ph]/i.test(a)||/shein\.com\/.+ltwebstatic\.com/i.test(a)?null:a}function Pe(t){const r=String(t||"").trim();return r?r.startsWith("http://")||r.startsWith("https://")||r.startsWith("data:")?Ae(r)||r:r.startsWith("/api/")?`${ve().replace(/\/$/,"")}${r}`:r:null}function oe(t){const r=t.replace(/\./g,"").replace(",","."),n=parseFloat(r);return!Number.isFinite(n)||n<=0?null:n.toFixed(2)}function Ce(t){const r=String(t||"");if(!r.trim())return{currentPrice:null,originalPrice:null};const n=r.match(/~R\$\s*([\d.,]+)\s*~/i),a=n?oe(n[1]):null,i=[...r.matchAll(/R\$\s*([\d.,]+)/gi)].map(m=>({raw:m[1],num:parseFloat(m[1].replace(/\./g,"").replace(",","."))}));if(!i.length)return{currentPrice:null,originalPrice:a};const c=i.filter(m=>Number.isFinite(m.num)&&m.num>0);if(!c.length)return{currentPrice:null,originalPrice:a};let x=c[c.length-1].raw;return c.length>=2&&(x=[...c].sort((h,v)=>h.num-v.num)[0].raw),{currentPrice:oe(x),originalPrice:a}}function qe(t){return t.mirrorSourceChatId||t.mirrorSourceGroupName||t.mirrorImportedAt||t.origin==="imported"?!0:String(t.notes||"").toLowerCase().includes("espelho de links")}function U(t){const r=t.mirrorImportedAt||t.createdAt;if(!r)return 0;const n=new Date(r).getTime();return Number.isFinite(n)?n:0}function ze(t){const r=new Map;for(const n of t){const a=String(n.mirrorSourceGroupName||"").trim()||"Espelho WhatsApp",i=U(n),c=i>0?new Date(i):null,x=c?c.toLocaleDateString("pt-BR",{day:"2-digit",month:"2-digit",year:"numeric"}):"Sem data",m=`${a}::${x}`;r.has(m)||r.set(m,{groupName:a,dayLabel:x,items:[],sortTs:i,minTs:i||Number.MAX_SAFE_INTEGER,maxTs:i||0});const h=r.get(m);h.items.push(n),i>h.sortTs&&(h.sortTs=i),i>0&&i<h.minTs&&(h.minTs=i),i>h.maxTs&&(h.maxTs=i)}return Array.from(r.entries()).map(([n,a])=>{a.items.sort((c,x)=>U(x)-U(c));let i="";if(a.minTs!==Number.MAX_SAFE_INTEGER&&a.maxTs>0){const c=x=>new Date(x).toLocaleTimeString("pt-BR",{hour:"2-digit",minute:"2-digit"});i=a.minTs===a.maxTs?c(a.maxTs):`${c(a.minTs)} â ${c(a.maxTs)}`}return{key:n,groupName:a.groupName,dayLabel:a.dayLabel,timeRangeLabel:i,items:a.items,sortTs:a.sortTs}}).sort((n,a)=>a.sortTs-n.sortTs)}
6function le(t){const r=new URLSearchParams;r.set("tab","biblioteca"),r.set("mirror","1");const n=t?.offerIds?.filter(a=>Number.isFinite(a)&&a>0)??(t?.offerId&&t.offerId>0?[t.offerId]:[]);return n.length===1?r.set("offerId",String(n[0])):n.length>1&&r.set("offerIds",n.join(",")),`/offers?${r.toString()}`}function Ee(t){const r=[`${t.scannedMessages} msg lida(s)`,t.imported?`${t.imported} importada(s)`:null,t.skipped?`${t.skipped} ignorada(s)`:null,t.failed?`${t.failed} falha(s)`:null].filter(Boolean).join(" · "),n=t.groupErrors.length>0&&t.groupsOk>0?`${t.groupsOk}/${t.groupsTotal} grupo(s) OK.`:null;if(t.groupErrors.length>0&&t.scannedMessages===0){l.error(t.groupErrors[0]??"Não foi possÃvel ler mensagens dos grupos.");return}if(t.groupErrors.length>0){l.warning("Varredura parcial",{description:[n,r,t.groupErrors[0]].filter(Boolean).join(" "),duration:8e3});return}if(t.imported>0){l.success("Varredura concluÃda",{description:`${r}. Confira na galeria.`,duration:6e3});return}if(t.scannedMessages===0){l.message("Nenhuma mensagem lida",{description:"O WhatsApp não devolveu histórico dos grupos. Reconecte ou use «Entrar no grupo» pelo convite.",duration:7e3});return}l.message("Varredura concluÃda â nada novo",{description:`${r}. Nenhum link novo de Shopee, Mercado Livre, Amazon ou Magalu nas últimas mensagens.`,duration:7e3})}function ce(t){if(!t)return null;const r=String(t).trim();if(!r)return null;if(/R\$/i.test(r))return r;const n=Number(r.replace(",","."));return!Number.isFinite(n)||n<=0?r:n.toLocaleString("pt-BR",{style:"currency",currency:"BRL"})}function Le(t,r){if(t.length!==r.length)return!1;const n=[...t].sort(),a=[...r].sort();return n.every((i,c)=>i===a[c])}function De({connected:t,groups:r,loadingGroups:n,canUse:a,onViewImports:i,embedded:c=!1,whatsappProvider:x=null}){const[m,h]=f.useState(!1),[v,W]=f.useState(!0),[p,P]=f.useState([]),[C,q]=f.useState(""),[E,me]=f.useState(""),[S,de]=f.useState(null),[L,ue]=f.useState(!0),u=b.linkMirror.getSettings.useQuery(void 0,{enabled:a}),$=u.data?.limits,T=$?.maxSourceGroups??3,z=$?.maxFetchMessages??30,D=$?.maxEnrichPerBatch??20,g=b.linkMirror.listImports.useQuery({limit:L?4:40},{enabled:a}),F=b.useUtils(),k=b.linkMirror.saveSettings.useMutation({onSuccess(s){const o=s.enabled&&s.listenNewMessages&&s.sourceChatIds.length>0;l.success(o?"Espelho salvo â ouvindo mensagens novas nos grupos selecionados.":"Espelho de links salvo."),u.refetch()},onError(s){l.error(s.message||"Erro ao salvar espelho.")}}),N=b.linkMirror.fetchRecent.useMutation({onSuccess(s){de(s),Ee(s),g.refetch(),u.refetch()},onError(s){l.error(s.message||"Erro ao buscar mensagens.")}}),y=b.linkMirror.enrichImportedOffers.useMutation({onSuccess(s){s.enriched>0?l.success(`Fotos e preços: ${s.enriched} oferta(s) atualizada(s).`,{description:s.partial||s.stillMissingImage>0?`${s.stillMissingImage} ainda sem foto â rode de novo (Shopee ~1 min/item; lote parcial ok).`:s.skipped>0||s.failed>0?`${s.skipped} sem dados novos · ${s.failed} falha(s).`:"Confira na galeria (modo Espelho WhatsApp).",duration:8e3}):s.stillMissingImage>0||s.partial?l.message("Algumas ofertas ainda estão sem foto.",{description:"A Shopee demora até ~1 min por produto. Clique de novo em «Buscar fotos e preços».",duration:8e3}):l.message("Nenhuma oferta pendente de enriquecimento.",{description:"As lojas podem bloquear a leitura automática. Abra o produto no conversor se precisar validar manualmente."}),F.offers.listMine.invalidate(),g.refetch()},onError(s){l.error(s.message||"Erro ao buscar fotos e preços.")}}),B=b.linkMirror.clearImports.useMutation({onSuccess(s){const o=Number(s.deleted||0),d=Number(s.deletedOffers||0);o>0||d>0?l.success([o>0?`${o} registro(s) de espelhamento removido(s)`:null,d>0?`${d} oferta(s) removida(s) da galeria`:null].filter(Boolean).join(" · ")+"."):l.success("Nenhum histórico para limpar."),g.refetch(),F.offers.listMine.invalidate()},onError(s){l.error(s.message||"Erro ao limpar histórico.")}}),O=b.offers.setProductImage.useMutation({onSuccess(){l.success("Foto enviada."),g.refetch(),F.offers.listMine.invalidate()},onError(s){l.error(s.message||"Erro ao enviar foto.")}});async function pe(s,o){try{const d=await Ne(o);await O.mutateAsync({offerId:s,imageDataUrl:d})}catch(d){l.error(d instanceof Error?d.message:"Falha ao ler a imagem.")}}const M=b.linkMirror.joinGroupByInvite.useMutation({onSuccess(s){l.success(`Entrou no grupo «${s.name}».`,{description:"Salve o espelho para incluir este grupo como fonte."}),q(""),P(o=>o.includes(s.chatId)?o:[...o,s.chatId])},onError(s){l.error(s.message||"Não foi possÃvel entrar no grupo.")}});f.useEffect(()=>{u.data&&(h(u.data.enabled),W(u.data.listenNewMessages),P(u.data.sourceChatIds))},[u.data]);const V=f.useMemo(()=>u.data?m!==u.data.enabled||v!==u.data.listenNewMessages||!Le(p,u.data.sourceChatIds):!1,[m,v,p,u.data]),Q=f.useMemo(()=>p.map(s=>r.find(d=>d.id===s)??{id:s,name:`Grupo salvo (${s.slice(0,12)}â¦)`}),[r,p]),H=f.useMemo(()=>g.data??[],[g.data]),X=f.useMemo(()=>{const s=E.trim().toLowerCase();return s?r.filter(o=>o.name.toLowerCase().includes(s)||o.id.toLowerCase().includes(s)):r},[r,E]);function xe(s){P(o=>o.includes(s)?o.filter(d=>d!==s):o.length>=T?(l.message(`Máximo de ${T} grupo(s) fonte.`),o):[...o,s])}async function he(){if(!p.length){l.message("Selecione ao menos um grupo fonte.");return}await k.mutateAsync({enabled:m,listenNewMessages:v,sourceChatIds:p})}async function fe(){if(!p.length){l.message("Selecione ao menos um grupo fonte.");return}V&&await k.mutateAsync({enabled:m,listenNewMessages:v,sourceChatIds:p});try{await N.mutateAsync({limit:z})}catch{return}l.message("Buscando fotos e preços dos produtos importadosâ¦",{description:"Shopee pode levar até ~1 min por oferta. Deixe concluir antes de fechar a página.",duration:8e3}),await y.mutateAsync({limit:Math.min(D,8)})}async function ge(){l.message("Buscando fotos e preçosâ¦",{description:"Prioriza ofertas com preço mas sem foto. Shopee: até ~1 min por item (até 8 por clique).",duration:8e3}),await y.mutateAsync({limit:Math.min(D,8)})}const K=k.isPending||N.isPending||M.isPending||y.isPending;return a?e.jsxs("section",{className:_("overflow-hidden rounded-2xl border-2 border-amber-200/90 bg-gradient-to-br from-amber-50/70 via-white to-orange-50/40 p-3 shadow-sm sm:p-4",!c&&"mt-4"),children:[e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("h3",{className:"flex items-center gap-2 text-sm font-black text-slate-900",children:[e.jsx(je,{className:"h-4 w-4 shrink-0 text-amber-600"}),"Espelho de links (MVP)"]}),e.jsxs("p",{className:"mt-1 max-w-2xl text-xs leading-relaxed text-slate-600",children:["Monitora grupos de achadinhos onde você já é membro, extrai links de produto, reconverte para seu ID e importa na"," ",e.jsx("strong",{className:"font-bold text-slate-800",children:"Galeria"})," para você revisar."," ",e.jsx("strong",{className:"font-bold text-slate-800",children:"Não republica automaticamente"})," ","â dispare pelo conversor ou piloto quando quiser."]})]}),i?e.jsxs(j,{type:"button",variant:"outline",onClick:i,className:"inline-flex h-11 min-h-[44px] w-full shrink-0 touch-manipulation items-center justify-center gap-1 rounded-xl border-amber-200 bg-white px-3 text-xs font-bold text-amber-900 hover:bg-amber-50 sm:w-auto",children:["Ver importações",e.jsx(G,{className:"h-3.5 w-3.5"})]}):e.jsxs(I,{to:le(),className:"inline-flex h-11 min-h-[44px] w-full shrink-0 items-center justify-center gap-1 rounded-xl border border-amber-200 bg-white px-3 text-xs font-bold text-amber-900 hover:bg-amber-50 touch-manipulation sm:w-auto",children:["Abrir galeria",e.jsx(G,{className:"h-3.5 w-3.5"})]})]}),t?null:e.jsxs("p",{className:"mt-3 rounded-xl border border-amber-200 bg-amber-50 px-3 py-2 text-xs font-semibold text-amber-900",children:["Conecte o WhatsApp na"," ",e.jsx(I,{to:"/affiliates",className:"underline underline-offset-2 hover:text-amber-950",children:"Central do Afiliado"})," ","para usar o espelho de links."]}),V?e.jsx("p",{className:"mt-3 rounded-xl border border-amber-300 bg-amber-100/80 px-3 py-2 text-xs font-semibold text-amber-950",children:"Alterações não salvas â clique em «Salvar espelho» ou elas serão aplicadas ao buscar mensagens."}):null,e.jsxs("div",{className:"mt-4 grid grid-cols-1 gap-4 lg:grid-cols-2",children:[e.jsxs("div",{className:"min-w-0 space-y-3 rounded-xl border border-slate-200 bg-white/90 p-3 sm:p-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx(A,{htmlFor:"mirror-enabled",className:"text-xs font-bold text-slate-800",children:"Ativar espelho"}),e.jsx(re,{id:"mirror-enabled",checked:m,onCheckedChange:h,disabled:!t||K})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx(A,{htmlFor:"mirror-listen",className:"text-xs font-bold text-slate-800",children:"Ouvir mensagens novas"}),e.jsx(re,{id:"mirror-listen",checked:v,onCheckedChange:W,disabled:!t||K})]}),m&&v&&p.length>0?e.jsxs("p",{className:"rounded-lg bg-emerald-50 px-2.5 py-2 text-[11px] font-medium text-emerald-900",children:["Ouvindo ",p.length," grupo(s) fonte â links novos entram na galeria automaticamente",x==="evolution"?" (Evolution: webhook + busca manual).":"."]}):null,x==="evolution"?e.jsx("p",{className:"rounded-lg border border-amber-200 bg-amber-50 px-2.5 py-2 text-[11px] font-medium text-amber-950",children:"WhatsApp via Evolution: salve o espelho e use «Buscar últimas mensagens» para importar. Tempo real depende do webhook alcançar a API."}):null,e.jsxs("div",{children:[e.jsx(A,{className:"text-[10px] font-black uppercase text-slate-500",children:"Link de convite do grupo (opcional)"}),e.jsxs("div",{className:"mt-1 flex flex-col gap-2 sm:flex-row",children:[e.jsx(te,{value:C,onChange:s=>q(s.target.value),placeholder:"https://chat.whatsapp.com/...",className:"h-10 text-xs",disabled:!t||M.isPending}),e.jsxs(j,{type:"button",variant:"outline",className:"h-10 min-h-[40px] touch-manipulation text-xs font-bold",disabled:!t||!C.trim()||M.isPending,onClick:()=>void M.mutateAsync({inviteUrlOrCode:C.trim()}),children:[M.isPending?e.jsx(w,{className:"mr-1.5 h-3.5 w-3.5 animate-spin"}):null,"Entrar no grupo"]})]})]}),e.jsxs("div",{children:[e.jsxs(A,{className:"text-[10px] font-black uppercase text-slate-500",children:["Grupos fonte (",p.length,"/",T,")"]}),Q.length>0?e.jsx("div",{className:"mt-1.5 flex flex-wrap gap-1.5",children:Q.map(s=>e.jsxs("span",{className:"inline-flex max-w-full items-center gap-1 rounded-full bg-amber-100 px-2 py-0.5 text-[10px] font-bold text-amber-950",children:[e.jsx(ae,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:"truncate",children:s.name})]},s.id))}):e.jsx("p",{className:"mt-1 text-[11px] text-slate-500",children:"Nenhum grupo selecionado ainda."}),e.jsxs("div",{className:"relative mt-2",children:[e.jsx(we,{className:"pointer-events-none absolute left-2.5 top-2.5 h-3.5 w-3.5 text-slate-400"}),e.jsx(te,{value:E,onChange:s=>me(s.target.value),placeholder:"Buscar grupo...",className:"h-9 pl-8 text-xs"})]}),e.jsx("div",{className:"mt-2 max-h-44 space-y-1 overflow-y-auto rounded-lg border border-slate-100 p-1",children:n?e.jsx("p",{className:"p-2 text-xs text-slate-500",children:"Carregando gruposâ¦"}):X.length?X.map(s=>
6{const o=p.includes(s.id);return e.jsxs("button",{type:"button",onClick:()=>xe(s.id),className:["flex min-h-[44px] w-full touch-manipulation items-center justify-between gap-2 rounded-lg px-2 py-2 text-left text-xs",o?"bg-amber-100 font-bold text-amber-950":"hover:bg-slate-50 text-slate-700"].join(" "),children:[e.jsx("span",{className:"truncate",children:s.name}),o?e.jsx(ae,{className:"h-4 w-4 shrink-0 text-amber-700"}):null]},s.id)}):e.jsx("p",{className:"p-2 text-xs text-slate-500",children:"Nenhum grupo encontrado. Use o link de convite ou aguarde a lista."})})]}),e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:flex-wrap",children:[e.jsxs(j,{type:"button",onClick:()=>void he(),disabled:!t||k.isPending,className:"h-11 min-h-[44px] w-full touch-manipulation bg-amber-600 text-xs font-bold text-white hover:bg-amber-700 sm:w-auto",children:[k.isPending?e.jsx(w,{className:"mr-1.5 h-3.5 w-3.5 animate-spin"}):null,"Salvar espelho"]}),e.jsxs(j,{type:"button",variant:"outline",onClick:()=>void fe(),disabled:!t||!p.length||N.isPending,className:"h-11 min-h-[44px] w-full touch-manipulation text-xs font-bold sm:w-auto",children:[N.isPending?e.jsx(w,{className:"mr-1.5 h-3.5 w-3.5 animate-spin"}):e.jsx(ne,{className:"mr-1.5 h-3.5 w-3.5"}),N.isPending?"Lendo WhatsAppâ¦":y.isPending?"Buscando fotos/preçosâ¦":`Buscar últimas ${z} msgs`]}),e.jsxs(j,{type:"button",variant:"outline",onClick:()=>void ge(),disabled:!t||y.isPending||N.isPending,className:"h-11 min-h-[44px] w-full touch-manipulation text-xs font-bold sm:w-auto",children:[y.isPending?e.jsx(w,{className:"mr-1.5 h-3.5 w-3.5 animate-spin"}):null,"Buscar fotos e preços"]}),e.jsx("p",{className:"mt-1.5 text-[10px] leading-snug text-slate-500 sm:col-span-2",children:"Novos posts: a foto do WhatsApp é gravada primeiro. «Buscar fotos» só completa o que ainda ficou sem imagem (raspagem da loja)."})]}),N.isPending?e.jsx("p",{className:"text-[11px] text-slate-500",children:"Pode levar até ~10 s por grupo (abre o chat no WhatsApp Web)."}):null,e.jsxs("p",{className:"flex items-start gap-1.5 text-[11px] text-amber-900/90",children:[e.jsx(Me,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),"Use só em grupos onde você é membro. O espelho importa na galeria â não envia posts sozinho (menos risco de ban/spam)."]})]}),e.jsxs("div",{className:"min-w-0 rounded-xl border border-slate-200 bg-white/90 p-3 sm:p-4",children:[e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-[10px] font-black uppercase tracking-wide text-slate-500",children:"Importações recentes"}),u.data?.lastFetchAt?e.jsxs("p",{className:"mt-1 text-[11px] leading-snug text-slate-500",children:["Ãltima varredura manual:"," ",e.jsx("span",{className:"font-semibold text-slate-700",children:new Date(u.data.lastFetchAt).toLocaleString("pt-BR")})]}):e.jsx("p",{className:"mt-1 text-[11px] text-slate-500",children:"Nenhuma varredura manual ainda."})]}),e.jsxs("div",{className:"flex flex-wrap items-stretch gap-2 sm:justify-end",children:[e.jsx(j,{type:"button",variant:"outline",size:"sm",className:"h-10 min-h-[44px] flex-1 touch-manipulation px-2.5 text-[11px] font-bold text-slate-700 sm:flex-none",onClick:()=>ue(s=>!s),children:L?"Ver todas":"Só 4 últimas"}),e.jsxs(j,{type:"button",variant:"outline",size:"sm",className:"h-10 min-h-[44px] flex-1 touch-manipulation px-2.5 text-[11px] font-bold text-red-700 hover:bg-red-50 hover:text-red-800 sm:flex-none",disabled:B.isPending,onClick:()=>{window.confirm(`Limpar o histórico do espelhamento? 7 8Isso também remove da galeria as ofertas importadas por aqui (incluindo as sem foto).`)&&B.mutate()},children:[B.isPending?e.jsx(w,{className:"mr-1.5 h-3.5 w-3.5 animate-spin"}):e.jsx(ye,{className:"mr-1.5 h-3.5 w-3.5"}),"Limpar"]}),e.jsx(j,{type:"button",variant:"outline",size:"sm",className:"h-10 min-h-[44px] w-10 shrink-0 touch-manipulation px-0 sm:w-auto sm:px-2.5",disabled:g.isFetching,"aria-label":"Atualizar importações",onClick:()=>void g.refetch(),children:g.isFetching?e.jsx(w,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(ne,{className:"h-3.5 w-3.5"})})]})]}),e.jsx("p",{className:"mt-1 text-[10px] text-slate-500",children:L?"Mostrando as 4 importações mais recentes.":"Mostrando histórico completo (até 40)."}),S?e.jsxs("div",{className:"mt-2 grid grid-cols-2 gap-1.5 rounded-lg border border-slate-100 bg-slate-50/90 p-2 text-[10px] sm:grid-cols-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-black uppercase text-slate-500",children:"Lidas"}),e.jsx("p",{className:"text-sm font-black text-slate-900",children:S.scannedMessages})]}),e.jsxs("div",{children:[e.jsx("p",{className:"font-black uppercase text-emerald-700",children:"Importadas"}),e.jsx("p",{className:"text-sm font-black text-emerald-800",children:S.imported})]}),e.jsxs("div",{children:[e.jsx("p",{className:"font-black uppercase text-slate-500",children:"Ignoradas"}),e.jsx("p",{className:"text-sm font-black text-slate-700",children:S.skipped})]}),e.jsxs("div",{children:[e.jsx("p",{className:"font-black uppercase text-red-700",children:"Falhas"}),e.jsx("p",{className:"text-sm font-black text-red-800",children:S.failed})]})]}):null,e.jsx("ul",{className:"mt-2 max-h-[min(28rem,55vh)] space-y-2.5 overflow-y-auto overscroll-y-contain [-webkit-overflow-scrolling:touch] sm:max-h-[28rem]",children:H.length?H.map(s=>{const o=Ce(s.messagePreview),d=ce(s.currentPrice||o.currentPrice||null),R=ce(s.originalPrice||o.originalPrice||null),J=s.convertedUrl||s.originalUrl,Y=Pe(s.productImage),Z=O.isPending&&Number(O.variables?.offerId)===Number(s.userOfferId);return e.jsxs("li",{className:"rounded-xl border border-slate-200 bg-white p-3 shadow-sm",children:[e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row",children:[e.jsx("div",{className:"mx-auto flex h-24 w-24 shrink-0 items-center justify-center overflow-hidden rounded-lg border border-slate-100 bg-slate-50 p-1 sm:mx-0 sm:h-16 sm:w-16",children:Y?e.jsx("img",{src:Y,alt:"",className:"max-h-full max-w-full object-contain",loading:"lazy"}):s.userOfferId?e.jsxs("label",{className:"flex h-full w-full cursor-pointer flex-col items-center justify-center gap-0.5 px-1 text-center touch-manipulation",children:[Z?e.jsx(w,{className:"h-4 w-4 animate-spin text-amber-700"}):e.jsx(Se,{className:"h-4 w-4 text-amber-700"}),e.jsx("span",{className:"text-[8px] font-bold leading-tight text-amber-900",children:"Enviar foto"}),e.jsx("input",{type:"file",accept:"image/png,image/jpeg,image/webp,image/*",className:"sr-only",disabled:Z,onChange:ee=>{const se=ee.target.files?.[0];ee.target.value="",se&&s.userOfferId&&pe(s.userOfferId,se)}})]}):e.jsx("div",{className:"flex h-full w-full items-center justify-center px-1 text-center text-[9px] font-semibold text-slate-400",children:"Sem foto"})}),e.jsxs("div",{className:"min-w-0 flex-1 text-center sm:text-left",children:[e.jsx("p",{className:"text-sm font-bold leading-snug text-slate-900 line-clamp-3",children:s.productTitle||s.originalUrl}),d?e.jsxs("p",{className:"mt-1 text-base font-black text-emerald-700 sm:text-sm",children:[d,R&&R!==d?e.jsx("span",{className:"ml-1.5 text-xs font-semibold text-slate-400 line-through",children:R}):null]}):null,e.jsxs("p",{className:"mt-1.5 text-[11px] leading-relaxed text-slate-500",children:[e.jsx("span",{className:"block sm:inline",children:s.sourceGroupName||"Grupo"}),e.jsx("span",{className:"hidden sm:inline",children:" · "}),e.jsx("span",{className:_("block font-bold sm:inline",s.status==="imported"?"text-emerald-700":s.status==="failed"?"text-red-700":"text-slate-600"),children:s.status==="imported"?"Importado":s.status==="failed"?"Falhou":"Ignorado"}),e.jsxs("span",{className:"mt-0.5 block text-slate-500 sm:mt-0 sm:inline",children:[e.jsx("span",{className:"hidden sm:inline",children:" · "}
8),new Date(s.createdAt).toLocaleString("pt-BR",{day:"2-digit",month:"2-digit",year:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"})]})]})]})]}),s.errorMessage?e.jsx("p",{className:"mt-2 text-[11px] text-red-700",children:s.errorMessage}):null,s.status==="imported"?e.jsxs("div",{className:"mt-2.5 flex flex-col gap-2 sm:flex-row sm:flex-wrap",children:[J?e.jsxs("a",{href:J,target:"_blank",rel:"noopener noreferrer",className:"inline-flex min-h-[44px] w-full touch-manipulation items-center justify-center gap-1 rounded-lg border border-slate-200 bg-slate-50 px-2.5 text-[11px] font-bold text-slate-800 hover:bg-slate-100 sm:w-auto sm:justify-start",children:["Abrir oferta",e.jsx(ke,{className:"h-3 w-3"})]}):null,s.userOfferId?e.jsxs(I,{to:le({offerId:s.userOfferId}),className:"inline-flex min-h-[44px] w-full touch-manipulation items-center justify-center gap-1 rounded-lg border border-amber-200 bg-amber-50 px-2.5 text-[11px] font-bold text-amber-900 hover:bg-amber-100 sm:w-auto sm:justify-start",children:["Ver na galeria",e.jsx(G,{className:"h-3 w-3"})]}):null]}):null]},s.id)}):e.jsx("li",{className:"rounded-lg border border-dashed border-slate-200 p-3 text-xs text-slate-500",children:"Nenhuma importação ainda. Ative o espelho ou busque mensagens recentes."})})]})]})]}):e.jsxs("section",{className:_("rounded-2xl border border-slate-200 bg-slate-50 p-4",!c&&"mt-4"),children:[e.jsx("p",{className:"text-sm font-bold text-slate-800",children:"Espelho de links"}),e.jsxs("p",{className:"mt-1 text-xs text-slate-600",children:["DisponÃvel no Elite com WhatsApp conectado. Conecte o WhatsApp na"," ",e.jsx(I,{to:"/affiliates",className:"font-semibold text-violet-700 underline-offset-2 hover:underline",children:"Central do Afiliado"}),"."]})]})}export{De as L,Me as S,le as b,ze as g,qe as i,Pe as r};
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.