// A person on a card: who, and the picture to draw when there is one.importFoundation/// A person on a card: who, and the picture to draw when there is one.publicstructCardPerson: Equatable, Sendable {publicvar id: Stringpublicvar name: Stringpublicvar pictureKey: String?publicinit(id: String, name: String, pictureKey: String?) {self.id = idself.name = nameself.pictureKey = pictureKey }/// A name's initials for a print with no picture: the first letter of its/// first and last words ("Asha Rao" → "AR", "Asha" → "A"); nil for no name.publicstaticfunc initials(_ name: String) -> String? {let words = name.split(whereSeparator: { $0.isWhitespace }).filter { $0.first?.isLetter == true }guardlet first = words.first?.first else { returnnil }let last = words.count > 1 ? words.last?.first.map { String($0) } ?? "" : ""return (String(first) + last).uppercased() }/// The name you would use out loud: the first word of a whole name; a/// single-word name is itself.publicstaticfunc firstName(_ fullName: String) -> String {let parts = fullName.split(whereSeparator: \.isWhitespace)return parts.first.map(String.init) ?? fullName }}