"""The actual successive attachment maps of CG-S6-06. CC0-1.0."""
from pathlib import Path
from xml.sax.saxutils import escape
root=Path(__file__).resolve().parents[1]
p=['<svg xmlns="http://www.w3.org/2000/svg" width="620" height="1020" viewBox="0 0 620 1020" role="img" aria-labelledby="title desc">',
 '<title id="title">The complete fundamental group through the actual attachments</title>',
 '<desc id="desc">The middle group is the lattice semidirect a free group. The cusp kills its two torus cycles and its meridian; their normal closure leaves two commuting generators. The first finite filling imposes x cubed equals c; the second imposes x fourth equals x cubed, giving the trivial group.</desc>',
 '<defs><marker id="arrow" markerUnits="userSpaceOnUse" markerWidth="12" markerHeight="10" refX="9" refY="5" orient="auto"><path d="M0 0L10 5L0 10Z" fill="#315e73"/></marker></defs>',
 '<rect width="620" height="1020" fill="#fcfaf5"/>']
def text(x,y,s,size=23):
 p.append(f'<text x="{x}" y="{y}" text-anchor="middle" font-family="Georgia,serif" font-size="{size}" fill="#213844">{escape(s)}</text>')
def box(y,h):
 p.append(f'<rect x="28" y="{y}" width="564" height="{h}" rx="12" fill="#eef4f3" stroke="#315e73" stroke-width="2"/>')
def arrow(y1,y2):
 p.append(f'<path d="M310 {y1}V{y2}" stroke="#315e73" stroke-width="3" marker-end="url(#arrow)"/>')
text(310,37,'The full group through each attachment',28)
box(62,129)
text(310,98,'Middle family J',27)
text(310,137,'Λ ⋊ F(ρ₁, ρ₂)',29)
text(310,173,'ρⱼ t(λ) ρⱼ⁻¹ = t(Aⱼλ)',23)
text(310,230,'Attach the cusp N₀',25)
text(310,265,'Kill t(ŵ), t(δ̂) and a₀;  ρ₁ρ₂a₀ = 1.',22)
text(310,300,'A₁ŵ = û − ŵ forces û into the normal closure.',21)
arrow(315,345)
box(357,113)
text(310,394,'ℤ² generated by c and x',28)
text(310,431,'c = t(γ̂) is central;  x = ρ₁, y = ρ₂ = x⁻¹.',21)
text(310,510,'Attach the order-three filling N₁',25)
text(310,546,'ρ₁³ = t(v₁), with γ(v₁) = +1:  x³ = c.',22)
arrow(560,590)
box(602,91)
text(310,640,'ℤ generated by x',28)
text(310,675,'The relation replaces c by x³.',22)
text(310,733,'Attach the order-four filling N₂',25)
text(310,769,'ρ₂⁴ = t(v₂), with γ(v₂) = −1:  y⁴ = c⁻¹.',21)
text(310,804,'Since y = x⁻¹,  x⁴ = c = x³.',23)
arrow(817,848)
box(860,89)
text(310,896,'x = 1, c = 1, y = 1',28)
text(310,933,'π₁(X) = 1',30)
text(310,991,'All maps come from the specified based overlaps.',22)
p.append('</svg>')
(root/'assets/fundamental-group-attachments.svg').write_text('\n'.join(p)+'\n',encoding='utf-8')
