import Foundation
import GenAPI
import IdentifiedCollections

public struct PinnedClipsContainer {
    public let pinnedClips: IdentifiedArray<ClipID, Clip>

    public init(pinnedClips: [Clip]) {
        self.pinnedClips = IdentifiedArray(uniqueElements: pinnedClips)
    }
}

extension PinnedClipsContainer {
    init(remote: GenAPI.PinnedClipsSchema) {
        let clips = remote.pinnedClips
        self.pinnedClips = IdentifiedArray(uniqueElements: clips.compactMap { try? Clip($0) })
    }
}
