from pathlib import Path
import json,hashlib
import sys
F=Path(sys.argv[1]) if len(sys.argv)>1 else Path.cwd()/'recreated-inputs'
F.mkdir(parents=True,exist_ok=True)
svg=lambda attrs,body:f'<svg xmlns="http://www.w3.org/2000/svg" {attrs}>{body}</svg>\n'
art='<rect x="32" y="40" width="220" height="112" rx="28" fill="#147d82" fill-opacity="0.5"/><circle cx="278" cy="96" r="57" fill="#ed9c76"/>'
files={
 'text.svg':svg('width="384" height="160" viewBox="0 0 384 160"','<path d="M24 128 H360" stroke="#147d82" stroke-width="4"/><text x="24" y="96" font-family="Arial" font-size="48" fill="#16334e">EDIT THIS</text>'),
 'transparent.svg':svg('width="384" height="192" viewBox="0 0 384 192"',art),
 'painted-white.svg':svg('width="384" height="192" viewBox="0 0 384 192"','<rect width="384" height="192" fill="white"/>'+art),
 'canvas-meet.svg':svg('width="480" height="240" viewBox="0 0 100 100"','<rect width="100" height="100" fill="#147d82"/><circle cx="50" cy="50" r="29" fill="#ed9c76"/>'),
 'rounding.svg':svg('width="101" height="67" viewBox="0 0 101 67"','<rect x="1" y="1" width="99" height="65" rx="8" fill="#16334e"/><path d="M10 52 L50 15 L91 52" fill="none" stroke="#6fd6bd" stroke-width="3"/>'),
 'inch-viewbox.svg':svg('width="2in" height="1in" viewBox="0 0 400 200"','<rect x="10" y="10" width="380" height="180" rx="24" fill="#147d82"/><circle cx="200" cy="100" r="56" fill="#ed9c76"/>'),
 'external.svg':svg('width="100" height="100"','<image href="https://example.invalid/no-request.png" width="100" height="100"/>'),
 'style.svg':svg('width="100" height="100"','<rect style="fill:red" width="100" height="100"/>'),
 'malformed.svg':'<svg xmlns="http://www.w3.org/2000/svg" width="100"><broken',
 'overside.svg':svg('width="4097" height="1"','<rect width="4097" height="1" fill="red"/>'),
}
for n,s in files.items():(F/n).write_text(s,encoding='utf-8',newline='\n')
rows=[{'file':n,'bytes':len(s.encode()),'sha256':hashlib.sha256(s.encode()).hexdigest(),'test_date':'2026-10-19','valid_case':n not in ['external.svg','style.svg','malformed.svg','overside.svg']} for n,s in files.items()]
(F/'input-manifest.json').write_text(json.dumps({'created_date':'2026-10-19','scope':'original synthetic SVGs; no user documents','files':rows},ensure_ascii=False,indent=2)+'\n',encoding='utf-8')
print('Created',len(rows),'original SVG input fixtures')
