import type { ProbeShellResult } from "@/types/probeshell";
import { DownloadIcon } from "lucide-react";
import { useTranslation } from "react-i18next";
import { toast } from "sonner";
import DecompiledCodeViewer from "@/components/decompiled-code-viewer";
import { QuickUsage } from "@/components/probeshell/quick-usage";
import { Button } from "@/components/ui/button";
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
import { useDecompiledSources } from "@/lib/decompile/use-decompiled-sources";
import { downloadBytes } from "@/lib/utils";
import CodeViewer from "../code-viewer";
import { BasicInfo } from "./basic-info";
export default function ShellResult({
packResult,
packMethod,
generateResult,
}: Readonly<{
packResult: string | undefined;
packMethod: string;
generateResult?: ProbeShellResult;
}>) {
const { t } = useTranslation(["common", "probeshell"]);
const { sources, isDecompiling, error } = useDecompiledSources(generateResult);
if (!generateResult) {
return ;
}
const showCode = packMethod === "JSP";
const height = 600;
const decompiledSourceHeight = 800;
const shellClassName = generateResult.shellClassName;
const shellBytesBase64 = generateResult.shellBytesBase64Str;
const sourcePlaceholder = isDecompiling
? `// ${t("common:decompiling")}`
: error
? `// ${t("common:decompileFailed", { error })}`
: "";
return (
{t("common:generateResult")}
{t("probeshell:shellClass")}
{packResult && (
{t("common:packerMethod")}:{packMethod}
({packResult?.length})
}
wrapLongLines={!showCode}
showLineNumbers={showCode}
language={showCode ? "java" : "text"}
height={height}
/>
)}
{shellClassName}}
button={
}
height={decompiledSourceHeight}
lines={sources.shell?.lines ?? null}
placeholder={sourcePlaceholder}
/>
);
}