/*
 * ImageToolbox is an image editor for android
 * Copyright (c) 2026 T8RIN (Malik Mukhametzyanov)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * You should have received a copy of the Apache License
 * along with this program.  If not, see <http://www.apache.org/licenses/LICENSE-2.0>.
 */

package com.t8rin.imagetoolbox.feature.pdf_tools.domain

import com.t8rin.imagetoolbox.feature.pdf_tools.domain.model.ExtractPagesAction
import com.t8rin.imagetoolbox.feature.pdf_tools.domain.model.PdfCreationParams
import com.t8rin.imagetoolbox.feature.pdf_tools.domain.model.PdfCropParams
import com.t8rin.imagetoolbox.feature.pdf_tools.domain.model.PdfExtractPagesParams
import com.t8rin.imagetoolbox.feature.pdf_tools.domain.model.PdfMetadata
import com.t8rin.imagetoolbox.feature.pdf_tools.domain.model.PdfPageNumbersParams
import com.t8rin.imagetoolbox.feature.pdf_tools.domain.model.PdfRemoveAnnotationParams
import com.t8rin.imagetoolbox.feature.pdf_tools.domain.model.PdfSignatureParams
import com.t8rin.imagetoolbox.feature.pdf_tools.domain.model.PdfWatermarkParams
import com.t8rin.imagetoolbox.feature.pdf_tools.domain.model.PrintPdfParams
import com.t8rin.imagetoolbox.feature.pdf_tools.domain.model.SearchablePdfPage
import kotlinx.coroutines.flow.Flow

interface PdfManager : PdfHelper {

    fun extractPages(
        uri: String,
        params: PdfExtractPagesParams
    ): Flow<ExtractPagesAction>

    suspend fun createPdf(
        imageUris: List<String>,
        params: PdfCreationParams
    ): String

    suspend fun createSearchablePdf(
        pages: List<SearchablePdfPage>,
        params: PdfCreationParams = PdfCreationParams(quality = 100)
    ): String

    suspend fun mergePdfs(
        uris: List<String>
    ): String

    suspend fun splitPdf(
        uri: String,
        pages: List<Int>?
    ): String

    suspend fun removePdfPages(
        uri: String,
        pages: List<Int>
    ): String

    suspend fun rotatePdf(
        uri: String,
        rotations: List<Int>
    ): String

    suspend fun rearrangePdf(
        uri: String,
        newOrder: List<Int>
    ): String

    suspend fun addPageNumbers(
        uri: String,
        params: PdfPageNumbersParams
    ): String

    suspend fun addWatermark(
        uri: String,
        params: PdfWatermarkParams
    ): String

    suspend fun addSignature(
        uri: String,
        params: PdfSignatureParams
    ): String

    suspend fun protectPdf(
        uri: String,
        password: String
    ): String

    suspend fun unlockPdf(
        uri: String,
        password: String
    ): String

    suspend fun extractPagesFromPdf(
        uri: String
    ): List<String>

    suspend fun compressPdf(
        uri: String,
        quality: Float
    ): String

    suspend fun convertToGrayscale(
        uri: String
    ): String

    suspend fun repairPdf(
        uri: String
    ): String

    suspend fun changePdfMetadata(
        uri: String,
        metadata: PdfMetadata?
    ): String

    suspend fun getPdfMetadata(
        uri: String
    ): PdfMetadata

    suspend fun stripText(
        uri: String
    ): List<String>

    suspend fun cropPdf(
        uri: String,
        params: PdfCropParams
    ): String

    suspend fun flattenPdf(
        uri: String,
        quality: Float
    ): String

    suspend fun detectPdfAutoRotations(
        uri: String
    ): List<Int>

    suspend fun extractImagesFromPdf(
        uri: String
    ): String?

    suspend fun convertToZip(
        uri: String,
        interval: Int
    ): String

    suspend fun printPdf(
        uri: String,
        params: PrintPdfParams
    ): String

    suspend fun removeAnnotations(
        uri: String,
        params: PdfRemoveAnnotationParams
    ): String

}