using PowderCoating.Application.DTOs.Company;
namespace PowderCoating.Application.Interfaces;
///
/// Manages the community formula library: sharing, unsharing, importing, and browsing.
///
public interface IFormulaLibraryService
{
///
/// Returns all published library entries, with AlreadyImported populated for the given company.
/// Optionally filters by search term, output mode, or industry hint.
///
Task> BrowseAsync(
int companyId,
string? search = null,
string? outputMode = null,
string? industryHint = null);
/// Full detail for the import preview modal, including field list and formula.
Task GetDetailAsync(int libraryItemId, int companyId);
///
/// Publishes a company template to the community library.
/// If the template was previously shared and unpublished, re-publishes the existing row.
/// Updates the library entry fields from the current template state on re-share.
///
Task ShareAsync(int companyId, string userId, ShareFormulaRequest request);
/// Sets IsPublished = false. Existing imports are unaffected.
Task UnshareAsync(int libraryItemId, int companyId);
///
/// Copies a library entry into the company's local CustomItemTemplate table.
/// If the company already has an import record for this entry, returns the existing template id.
///
Task ImportAsync(int libraryItemId, int companyId, string userId);
///
/// Returns the library status for a given CustomItemTemplate — whether it is shared,
/// eligible to be shared, and where it was imported from if applicable.
///
Task GetTemplateLibraryStatusAsync(int templateId, int companyId);
///
/// Nulls out DiagramImagePath on the FormulaLibraryItem and all imported copies
/// when a source template's diagram is removed. Call from CompanySettingsController
/// when a diagram is deleted or replaced.
///
Task CascadeRemoveDiagramAsync(int sourceCustomItemTemplateId);
///
/// Records or toggles a thumbs-up/down vote from the given company.
/// If the same vote already exists it is removed (toggle off).
/// If the opposite vote exists it is replaced.
/// Companies cannot rate their own formulas.
/// Returns the updated counts for the library entry.
///
Task<(int ThumbsUp, int ThumbsDown, bool? MyVote)> RateAsync(
int libraryItemId, int companyId, bool isPositive);
}