/* global React, Icon */ // AZOR live demo: URL input -> /api/analyze -> in-page presentation. const { useState, useMemo } = React; const STEPS = [ "Pobieranie strony postepowania", "Analiza dokumentow i zmian", "Budowa raportu 8 sekcji", "Ocena ryzyk i decyzja", "Prezentacja wyniku" ]; function AzorDemo() { const [url, setUrl] = useState(""); const [deepParse, setDeepParse] = useState(true); const [loading, setLoading] = useState(false); const [stepIdx, setStepIdx] = useState(-1); const [error, setError] = useState(""); const [result, setResult] = useState(null); async function runAnalysis() { if (!url.trim()) return; setError(""); setResult(null); setLoading(true); setStepIdx(0); const ticker = setInterval(() => { setStepIdx((prev) => (prev < STEPS.length - 1 ? prev + 1 : prev)); }, 850); try { const res = await fetch("/api/analyze", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ url: url.trim(), deep_parse: deepParse }) }); const contentType = (res.headers.get("content-type") || "").toLowerCase(); let data; if (contentType.includes("application/json")) { data = await res.json(); } else { throw new Error("Nieprawidlowy format odpowiedzi z API."); } if (!res.ok || !data.success) { throw new Error(data.error || "Analiza nieudana."); } setResult(data); setStepIdx(STEPS.length - 1); } catch (e) { setError(e?.message || "Blad analizy."); } finally { clearInterval(ticker); setLoading(false); } } function reset() { setUrl(""); setResult(null); setError(""); setStepIdx(-1); setLoading(false); } const decisionClass = useMemo(() => { const d = result?.report_json?.go_no_go?.decision || ""; if (d === "STARTUJEMY") return { bg: "var(--olive-600)", fg: "#fff" }; if (d === "NIE STARTUJEMY") return { bg: "var(--crimson-700)", fg: "#fff" }; return { bg: "var(--amber-500)", fg: "#1f1606" }; }, [result]); return ( <>
azor.analyze {deepParse ? "deep pdf/zip mode" : "quick html mode"}
{!result && (
> URL POSTEPOWANIA
setUrl(e.target.value)} onKeyDown={(e) => e.key === "Enter" && !loading && runAnalysis()} placeholder="https://biosg.ezamawiajacy.pl/.../details" style={{ flex: 1, border: "none", outline: "none", background: "transparent", fontFamily: "var(--font-mono)", fontSize: 12, padding: "10px 0", color: "var(--ink)" }} />
{loading && (
{STEPS.map((s, i) => { const done = i < stepIdx; const active = i === stepIdx; return (
{done ? "OK " : active ? "... " : "o "} {s}
); })}
)} {error && (
{error}
)}
)} {result && (
{result.report_json?.basic_data?.proceeding_number || "brak numeru"}
{result.report_json?.basic_data?.title || "Analiza przetargu"}
Tryb: {result.report_json?.parser_mode === "deep_pdf" ? "Pelna analiza PDF/ZIP" : "Szybka analiza HTML"}
{result.report_json?.go_no_go?.decision || "WARUNKOWO"}
)}
{result && } ); } function ReportWorkspace({ report, onClose }) { const meta = report?.basic_data || {}; const decision = report?.go_no_go?.decision || "WARUNKOWO"; const risks = report?.risk_register || []; const docs = report?.document_insights || []; const decisionTone = decision === "STARTUJEMY" ? "var(--olive-600)" : decision === "NIE STARTUJEMY" ? "var(--crimson-700)" : "var(--amber-500)"; return (
AZOR
{report?.parser_mode === "deep_pdf" ? "PELNA ANALIZA PDF" : "SZYBKA ANALIZA HTML"}
{meta.proceeding_number || "BRAK NUMERU"}

{meta.title || "Analiza przetargu"}

); } function Kpi({ label, value }) { return (
{label}
{value}
); } function Panel({ title, children }) { return (
{title}
{children}
); } function SmallLine({ children }) { return
{children}
; } function DocLine({ doc }) { const label = doc.kind || doc.doc_type || "dokument"; const parsed = doc.parsed ? "OK" : ""; return (
{doc.name}
{label} {doc.size ? `| ${doc.size}` : ""} {parsed ? `| parsed ${parsed}` : ""}
); } function ReportPresentation({ report }) { const meta = report?.basic_data || {}; const buyer = report?.authority || {}; const req = report?.experience_requirement || {}; const scope = report?.scope_of_work || {}; const risk = report?.risk_register || []; return (
`ZIP: ${z.name} | pliki: ${z.files_count}`), ...(report.documents || []).slice(0, 8).map((d) => `${d.name} | ${d.size || "-"}`) ]} /> `${d.date || "-"} | ${d.name}`)} /> `Budowlana: ${x}`), ...(scope.sanitary || []).map((x) => `Sanitarna: ${x}`), ...(scope.electrical || []).map((x) => `Elektryczna: ${x}`), ...(scope.terrain || []).map((x) => `Teren: ${x}`), ...((report.zip_manifests || []).flatMap((z) => (z.files || []).slice(0, 5).map((f) => `${f.kind}: ${f.name}`))).slice(0, 10) ]} /> `[${String(r.level || "").toUpperCase()}] ${r.area}: ${r.note}`), ...(report.missing_info || []).slice(0, 5).map((m) => `Brak: ${m.field} (${m.impact_on_bid})`) ]} /> `Warunek: ${x}`)) ]} />
); } function SectionCard({ code, title, lines }) { const list = (lines || []).filter(Boolean); return (
{code} {title}
{list.length === 0 ? Brak danych : null} {list.map((line, i) => (
- {line}
))}
); } function MetaCard({ k, v }) { return (
{k}
{v}
); } const miniBtnStyle = { textDecoration: "none", border: "1px solid var(--rule-strong)", background: "#fff", color: "var(--ink-2)", borderRadius: "var(--r-sm)", padding: "7px 11px", fontFamily: "var(--font-mono)", fontSize: 10, letterSpacing: "0.04em", cursor: "pointer" }; window.AzorDemo = AzorDemo;