package me.qwq.doghouse.flexmark.ext.plantuml;

import org.jetbrains.annotations.NotNull;

import com.vladsch.flexmark.html.HtmlRenderer;
import com.vladsch.flexmark.html.HtmlRenderer.Builder;
import com.vladsch.flexmark.parser.Parser;
import com.vladsch.flexmark.util.data.DataKey;
import com.vladsch.flexmark.util.data.MutableDataHolder;

public class PlantUMLExtension implements Parser.ParserExtension
, HtmlRenderer.HtmlRendererExtension{
    
    final private static String DEFAULT_PLANTUML_LANGUAGE = "plantuml";
    
    final public static DataKey<String> PLANTUML_LANGUAGE = new DataKey<>("MERMAID_LANGUAGE", DEFAULT_PLANTUML_LANGUAGE);
    final public static DataKey<String> BLOCK_PLANTUML_CLASS = new DataKey<>("BLOCK_PLANTUML_CLASS", "plantuml");
    final public static DataKey<Boolean> RENDER_BLOCK_PLANTUML = new DataKey<>("RENDER_BLOCK_PLANTUML", true);
    final public static DataKey<Boolean> DARK_MODE = new DataKey<>("DARK_MODE", false);
    final public static DataKey<Boolean> BOTH_MODES = new DataKey<>("BOTH_MODES", false);
    final public static DataKey<String> DARK_MODE_CLASS = new DataKey<>("DARK_MODE_CLASS", "dark");
    final public static DataKey<Boolean> IMG_REFERRER_POLICY_SAME_ORIGIN = new DataKey<>("IMG_REFERRER_POLICY_SAME_ORIGIN", true);
    
    private PlantUMLExtension() {
    }
    
    public static PlantUMLExtension create() {
        return new PlantUMLExtension();
    }

    @Override
    public void rendererOptions(@NotNull MutableDataHolder options) {
    }

    @Override
    public void extend(@NotNull Builder htmlRendererBuilder,
            @NotNull String rendererType) {
        if (htmlRendererBuilder.isRendererType("HTML")) {
            htmlRendererBuilder.nodeRendererFactory(new PlantUMLNodeRenderer.Factory());
        } else {
            //rendererBuilder.nodeRendererFactory(new GitLabJiraRenderer.Factory());
        }
        
    }

    @Override
    public void parserOptions(MutableDataHolder options) {
        
    }

    @Override
    public void extend(com.vladsch.flexmark.parser.Parser.Builder parserBuilder) {
    }

}
