1import{r as v,j as s}from"./vendor-react-laEpRAYK.js";import{b as gs,ab as g,ac as p,al as ps,am as js,an as Y,ao as G,ad as D,ae as B,bl as _,aV as k,aa as fs,B as d,u as l,s as f,aG as J,aH as K,aI as W,aJ as X,bV as bs,aK as P,I as Ns,ah as Q}from"./index-CdVT36Rl.js";import{g as b,v as Z,H as ss,aq as es,br as vs,ak as ws,bm as ys,j as T,s as Ss,an as Is,bs as as,bt as ts,as as rs,D as cs,a3 as Ls}from"./vendor-icons-BrcIIWvK.js";import"./vendor-pdf-Dvu_SL5_.js";import"./vendor-radix-CCEge6f_.js";import"./utils-B8VeSWBZ.js";import"./vendor-supabase-BoBgOU0W.js";import"./vendor-router-DYxBvg43.js";import"./vendor-query-DcdIi559.js";import"./vendor-dates-Di6Qw362.js";import"./vendor-motion-aCppnIeO.js";import"./vendor-carousel-UBN6M1Fg.js";import"./vendor-forms-jNas-3k8.js";import"./vendor-charts-BSAJ30E_.js";function Vs(){const{brandId:A}=gs(),[i,is]=v.useState(null),[o,ls]=v.useState(null),[ns,ds]=v.useState(!0),[j,M]=v.useState(!1),[y,V]=v.useState(!1),[F,q]=v.useState(!1),[$,H]=v.useState({processed:0,success:0,total:0}),[E,O]=v.useState(null),[t,m]=v.useState({discoveredUrls:[],isDiscovering:!1,isScraping:!1,selectedBrandId:A,batchSize:5,currentBatch:0,totalBatches:0,processedCount:0,failedCount:0,log:[]}),L=async()=>{try{const e="%supabase.co/storage%",a=()=>f.from("scraped_products").select("id",{count:"exact",head:!0}),[c,r,n,x,N,u,h,I]=await Promise.all([a(),a().not("image_url","is",null),a().like("image_url",e),a().not("pdf_url","is",null),a().not("price_retail","is",null),a().not("ingredients","is",null),a().not("benefits","is",null),a().not("usage_instructions","is",null)]);is({total:c.count??0,withImages:r.count??0,withLocalImages:n.count??0,withPdfs:x.count??0,withPrices:N.count??0,withIngredients:u.count??0,withBenefits:h.count??0,withUsage:I.count??0});const{data:C}=await f.from("scraping_jobs").select("id, job_type, status, total_urls, processed_urls, failed_urls, current_index, started_at, completed_at, last_error, created_at, updated_at").eq("job_type","young-living-catalog").order("created_at",{ascending:!1}).limit(1).single();ls(C)}catch{}finally{ds(!1)}};v.useEffect(()=>{L();const e=setInterval(L,1e4);return()=>clearInterval(e)},[]);const w=e=>{m(a=>({...a,log:[...a.log,`[${new Date().toLocaleTimeString()}] ${e}`]}))},os=async()=>{m(e=>({...e,isDiscovering:!0,log:[]})),w("Iniciando descubrimiento de URLs de Labiatae...");try{const{data:e,error:a}=await f.functions.invoke("firecrawl-map",{body:{url:"https://www.labiatae.com/aceites-esenciales/",options:{limit:500,includeSubdomains:!1}}});if(a)throw a;const c=(e?.links||[]).filter(r=>r.includes("/aceites-esenciales/")&&!r.endsWith("/aceites-esenciales/")&&!r.includes("?")&&!r.includes("#"));w(`Descubiertas ${c.length} URLs de productos`),m(r=>({...r,discoveredUrls:c,isDiscovering:!1,totalBatches:Math.ceil(c.length/r.batchSize)})),l.success(`Descubiertas ${c.length} URLs de productos`)}catch(e){w(`Error: ${e instanceof Error?e.message:"Error desconocido"}`),l.error("Error al descubrir URLs"),m(a=>({...a,isDiscovering:!1}))}},ms=async()=>{const{discoveredUrls:e,batchSize:a,currentBatch:c,selectedBrandId:r}=t;if(e.length===0){l.error("Primero descubre las URLs");return}const n=c*a,x=Math.min(n+a,e.length),N=e.slice(n,x);if(N.length===0){l.success("¡Scraping completado! Todos los lotes procesados.");return}m(u=>({...u,isScraping:!0})),w(`Procesando lote ${c+1}/${t.totalBatches} (${N.length} URLs)`);try{const{data:u,error:h}=await f.functions.invoke("scrape-labiatae",{body:{urls:N,brand_id:r,batch_size:a}});if(h)throw h;const I=u?.processed||0,C=u?.failed||0;w(`Lote completado: ${I} productos procesados, ${C} fallidos`),m(U=>({...U,isScraping:!1,currentBatch:U.currentBatch+1,processedCount:U.processedCount+I,failedCount:U.failedCount+C})),l.success(`Lote ${c+1} completado: ${I} productos`),await L()}catch(u){w(`Error en lote: ${u instanceof Error?u.message:"Error desconocido"}`),l.error("Error al procesar el lote"),m(h=>({...h,isScraping:!1}))}},xs=async()=>{const{discoveredUrls:e,batchSize:a,selectedBrandId:c}=t;if(e.length===0){l.error("Primero descubre las URLs");return}m(n=>({...n,isScraping:!0,currentBatch:0,processedCount:0,failedCount:0}));const r=Math.ceil(e.length/a);for(let n=0;n<r;n++){const x=n*a,N=Math.min(x+a,e.length),u=e.slice(x,N);w(`Procesando lote ${n+1}/${r} (${u.length} URLs)`);try{const{data:h,error:I}=await f.functions.invoke("scrape-labiatae",{body:{urls:u,brand_id:c,batch_size:a}});if(I)throw I;const C=h?.processed||0,U=h?.failed||0;w(`Lote ${n+1} completado: ${C} productos, ${U} fallidos`),m(R=>({...R,currentBatch:n+1,processedCount:R.processedCount+C,failedCount:R.failedCount+U})),n<r-1&&await new Promise(R=>setTimeout(R,2e3))}catch(h){w(`Error en lote ${n+1}: ${h instanceof Error?h.message:"Error"}`)}}m(n=>({...n,isScraping:!1})),l.success("Scraping de Labiatae completado"),await L()},us=()=>{m({discoveredUrls:[],isDiscovering:!1,isScraping:!1,selectedBrandId:A,batchSize:5,currentBatch:0,totalBatches:0,processedCount:0,failedCount:0,log:[]})},z=async e=>{M(!0),O(e);try{const a=e==="regular"?{}:e==="images"?{rescrapeForImages:!0,limit:10}:e==="discover"?{discoverUrls:!0}:{deepRescrape:!0,limit:10},{data:c,error:r}=await f.functions.invoke("scrape-catalog",{body:a});if(r)throw r;l.success(e==="regular"?`Procesados ${c.processed||0} productos`:e==="images"?`Actualizadas imágenes de ${c.processed||0} productos`:e==="discover"?`Descubiertas ${c.totalUrls||0} URLs (${c.newUrls||0} nuevas)`:`Deep rescrape completado: ${c.processed||0} productos`),await L()}catch{l.error("Error al ejecutar el scraping")}finally{M(!1),O(null)}},hs=async()=>{V(!0);try{const{data:e,error:a}=await f.functions.invoke("download-product-images",{body:{batchSize:20}});if(a)throw a;l.success(`Descargadas ${e.successful||0} imágenes${e.failed>0?` (${e.failed} fallidas)`:""}`),await L()}catch{l.error("Error al descargar imágenes")}finally{V(!1)}};if(ns)return s.jsx(g,{children:s.jsx(p,{className:"py-8",children:s.jsxs("div",{className:"flex items-center justify-center gap-2 text-muted-foreground",children:[s.jsx(b,{className:"h-5 w-5 animate-spin"}),"Cargando estadÃsticas..."]})})});const S=(e,a)=>a>0?Math.round(e/a*100):0;return s.jsxs(ps,{defaultValue:"general",className:"space-y-6",children:[s.jsxs(js,{className:"grid w-full grid-cols-2",children:[s.jsxs(Y,{value:"general",className:"gap-2",children:[s.jsx(Z,{className:"h-4 w-4"}),"Young Living"]}),s.jsxs(Y,{value:"labiatae",className:"gap-2",children:[s.jsx(ss,{className:"h-4 w-4"}),"Labiatae"]})]}),s.jsxs(G,{value:"general",className:"space-y-6",children:[s.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-5 ga
1p-4",children:[s.jsx(g,{children:s.jsx(p,{className:"pt-6",children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"p-2 rounded-lg bg-primary/10",children:s.jsx(Z,{className:"h-5 w-5 text-primary"})}),s.jsxs("div",{children:[s.jsx("p",{className:"text-2xl font-semibold",children:i?.total||0}),s.jsx("p",{className:"text-xs text-muted-foreground",children:"Productos"})]})]})})}),s.jsx(g,{children:s.jsx(p,{className:"pt-6",children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"p-2 rounded-lg bg-success/20 dark:bg-success/30",children:s.jsx(es,{className:"h-5 w-5 text-success"})}),s.jsxs("div",{children:[s.jsxs("p",{className:"text-2xl font-semibold",children:[i?.withImages||0,s.jsxs("span",{className:"text-sm font-normal text-muted-foreground ml-1",children:["(",S(i?.withImages||0,i?.total||0),"%)"]})]}),s.jsx("p",{className:"text-xs text-muted-foreground",children:"Con imagen"})]})]})})}),s.jsx(g,{className:"border-success/20 dark:border-success",children:s.jsx(p,{className:"pt-6",children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"p-2 rounded-lg bg-success/20 dark:bg-success/30",children:s.jsx(vs,{className:"h-5 w-5 text-success"})}),s.jsxs("div",{children:[s.jsxs("p",{className:"text-2xl font-semibold",children:[i?.withLocalImages||0,s.jsxs("span",{className:"text-sm font-normal text-muted-foreground ml-1",children:["(",S(i?.withLocalImages||0,i?.total||0),"%)"]})]}),s.jsx("p",{className:"text-xs text-muted-foreground",children:"Imágenes locales"})]})]})})}),s.jsx(g,{children:s.jsx(p,{className:"pt-6",children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"p-2 rounded-lg bg-info/20 dark:bg-info/30",children:s.jsx(ws,{className:"h-5 w-5 text-info"})}),s.jsxs("div",{children:[s.jsxs("p",{className:"text-2xl font-semibold",children:[i?.withPdfs||0,s.jsxs("span",{className:"text-sm font-normal text-muted-foreground ml-1",children:["(",S(i?.withPdfs||0,i?.total||0),"%)"]})]}),s.jsx("p",{className:"text-xs text-muted-foreground",children:"Con PDF"})]})]})})}),s.jsx(g,{children:s.jsx(p,{className:"pt-6",children:s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"p-2 rounded-lg bg-warning/20 dark:bg-warning/30",children:s.jsx(ys,{className:"h-5 w-5 text-warning"})}),s.jsxs("div",{children:[s.jsxs("p",{className:"text-2xl font-semibold",children:[i?.withPrices||0,s.jsxs("span",{className:"text-sm font-normal text-muted-foreground ml-1",children:["(",S(i?.withPrices||0,i?.total||0),"%)"]})]}),s.jsx("p",{className:"text-xs text-muted-foreground",children:"Con precio"})]})]})})})]}),s.jsxs(g,{children:[s.jsxs(D,{children:[s.jsxs(B,{className:"text-lg flex items-center gap-2",children:[s.jsx(T,{className:"h-5 w-5 text-primary"}),"Información Detallada"]}),s.jsx(_,{children:"Productos con información enriquecida desde deep scraping"})]}),s.jsxs(p,{className:"space-y-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex justify-between text-sm",children:[s.jsx("span",{className:"text-muted-foreground",children:"Ingredientes"}),s.jsxs("span",{className:"font-medium",children:[i?.withIngredients||0," / ",i?.total||0]})]}),s.jsx(k,{value:S(i?.withIngredients||0,i?.total||0),className:"h-2"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex justify-between text-sm",children:[s.jsx("span",{className:"text-muted-foreground",children:"Beneficios"}),s.jsxs("span",{className:"font-medium",children:[i?.withBenefits||0," / ",i?.total||0]})]}),s.jsx(k,{value:S(i?.withBenefits||0,i?.total||0),className:"h-2"})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex justify-between text-sm",children:[s.jsx("span",{className:"text-muted-foreground",children:"Instrucciones de uso"}),s.jsxs("span",{className:"font-medium",children:[i?.withUsage||0," / ",i?.total||0]})]}),s.jsx(k,{value:S(i?.withUsage||0,i?.total||0),className:"h-2"})]})]})]}),o&&s.jsxs(g,{children:[s.jsx(D,{children:s.jsxs(B,{className:"text-lg flex items-center gap-2",children:[o.status==="in_progress"?s.jsx(b,{className:"h-5 w-5 animate-spin text-primary"}):o.status==="completed"?s.jsx(Ss,{className:"h-5 w-5 text-success"}):s.jsx(Is,{className:"h-5 w-5 text-warning"}),"Estado del Trabajo"]})}),s.jsxs(p,{children:[s.jsxs("div",{className:"flex items-center gap-4 mb-4",children:[s.jsx(fs,{variant:o.status==="completed"?"default":"secondary",className:o.status==="in_progress"?"bg-info/20 text-info":"",children:o.status==="in_progress"?"En progreso":o.status==="completed"?"Completado":"Pendiente"}),s.jsxs("span",{className:"text-sm text-muted-foreground",children:[o.processed_urls," / ",o.total_urls," procesados"]}),o.failed_urls>0&&s.jsxs("span",{className:"text-sm text-destructive",children:[o.failed_urls," fallidos"]})]}),s.jsx(k,{value:o.current_index/o.total_urls*100,className:"h-2"})]})]}),s.jsxs(g,{className:"border-primary/30 bg-primary/5",children:[s.jsxs(D,{children:[s.jsxs(B,{className:"text-lg flex items-center gap-2",children:[s.jsx(T,{className:"h-4 w-4 text-primary"})," YL Worldwide â Deep US Discovery"]}),s.jsxs(_,{children:["Sitemap XML + category seeds (slique, ejercicios-deportes, cbdâ¦). Inserta faltantes como drafts ",s.jsx("code",{children:"is_published=false"}),"."]})]}),s.jsx(p,{children:s.jsxs("div",{className:"flex flex-wrap gap-3",children:[s.jsx(d,{variant:"outline",onClick:async()=>{const e=l.loading("Ejecutando dry-run USâ¦"),{data:a,error:c}=await f.functions.invoke("audit-yl-worldwide",{body:{country:"us",dryRun:!0,limit:300}});if(l.dismiss(e),c)return l.error(`Error: ${c.message}`);const r=a?.stats??{};l.success(`Dry-run OK · descubiertos ${r.discovered??0} · existentes ${r.existing??0} · faltarÃan ${(r.discovered??0)-(r.existing??0)}`)},children:"Dry-Run US (preview)"}),s.jsx(d,{className:"bg-primary",onClick:async()=>
1{if(!confirm("Insertar drafts de productos YL US faltantes (hasta 150)?"))return;const e=l.loading("Ingestando US deep (puede tardar 2-5 min)â¦"),{data:a,error:c}=await f.functions.invoke("audit-yl-worldwide",{body:{country:"us",dryRun:!1,limit:150,concurrency:4}});if(l.dismiss(e),c)return l.error(`Error: ${c.message}`);const r=a?.stats??{};l.success(`Insertados ${r.inserted??0} · existentes ${r.existing??0} · fallidos ${r.failed??0}`)},children:"Ejecutar Deep US (insertar drafts)"}),s.jsx(d,{variant:"ghost",onClick:async()=>{const e=l.loading("Audit ALL countries (ES+US)â¦"),{data:a,error:c}=await f.functions.invoke("audit-yl-worldwide",{body:{country:"all",dryRun:!1,limit:200,concurrency:4}});if(l.dismiss(e),c)return l.error(`Error: ${c.message}`);const r=a?.stats??{};l.success(`ALL · insertados ${r.inserted??0} · existentes ${r.existing??0}`)},children:"ALL (ES + US)"})]})})]}),s.jsxs("div",{className:"grid md:grid-cols-2 gap-6",children:[s.jsxs(g,{children:[s.jsxs(D,{children:[s.jsx(B,{className:"text-lg",children:"Acciones de Scraping"}),s.jsx(_,{children:"Ejecuta diferentes tipos de scraping para actualizar el catálogo"})]}),s.jsxs(p,{children:[s.jsxs("div",{className:"flex flex-wrap gap-3",children:[s.jsxs(d,{onClick:()=>z("discover"),disabled:j||y,variant:"outline",className:"gap-2 border-primary text-primary hover:bg-primary/10",children:[j&&E==="discover"?s.jsx(b,{className:"h-4 w-4 animate-spin"}):s.jsx(as,{className:"h-4 w-4"}),"Descubrir URLs"]}),s.jsxs(d,{onClick:()=>z("regular"),disabled:j||y,variant:"outline",className:"gap-2",children:[j&&E==="regular"?s.jsx(b,{className:"h-4 w-4 animate-spin"}):s.jsx(ts,{className:"h-4 w-4"}),"Scraping Normal"]}),s.jsxs(d,{onClick:()=>z("images"),disabled:j||y,variant:"outline",className:"gap-2",children:[j&&E==="images"?s.jsx(b,{className:"h-4 w-4 animate-spin"}):s.jsx(es,{className:"h-4 w-4"}),"Actualizar Imágenes"]}),s.jsxs(d,{onClick:()=>z("deep"),disabled:j||y,className:"gap-2 bg-primary",children:[j&&E==="deep"?s.jsx(b,{className:"h-4 w-4 animate-spin"}):s.jsx(T,{className:"h-4 w-4"}),"Deep Rescrape"]}),s.jsx(d,{onClick:L,disabled:j||y,variant:"ghost",size:"icon",children:s.jsx(rs,{className:"h-4 w-4"})})]}),s.jsxs("p",{className:"text-xs text-muted-foreground mt-4",children:[s.jsx("strong",{children:"Deep Rescrape:"})," Extrae ingredientes, beneficios, instrucciones de uso y aceites relacionados."]})]})]}),s.jsxs(g,{className:"border-success/20 dark:border-success",children:[s.jsxs(D,{children:[s.jsxs(B,{className:"text-lg flex items-center gap-2",children:[s.jsx(cs,{className:"h-5 w-5 text-success"}),"Descarga de Imágenes"]}),s.jsx(_,{children:"Descarga imágenes externas a nuestro servidor para optimización"})]}),s.jsx(p,{children:s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"p-4 rounded-lg bg-success/10 dark:bg-success/20 border border-success/20 dark:border-success",children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsx("span",{className:"text-sm font-medium",children:"Progreso de descarga"}),s.jsxs("span",{className:"text-sm text-muted-foreground",children:[i?.withLocalImages||0," / ",i?.withImages||0]})]}),s.jsx(k,{value:S(i?.withLocalImages||0,i?.withImages||0),className:"h-2"}),s.jsxs("p",{className:"text-xs text-muted-foreground mt-2",children:[(i?.withImages||0)-(i?.withLocalImages||0)," imágenes pendientes de descargar"]})]}),s.jsxs(d,{onClick:hs,disabled:j||y,className:"w-full gap-2 bg-success hover:bg-success",children:[y?s.jsx(b,{className:"h-4 w-4 animate-spin"}):s.jsx(cs,{className:"h-4 w-4"}),"Descargar Imágenes (20 por lote)"]}),s.jsx("p",{className:"text-xs text-muted-foreground",children:"Las imágenes se descargan desde URLs externas y se almacenan en nuestro servidor para mejor rendimiento y disponibilidad."}),s.jsxs("div",{className:"border-t pt-4 mt-4 space-y-3",children:[s.jsx("h4",{className:"text-sm font-medium flex items-center gap-2",children:"⨠Eliminar fondos con IA"}),s.jsx("p",{className:"text-xs text-muted-foreground",children:"Procesa imágenes de productos para eliminar fondos automáticamente usando IA. Las imágenes se guardan como PNG transparente."}),$.total>0&&s.jsxs("div",{className:"space-y-1",children:[s.jsxs("div",{className:"flex justify-between text-xs",children:[s.jsxs("span",{children:[$.processed," procesados"]}),s.jsxs("span",{className:"text-success",children:[$.success," exitosos"]})]}),s.jsx(k,{value:$.processed/$.total*100,className:"h-2"})]}),s.jsx(d,{onClick:async()=>{q(!0),H({processed:0,success:0,total:0});let e=0;const a=2;
1let c=0,r=0;try{for(let n=0;n<50;n++){const{data:x,error:N}=await f.functions.invoke("remove-bg",{body:{batchSize:a,offset:e}});if(N)throw N;if(!x||x.processed===0||(c+=x.processed,r+=x.success,e=x.nextOffset,H({processed:c,success:r,total:c+a}),x.processed<a))break}l.success(`Fondos eliminados: ${r} de ${c} imágenes`)}catch{l.error("Error al eliminar fondos")}finally{q(!1)}},disabled:j||y||F,variant:"outline",className:"w-full gap-2 border-accent text-accent hover:bg-accent/10 dark:border-accent dark:text-accent dark:hover:bg-violet-950",children:F?s.jsxs(s.Fragment,{children:[s.jsx(b,{className:"h-4 w-4 animate-spin"}),"Procesando lote ",Math.ceil(($.processed+1)/2),"..."]}):s.jsx(s.Fragment,{children:"⨠Eliminar fondos (2 por lote)"})})]})]})})]})]})]}),s.jsx(G,{value:"labiatae",className:"space-y-6",children:s.jsxs(g,{className:"border-success/20 dark:border-success",children:[s.jsxs(D,{children:[s.jsxs(B,{className:"text-lg flex items-center gap-2",children:[s.jsx(ss,{className:"h-5 w-5 text-success"}),"Scraping de Labiatae"]}),s.jsx(_,{children:"Importa productos de aceites esenciales desde labiatae.com"})]}),s.jsxs(p,{className:"space-y-6",children:[s.jsxs("div",{className:"grid md:grid-cols-3 gap-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{className:"text-sm font-medium",children:"Marca destino"}),s.jsxs(J,{value:t.selectedBrandId,onValueChange:e=>m(a=>({...a,selectedBrandId:e})),children:[s.jsx(K,{children:s.jsx(W,{})}),s.jsx(X,{children:Object.entries(bs).map(([e,a])=>s.jsx(P,{value:e,children:a.name},e))})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{className:"text-sm font-medium",children:"Tamaño de lote"}),s.jsxs(J,{value:t.batchSize.toString(),onValueChange:e=>m(a=>({...a,batchSize:parseInt(e),totalBatches:Math.ceil(a.discoveredUrls.length/parseInt(e))})),children:[s.jsx(K,{children:s.jsx(W,{})}),s.jsxs(X,{children:[s.jsx(P,{value:"3",children:"3 productos"}),s.jsx(P,{value:"5",children:"5 productos"}),s.jsx(P,{value:"10",children:"10 productos"}),s.jsx(P,{value:"15",children:"15 productos"})]})]})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{className:"text-sm font-medium",children:"URLs descubiertas"}),s.jsx(Ns,{value:t.discoveredUrls.length.toString(),disabled:!0,className:"bg-muted"})]})]}),t.discoveredUrls.length>0&&s.jsxs("div",{className:"p-4 rounded-lg bg-success/10 dark:bg-success/20 border border-success/20 dark:border-success",children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsx("span",{className:"text-sm font-medium",children:"Progreso de scraping"}),s.jsxs("span",{className:"text-sm text-muted-foreground",children:["Lote ",t.currentBatch," / ",t.totalBatches]})]}),s.jsx(k,{value:t.totalBatches>0?t.currentBatch/t.totalBatches*100:0,className:"h-2"}),s.jsxs("div",{className:"flex gap-4 mt-2 text-xs text-muted-foreground",children:[s.jsxs("span",{className:"text-success",children:["â ",t.processedCount," procesados"]}),t.failedCount>0&&s.jsxs("span",{className:"text-destructive",children:["â ",t.failedCount," fallidos"]})]})]}),s.jsxs("div",{className:"flex flex-wrap gap-3",children:[s.jsxs(d,{onClick:os,disabled:t.isDiscovering||t.isScraping,variant:"outline",className:"gap-2 border-success text-success hover:bg-success/10",children:[t.isDiscovering?s.jsx(b,{className:"h-4 w-4 animate-spin"}):s.jsx(as,{className:"h-4 w-4"}),"1. Descubrir URLs"]}),s.jsxs(d,{onClick:ms,disabled:t.isDiscovering||t.isScraping||t.discoveredUrls.length===0,variant:"outline",className:"gap-2",children:[t.isScraping?s.jsx(b,{className:"h-4 w-4 animate-spin"}):s.jsx(ts,{className:"h-4 w-4"}),"2. Siguiente Lote"]}),s.jsxs(d,{onClick:xs,disabled:t.isDiscovering||t.isScraping||t.discoveredUrls.length===0,className:"gap-2 bg-success hover:bg-success",children:[t.isScraping?s.jsx(b,{className:"h-4 w-4 animate-spin"}):s.jsx(T,{className:"h-4 w-4"}),"Procesar Todo"]}),s.jsxs(d,{onClick:us,disabled:t.isDiscovering||t.isScraping,variant:"ghost",className:"gap-2",children:[s.jsx(rs,{className:"h-4 w-4"}),"Reiniciar"]})]}),t.discoveredUrls.length>0&&s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("label",{className:"text-sm font-medium",children:["URLs encontradas (",t.discoveredUrls.length,")"]}),s.jsxs("a",{href:"https://www.labiatae.com/aceites-esenciales/",target:"_blank",rel:"noopener noreferrer",className:"text-xs text-success hover:underline flex items-center gap-1",children:["Ver catálogo ",s.jsx(Ls,{className:"h-3 w-3"})]})]}),s.jsx(Q,{className:"h-40 rounded-md border p-3",children:s.jsxs("div",{className:"space-y-1",children:[t.discoveredUrls.slice(0,50).map((e,a)=>s.jsxs("div",{className:"text-xs text-muted-foreground truncate",children:[a<t.currentBatch*t.batchSize?s.jsx("span",{className:"text-success",children:"â"}
1):s.jsx("span",{className:"text-muted-foreground/50",children:"â"})," ",e.replace("https://www.labiatae.com","")]},a)),t.discoveredUrls.length>50&&s.jsxs("div",{className:"text-xs text-muted-foreground italic",children:["... y ",t.discoveredUrls.length-50," más"]})]})})]}),t.log.length>0&&s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{className:"text-sm font-medium",children:"Log de actividad"}),s.jsx(Q,{className:"h-32 rounded-md border bg-muted/50 p-3",children:s.jsx("div",{className:"space-y-1 font-mono text-xs",children:t.log.map((e,a)=>s.jsx("div",{className:e.includes("Error")?"text-destructive":"text-muted-foreground",children:e},a))})})]})]})]})})]})}export{Vs as ScrapingPanel};
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.