with open('/home/crogers2287/projects/dope_wars_2026/lib/screens/market_screen.dart', 'r') as f:
    content = f.read()

# Fix _handleBuy to pass mode + stashSpace
old_buy = """    final qty = await showQuantityDialog(context,
      title: 'Buy \${product.name} \${product.emoji}',
      maxQuantity: maxQty,
      pricePerUnit: price,
    );"""
new_buy = """    final qty = await showQuantityDialog(context,
      title: 'Buy \${product.name} \${product.emoji}',
      maxQuantity: maxQty,
      pricePerUnit: price,
      mode: DealMode.buying,
      stashSpace: maxBySpace,
      unitsOwned: state.player.quantityOf(product.id),
    );"""

# Fix _handleSell to pass mode + unitsOwned
old_sell = """    final qty = await showQuantityDialog(context,
      title: 'Sell \${product.name} \${product.emoji}',
      maxQuantity: owned,
      pricePerUnit: price,
    );"""
new_sell = """    final qty = await showQuantityDialog(context,
      title: 'Sell \${product.name} \${product.emoji}',
      maxQuantity: owned,
      pricePerUnit: price,
      mode: DealMode.selling,
      unitsOwned: owned,
      stashSpace: state.player.stashLimit - state.player.totalInventoryCount,
    );"""

content = content.replace(old_buy, new_buy, 1)
content = content.replace(old_sell, new_sell, 1)

with open('/home/crogers2287/projects/dope_wars_2026/lib/screens/market_screen.dart', 'w') as f:
    f.write(content)
print("Done")
