import Foundation struct SettingsControl: Hashable, Identifiable, Sendable { let id: String let section: SettingsSection let searchText: SettingsSearchText init(_ id: String, section: SettingsSection, title: String, help: String = "", synonyms: [String] = []) { self.id = id self.section = section searchText = SettingsSearchText(title: title, help: help, synonyms: synonyms) } var title: String { searchText.title } func scoped(to section: SettingsSection) -> Self { guard self.section != section else { return self } return Self( "\(section.rawValue).\(id)", section: section, title: title, help: searchText.help, synonyms: searchText.synonyms) } } @MainActor protocol SearchableSettingsPane { static var searchControls: [SettingsControl] { get } } extension SearchableSettingsPane { static func control(_ id: String) -> SettingsControl { guard let control = searchControls.first(where: { $0.id == id }) else { preconditionFailure("Missing settings control: \(id)") } return control } }