package com.heyu.api.baidu.response.convert;


import com.fasterxml.jackson.annotation.JsonProperty;
import com.heyu.api.baidu.response.BBaseResp;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

/***
 * https://console.bce.baidu.com/support/?_=1740703582749&timestamp=1740704125877#/api?product=AI&project=%E6%96%87%E5%AD%97%E8%AF%86%E5%88%AB&parent=%E6%99%BA%E8%83%BD%E6%96%87%E6%A1%A3%E5%88%86%E6%9E%90&api=rest%2F2.0%2Fbrain%2Fonline%2Fv2%2Fparser%2Ftask&method=post
 *
 * 文档解析-获取结果
 */
@NoArgsConstructor
@Data
public class BParserTextQueryResp extends BBaseResp {


    @JsonProperty("file_name")
    private String fileName;
    @JsonProperty("file_id")
    private String fileId;
    @JsonProperty("pages")
    private List<PagesDTO> pages;
    @JsonProperty("chunks")
    private List<ChunksDTO> chunks;

    @NoArgsConstructor
    @Data
    public static class PagesDTO {
        @JsonProperty("page_id")
        private String pageId;
        @JsonProperty("page_num")
        private Integer pageNum;
        @JsonProperty("text")
        private String text;
        @JsonProperty("layouts")
        private List<LayoutsDTO> layouts;
        @JsonProperty("tables")
        private List<TablesDTO> tables;
        @JsonProperty("images")
        private List<?> images;
        @JsonProperty("meta")
        private MetaDTO meta;

        @NoArgsConstructor
        @Data
        public static class MetaDTO {
            @JsonProperty("page_width")
            private Integer pageWidth;
            @JsonProperty("page_height")
            private Integer pageHeight;
            @JsonProperty("is_scan")
            private Boolean isScan;
            @JsonProperty("page_angle")
            private Integer pageAngle;
            @JsonProperty("page_type")
            private String pageType;
            @JsonProperty("sheet_name")
            private String sheetName;
        }

        @NoArgsConstructor
        @Data
        public static class LayoutsDTO {
            @JsonProperty("layout_id")
            private String layoutId;
            @JsonProperty("text")
            private String text;
            @JsonProperty("position")
            private List<Integer> position;
            @JsonProperty("type")
            private String type;
            @JsonProperty("sub_type")
            private String subType;
            @JsonProperty("parent")
            private String parent;
            @JsonProperty("children")
            private List<String> children;
        }

        @NoArgsConstructor
        @Data
        public static class TablesDTO {
            @JsonProperty("layout_id")
            private String layoutId;
            @JsonProperty("markdown")
            private String markdown;
            @JsonProperty("position")
            private List<Integer> position;
            @JsonProperty("cells")
            private List<CellsDTO> cells;
            @JsonProperty("matrix")
            private List<List<Integer>> matrix;
            @JsonProperty("merge_table")
            private String mergeTable;

            @NoArgsConstructor
            @Data
            public static class CellsDTO {
                @JsonProperty("layout_id")
                private String layoutId;
                @JsonProperty("text")
                private String text;
                @JsonProperty("position")
                private List<Integer> position;
                @JsonProperty("type")
                private String type;
                @JsonProperty("sub_type")
                private String subType;
                @JsonProperty("parent")
                private String parent;
                @JsonProperty("children")
                private Object children;
            }
        }
    }

    @NoArgsConstructor
    @Data
    public static class ChunksDTO {
        @JsonProperty("chunk_id")
        private String chunkId;
        @JsonProperty("content")
        private String content;
        @JsonProperty("type")
        private String type;
        @JsonProperty("meta")
        private MetaDTO meta;

        @NoArgsConstructor
        @Data
        public static class MetaDTO {
            @JsonProperty("title")
            private List<String> title;
            @JsonProperty("position")
            private List<PositionDTO> position;

            @NoArgsConstructor
            @Data
            public static class PositionDTO {
                @JsonProperty("box")
                private List<Integer> box;
                @JsonProperty("page_num")
                private Integer pageNum;
            }
        }
    }
}