-- Bspin production operator seed template.
-- Review values before running against the production Supabase/Postgres database.
-- Do not store the real shared secret here. Put it in Vercel as OPERATOR_SECRET_BSPIN_PRODUCTION.
-- The casino-provided production wallet URL is https://rougereelsapi.bspin.io/wallet/.
-- Store callback_base_url as https://rougereelsapi.bspin.io because Rouge Reels appends /wallet/<action>.
-- Expected balance callback URL: https://rougereelsapi.bspin.io/wallet/balance.
-- Current go-live gate status:
-- - Legal review: complete.
-- - External certification: not required for this Bspin production launch.
-- - Security recheck, jurisdiction, seed-encryption, observability, and operator
--   callback review must be complete before real-money traffic.

INSERT INTO public.operators (
  id,
  name,
  status,
  callback_base_url,
  currency,
  theme
)
VALUES (
  'bspin-production',
  'Bspin Production',
  'active',
  'https://rougereelsapi.bspin.io',
  'USD',
  '{
    "brandName": "Bspin",
    "logoText": "BS",
    "primary": "#16a86f",
    "accent": "#ffd166",
    "background": "#0d1117",
    "showBalanceInEmbed": true
  }'::jsonb
)
ON CONFLICT (id) DO UPDATE SET
  name = EXCLUDED.name,
  status = EXCLUDED.status,
  callback_base_url = EXCLUDED.callback_base_url,
  currency = EXCLUDED.currency,
  theme = EXCLUDED.theme,
  updated_at = now();

INSERT INTO public.operator_game_configs (
  operator_id,
  game_type,
  enabled,
  min_bet,
  max_bet,
  max_payout,
  house_edge,
  profile
)
VALUES
  (
    'bspin-production',
    'dice',
    true,
    0.1,
    500,
    50000,
    0.01,
    '{"directions": ["over", "under"], "targetMin": 1, "targetMax": 99, "stakeStep": 0.1}'::jsonb
  ),
  (
    'bspin-production',
    'limbo',
    true,
    0.1,
    250,
    50000,
    0.01,
    '{"targetMultiplierMin": 1.01, "targetMultiplierMax": 1000, "stakeStep": 0.1}'::jsonb
  ),
  (
    'bspin-production',
    'plinko',
    true,
    0.1,
    100,
    50000,
    NULL,
    '{"rows": 12, "rowOptions": [8, 9, 10, 11, 12, 13, 14, 15, 16], "risk": "medium", "riskOptions": ["low", "medium", "high"], "stakeStep": 0.1}'::jsonb
  ),
  (
    'bspin-production',
    'keno',
    true,
    0.1,
    25,
    50000,
    NULL,
    '{"numberCount": 40, "drawCount": 10, "minPicks": 1, "maxPicks": 10, "stakeStep": 0.1}'::jsonb
  ),
  (
    'bspin-production',
    'mines',
    true,
    0.1,
    100,
    50000,
    0.01,
    '{"tileCount": 25, "defaultMineCount": 3, "minMineCount": 1, "maxMineCount": 24, "stakeStep": 0.1}'::jsonb
  ),
  (
    'bspin-production',
    'blackjack',
    true,
    0.1,
    100,
    50000,
    NULL,
    '{"blackjackPayout": "3:2", "insurancePayout": "2:1", "dealerStandsSoft17": true, "unlimitedDecks": true, "splitLimit": 1, "stakeStep": 0.1}'::jsonb
  )
ON CONFLICT (operator_id, game_type) DO UPDATE SET
  enabled = EXCLUDED.enabled,
  min_bet = EXCLUDED.min_bet,
  max_bet = EXCLUDED.max_bet,
  max_payout = EXCLUDED.max_payout,
  house_edge = EXCLUDED.house_edge,
  profile = EXCLUDED.profile,
  updated_at = now();
