--[[----------------------------------------------------------------------------

ADOBE CONFIDENTIAL
------------------
Copyright 2020 Adobe
All Rights Reserved.

NOTICE: All information contained herein is, and remains
the property of Adobe and its suppliers, if any. The intellectual
and technical concepts contained herein are proprietary to Adobe
and its suppliers and are protected by all applicable intellectual
property laws, including trade secret and copyright laws.
Dissemination of this information or reproduction of this material
is strictly forbidden unless prior written permission is obtained
from Adobe.

------------------------------------------------------------------------------]]

	-- WF.oz_client.managed_catalog
local WFCatVersions = require 'WFCatVersions'

	-- WF.lrmobile.models
local LrmCatXmpDevelop = require 'LrmCatXmpDevelop'

	-- WF.core.models
local WFModelsUtils = require 'WFModelsUtils'

--------------------------------------------------------------------------------

local LrmLibraryVersionsModelImp = {}

--==============================================================================

local function getExternalXmpDevelopModel( catalog, versionId )

	local result =  LrmCatXmpDevelop.getExternalXmpDevelop( catalog, versionId )
		
		:map( function( _, xmpRelPath )
			
			return xmpRelPath
			
		end )
	
	return {
		value = result
	}

end

--------------------------------------------------------------------------------

function LrmLibraryVersionsModelImp:createVersionForAsset( assetId, createdManually, versionName )

	return WFModelsUtils.createModelForFunction( self._wfCatalogStream, 
			WFCatVersions.createVersionForAsset, assetId, createdManually, versionName )
		
end

--------------------------------------------------------------------------------

function LrmLibraryVersionsModelImp:createVersionForAssetWithSettings( assetId, createdManually, versionName, developSettings )

	return WFModelsUtils.createModelForFunction( self._wfCatalogStream, 
			WFCatVersions.createVersionForAssetWithSettings, assetId, createdManually, versionName, developSettings )
		
end

--------------------------------------------------------------------------------

function LrmLibraryVersionsModelImp:createVersionForAssetWithExternalSettings( assetId, createdManually, versionName, developSettings )

	return WFModelsUtils.createModelForFunction( self._wfCatalogStream, 
			WFCatVersions.createVersionForAssetWithExternalSettings, assetId, createdManually, versionName, developSettings )
		
end

--------------------------------------------------------------------------------

function LrmLibraryVersionsModelImp:duplicateVersion( sourceVersionId, createdManually, versionName )

	return WFModelsUtils.createModelForFunction( self._wfCatalogStream, 
			WFCatVersions.duplicateVersion, sourceVersionId, createdManually, versionName )
		
end

--------------------------------------------------------------------------------

function LrmLibraryVersionsModelImp:getAllVersionsByAssetId( assetId, includeFakeImportStateVersion )

	return WFModelsUtils.createModelForFunction( self._wfCatalogStream, 
			WFCatVersions.getAllVersionsStreamForAsset, assetId, includeFakeImportStateVersion )

end

--------------------------------------------------------------------------------

function LrmLibraryVersionsModelImp:getManualVersionsByAssetId( assetId, includeFakeImportStateVersion )

	return WFModelsUtils.createModelForFunction( self._wfCatalogStream, 
			WFCatVersions.getManualVersionsStreamForAsset, assetId, includeFakeImportStateVersion )

end

--------------------------------------------------------------------------------

function LrmLibraryVersionsModelImp:getAutoVersionsByAssetId( assetId, includeFakeImportStateVersion )

	return WFModelsUtils.createModelForFunction( self._wfCatalogStream, 
			WFCatVersions.getAutoVersionsStreamForAsset, assetId, includeFakeImportStateVersion )

end

--------------------------------------------------------------------------------

function LrmLibraryVersionsModelImp:renameVersion( versionId, versionName )

	return WFModelsUtils.createModelForFunction( self._wfCatalogStream, 
			WFCatVersions.renameVersion, versionId, versionName )

end

--------------------------------------------------------------------------------

function LrmLibraryVersionsModelImp:getVersionsAnalytics()

	return WFModelsUtils.createModelForFunction( self._wfCatalogStream, 
			WFCatVersions.getVersionsAnalytics )

end

--------------------------------------------------------------------------------

function LrmLibraryVersionsModelImp:deleteVersion( versionId )

	return WFModelsUtils.createModelForFunction( self._wfCatalogStream, 
			WFCatVersions.deleteVersion, versionId )

end

--------------------------------------------------------------------------------

function LrmLibraryVersionsModelImp:deleteAllVersionsForAsset( assetId )

	return WFModelsUtils.createModelForFunction( self._wfCatalogStream, 
			WFCatVersions.deleteAllVersionsForAsset, assetId )

end

--------------------------------------------------------------------------------

function LrmLibraryVersionsModelImp:deleteManualVersionsForAsset( assetId )

	return WFModelsUtils.createModelForFunction( self._wfCatalogStream, 
			WFCatVersions.deleteManualVersionsForAsset, assetId )

end

--------------------------------------------------------------------------------

function LrmLibraryVersionsModelImp:deleteAutoVersionsForAsset( assetId )

	return WFModelsUtils.createModelForFunction( self._wfCatalogStream, 
			WFCatVersions.deleteAutoVersionsForAsset, assetId )

end

--------------------------------------------------------------------------------

function LrmLibraryVersionsModelImp:compareCurrentSettings( docId, developSettings )

	return WFModelsUtils.createModelForFunction( self._wfCatalogStream, 
			WFCatVersions.compareCurrentSettings, docId, developSettings )

end

--------------------------------------------------------------------------------

function LrmLibraryVersionsModelImp:downloadExternalizedXmpForVersion( versionId )

	return getExternalXmpDevelopModel( self.catalog, versionId )

end

--------------------------------------------------------------------------------

function LrmLibraryVersionsModelImp:maybeDeleteTempAutoVersion( assetId, withinSeconds )

	return WFModelsUtils.createModelForFunction( self._wfCatalogStream, 
			WFCatVersions.maybeDeleteTempAutoVersion, assetId, withinSeconds )

end

--------------------------------------------------------------------------------

function LrmLibraryVersionsModelImp:getAutoVersionCountForAsset( assetId )

	return WFModelsUtils.createModelForFunction( self._wfCatalogStream, 
			WFCatVersions.getAutoVersionCountForAsset, assetId )

end

--------------------------------------------------------------------------------

return LrmLibraryVersionsModelImp
