import * as React from "react"; import { cn } from "./lib/utils"; export type AspectRatioPreset = "16:9" | "3:1" | "2:1" | "1:1" | "4:3" | "21:9"; export const ASPECT_RATIO_PRESETS: Record = { "16:9": { ratio: 16 / 9, label: "16:9 STAGE SCREEN", description: "Widescreen stage and cinema monitor" }, "3:1": { ratio: 3 / 1, label: "3:1 BOARDING VOUCHER", description: "Elongated travel pass & wristband voucher" }, "2:1": { ratio: 2 / 1, label: "2:1 ADMISSION PASS", description: "Classic arena ticket and concert stub" }, "1:1": { ratio: 1 / 1, label: "1:1 BADGE", description: "Square accreditation pass and credential badge" }, "4:3": { ratio: 4 / 3, label: "4:3 RETRO SCREEN", description: "Classic broadcast display" }, "21:9": { ratio: 21 / 9, label: "21:9 ULTRA STAGE", description: "Panoramic arena backdrop display" }, }; export function isAspectRatioPreset(value: unknown): value is AspectRatioPreset { return typeof value === "string" && value in ASPECT_RATIO_PRESETS; } export interface AspectRatioProps extends React.HTMLAttributes { ratio?: number | AspectRatioPreset; perforated?: boolean; cornerGuides?: boolean; cornerNotches?: boolean; label?: string; serial?: string; variant?: "default" | "perforated" | "stub" | "screen"; innerClassName?: string; } export function AspectRatio({ ratio = "16:9", perforated = false, cornerGuides = false, cornerNotches = false, label, serial, variant = "default", className, innerClassName, style, children, ...props }: AspectRatioProps) { const isPreset = isAspectRatioPreset(ratio); const preset = isPreset ? ASPECT_RATIO_PRESETS[ratio] : undefined; const resolvedRatio = typeof ratio === "number" ? ratio : preset?.ratio ?? 16 / 9; const displayLabel = label ?? preset?.label; const isPerforated = perforated || variant === "perforated"; return (
{/* Inner Perforated Frame Guideline */} {isPerforated && (