1import{j as e}from"./ui-CdP0ro2F.js";import{a as s}from"./vendor-Cr9yl5FV.js";import{C as r,a,b as t,c as d}from"./card-DVW0a1C9.js";import{T as l}from"./textarea-DEcS_pDX.js";import{n,a0 as i,B as o}from"../index.js";import{d as m,a as c}from"./utils-D4y8RIdq.js";import{R as x}from"./rotate-ccw-CwU3zeg5.js";function f({initialContent:f,action:u}){const[h,g]=s.useState(f||""),[j,p]=s.useState(""),[b,v]=s.useState([]),[N,k]=s.useState("lines");s.useEffect(()=>{f&&"diff"===u&&g(f)},[f,u]);const C=()=>{const e="lines"===N?m(h,j):c(h,j);v(e)},w=s.useCallback(()=>{g(""),p(""),v([])},[]);return n({onExecute:C,onClear:w}),e.jsxs(r,{className:"tool-card",children:[e.jsx(a,{children:e.jsxs(t,{className:"flex items-center gap-2 text-foreground",children:[e.jsx(i,{className:"h-5 w-5 text-dev-primary"}),"Text Diff Checker"]})}),e.jsxs(d,{className:"space-y-4",children:[e.jsxs("div",{className:"flex gap-2 mb-4",children:[e.jsx(o,{onClick:()=>k("lines"),variant:"lines"===N?"default":"outline",size:"sm",children:"Line Diff"}),e.jsx(o,{onClick:()=>k("words"),variant:"words"===N?"default":"outline",size:"sm",children:"Word Diff"})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-2 text-foreground",children:"Original Text"}),e.jsx(l,{placeholder:"Enter original text...",value:h,onChange:e=>g(e.target.value),className:"w-full min-h-[200px] font-mono text-sm bg-muted/50 border-border/50"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-2 text-foreground",children:"Modified Text"}),e.jsx(l,{placeholder:"Enter modified text...",value:j,onChange:e=>p(e.target.value),className:"w-full min-h-[200px] font-mono text-sm bg-muted/50 border-border/50"})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(o,{onClick:C,className:"bg-dev-primary hover:bg-dev-primary/80 text-dev-primary-foreground px-4",children:[e.jsx(i,{className:"h-4 w-4 mr-2"}),"Compare Texts"]}),e.jsxs(o,{onClick:w,variant:"outline",size:"sm",children:[e.jsx(x,{className:"h-4 w-4 mr-2"}),"Clear"]})]}),0===b.length?null:e.jsxs("div",{className:"space-y-2",children:[e.jsx("h4",{className:"text-sm font-semibold text-dev-primary",children:"Differences"}),e.jsx("div",{className:"bg-muted/30 border border-border/50 rounded-md p-4 max-h-96 overflow-auto",children:e.jsx("pre",{className:"text-sm font-mono whitespace-pre-wrap",children:b.map((s,r)=>{const a=s.added?"bg-green-500/20 text-green-500 dark:text-green-400 dark:bg-green-950/30":s.removed?"bg-red-500/20 text-red-500 dark:text-red-400 dark:bg-red-950/30":"text-foreground",t=s.added?"+ ":s.removed?"- ":" ";return e.jsx("span",{className:a,children:"lines"===N?s.value.split("\n").map((e,s,r)=>s<r.length-1?`${t}${e}\n`:e?`${t}${e}`:"").join(""):s.value},r)})})}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[e.jsx("span",{className:"inline-block w-4 h-4 bg-green-500/20 rounded mr-1"}),"Added",e.jsx("span",{className:"inline-block w-4 h-4 bg-red-500/20 rounded mr-1 ml-4"}),"Removed"]})]})]})]})}export{f as TextDiff};
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.