         return assetFetchOptions
     }
     
+    internal weak var camera: UIViewController?
     private var metadataFromCamera: [AnyHashable : Any]?
     private func createCamera() -> UIViewController {
         let didCancel = { [unowned self] () in

    }
    
    @objc open func presentCamera() {
        self.present(camera: self.createCamera())
    }
    
    internal weak var camera: UIViewController?
    @objc open func present(camera: UIViewController) {
        if self.inline {
            UIApplication.shared.keyWindow!.rootViewController!.present(camera, animated: true, completion: nil)
        } else {
            self.present(camera, animated: true, completion: nil)
        }
    }
    
    @objc open func dismissCamera() {
        if let _ = self.camera {
            if self.inline {
                UIApplication.shared.keyWindow!.rootViewController!.dismiss(animated: true, completion: nil)
            } else {
                self.dismiss(animated: true, completion: nil)
            }
            self.camera = nil
        }
    }

        }
    }
    
    // MARK: - Selection
        
    @objc open func select(asset: DKAsset, updateGroupDetailVC: Bool = true) {
        if self.singleSelect {
            self.deselectAll()
        }
        
        if self.assets[asset.localIdentifier] != nil { return }
        
        self.selectedAssetIdentifiers.append(asset.localIdentifier)
        self.assets[asset.localIdentifier] = asset
        self.clearSelectedAssetsCache()
        
        if self.sourceType == .camera || (self.singleSelect && self.autoCloseOnSingleSelect) {
            self.done()
        } else {
            self.triggerSelectedChanged()
            self.UIDelegate.imagePickerController(self, didSelectAssets: [asset])
            
            if updateGroupDetailVC, let rootVC = self.viewControllers.first as? DKAssetGroupDetailVC {
                rootVC.collectionView?.reloadData()
            }
        }
    }
    
    @objc open func select(assets: [DKAsset], updateGroupDetailVC: Bool = true) {
        var needsUpdateGroupDetailVC = false
        
        for asset in assets {
            self.select(asset: asset, updateGroupDetailVC: false)
            needsUpdateGroupDetailVC = true
        }
        
        if needsUpdateGroupDetailVC, updateGroupDetailVC, let rootVC = self.viewControllers.first as? DKAssetGroupDetailVC {
            rootVC.collectionView?.reloadData()
        }
    }
    
    @objc open func deselect(asset: DKAsset, updateGroupDetailVC: Bool = true) {
        if self.assets[asset.localIdentifier] == nil { return }
        
        self.selectedAssetIdentifiers.remove(at: self.selectedAssetIdentifiers.index(of: asset.localIdentifier)!)
        self.assets[asset.localIdentifier] = nil
        self.clearSelectedAssetsCache()
        
        self.triggerSelectedChanged()
        self.UIDelegate.imagePickerController(self, didDeselectAssets: [asset])
        
        if updateGroupDetailVC, let rootVC = self.viewControllers.first as? DKAssetGroupDetailVC {
            rootVC.collectionView?.reloadData()
        }
    }
    
    @objc open func deselectAll(updateGroupDetailVC: Bool = true) {
        if self.selectedAssetIdentifiers.count > 0 {
            let assets = self.selectedAssets
            self.selectedAssetIdentifiers.removeAll()
            self.assets.removeAll()
            self.clearSelectedAssetsCache()
            
            self.triggerSelectedChanged()
            self.UIDelegate.imagePickerController(self, didDeselectAssets: assets)
            
            
            if updateGroupDetailVC, let rootVC = self.viewControllers.first as? DKAssetGroupDetailVC {
                rootVC.collectionView?.reloadData()
            }
        }
    }
    
    @objc open func setSelectedAssets(assets: [DKAsset]) {
        if assets.count > 0 {
            self.deselectAll(updateGroupDetailVC: false)
            self.select(assets: assets, updateGroupDetailVC: true)
        } else {
            self.deselectAll(updateGroupDetailVC: true)
        }
    }
    
    open func index(of asset: DKAsset) -> Int? {
        if self.contains(asset: asset) {
            return self.selectedAssetIdentifiers.index(of: asset.localIdentifier)
        } else {
            return nil
        }
    }
    
    @objc func contains(asset: DKAsset) -> Bool {
        return self.assets[asset.localIdentifier] != nil
    }
    
    private var internalSelectedAssetsCache: [DKAsset]?
    @objc public var selectedAssets: [DKAsset] {
        get {
            if self.internalSelectedAssetsCache != nil {
                return self.internalSelectedAssetsCache!
            }
            
            var assets = [DKAsset]()
            for assetIdentifier in self.selectedAssetIdentifiers {
                assets.append(self.assets[assetIdentifier]!)
            }
            
            self.internalSelectedAssetsCache = assets

            return assets
        }
    }
    
    private func clearSelectedAssetsCache() {
        self.internalSelectedAssetsCache = nil
    }
    
    // MARK: - Orientation
    
    @objc open override var shouldAutorotate : Bool {
        return self.allowsLandscape && self.sourceType != .camera ? true : false
