Z26645

{
    "Z1K1": "Z2",
    "Z2K1": {
        "Z1K1": "Z6",
        "Z6K1": "Z26645"
    },
    "Z2K2": {
        "Z1K1": "Z14",
        "Z14K1": "Z26643",
        "Z14K3": {
            "Z1K1": "Z16",
            "Z16K1": "Z600",
            "Z16K2": "function Z26643( Z26643K1 ) {\r\n\tvar input = Z26643K1;\r\n\tconst prefOptions = [\"dmye\", \"dmey\", \"mdye\", \"mdey\", \"yemd\", \"eymd\", \"yedm\", \"eydm\"];\r\n\tconst separators=[\" \",\"\\t\",\"/\",\"\\\\\",\"'\",'\"',\"|\", \"।\", \",\", \".\"];\r\n\r\n\tfunction languageSpecificOptions(){\r\n\t\tdefineLiterals({\r\n\t\t\t\"জানুয়ারি\": 0n, \"জানুয়ারী\": 0n,\r\n\t\t\t\"ফেব্রুয়ারি\": 1n, \"ফেব্রুয়ারী\": 1n,\r\n\t\t\t\"মার্চ\": 2n,\r\n\t\t\t\"এপ্রিল\": 3n,\r\n\t\t\t\"মে\": 4n,\r\n\t\t\t\"জুন\": 5n,\r\n\t\t\t\"জুলাই\": 6n,\r\n\t\t\t\"আগস্ট\": 7n,\r\n\t\t\t\"সেপ্টেম্বর\": 8n,\r\n\t\t\t\"অক্টোবর\": 9n,\r\n\t\t\t\"নভেম্বর\": 10n,\r\n\t\t\t\"ডিসেম্বর\": 11n\r\n\t\t}, MONTH, LENIENT);\r\n\r\n\t\tdefineLiterals({\r\n\t\t\t\"খ্রিস্টাব্দ\": 1n, \"খ্রিঃ\": 1n, \"সাল\": 1n, \"খ্রি\": 1n,\r\n\t\t\t\"খ্রিস্টপূর্ব\": -1n, \"খ্রিঃপূঃ\": -1n\r\n\t\t}, ERA, LENIENT);\r\n\r\n\t\tdefineConstraint([\"শে\", \"লা\", \"রা\", \"ঠা\"], DAY, BEFORE);\r\n\t}\r\n\r\n\tconst DAY = 0;\r\n\tconst MONTH = 1;\r\n\tconst YEAR = 2;\r\n\tconst ERA = 3;\r\n\r\n\tconst BEFORE = 10;\r\n\tconst AFTER = 20;\r\n\r\n\tconst LENIENT = true;\r\n\r\n\tvar _day, _month, _year, _era, _nSteps, _forced, _isToBeIgnored;\r\n\r\n\tfunction defineLiterals(literals, meaning, compMode = LENIENT, forced = false){\r\n\t\tlet bestGuess = null;\r\n\t\tconst compFunc = compMode == LENIENT ? lenientComp : lessLenientComp;\r\n\t\tfor (let m in literals){\r\n\t\t\tlet target = m.split(\" \");\r\n\t\t\tlet ok = true;\r\n\t\t\tfor (let t = 0; t \u003C target.length; ++t){\r\n\t\t\t\tif (elements[iAtt+t] == undefined || !compFunc(elements[iAtt+t], target[t])){\r\n\t\t\t\t\tok = false;\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tif (ok){\r\n\t\t\t\tif (bestGuess == null || bestGuess[1] \u003C target.length){\r\n\t\t\t\t\tbestGuess = [literals[m], target.length];\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\tif (bestGuess == null) return false;\r\n\r\n\t\tif (typeof(meaning) == \"number\") meaning = [meaning];\r\n\t\tfor (let m of meaning){\r\n\t\t\tswitch(m){\r\n\t\t\t\tcase DAY: _day = bestGuess[0]; break;\r\n\t\t\t\tcase MONTH: _month = bestGuess[0]; break;\r\n\t\t\t\tcase YEAR: _year = bestGuess[0]; break;\r\n\t\t\t\tcase ERA: _era = bestGuess[0]; break;\r\n\t\t\t}\r\n\t\t}\r\n\t\t_nSteps = bestGuess[1];\r\n\t\tif (forced) _forced = meaning;\r\n\t\treturn true;\r\n\t}\r\n\r\n\tfunction defineConstraint(literals, meaning, position){\r\n\t\tlet bestGuess = null;\r\n\t\tfor (let m of literals){\r\n\t\t\tlet target = m.split(\" \");\r\n\t\t\tlet ok = true;\r\n\t\t\tfor (let t = 0; t \u003C target.length; ++t){\r\n\t\t\t\tif (elements[iAtt+t] == undefined || !lessLenientComp(elements[iAtt+t], target[t])){\r\n\t\t\t\t\tok = false;\r\n\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tif (ok){\r\n\t\t\t\tif (bestGuess == null || bestGuess \u003C target.length){\r\n\t\t\t\t\tbestGuess = target.length;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t\tif (bestGuess == null) return false;\r\n\r\n\t\tif (typeof(meaning) == \"number\") meaning = [meaning];\r\n\t\t_constraintsList.push({pos:possibilities.length, meaning:meaning, type: position});\r\n\t\t_nSteps = bestGuess;\r\n\t\t_isToBeIgnored = true;\r\n\t\treturn true;\r\n\t}\r\n\r\n\tfunction lenientComp(a,b){\r\n\t\ta = a.toLowerCase().replace(/,|\\.|;|:/g,\"\");\r\n\t\tb = b.toLowerCase();\r\n\t\tif (a == \"\") return false;\r\n\t\treturn b.startsWith(a);\r\n\t}\r\n\r\n\tfunction lessLenientComp(a,b){\r\n\t\ta = a.toLowerCase().replace(/,|\\.|;|:/g,\"\");\r\n\t\tb = b.toLowerCase();\r\n\t\tif (a == \"\") return false;\r\n\t\treturn a == b;\r\n\t}\r\n\r\n\tfunction extractNumber(str) {\r\n\t\tconst bengaliToArabic = {'০':'0', '১':'1', '২':'2', '৩':'3', '৪':'4', '৫':'5', '৬':'6', '৭':'7', '৮':'8', '৯':'9'};\r\n\t\tconst bengaliNumWords = {\r\n\t\t\t\"এক\": 1, \"দুই\": 2, \"তিন\": 3, \"চার\": 4, \"পাঁচ\": 5, \"ছয়\": 6, \"সাত\": 7,\r\n\t\t\t\"আট\": 8, \"নয়\": 9, \"দশ\": 10, \"এগার\": 11, \"বার\": 12, \"তের\": 13,\r\n\t\t\t\"চৌদ্দ\": 14, \"পনের\": 15, \"ষোল\": 16, \"সতের\": 17, \"আঠার\": 18, \"উনিশ\": 19,\r\n\t\t\t\"বিশ\": 20, \"একুশ\": 21, \"বাইশ\": 22, \"তেইশ\": 23, \"চব্বিশ\": 24, \"পঁচিশ\": 25,\r\n\t\t\t\"ছাব্বিশ\": 26, \"সাতাশ\": 27, \"আঠাশ\": 28, \"ঊনত্রিশ\": 29, \"ত্রিশ\": 30, \"একত্রিশ\": 31\r\n\t\t};\r\n\r\n\t\tif (bengaliNumWords[str]) {\r\n\t\t\treturn BigInt(bengaliNumWords[str]);\r\n\t\t}\r\n\r\n\t\tstr = str.replace(/[০-৯]/g, (match) =\u003E bengaliToArabic[match]);\r\n\t\tlet res = /-?[0-9]+/.exec(str);\r\n\t\tif (res != null) {\r\n\t\t\treturn BigInt(res);\r\n\t\t}\r\n\t\treturn null;\r\n\t}\r\n\r\n\tfunction forceToYear(s){\r\n\t\tlet res=(/-?\\+?[০-৯0-9]+/.exec(s))?.[0];\r\n\t\tif (res == null) return false;\r\n\t\tif (res.length \u003E 4) return true;\r\n\t\tif (res.length \u003E 2 \u0026\u0026 res \u003E 31) return true;\r\n\t\tif (res[0] == \"-\" || res[0] == \"+\") return true;\r\n\t\treturn false;\r\n\t}\r\n\r\n\tinput = input.replace(/-|—|‒|–|—|⸺|⸺/g, \"-\");\r\n\r\n\tvar elements = [\"\"];\r\n\tfor (let i = 0; i \u003C input.length;){\r\n\t\tlet s = separators.find((v) =\u003E input.substring(i, i+v.length) == v);\r\n\t\tif (s !== undefined){\r\n\t\t\tif(elements[elements.length-1] != \"\") elements.push(\"\");\r\n\t\t\ti += s.length;\r\n\t\t\tcontinue;\r\n\t\t}\r\n\t\telements[elements.length-1] += input[i++];\r\n\t}\r\n\tif(elements[elements.length-1] == \"\") elements.pop();\r\n\r\n\tlet elSeparato = [];\r\n\tfor (let i = 0; i \u003C elements.length; ++i){\r\n\t\tfor (let e of elements[i].matchAll(/((?:(?\u003C=^|\\s)[\\-\\+])?[০-৯0-9]+)?(?:-?([^০-৯0-9\\-]+))?/g)){\r\n\t\t\telSeparato.push(e.splice(1))\r\n\t\t}\r\n\t}\r\n\telSeparato = elSeparato.flat();\r\n\telements = elSeparato.filter((v) =\u003E (v != null \u0026\u0026 v != \"\"));\r\n\r\n\tvar possibilities = [];\r\n\tvar _constraintsList = [];\r\n\r\n\tfor(var iAtt = 0; iAtt \u003C elements.length; iAtt += _nSteps){\r\n\t\t_nSteps = 1;\r\n\t\tlet n = extractNumber(elements[iAtt]);\r\n\t\t_day = null; _month = null; _year = null; _era = null;\r\n\t\t_forced = null; _isToBeIgnored = false;\r\n\r\n\t\tlanguageSpecificOptions();\r\n\r\n\t\tlet p = [];\r\n\t\tp.push(_day ?? ((n != null \u0026\u0026 n \u003E 0n \u0026\u0026 n \u003C= 31n) ? n : null));\r\n\t\tp.push(_month ?? ((n != null \u0026\u0026 n \u003E 0n \u0026\u0026 n \u003C= 12n) ? n-1n :null));\r\n\t\tp.push(_year ?? n);\r\n\t\tp.push(_era);\r\n\r\n\t\tif (_forced != null){\r\n\t\t\tfor (let j = 0; j \u003C= 3; ++j){\r\n\t\t\t\tif (_forced.find((v) =\u003E (v == j)) == undefined) p[j] = null;\t\r\n\t\t\t}\r\n\t\t} else if (forceToYear(elements[iAtt])){\r\n\t\t\tp[0] = null;\r\n\t\t\tp[1] = null;\r\n\t\t}\r\n\r\n\t\tif (!_isToBeIgnored) possibilities.push(p);\r\n\t}\r\n\r\n\tif (_constraintsList.length \u003E 0){\r\n\t\tfor (let pAtt = 0; pAtt \u003C possibilities.length; ++pAtt){\r\n\t\t\tfor (let c of _constraintsList){\r\n\t\t\t\tif ((c.type == AFTER \u0026\u0026 pAtt != c.pos) || (c.type == BEFORE \u0026\u0026 pAtt != c.pos - 1)){\r\n\t\t\t\t\tfor(let m of c.meaning){\r\n\t\t\t\t\t\tpossibilities[pAtt][m] = null;\t\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\tpossibilities = possibilities.filter((v) =\u003E (v[0] != null || v[1] != null || v[2] != null || v[3] != null));\r\n\r\n\tfor (let i = 0; i \u003C prefOptions.length; ++i){\r\n\t\tlet actPref = prefOptions[i];\r\n\t\tlet d, m;\r\n\t\t\r\n\t\tlet pMap = {};\r\n\t\tlet pIndex = 0;\r\n\t\tfor (const char of actPref) {\r\n\t\t\tif (pIndex \u003C possibilities.length) {\r\n\t\t\t\tpMap[char] = pIndex++;\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\td = possibilities[pMap[\"d\"]]?.[DAY];\r\n\t\tm = possibilities[pMap[\"m\"]]?.[MONTH];\r\n\r\n\t\tif (d != null \u0026\u0026 m != null){\r\n\t\t\t\r\n\t\t\tif (d \u003E 0 \u0026\u0026 d \u003C= 31 \u0026\u0026 m \u003E= 0 \u0026\u0026 m \u003C 12) {\r\n\t\t\t\treturn {\r\n\t\t\t\t\tK1: Number(m), \r\n\t\t\t\t\tK2: Number(d)    \r\n\t\t\t\t};\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n\treturn null;\r\n}"
        }
    },
    "Z2K3": {
        "Z1K1": "Z12",
        "Z12K1": [
            "Z11",
            {
                "Z1K1": "Z11",
                "Z11K1": "Z1002",
                "Z11K2": "read Day of roman year, Bangla (JS)"
            }
        ]
    },
    "Z2K4": {
        "Z1K1": "Z32",
        "Z32K1": [
            "Z31"
        ]
    },
    "Z2K5": {
        "Z1K1": "Z12",
        "Z12K1": [
            "Z11"
        ]
    }
}