/*
 * SDK Pullenti Unitext, version 4.33, fabruary 2026. Copyright (c) 2013-2026, Pullenti. All rights reserved. 
 * Non-Commercial Freeware and Commercial Software. 
 * This class is generated using the converter Unisharping (www.unisharping.ru) from Pullenti C# project. 
 * The latest version of the code is available on the site www.pullenti.ru
 */

package com.pullenti.unitext.internal.uni;

public class CorrFootnoteTag {

    public CorrFootnoteTyps typ = CorrFootnoteTyps.DIGIT;

    public int number;

    public static CorrFootnoteTag tryParse(String text, com.pullenti.unisharp.Outargwrapper<Integer> i, boolean forContaiter, boolean robust) {
        for (; i.value < text.length(); i.value++) {
            if (!com.pullenti.unisharp.Utils.isWhitespace(text.charAt(i.value))) 
                break;
        }
        if (i.value >= text.length()) 
            return null;
        if (text.charAt(i.value) != '<') {
            if (robust && text.charAt(i.value) == '*') {
                CorrFootnoteTag res1 = _new333(CorrFootnoteTyps.STARS);
                for (; i.value < text.length(); i.value++) {
                    if (text.charAt(i.value) != '*') {
                        i.value--;
                        break;
                    }
                    else 
                        res1.number++;
                }
                return res1;
            }
            if (((((i.value + 10) < text.length()) && text.charAt(i.value) == 'С' && text.charAt(i.value + 1) == 'н') && text.charAt(i.value + 2) == 'о' && text.charAt(i.value + 3) == 'с') && text.charAt(i.value + 4) == 'к' && text.charAt(i.value + 5) == 'а') {
                int j;
                int num = 0;
                for (j = i.value + 7; j < text.length(); j++) {
                    if (text.charAt(j) == ':' && num > 0) {
                        CorrFootnoteTag res1 = _new334(CorrFootnoteTyps.DIGIT, num);
                        i.value = j;
                        return res1;
                    }
                    else if (Character.isDigit(text.charAt(j))) 
                        num = (num * 10) + ((((int)text.charAt(j)) - ((int)'0')));
                    else 
                        break;
                }
            }
            if (Character.isDigit(text.charAt(i.value)) && forContaiter) {
                int j;
                int num = 0;
                for (j = i.value; j < text.length(); j++) {
                    if (Character.isDigit(text.charAt(j))) 
                        num = (num * 10) + ((((int)text.charAt(j)) - ((int)'0')));
                    else if (text.charAt(j) == ')') {
                        CorrFootnoteTag res1 = _new334(CorrFootnoteTyps.VERYDOUBT, num);
                        i.value = j;
                        return res1;
                    }
                    else 
                        break;
                }
            }
            return null;
        }
        if ((i.value + 2) >= text.length()) 
            return null;
        int ii = i.value + 1;
        if (text.charAt(ii) != '*' && !Character.isDigit(text.charAt(ii))) 
            return null;
        CorrFootnoteTag res = _new333((text.charAt(ii) == '*' ? CorrFootnoteTyps.STARS : CorrFootnoteTyps.DIGIT));
        for (; ii < text.length(); ii++) {
            if (text.charAt(ii) == '*' && res.typ == CorrFootnoteTyps.STARS) 
                res.number++;
            else if (Character.isDigit(text.charAt(ii)) && res.typ == CorrFootnoteTyps.DIGIT) 
                res.number = (res.number * 10) + ((((int)text.charAt(ii)) - ((int)'0')));
            else if (text.charAt(ii) == '>') {
                i.value = ii;
                return res;
            }
            else 
                break;
        }
        return null;
    }

    public static CorrFootnoteTag _new311(int _arg1, CorrFootnoteTyps _arg2) {
        CorrFootnoteTag res = new CorrFootnoteTag();
        res.number = _arg1;
        res.typ = _arg2;
        return res;
    }

    public static CorrFootnoteTag _new333(CorrFootnoteTyps _arg1) {
        CorrFootnoteTag res = new CorrFootnoteTag();
        res.typ = _arg1;
        return res;
    }

    public static CorrFootnoteTag _new334(CorrFootnoteTyps _arg1, int _arg2) {
        CorrFootnoteTag res = new CorrFootnoteTag();
        res.typ = _arg1;
        res.number = _arg2;
        return res;
    }
    public CorrFootnoteTag() {
    }
}
