/**
 * Tool for submitting content to GitHub portfolio repositories
 * Replaces the broken issue-based submission with direct repository saves
 *
 * FIXES IMPLEMENTED (PR #503):
 * 1. TYPE SAFETY FIX #1 (Issue #497): Changed apiCache from 'any' to proper APICache type
 * 2. TYPE SAFETY FIX #2 (Issue #497): Replaced complex type casting with PortfolioElementAdapter
 * 3. PERFORMANCE (PR #496 recommendation): Using FileDiscoveryUtil for optimized file search
 */
import { GitHubAuthManager } from '../../auth/GitHubAuthManager.js';
import { PortfolioRepoManager } from '../../portfolio/PortfolioRepoManager.js';
import { TokenManager } from '../../security/tokenManager.js';
import { PortfolioManager } from '../../portfolio/PortfolioManager.js';
import { PortfolioIndexManager } from '../../portfolio/PortfolioIndexManager.js';
import { ElementType } from '../../portfolio/types.js';
import { APICache } from '../../cache/APICache.js';
import { PortfolioElement, SubmitToPortfolioParams, SubmitToPortfolioResult } from './types.js';
export type { PortfolioElement, SubmitToPortfolioParams, SubmitToPortfolioResult };
import { IRateLimiter } from '../../utils/GitHubRateLimiter.js';
import { IFileOperationsService } from '../../services/FileOperationsService.js';
export interface ElementDetectionMatch {
    type: ElementType;
    path: string;
}
export interface ElementDetectionResult {
    found: boolean;
    matches: ElementDetectionMatch[];
}
export interface SubmitToPortfolioToolDependencies {
    authManager: GitHubAuthManager;
    portfolioRepoManager: PortfolioRepoManager;
    portfolioManager: PortfolioManager;
    portfolioIndexManager: PortfolioIndexManager;
    rateLimiter: IRateLimiter;
    fileOperations: IFileOperationsService;
    tokenManager: TokenManager;
}
export declare class SubmitToPortfolioTool {
    private authManager;
    private portfolioRepoManager;
    private portfolioManager;
    private portfolioIndexManager;
    private rateLimiter;
    private fileOperations;
    private tokenManager;
    constructor(apiCache: APICache, dependencies: SubmitToPortfolioToolDependencies);
    /**
     * Validates and normalizes input parameters to prevent Unicode attacks and ensure data safety
     * @param params The input parameters from the user
     * @returns Validation result with normalized name or error response
     */
    private validateAndNormalizeParams;
    /**
     * Checks if the user is authenticated with GitHub
     * @returns Authentication check result with status or error response
     */
    private checkAuthentication;
    /**
     * Discovers content locally with smart type detection
     * @param safeName The normalized name to search for
     * @param explicitType Optional explicit element type provided by user
     * @param originalName Original user-provided name for error messages
     * @returns Content discovery result with element type and path or error response
     */
    private discoverContentWithTypeDetection;
    /**
     * Validates file size and content security before processing
     * @param localPath Path to the local file to validate
     * @returns Validation result with content or error response
     */
    private validateFileAndContent;
    /**
     * Prepares metadata for the portfolio element
     * @param safeName The normalized name of the element
     * @param elementType The type of the element
     * @param authStatus Authentication status containing username
     * @returns Metadata object for the element
     */
    private prepareElementMetadata;
    /**
     * Formats metadata as YAML string for display
     * PERFORMANCE: Uses array join instead of string concatenation for better performance
     */
    private formatMetadataAsYaml;
    /**
     * Extracts metadata from an element file
     * Parses YAML frontmatter to get the actual metadata
     * SECURITY: Uses SecureYamlParser instead of yaml.load to prevent code execution (DMCP-SEC-005)
     * @param filePath Path to the element file
     * @returns Extracted metadata or null if parsing fails
     */
    private extractElementMetadata;
    /**
     * Validates GitHub token and checks for expiration before usage
     * SECURITY ENHANCEMENT (Task #5): Token expiration validation to prevent stale token usage
     * @param token The GitHub token to validate
     * @returns Validation result with status and expiration info
     */
    private validateTokenBeforeUsage;
    /**
     * Enhanced path validation for portfolio operations with comprehensive security checks
     * SECURITY ENHANCEMENT (Task #7): Additional validation for special characters and malicious patterns
     * @param filePath The file path to validate
     * @returns Validation result with secure path or error response
     */
    private validatePortfolioPath;
    /**
     * Smart token management for long operations with refresh-like capabilities
     * SECURITY ENHANCEMENT (Task #14): Token refresh logic for long operations
     *
     * Note: GitHub OAuth device flow tokens don't have traditional refresh tokens,
     * but we can implement smart validation and guidance for long operations
     *
     * @param operationType Type of operation being performed
     * @returns Token management result with recommendations
     */
    private manageTokenForLongOperation;
    /**
     * Provides user guidance for token refresh when operations fail due to token issues
     * SECURITY ENHANCEMENT (Task #14): User guidance for authentication refresh
     */
    private formatTokenRefreshGuidance;
    /**
     * Sets up GitHub repository access and ensures portfolio repository exists
     * @param authStatus Authentication status containing username
     * @returns Setup result or error response
     */
    private setupGitHubRepository;
    /**
     * Check if content already exists in the portfolio repository
     * Prevents duplicate uploads by comparing content hashes
     * @param repoFullName GitHub repository full name (owner/repo)
     * @param filePath Path to the file in the repository
     * @param content Content to check against existing
     * @returns true if identical content exists, false otherwise
     */
    private checkExistingContent;
    /**
     * Check if an issue for this content already exists in the collection
     * @param elementName Name of the element to check
     * @param username User submitting the element
     * @param token GitHub token for API access
     * @returns URL of existing issue if found, null otherwise
     */
    private checkExistingIssue;
    /**
     * Submits element to portfolio and handles the complete response workflow
     * @param safeName The normalized name of the element
     * @param elementType The type of the element
     * @param metadata The metadata for the element
     * @param content The content of the element
     * @param authStatus Authentication status containing username and token
     * @returns Complete submission result with success message or error
     */
    private submitElementAndHandleResponse;
    execute(params: SubmitToPortfolioParams): Promise<SubmitToPortfolioResult>;
    /**
     * Prompts user to submit content to the DollhouseMCP collection
     * ENHANCEMENT (Issue #549): Complete the community contribution workflow
     */
    private promptForCollectionSubmission;
    /**
     * Creates an issue in the DollhouseMCP/collection repository
     * ENHANCEMENT (Issue #549): GitHub API integration for collection submission
     */
    private createCollectionIssue;
    private findLocalContent;
    /**
     * Smart element type detection - searches across ALL element types for content
     * PERFORMANCE OPTIMIZATION (Task #9): Uses early termination for exact matches
     * This replaces the previous hardcoded default to PERSONA and enables proper type detection
     *
     * @param name The content name to search for
     * @returns Detection result with found matches across all element types
     */
    private detectElementType;
    /**
     * UX IMPROVEMENT: Generate name suggestions for similar content
     * PERFORMANCE OPTIMIZATION (Task #8): Enhanced batch operation handling with clear partial failure reporting
     * Helps users find content when exact matches fail
     */
    private generateNameSuggestions;
    /**
     * Simple similarity calculation using Levenshtein-like approach
     * Returns value between 0 and 1, where 1 is identical
     */
    private calculateSimilarity;
    /**
     * UX IMPROVEMENT: Save element with automatic retry logic for transient failures
     * Handles common GitHub API issues like rate limits and temporary network problems
     */
    private saveElementWithRetry;
    /**
     * Determine if an error is worth retrying
     * Retryable: network issues, rate limits, temporary GitHub API problems
     * Non-retryable: authentication issues, validation errors, permanent failures
     */
    private isRetryableError;
}
//# sourceMappingURL=submitToPortfolioTool.d.ts.map