#!/usr/bin/env python3
"""Build the Bonanzo bank pitch deck in Google Slides."""
import json
from google.oauth2.credentials import Credentials
from googleapiclient.discovery import build

with open('/Users/assafdagan/.clawdbot/skills/gmail/tokens/bot-calendar.json') as f:
    token_data = json.load(f)
with open('/Users/assafdagan/.clawdbot/skills/gmail/credentials.json') as f:
    cred_data = json.load(f)['installed']

creds = Credentials(
    token=token_data['token'],
    refresh_token=token_data['refresh_token'],
    token_uri=cred_data['token_uri'],
    client_id=cred_data['client_id'],
    client_secret=cred_data['client_secret'],
    scopes=token_data['scopes']
)

slides_service = build('slides', 'v1', credentials=creds)
PRES_ID = '1QvQ7WTuOX9ampVhfJLmGSwE8KVTIEbWRsjYs7B9G0jQ'

# Color constants (RGB 0-1)
DARK = {'red': 0.1, 'green': 0.1, 'blue': 0.12}
WHITE = {'red': 1, 'green': 1, 'blue': 1}
ACCENT = {'red': 0.2, 'green': 0.6, 'blue': 0.4}  # Green accent
LIGHT_BG = {'red': 0.96, 'green': 0.96, 'blue': 0.97}

def emu(inches):
    return int(inches * 914400)

def make_slide(requests, slide_id, title, body_text, bg_color=None, title_color=None, body_color=None):
    """Create a slide with title and body text."""
    title_id = f"{slide_id}_title"
    body_id = f"{slide_id}_body"
    
    # Create slide
    requests.append({
        'createSlide': {
            'objectId': slide_id,
            'slideLayoutReference': {'predefinedLayout': 'BLANK'}
        }
    })
    
    # Background color
    if bg_color:
        requests.append({
            'updatePageProperties': {
                'objectId': slide_id,
                'pageProperties': {
                    'pageBackgroundFill': {
                        'solidFill': {'color': {'rgbColor': bg_color}}
                    }
                },
                'fields': 'pageBackgroundFill'
            }
        })
    
    # Title text box
    requests.append({
        'createShape': {
            'objectId': title_id,
            'shapeType': 'TEXT_BOX',
            'elementProperties': {
                'pageObjectId': slide_id,
                'size': {'width': {'magnitude': emu(8.5), 'unit': 'EMU'},
                         'height': {'magnitude': emu(1.2), 'unit': 'EMU'}},
                'transform': {'scaleX': 1, 'scaleY': 1,
                             'translateX': emu(0.75), 'translateY': emu(0.4),
                             'unit': 'EMU'}
            }
        }
    })
    requests.append({
        'insertText': {'objectId': title_id, 'text': title, 'insertionIndex': 0}
    })
    requests.append({
        'updateTextStyle': {
            'objectId': title_id,
            'style': {
                'fontSize': {'magnitude': 28, 'unit': 'PT'},
                'bold': True,
                'foregroundColor': {'opaqueColor': {'rgbColor': title_color or DARK}}
            },
            'textRange': {'type': 'ALL'},
            'fields': 'fontSize,bold,foregroundColor'
        }
    })
    
    # Body text box
    requests.append({
        'createShape': {
            'objectId': body_id,
            'shapeType': 'TEXT_BOX',
            'elementProperties': {
                'pageObjectId': slide_id,
                'size': {'width': {'magnitude': emu(8.5), 'unit': 'EMU'},
                         'height': {'magnitude': emu(3.5), 'unit': 'EMU'}},
                'transform': {'scaleX': 1, 'scaleY': 1,
                             'translateX': emu(0.75), 'translateY': emu(1.8),
                             'unit': 'EMU'}
            }
        }
    })
    requests.append({
        'insertText': {'objectId': body_id, 'text': body_text, 'insertionIndex': 0}
    })
    requests.append({
        'updateTextStyle': {
            'objectId': body_id,
            'style': {
                'fontSize': {'magnitude': 14, 'unit': 'PT'},
                'foregroundColor': {'opaqueColor': {'rgbColor': body_color or DARK}}
            },
            'textRange': {'type': 'ALL'},
            'fields': 'fontSize,foregroundColor'
        }
    })

requests = []

# Delete default slide
requests.append({'deleteObject': {'objectId': 'p'}})

# ── SLIDE 1: Title ──
make_slide(requests, 'slide01',
    'Bonanzo',
    'Initial Wealth Management\nfor a Generation That Wants to Earn\n\n\nAssaf Dagan  ·  Tal Goren',
    bg_color=DARK, title_color=WHITE, body_color=WHITE)
# Make title bigger for cover
requests.append({
    'updateTextStyle': {
        'objectId': 'slide01_title',
        'style': {'fontSize': {'magnitude': 48, 'unit': 'PT'}},
        'textRange': {'type': 'ALL'},
        'fields': 'fontSize'
    }
})

# ── SLIDE 2: The Shift (Ogilvy copy) ──
make_slide(requests, 'slide02',
    'Your Next Million Customers Are Under 16.\nThey\'re Already Earning.',
    '• 73% of children aged 10-17 earn money outside of traditional allowances\n  — through gig work, resale, digital services, and content creation.\n\n• The informal youth economy exceeds $50 billion globally\n  — yet not a single dollar is captured by a financial institution.\n\n• Over 40% of Gen Alpha already consider themselves "entrepreneurs"\n  — they don\'t want to learn about money. They want to use it.\n\n• By age 14, spending habits and brand loyalties are largely formed\n  — the bank that captures them at 12 owns the relationship at 22.\n\nThis generation isn\'t waiting for permission.\nThe only question is whether you\'re there when they start.')

# ── SLIDE 3: The Gap ──
make_slide(requests, 'slide03',
    'Money Flows. Infrastructure Doesn\'t.',
    'Today, when a child earns money:\n\n→  It goes into a parent\'s bank account (invisible to the child)\n→  It stays as cash in a drawer (unmanaged, untracked)\n→  It flows through grey digital channels (unprotected)\n→  It disappears entirely (no record, no learning)\n\nThe result:\n•  Children lose visibility and agency over money they earned\n•  Parents are anxious and overwhelmed\n•  Employers avoid hiring minors due to friction\n•  Financial institutions miss the earliest possible client relationship\n\nThere is no regulated infrastructure for a child\'s first earned income.\nBonanzo builds it.')

# ── SLIDE 4: The Solution ──
make_slide(requests, 'slide04',
    'Bonanzo: Three Parties. One System.',
    'Bonanzo connects:\n\n🧒  CHILDREN — who want to work, earn, and reach self-defined goals\n👨‍👩‍👧  PARENTS — who require safety, transparency, and approval\n🏪  EMPLOYERS & COMMUNITY — who need a simple, compliant way to engage minors\n\nBonanzo is not a financial education app.\nIt is not a bank.\n\nIt is Initial Wealth Management —\nthe infrastructure for managing the first money a child earns.\n\nA new category. A new asset class. A new relationship.')

# ── SLIDE 5: How It Works ──
make_slide(requests, 'slide05',
    'The Triple Interface',
    'THE TEEN                          THE PARENT                       THE MARKET\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n\nFinds gig or creates listing         Approves gig                      Posts gig\n(local job / second-hand)            (safety & suitability check)      (local business / neighbor)\n\nCompletes job and earns              Sets \'money taxonomy\'             Verifies and pays\n(action-based learning)              (guides saving & spending)        (digital transactions)\n\nFinancial goals dashboard            Oversight dashboard               Talent pool access\n(visualizing goals & progress)       (full transparency)               (motivated, safe help)\n\n\nOne platform. Three experiences. Complete visibility for everyone.')

# ── SLIDE 6: Age-Tiered Architecture ──
make_slide(requests, 'slide06',
    'Designed to Grow With the Child',
    'AGES 8+  ·  LOCAL MARKETPLACE\n•  Buy and sell second-hand items within their area\n•  Real pricing decisions, real responsibility\n•  No shipping — local exchange removes logistics friction\n•  First exposure to earning and trading\n\nAGES 12+  ·  WORK MARKETPLACE\n•  Casual local jobs: dog walking, tech help, errands\n•  Digital micro-tasks appropriate for minors\n•  Age-matched, capability-matched, regulation-aligned\n•  Real employers, real earnings, real financial management\n\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\nBUILT-IN FUNNEL: Enter at 8. Earn at 12. Stay for life.\nThis is not an app lifecycle. It is a financial relationship lifecycle.')

# ── SLIDE 7: Why You, The Bank (THE slide — Ogilvy copy) ──
make_slide(requests, 'slide07',
    'Why This Is Your Opportunity',
    'Every bank in the world acquires customers the same way:\nwait until they turn 18, then compete on rates.\n\nBonanzo changes the equation entirely.\n\n\n🎯  ZERO-CAC ACQUISITION\nClients acquired at age 12 — not 22.\nNo marketing spend. No rate wars. They come to you through the platform.\nIndustry average CAC: $400+. Bonanzo CAC: approaching zero.\n\n📈  COMPOUNDING AUM FROM CHILDHOOD\nEvery earned shekel flows into an account held by you.\n10 years of deposits before they choose their "adult" bank.\n(By then, they already have one.)\n\n🔒  UNBREAKABLE RETENTION\nWork history + earnings record + savings + goals = massive switching cost.\nThis isn\'t an app they delete. It\'s their financial identity.\n\n📊  NEXT-GEN BEHAVIORAL DATA\nDeep insight into the earning, spending, and saving behaviors\nof tomorrow\'s most valuable consumer segment — years before anyone else.\n\n🏆  FIRST-MOVER ADVANTAGE\nThe first bank to own "Initial Wealth Management" defines the category.\nEvery competitor after you is a follower.',
    bg_color=DARK, title_color=WHITE, body_color=WHITE)

# ── SLIDE 8: Market Size ──
make_slide(requests, 'slide08',
    'The "Piggy Bank Economy"',
    'ISRAEL PILOT\n•  ~2 million children aged 8-17\n•  95%+ smartphone household penetration\n•  Dense urban environment ideal for local marketplace\n•  Strong gig economy culture\n\nADDRESSABLE MARKET\n•  Tel Aviv metro: ~400K children aged 8-17\n•  Target pilot: 5,000 families in Year 1\n•  Expansion: National Israel → International\n\nGLOBAL OPPORTUNITY\n•  $50B+ in informal youth earnings globally\n•  350M+ children in addressable markets (US, EU, UK, ANZ)\n•  No platform currently captures this liquidity\n•  Youth fintech market growing 25%+ YoY\n\nThis is not a niche. It is an untapped asset class.')

# ── SLIDE 9: Revenue Model ──
make_slide(requests, 'slide09',
    'Three Revenue Streams',
    '1 ·  MONTHLY SUBSCRIPTION\n•  9.90 ILS / child / month (~$2.70)\n•  Paid by parents for safety, access, and financial tools\n•  Deliberately low to drive adoption\n•  At 50K subscribers: ~$1.6M ARR\n\n2 ·  EMPLOYER TRANSACTION FEE\n•  Small percentage on each gig payment\n•  Charged to the employer — never from the child\n•  Scales with marketplace volume\n\n3 ·  AUM REVENUE SHARE\n•  Percentage on managed savings and investments\n•  Shared with bank partner\n•  Grows as cohorts age up and balances compound\n•  The long-term value driver\n\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\nBuilt for long-term engagement, not one-off transactions.\nLTV increases every year a child stays on the platform.')

# ── SLIDE 10: Competitive Landscape ──
make_slide(requests, 'slide10',
    'Adjacent Players. No Direct Competitor.',
    'GREENLIGHT (US)\n✓ Debit card + allowance     ✗ No work marketplace     ✗ No earning mechanism\n\nGOHENRY (UK/US)\n✓ Spending control            ✗ No real employers       ✗ No community jobs\n\nBUSYKID (US)\n✓ Chore tracking              ✗ No real-world gigs      ✗ Family-only\n\nFAMZOO (US)\n✓ Virtual family bank         ✗ No marketplace          ✗ No external earning\n\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\nBONANZO\n✓ Real work marketplace  ✓ Real employers  ✓ Real earnings\n✓ Savings & investment   ✓ Local community  ✓ Full cycle\n\nEvery competitor manages money children receive.\nBonanzo manages money children earn.\nThat is the difference.')

# ── SLIDE 11: Compliance ──
make_slide(requests, 'slide11',
    'Compliance & Safety Framework',
    'REGULATORY ALIGNMENT\n•  Israeli Youth Employment Law (חוק עבודת נוער) — age-appropriate task matching\n•  Privacy Protection Law (הגנת הפרטיות) — minor data protection\n•  KYC performed once on the parent; child as named beneficiary\n•  All work classified as casual/informal — not employment\n\nSAFETY ARCHITECTURE\n•  Parental approval required for every gig\n•  Age-appropriate task filtering (automated + manual review)\n•  Community reputation and rating system\n•  Geographic proximity requirements for local jobs\n•  Real-time parental visibility into all activity\n\nRESPONSIBILITY SPLIT\n•  Bonanzo: Platform, task vetting, user safety, marketplace operations\n•  Bank Partner: Financial accounts, KYC/AML, fund management, regulatory compliance\n•  Insurance: Liability framework under development with [insurance partner]\n\nDesigned for bank-grade compliance from day one.')

# ── SLIDE 12: Go-to-Market ──
make_slide(requests, 'slide12',
    'Go-to-Market: Tel Aviv Pilot',
    'PHASE 1  ·  FOUNDATION (Months 1-3)\n•  500 families in central Tel Aviv\n•  Curate first 200 gig listings before launch\n•  Partner with: local businesses, community centers, schools\n•  Second-hand marketplace live for ages 8+\n\nPHASE 2  ·  VALIDATION (Months 4-6)\n•  Expand to 2,000 families\n•  Work marketplace live for ages 12+\n•  Measure: activation rate, gigs completed, savings rate, NPS\n•  Iterate on product based on real behavior\n\nPHASE 3  ·  SCALE (Months 7-12)\n•  5,000 families across Tel Aviv metro\n•  Launch financial partner integration\n•  Begin national expansion planning\n\nSUCCESS METRICS\n•  Family activation rate >60%\n•  Monthly gig completion rate >3 per active teen\n•  Savings rate >40% of earnings\n•  NPS >50')

# ── SLIDE 13: Team ──
make_slide(requests, 'slide13',
    'The Team',
    'TAL GOREN\nStrategic consultant and business developer specializing in venture growth,\nfundraising, and international partnerships. Former startup CEO and founder.\nMultidisciplinary background spanning political journalism, international\ndocumentary filmmaking, and tech ventures. Sharp strategic communication\nand market analysis.\n\n\nASSAF DAGAN\nFounder of Any Studios, a branding and communication agency based in New York.\nCrafted digital strategies for global brands including the Élysée Palace (Paris),\nAudi, Levi\'s, and Wiz. Award-winning creative director with a global outlook\nand proven ability to identify a brand\'s distinctive position within its market.\n\n\nADVISORY\n[Legal / compliance advisor — to be added]\n[Fintech / banking advisor — to be added]')

# ── SLIDE 14: The Ask (Ogilvy copy) ──
make_slide(requests, 'slide14',
    'The Partnership',
    'WHAT BONANZO BRINGS\n•  The platform: marketplace, matching, engagement\n•  User acquisition: families, employers, communities\n•  Product experience: three interfaces, age-tiered design\n•  Brand positioning: "Initial Wealth Management" category creation\n\nWHAT THE BANK BRINGS\n•  Financial infrastructure: savings accounts, investment products\n•  Regulatory compliance: KYC/AML, fund management, licensing\n•  Trust: institutional credibility that parents require\n•  Scale: national and international banking rails\n\nTHE STRUCTURE\n•  Exclusive partnership for Initial Wealth Management in [market]\n•  Revenue share on subscription, transaction fees, and AUM\n•  Co-branded product: [Bank] × Bonanzo\n•  Joint pilot: Tel Aviv, 6 months, 5,000 families\n\n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\nChildren are already earning. Money is already moving.\nThe only question is: will you be the bank that captures it?',
    bg_color=DARK, title_color=WHITE, body_color=WHITE)

# Execute all requests
print(f"Sending {len(requests)} requests...")
response = slides_service.presentations().batchUpdate(
    presentationId=PRES_ID,
    body={'requests': requests}
).execute()
print(f"Done. {len(response.get('replies',[]))} replies.")
print(f"URL: https://docs.google.com/presentation/d/{PRES_ID}/edit")
