1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[70604],{70604:(e,t,r)=>{r.r(t),r.d(t,{default:()=>m});var a=r(95155),s=r(12115),n=r(98500),l=r.n(n),i=r(50910);let d={result:null,loading:!1,error:null,latencyMs:null},o=(0,s.lazy)(()=>Promise.all([r.e(94080),r.e(81086),r.e(96024),r.e(15159)]).then(r.bind(r,15159)));function c(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(2)} MB`}function x({result:e,latencyMs:t}){let[r,n]=(0,s.useState)("markdown"),[l,i]=(0,s.useState)(!1),d=new TextEncoder().encode(e.content).length,m=d>262144,u=m?e.content.slice(0,262144):e.content;return(0,a.jsxs)("div",{className:"space-y-3","data-testid":"scrape-result",children:[(0,a.jsxs)("div",{className:"flex flex-wrap justify-between items-center gap-2 p-3 bg-bg-alt rounded-lg border border-border text-xs text-text-muted",children:[(0,a.jsxs)("div",{className:"flex flex-wrap gap-x-4 gap-y-1 items-center",children:[e.provider&&(0,a.jsxs)("span",{children:["Provider:"," ",(0,a.jsx)("span",{className:"font-medium text-text-main",children:e.provider})]}),null!=t&&(0,a.jsxs)("span",{children:["Lat\xeancia:"," ",(0,a.jsxs)("span",{className:"font-medium text-text-main",children:[t,"ms"]})]}),(0,a.jsxs)("span",{children:["Tamanho:"," ",(0,a.jsx)("span",{className:"font-medium text-text-main",children:c(d)})]}),e.links.length>0&&(0,a.jsxs)("span",{children:["Links:"," ",(0,a.jsx)("span",{className:"font-medium text-text-main",children:e.links.length})]})]}),(0,a.jsxs)("div",{className:"flex gap-1",children:[(0,a.jsx)("button",{className:["px-2.5 py-1 rounded-md text-[11px] font-medium transition-colors","markdown"===r?"bg-primary/15 text-primary":"bg-black/5 dark:bg-white/5 text-text-muted hover:text-text-main"].join(" "),onClick:()=>n("markdown"),"data-testid":"toggle-markdown",children:"Preview"}),(0,a.jsx)("button",{className:["px-2.5 py-1 rounded-md text-[11px] font-medium transition-colors","raw"===r?"bg-primary/15 text-primary":"bg-black/5 dark:bg-white/5 text-text-muted hover:text-text-main"].join(" "),onClick:()=>n("raw"),"data-testid":"toggle-raw",children:"Raw"})]})]}),e.metadata&&(e.metadata.title||e.metadata.description)&&(0,a.jsxs)("div",{className:"p-3 bg-surface border border-border rounded-lg text-xs",children:[e.metadata.title&&(0,a.jsx)("div",{className:"font-semibold text-text-main mb-0.5",children:e.metadata.title}),e.metadata.description&&(0,a.jsx)("div",{className:"text-text-muted",children:e.metadata.description}),(0,a.jsx)("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",className:"text-accent hover:underline block mt-1 truncate",children:e.url})]}),m&&(0,a.jsxs)("div",{className:"flex items-center justify-between p-3 bg-warning/10 border border-warning/30 rounded-lg text-xs text-warning","data-testid":"truncation-warning",children:[(0,a.jsxs)("span",{children:["Conte\xfado truncado a 256 KB (tamanho original: ",c(d),")"]}),(0,a.jsx)("button",{className:"ml-3 text-xs px-2 py-1 rounded bg-warning/20 text-warning hover:bg-warning/30 transition-colors",onClick:()=>i(!0),"data-testid":"view-raw-button",children:"Ver raw completo"})]}),"markdown"===r?(0,a.jsx)("div",{className:"prose prose-sm dark:prose-invert max-w-none p-4 bg-surface border border-border rounded-lg overflow-auto","data-testid":"markdown-preview",children:(0,a.jsx)(s.Suspense,{fallback:(0,a.jsx)("pre",{className:"text-xs whitespace-pre-wrap text-text-muted",children:u}),children:(0,a.jsx)(o,{content:u})})}):(0,a.jsx)("textarea",{readOnly:!0,value:u,className:"w-full h-64 bg-surface border border-border rounded-lg p-3 text-xs text-text-main font-mono resize-none focus:outline-none","data-testid":"raw-content","aria-label":"Raw scraped content"}),l&&(0,a.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60","data-testid":"raw-modal",children:(0,a.jsxs)("div",{className:"bg-surface border border-border rounded-xl shadow-2xl w-[90vw] max-w-4xl h-[80vh] flex flex-col",children:[(0,a.jsxs)("div",{className:"flex justify-between items-center px-4 py-3 border-b border-border",children:[(0,a.jsxs)("span",{className:"text-sm font-semibold text-text-main",children:["Raw content â ",c(d)]}),(0,a.jsx)("button",{className:"text-text-muted hover:text-text-main",onClick:()=>i(!1),"aria-label":"Close raw content modal",children:"â"})]}),(0,a.jsx)("textarea",{readOnly:!0,value:e.content,className:"flex-1 bg-bg-alt p-4 text-xs text-text-main font-mono resize-none focus:outline-none rounded-b-xl","data-testid":"raw-modal-content"})]})})]})}function m({configState:e,onMetrics:t}
1){let r=(0,i.c)("search"),[n,o]=(0,s.useState)(""),[c,u]=(0,s.useState)(null),{result:p,loading:h,error:b,latencyMs:f,fetch:g,reset:v}=function(){let[e,t]=(0,s.useState)(d),r=(0,s.useCallback)(async e=>{if(!e.url.trim())return void t(e=>({...e,error:"URL is required",loading:!1}));t({result:null,loading:!0,error:null,latencyMs:null});let r=Date.now();try{let a={url:e.url,format:e.format??"markdown"};void 0!==e.full_page&&(a.full_page=e.full_page),e.provider&&(a.provider=e.provider);let s=await globalThis.fetch("/v1/web/fetch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)}),n=Date.now()-r,l=await s.json();if(!s.ok)return void t({result:null,loading:!1,error:l?.error?.message??l?.error??`Error ${s.status}`,latencyMs:n});let i={provider:l.provider??"",url:l.url??e.url,content:l.content??"",links:Array.isArray(l.links)?l.links:[],metadata:l.metadata??null,screenshot_url:l.screenshot_url??null};t({result:i,loading:!1,error:null,latencyMs:n})}catch(a){let e=Date.now()-r;t({result:null,loading:!1,error:a instanceof Error?a.message:"Network error",latencyMs:e})}},[]),a=(0,s.useCallback)(()=>{t(d)},[]);return{...e,fetch:r,reset:a}}(),j=async()=>{(u(null),n.trim())?function(e){try{let t=new URL(e.trim());return"http:"===t.protocol||"https:"===t.protocol}catch{return!1}}(n)?(v(),await g({url:n.trim(),format:e.fetchFormat,full_page:e.fullPage,provider:e.provider&&"auto"!==e.provider?e.provider:void 0})):u(r("scrapeUrlInvalid")):u(r("scrapeUrlRequired"))};return(0,s.useEffect)(()=>{null!=f&&t?.(f,null)},[f,t]),(0,a.jsxs)("div",{className:"flex flex-col h-full p-4 space-y-4","data-testid":"scrape-tab",children:[(0,a.jsxs)("div",{className:"bg-surface border border-border rounded-lg p-4 space-y-3",children:[(0,a.jsx)("label",{htmlFor:"scrape-url",className:"block text-[10px] font-semibold text-text-muted uppercase tracking-wider",children:r("scrapeUrl")}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)("input",{id:"scrape-url",type:"url",value:n,onChange:e=>{o(e.target.value),c&&u(null)},placeholder:"https://example.com/article",className:"flex-1 bg-bg-alt border border-border rounded-lg px-3 py-2 text-sm text-text-main focus:outline-none focus:ring-2 focus:ring-primary/30",onKeyDown:e=>{"Enter"===e.key&&j()},"data-testid":"url-input"}),(0,a.jsx)("button",{className:"px-4 py-2 rounded-lg bg-primary text-white text-sm font-medium hover:bg-primary/90 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",onClick:()=>void j(),disabled:h,"data-testid":"scrape-button",children:h?r("scrapeExtracting"):r("scrapeExtract")})]}),c&&(0,a.jsx)("p",{className:"text-xs text-error","data-testid":"url-error",children:c}),(0,a.jsxs)("div",{className:"flex flex-wrap gap-x-4 gap-y-1 text-[11px] text-text-muted",children:[(0,a.jsxs)("span",{children:["Format: ",(0,a.jsx)("span",{className:"text-text-main font-medium",children:e.fetchFormat})]}),(0,a.jsxs)("span",{children:["Full page:"," ",(0,a.jsx)("span",{className:"text-text-main font-medium",children:e.fullPage?"Yes":"No"})]}),(0,a.jsxs)("span",{children:["Provider:"," ",(0,a.jsx)("span",{className:"text-text-main font-medium",children:"auto"!==e.provider&&e.provider?e.provider:"auto"})]})]})]}),b&&!h&&(0,a.jsx)("div",{className:"p-4 bg-error/10 border border-error/30 rounded-lg text-sm text-error","data-testid":"scrape-error",children:b}),h&&(0,a.jsx)("div",{className:"flex items-center justify-center py-12","data-testid":"scrape-loading",children:(0,a.jsx)("span",{className:"material-symbols-outlined text-[32px] text-primary animate-spin","aria-hidden":"true",children:"progress_activity"})}),p&&!h&&(0,a.jsx)(x,{result:p,latencyMs:f}),!p&&!h&&!b&&(0,a.jsxs)("div",{className:"flex flex-col items-center justify-center flex-1 text-center py-12","data-testid":"scrape-empty-state",children:[(0,a.jsx)("span",{className:"text-3xl mb-3","aria-hidden":"true",children:"\uD83D\uDCC4"}),(0,a.jsx)("p",{className:"text-sm text-text-muted mb-1",children:r("scrapeEmptyState")}),(0,a.jsxs)("p",{className:"text-xs text-text-muted",children:[r("scrapeProvidersAvailable")," ",(0,a.jsx)(l(),{href:"/dashboard/providers",className:"text-accent hover:underline",children:r("configureProvider")})]})]})]})}}}]);
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.