# ── Generated by Nexa Transpiler ──────────────────────────────
# This file was auto-generated from a .nexa source file.
# Do not edit directly — regenerate with: nexa compile <file>
# ─────────────────────────────────────────────────────────────
from __future__ import annotations
import asyncio, math, json, os, random, functools, time as _time

# ── Nexa runtime stubs ───────────────────────────────────────
_nexa_modules = {}
def _nexa_opt_access(obj, attr):
    if obj is None: return None
    if isinstance(obj, dict): return obj.get(attr)
    return getattr(obj, attr, None)

print('=== Nexa v9 Showcase ===\n')
print('--- 1. Ternary Operator ---')
age = 22
status = ('Adult' if (age >= 18) else 'Minor')
print(f"Age {age} status: {status}")
assert status == 'Adult'
print('\n--- 2. Nullish Coalescing ---')
missing_val = None
actual_val = 42
default1 = (missing_val if missing_val is not None else 10)
default2 = (actual_val if actual_val is not None else 10)
print(f"missing ?? 10 = {default1}")
print(f"42 ?? 10      = {default2}")
assert default1 == 10
assert default2 == 42
print('\n--- 3. Optional Chaining ---')
user_with_addr = {'address': {'city': 'Nova City'}}
user_no_addr = {'name': 'Alice'}
city1 = _nexa_opt_access(_nexa_opt_access(user_with_addr, 'address'), 'city')
city2 = _nexa_opt_access(_nexa_opt_access(user_no_addr, 'address'), 'city')
print(f"User with addr city: {city1}")
print(f"User without addr city: {city2}")
assert city1 == 'Nova City'
assert city2 == None
print('\n--- 4. Spread and Rest Operators ---')
def sum_all(first, *rest):
    print(f"First element: {first}, Rest array: {rest}")
    return functools.reduce(lambda a, b: (a + b), rest, first)
total = sum_all(10, 20, 30, 40)
print(f"sum_all result: {total}")
assert total == 100
arr1 = [1, 2, 3]
arr2 = [0, *arr1, 4, 5]
print(f"Combined Array: {arr2}")
assert arr2 == [0, 1, 2, 3, 4, 5]
default_config = {'debug': False, 'timeout': 30}
user_config = {'timeout': 60, 'logging': True}
final_config = {**default_config, **user_config}
print(f"Merged Config: {final_config}")
my_args = [5, 10, 2]
spread_sum = sum_all(0, *my_args)
print(f"Spread Sum Call result: {spread_sum}")
assert spread_sum == 17
print('\n✅ All Nexa v9 features successfully verified!')
