// Asked of you, as slips of dyed paper — the model under the band.//// The picture (05-home) draws each question that waits on the owner as a torn// slip: the count and what it counts, typed, one row of three. What a slip SAYS// is the core's (`shell.today`'s `parts.asked`),// where it goes is the row's own path, and the one thing decided here is the// paper: which dye, and how the slips break into rows.//// THE DYE BELONGS TO THE QUEUE, not to the position. A queue keeps its colour// when the one before it empties — questions are always the sage slip, invites// the blue one, locked documents the peach one — so the eye learns the slips// the way it learns the caps. A total `switch`, so a new queue is a compile// error rather than a slip with no paper.//// Pure, so `DecideSlipsTests` pins it without a renderer.importCottonKitimportFoundationpublicstructDecideSlip: Sendable, Equatable, Identifiable {publiclet key: AskedKeypubliclet label: Stringpubliclet path: Stringpubliclet dye: PaperDye/// The database the slip's row counts in (`AskedItem.database`).publicvar database: FeedRowDatabase? = nil/// One key in two databases is two slips.publicvar id: String { FeedRowDatabase.key(database, id: key.rawValue) }/// Where the slip's tap opens: its path, in its own database.publicvar link: DatabaseLink? {Route.parse(path).map { FeedRowDatabase.link(database, route: $0) } }}publicenumDecideSlips {/// The band's slips, in the band's own order — the items are already the/// crate's order, and nothing here re-sorts them.publicstaticfunc slips(_ items: [AskedItem]) -> [DecideSlip] { items.map {DecideSlip(key: $0.key, label: $0.label, path: $0.path, dye: dye($0.key), database: $0.database) } }/// The slips broken into as few rows as `columns` (the theme's/// `board_asked_band_columns`: three is what the picture lays, and what a/// phone's width holds with the longest sentence still wrapping to three/// typed lines) allows, and BALANCED/// across them: four slips are two and two, never three and an orphan/// under them; seven are three, two and two. A longer row always comes/// first, and no row is more than one slip longer than another.publicstaticfunc rows(_ slips: [DecideSlip], columns: Int) -> [[DecideSlip]] {guard !slips.isEmpty, columns > 0else { return [] }let rowCount = (slips.count + columns - 1) / columnslet base = slips.count / rowCountlet longer = slips.count % rowCountvar rows: [[DecideSlip]] = []var start = 0for index in0..<rowCount {let length = base + (index < longer ? 1 : 0) rows.append(Array(slips[start..<start + length])) start += length }return rows }/// How many cells a row of `rows` is laid across — the first (longest)/// row's count, so a shorter row keeps its slips that width.publicstaticfunc width(of rows: [[DecideSlip]]) -> Int { rows.first?.count ?? 0 }/// Each queue's paper.publicstaticfunc dye(_ key: AskedKey) -> PaperDye {switch key {case .joinRequests: return .pinkcase .assistantsAsked: return .sagecase .invites: return .bluecase .passwords: return .peachcase .aiAccess: return .cream } }}