from datetime import timedelta
from app.models import Slot

slotQRCodes = [
    "A1-X06SA",
    "A2-X06SA",
    "A3-X06SA",
    "A4-X06SA",
    "A5-X06SA",
    "B1-X06SA",
    "B2-X06SA",
    "B3-X06SA",
    "B4-X06SA",
    "B5-X06SA",
    "C1-X06SA",
    "C2-X06SA",
    "C3-X06SA",
    "C4-X06SA",
    "C5-X06SA",
    "D1-X06SA",
    "D2-X06SA",
    "D3-X06SA",
    "D4-X06SA",
    "D5-X06SA",
    "A1-X10SA",
    "A2-X10SA",
    "A3-X10SA",
    "A4-X10SA",
    "A5-X10SA",
    "B1-X10SA",
    "B2-X10SA",
    "B3-X10SA",
    "B4-X10SA",
    "B5-X10SA",
    "C1-X10SA",
    "C2-X10SA",
    "C3-X10SA",
    "C4-X10SA",
    "C5-X10SA",
    "D1-X10SA",
    "D2-X10SA",
    "D3-X10SA",
    "D4-X10SA",
    "D5-X10SA",
    "NB1",
    "NB2",
    "NB3",
    "NB4",
    "NB5",
    "NB6",
    "X10SA-Beamline",
    "X06SA-Beamline",
    "X06DA-Beamline",
    "Outgoing X10SA",
    "Outgoing X06SA",
]


def timedelta_to_str(td: timedelta) -> str:
    days, seconds = td.days, td.seconds
    hours = days * 24 + seconds // 3600
    minutes = (seconds % 172800) // 60
    return f"PT{hours}H{minutes}M"


slots = [
    Slot(
        id=str(i + 1),  # Convert id to string to match your schema
        qr_code=qrcode,
        label=qrcode.split("-")[0],
        qr_base=qrcode.split("-")[1] if "-" in qrcode else "",
        occupied=False,
        needs_refill=False,
    )
    for i, qrcode in enumerate(slotQRCodes)
]
