import SwiftUI

// MARK: - Message Bubble Shape

struct MessageBubbleShape: Shape {
    let position: BubblePosition
    let outgoing: Bool
    private let mergeType: BubbleMergeType
    private let metrics: BubbleMetrics

    init(position: BubblePosition, outgoing: Bool) {
        self.position = position
        self.outgoing = outgoing
        self.mergeType = BubbleGeometryEngine.mergeType(for: position)
        self.metrics = .telegram()
    }

    static var tailProtrusion: CGFloat {
        BubbleMetrics.telegram().tailProtrusion
    }

    func path(in rect: CGRect) -> Path {
        BubbleGeometryEngine.makeSwiftUIPath(
            in: rect,
            mergeType: mergeType,
            outgoing: outgoing,
            metrics: metrics
        )
    }
}
