#!/usr/bin/env python3
"""Replace all story blocks in generate_week9_new.py with Week 9 content."""

with open('generate_week9_new.py') as f:
    content = f.read()

# Monday story (lines 104-141)
old_monday = '''MONDAY_STORY = (
    'On a cold day in <strong>summer</strong>, Leo the <strong>kitten</strong> found a box of '
    '<strong>cotton</strong> balls by the garden <strong>tunnel</strong>. '
    'He wanted to build a <strong>bigger</strong> castle than last time. '
    '"I need a <strong>ladder</strong> to climb up!" he purred. '
    'His friend Pip the <strong>hopper</strong> frog jumped over to help. '
    'The campfire started to <strong>fizzle</strong> as the rain came down. '
    'Pip found a <strong>puddle</strong> full of floating leaves. '
    '"Let us share the <strong>butter</strong> crackers," said Pip. '
    'But the lemon ones tasted <strong>bitter</strong> and Pip made a face. '
    'Then Leo gave Pip the warmest <strong>hugger</strong> squeeze ever. '
    'They built the biggest castle together!"'''

new_monday = '''MONDAY_STORY = (
    'When Maya first walked into the new classroom, she felt <strong>unhappy</strong>. '
    'She didn\'t know anyone yet. '
    'The teacher asked them to <strong>unpack</strong> their supplies. '
    'Maya found her desk was next to a girl who looked <strong>unknown</strong> at first. '
    '"I\'ll <strong>return</strong> your pencil," said the girl after Maya dropped hers. '
    'They started to talk and didn\'t <strong>disagree</strong> about anything. '
    '"Let\'s <strong>remake</strong> our book covers together," suggested Maya. '
    'The teacher said, "I <strong>discover</strong> new friends every year!" '
    'By lunchtime, Maya wasn\'t <strong>dishonest</strong> about how she felt anymore. '
    '"I\'m actually having fun!" she said. '
    'The playground looked a little <strong>unsafe</strong> with no adults around yet. '
    'When recess ended, they had to <strong>reopen</strong> their books. '
    'Maya didn\'t <strong>dislike</strong> the new school at all. '
    'She even started to <strong>remove</strong> her worried feelings."'''

replacements = [
    ('MONDAY_STORY', old_monday, new_monday),
]

# Tuesday story
old_tuesday = '''TUESDAY_READING = (
    'At the old aquarium, Sam the <strong>bunny</strong> loved to <strong>hop</strong> around the rocks. '
    'He was a <strong>jumper</strong> who always wanted to be the first to try something new. '
    'One day, the aquarium workers put in a giant <strong>lagoon</strong> pool. '
    'Sam\'s friend Dot the <strong>duckling</strong> wasn\'t sure about the water. '
    '"Don'\''t worry!" said Sam. "The <strong>water</strong> is warm and safe." '
    'They jumped in together and splashed in the <strong>muddy</strong> bottom. '
    'The <strong>sniper</strong> fish watched them with big eyes. '
    'After swimming, they found a <strong>pocket</strong> full of shiny shells. '
    'Dot was <strong>sadder</strong> when it was time to go home. '
    '"We can <strong>climb</strong> back tomorrow!" Sam promised.'''

new_tuesday = '''TUESDAY_READING = (
    'At the science lab, Dr. Lee asked her students to <strong>unpack</strong> their experiment kits. '
    '"First, we will <strong>discover</strong> what happens when ice meets warm water," she said. '
    'Tom was <strong>unknown</strong> to the other students because he was new. '
    'He didn\'t want to <strong>disagree</strong> with the group plan. '
    '"If we get different results, we can <strong>remake</strong> the experiment," said Dr. Lee. '
    'Sarah had to <strong>remove</strong> her gloves before using the microscope. '
    '"Let\'s <strong>return</strong> the samples to the freezer after we finish," Tom suggested. '
    'The results were not <strong>dishonest</strong> — every measurement was accurate. '
    'When the lab ended, they <strong>reopened</strong> their notebooks to record data. '
    'The <strong>unsafe</strong> chemicals were locked away for the last experiment. '
    'Everyone could <strong>dislike</strong> cold water, but the experiment was worth it. '
    'The class wasn\'t <strong>unhappy</strong> about working in science."'''

replacements.append(('TUESDAY_READING', old_tuesday, new_tuesday))

# Wednesday story
old_wednesday = '''WEDNESDAY_READING = (
    'At the big <strong>butter</strong> farm, <strong>hopper</strong> frogs lived in a <strong>puddle</strong> behind the barn. '
    'The <strong>kitten</strong> from next door always tried to catch them. '
    'One day, a <strong>ladder</strong> fell into the <strong>puddle</strong> and made a splash! '
    'The frogs hopped onto the <strong>ladder</strong> and used it as a bridge. '
    'The <strong>kitten</strong> tried to climb up but <strong>fizzled</strong> into the <strong>puddle</strong>. '
    '"We can <strong>bigger</strong> our <strong>tunnel</strong>!" said one frog. '
    'They built a <strong>bigger</strong> <strong>tunnel</strong> under the <strong>cotton</strong> field. '
    'The <strong>kitten</strong> couldn\'t <strong>fit</strong> through, so she went home. '
    'The frogs had a <strong>feather</strong>-soft nap that afternoon. '
    'They didn'\''t <strong>worry</strong> about the <strong>kitten</strong> anymore.'''

new_wednesday = '''WEDNESDAY_READING = (
    'Captain Finn stood at the edge of the <strong>unknown</strong> forest. '
    'His map was old and many places were <strong>unknown</strong> to explorers. '
    '"We must <strong>discover</strong> what lies beyond these trees," he said to his crew. '
    'One crew member was <strong>unhappy</strong> about the journey. '
    '"I <strong>disagree</strong> with this plan," said Jack. '
    '"We should <strong>return</strong> to the ship and rest," Jack continued. '
    'Captain Finn didn\'t <strong>dislike</strong> Jack\'s idea, but he knew they had to try. '
    'They <strong>removed</strong> their hats and entered the trees. '
    'Inside, they found an old cabin that they could <strong>remake</strong> into a shelter. '
    'Jack began to <strong>unpack</strong> their supplies near the fire. '
    'They had to <strong>reopen</strong> their maps to find the right direction. '
    'Jack wasn\'t being <strong>dishonest</strong> — he really wanted to go home. '
    'By sunset, even Jack felt <strong>unsafe</strong> waiting in the dark without a flashlight."'''

replacements.append(('WEDNESDAY_READING', old_wednesday, new_wednesday))

# Thursday story
old_thursday = '''THURSDAY_STORY = (
    'On a rainy afternoon, the <strong>butter</strong>flies couldn'\''t fly. '
    'Instead, they watched the <strong>bunny</strong> and <strong>hopper</strong> play in the <strong>puddle</strong>. '
    'The <strong>kitten</strong> tried to <strong>climb</strong> the <strong>ladder</strong> but it slipped. '
    '"Be <strong>safer</strong>!" called the <strong>duckling</strong>. '
    'The <strong>bunny</strong> built a <strong>bigger</strong> fort out of <strong>cotton</strong> boxes. '
    'The <strong>kitten</strong> helped carry <strong>cotton</strong> to make it <strong>bigger</strong>. '
    'They all shared <strong>butter</strong> cookies after their fun. '
    'The rain started to <strong>fizzle</strong> and the sun came out. '
    'The <strong>butter</strong>flies could finally fly again. '
    'Everyone agreed it was the <strong>bigger</strong> day they'\''d ever had.'''

new_thursday = '''THURSDAY_STORY = (
    'Detective Sam had to <strong>discover</strong> who took the treasure from the museum. '
    'The <strong>unknown</strong> thief left no fingerprints. '
    '"We must <strong>reopen</strong> the case file," Sam told his partner. '
    'His partner didn\'t <strong>disagree</strong>. '
    '"Every clue matters," she said. '
    'They <strong>removed</strong> the old evidence bag and checked it carefully. '
    'The guard was not <strong>dishonest</strong> — he told the truth about everything. '
    '"We need to <strong>return</strong> to the crime scene," Sam decided. '
    'When they <strong>remake</strong> their search plan, they found a hidden key. '
    'They <strong>unpacked</strong> the dusty box behind the painting. '
    'No one felt <strong>unhappy</strong> when they solved the mystery. '
    'The guard didn\'t <strong>dislike</strong> the attention from the news. '
    'The broken window made the building <strong>unsafe</strong>, so they called the police."'''

replacements.append(('THURSDAY_STORY', old_thursday, new_thursday))

# Friday review story
old_friday = '''FRIDAY_REVIEW_STORY = (
    'On Friday, the <strong>bunny</strong> hosted a <strong>butter</strong> cookie party. '
    'All the animals from the <strong>tunnel</strong> came to celebrate. '
    'The <strong>duckling</strong> brought <strong>cotton</strong> candy made from <strong>cotton</strong> plants. '
    'The <strong>kitten</strong> baked <strong>bigger</strong> cookies than anyone else. '
    'The <strong>hopper</strong> frogs did a <strong>ladder</strong> jumping contest. '
    'The <strong>butter</strong>flies decorated the <strong>tunnel</strong> with <strong>feather</strong> art. '
    'They all agreed it was the <strong>summer</strong> of their lives. '
    'After the party, everyone went home <strong>happy</strong>.'''

new_friday = '''FRIDAY_REVIEW_STORY = (
    'On the last day of Prefix week, our class had a spelling party. '
    'We decorated with <strong>unknown</strong> mystery clues and discovery maps. '
    'Jake brought a puppet named Unhappy who always needed a friend. '
    'Sarah built a paper disagreement machine that made funny sounds. '
    'I had to <strong>unpack</strong> the party supplies from the big box. '
    'Our teacher said our work was not <strong>dishonest</strong> — it was all real effort. '
    'When the party ended, we had to <strong>return</strong> all the decorations. '
    'No one wanted to <strong>remove</strong> their party hats. '
    'We even <strong>remake</strong> our spelling posters with better drawings. '
    'Our teacher said the old gym was too <strong>unsafe</strong> for parties. '
    'Everyone agreed we didn\'t <strong>dislike</strong> learning about prefixes. '
    'Our teacher said we had <strong>reopened</strong> our love for spelling!"'''

replacements.append(('FRIDAY_REVIEW_STORY', old_friday, new_friday))

# Apply replacements
success_count = 0
for name, old, new in replacements:
    if old in content:
        content = content.replace(old, new)
        print(f"✓ Replaced {name}")
        success_count += 1
    else:
        print(f"✗ Could not find {name}")
        # Try to show what's there
        idx = content.find(name)
        if idx >= 0:
            print(f"  Found '{name}' at position {idx}")
            print(f"  Context: {content[idx:idx+200]}")

print(f"\nReplaced {success_count}/{len(replacements)} stories")

with open('generate_week9_new.py', 'w') as f:
    f.write(content)