 import WebKit
 import AppKit
 
+extension WebView: KVOCapable {}
+
 class URLShareMacViewController: XPURLShareViewController {
     
     // MARK: Outlets

    // MARK: Stage 2 - Animate Card into View
    
    private func configureCard(item: SerializableURLItem) -> Bool {
        var webViewNeeded = false
        if let pageTitle = item.pageTitle {
            self.pageTitleLabel?.stringValue = pageTitle

    }
}

fileprivate extension NSView {
    fileprivate var snapshot: NSImage? {
        let _layer = self.layer?.sublayers?.first ?? self.layer
        guard let layer = _layer, let colorSpace = CGColorSpace(name: CGColorSpace.sRGB) else { return .none }
        let bounds = layer.bounds
        
        let pixelsHigh = Int(floor(bounds.size.height))
        let pixelsWide = Int(floor(bounds.size.width))
        
        let _context = CGContext(data: nil,
                                width: pixelsWide,
                                height: pixelsHigh,
                                bitsPerComponent: 8,
                                bytesPerRow: 0,
                                space: colorSpace,
                                bitmapInfo: CGImageAlphaInfo.premultipliedLast.rawValue)
        
        guard let context = _context else { return .none }
        layer.render(in: context)
        guard let _image = context.makeImage() else { return .none }
        let image = NSImage(cgImage: _image, size: NSSize.zero)
        return image
    }
}
