Z27990

{
    "Z1K1": "Z2",
    "Z2K1": {
        "Z1K1": "Z6",
        "Z6K1": "Z27990"
    },
    "Z2K2": {
        "Z1K1": "Z14",
        "Z14K1": "Z23990",
        "Z14K3": {
            "Z1K1": "Z16",
            "Z16K1": "Z600",
            "Z16K2": "function Z23990( Z23990K1 ) {\n\tvar input=Z23990K1;\n\tconst separators=[\" \",\"\\t\",\"/\",\"\\\\\",\"'\",'\"',\"|\"];\n\tconst prefOptions=[\n\t\t//Gregorian\n\t\t\"cmdye\",\"cmdey\",\"cyemd\",\"ceymd\",\"cdmye\",\"cdmey\",\"cyedm\",\"ceydm\",\n\t\t//Hijri\n\t\t\"cndu\",\"cund\",\"cdnu\",\"cudn\", \"cdun\"\n\t\t];\n\t\n\tfunction forceToYear(s){\n\t\tlet res=(/-?\\+?[0-9]+/.exec(s))?.[0];\n\t\tif (res==null){\n\t\t\treturn false;\n\t\t}\n\t\t//Wikifunctions.Debug(res);\n\t\tif (res.length\u003E2) return true;\n\t\tif (res[0]==\"-\" || res[0]==\"+\") return true;\n\t\treturn false;\n\t}\n\n\tfunction languageSpecificOptions(){\n\t\t\n\t\tdefineLiteralFunction(function(t,i){\n\t\t\tif (forceToYear(t[i])){\n\t\t\t\treturn [extractNumber(t[i]),1];\n\t\t\t}\n\t\t\treturn null;\n\t\t},[YEAR,HIJRI_YEAR],true);\n\t\t\n\t\t//TODO: read years in words\n\t\t\n\t\tdefineLiterals({\n\t\t\tsilimiingoli: GREGORIAN,\n\t\t\t\"silimin\": GREGORIAN,\n\t\t\t\"Dagbaŋ\": HIJRI,\n\t\t\t\"mahamadiya\": HIJRI\n\t\t},CALENDAR);\n\t\tdefineLiterals({\n\t\t\tJA:1n,\n\t\t\tFE:2n,\n\t\t\tMR:3n,\n\t\t\tAP:4n,\n\t\t\tMY:5n,\n\t\t\tJN:6n,\n\t\t\tJL:7n,\n\t\t\tAU:8n,\n\t\t\tSE:9n,\n\t\t\tOC:10n,\n\t\t\tNV:11n,\n\t\t\tDE:12n,\n\t\t\tjanuary:1n,\n\t\t\tfebruary:2n,\n\t\t\tmarch:3n,\n\t\t\tapril:4n,\n\t\t\tmay:5n,\n\t\t\tjune:6n,\n\t\t\tjuly:7n,\n\t\t\taugust:8n,\n\t\t\tseptember:9n,\n\t\t\toctober:10n,\n\t\t\tnovember:11n,\n\t\t\tdecember:12n\n\t\t},MONTH);\n\t\tdefineLiterals({\n\t\t\ti:1n,\n\t\t\tii:2n,\n\t\t\tiii:3n,\n\t\t\tiv:4n,\n\t\t\tiiii:4n,\n\t\t\tv:5n,\n\t\t\tvi:6n,\n\t\t\tvii:7n,\n\t\t\tviii:8n,\n\t\t\tviiii:9n,\n\t\t\tix:9n,\n\t\t\tx:10n,\n\t\t\txi:11n,\n\t\t\txii:12n\n\t\t},MONTH,NORMAL);\n\t\t\n\t\t//TODO: check these names\n\t\tdefineLiterals({\n\t\t\t\"Buɣum chuɣu\":1n,\n\t\t\t\"Buɣim\":1n,\n\t\t\t\"Muharram\":1n,\n\t\t\t\"Damba Bilaa\":2n,\n\t\t\t\"Safar\":2n,\n\t\t\t\"Damba\":3n,\n\t\t\t\"Rabi al Awwal\":3n,\n\t\t\t\"Gambanda\":4n,\n\t\t\t\"Rabi al Thani\":4n,\n\t\t\t\"Bandacheena\":5n,\n\t\t\t\"Jumada al Awwal\":5n,\n\t\t\t\"Kpini Bilaa\":6n,\n\t\t\t\"Jumada al Thani\":6n,\n\t\t\t\"Kpini\":7n,\n\t\t\t\"Rajab\":7n,\n\t\t\t\"Nolɔri Bilaa\":8n,\n\t\t\t\"Shaban\":8n,\n\t\t\t\"Sha ban\":8n,\n\t\t\t\"Nolɔri\":9n,\n\t\t\t\"ramadan\":9n,\n\t\t\t\"Kɔnyuri\":10n,\n\t\t\t\"Shawwal\":10n,\n\t\t\t\"Chimsi Bilaa\":11n,\n\t\t\t\"hu al Qadah\":11n,\n\t\t\t\"Chimsi\":12n,\n\t\t\t\"Dhu al Hijjah\":12n,\n\t\t},HIJRI_MONTH, NORMAL);\n\t\t\n\t\tdefineLiterals({\n\t\t\tad:1n,\n\t\t\tbc:-1n,\n\t\t\tbce:-1n,\n\t\t\tce:1n,\n\t\t},ERA,LETTER_BY_LETTER);\n\t\tdefineLiterals({\n\t\t\t\"pɔi anabi Yisa dɔɣam\":-1n,\n\t\t\t\"ti zaamani\":1n,\n\t\t\t\"Anabi Yisa kpibu nyaaga\":1n\n\t\t},ERA);\n\t\t//forced as days\n\t\tdefineLiterals({\n\t\t\tdahinyini: 1n,\n\t\t\tdabaayi: 2n,\n\t\t\tdabaata: 3n,\n\t\t\tdabaanahi: 4n,\n\t\t\tdabaanu: 5n,\n\t\t\tdabaayɔbu: 6n,\n\t\t\tdabaapɔin: 7n,\n\t\t\tdabaanii: 8n,\n\t\t\tdabaawɔi: 9n,\n\t\t},DAY,NORMAL);\n\t\t//days or years\n\t\tdefineLiterals({\n\t\t\tyini:1n,\n\t\t\tayi:2n,\n\t\t\tata:3n,\n\t\t\tanahi:4n,\n\t\t\tanu:5n,\n\t\t\tayobu:6n,\n\t\t\tapɔi:7n,\n\t\t\tanii:8n,\n\t\t\tawei:9n,\n\t\t\t\"Pia\": 10n,\n\t\t\t\"piniyini\": 11n,\n\t\t\t\"pia ni yini\": 11n,\n\t\t\t\"pinaayi\": 12n,\n\t\t\t\"pia ni ayi\": 12n,\n\t\t\t\"pin ayi\": 12n,\n\t\t\t\"pinaata\": 13n,\n\t\t\t\"pin ata\": 13n,\n\t\t\t\"pia ni ata\": 13n,\n\t\t\t\"pinaanahi\": 14n,\n\t\t\t\"pia ni anahi\": 14n,\n\t\t\t\"pin anahi\": 14n,\n\t\t\t\"pinaanu\": 15n,\n\t\t\t\"pia ni anu\": 15n,\n\t\t\t\"pin anu\": 15n,\n\t\t\t\"pinaayobu\": 16n,\n\t\t\t\"pia ni ayobu\": 16n,\n\t\t\t\"pin ayobu\": 16n,\n\t\t\t\"pinaapɔin\": 17n,\n\t\t\t\"pia ni apɔi\": 17n,\n\t\t\t\"pin apɔi\": 17n,\n\t\t\t\"pishiayika\": 18n,\n\t\t\t\"pishi ayi ka\": 18n,\n\t\t\t\"pisiyinika\": 19n,\n\t\t\t\"pishi yini ka\": 19n,\n\t\t\t\"pishi\": 20n,\n\t\t\t\"pishi ni yini\": 21n,\n\t\t\t\"pishi ni ayi\": 22n,\n\t\t\t\"pishi ni ata\": 23n,\n\t\t\t\"Pishi ni anahi\": 24n,\n\t\t\t\"Pishi ni anu\": 25n,\n\t\t\t\"Pishi ni ayobu\": 26n,\n\t\t\t\"Pishi ni apɔin\": 27n,\n\t\t\t\"Pihita ayika\": 28n,\n\t\t\t\"Pihita ayi ka\": 28n,\n\t\t\t\"Pihitayinika\": 29n,\n\t\t\t\"Pihita yini ka\": 29n,\n\t\t\t\"pihita\": 30n,\n\t\t\t\"pihita ni yini\": 31n,\n\t\t},[DAY,YEAR,HIJRI_YEAR],NORMAL);\n\t\tdefineConstraint([\"st\",\"nd\",\"rd\",\"th\"],DAY,AFTER);\t//forced after a day\n\t\tdefineConstraint([\"yuuni\"],YEAR, BEFORE_OR_AFTER);\t\t//forced before or after a year\n\t\tdefineConstraint([\"hijira yuun\"],HIJRI_YEAR, BEFORE_OR_AFTER);\n\t\tdefineConstraint([\"biɛɣu\"],DAY, BEFORE);\t\t\t//forced before a day\n\t\tdefineConstraint([\"dali\"],DAY, BEFORE_OR_AFTER);\t\t//forced before or after a day\n\t\tdefineConstraint([\"AH\",\"a h\"],HIJRI_YEAR, BEFORE_OR_AFTER);\n\t\tdefineConstraint([\"goli\"],[MONTH,HIJRI_MONTH],BEFORE_OR_AFTER);\n\t}\n\t\n\tfunction calendarFormat(o){\n\t\tif (o[CALENDAR]!=null){\n\t\t\treturn o[CALENDAR];\n\t\t}\n\t\tif (o[HIJRI_MONTH]!=null || o[HIJRI_YEAR]!=null){\n\t\t\treturn HIJRI;\n\t\t}\n\t\treturn GREGORIAN;\n\t}\n\tfunction formatOutput(o){\n\t\tif (calendarFormat(o)===HIJRI){\n\t\t\tif (o[HIJRI_MONTH]==null || o[HIJRI_YEAR]==null){\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\t\n\t\t\t//TODO: Throw error advising that Hijri calendar is not supported yet\n\t\t\t//TODO: Actually support Hijri calendar\n\t\t\tWikifunctions.Error(\"Z28153\",[input,\"dag;en-us\"]);\n\t\t}\n\t\tlet year;\n\t\tif (o[ERA]!=null){\n\t\t\tyear = o[ERA]==-1n ? -(o[YEAR]\u003C0n ? -o[YEAR] : o[YEAR])+1n : (o[YEAR]\u003C0n ? -o[YEAR] : o[YEAR]);\n\t\t} else{\n\t\t\tyear=o[YEAR];\n\t\t}\n\n\t\treturn{\n\t\t\tK3: Number(o[DAY]),\n\t\t\tK2: Number(o[MONTH])-1,\n\t\t\tK1: year\n\t\t};\n\t}\n\n\n\t//IMPORTANT: delete_chain must contain all the fields\n\tconst delete_chain=\"cnuedmy\";\n\n\t// FIELDS\n\tconst DAY='d';\n\tconst MONTH='m';\n\tconst YEAR='y';\n\tconst ERA='e';\n\tconst CALENDAR='c';\n\tconst HIJRI_YEAR='u';\n\tconst HIJRI_MONTH='n';\n\n\t// SPECIAL VALUES\n\tconst BC=-1n;\n\tconst AD=1n;\n\tconst GREGORIAN=Symbol();\n\tconst HIJRI=Symbol();\n\n\t// NUMERIC ELEMENTS SETTINGS\n\tconst numericElements=\"dmynu\";\n\tconst numericElementMin={\n\t\td:1n,\n\t\tm:1n,\n\t\tn:1n,\n\t};\n\tconst numericElementMax={\n\t\td:31n,\n\t\tm:12n,\n\t\tn:12n,\n\t};\n\n\t//END OF LANGUAGE-SPECIFIC CODE\n\t\n\t//Start of general code\n\tconst BEFORE=10;\n\tconst AFTER=20;\n\tconst BEFORE_OR_AFTER=30;\n\n\tconst LENIENT=true;\n\tconst NORMAL=false;\n\tconst LETTER_BY_LETTER=Symbol();\n\t\n\tfunction MultipleMeanings(m,e){\n\t\tfor (let i=0; i\u003Cm.length; ++i){\n\t\t\tthis[m[i]]=e[i];\n\t\t}\n\t}\n\n\tfunction defineLiterals(literals,meaning,compMode=LENIENT, forced=false){\n\t\tlet bestGuess=null;\n\t\tconst compFunc= compMode==LENIENT ? lenientComp : lessLenientComp;\n\t\tfor (let m in literals){\n\t\t\tlet target=m.split(\" \");\n\t\t\tlet ok=true;\n\t\t\tfor (let t=0; t\u003Ctarget.length; ++t){\n\t\t\t\tif (elements[iAtt+t]==undefined || !compFunc(elements[iAtt+t],target[t])){\n\t\t\t\t\tok=false;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (ok){\n\t\t\t\tif (bestGuess == null || bestGuess[1]\u003Ctarget.length){\n\t\t\t\t\tbestGuess = [literals[m],target.length];\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if (compMode==LETTER_BY_LETTER ){\n\t\t\t\tlet target=m.split(\"\");\n\t\t\t\ttarget.filter((l)=\u003El!=\" \");\n\t\t\t\tlet ok=true;\n\t\t\t\tfor (let t=0; t\u003Ctarget.length; ++t){\n\t\t\t\t\tif (elements[iAtt+t]==undefined || !compFunc(elements[iAtt+t],target[t])){\n\t\t\t\t\t\tok=false;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (ok){\n\t\t\t\t\tif (bestGuess == null || bestGuess[1]\u003Ctarget.length){\n\t\t\t\t\t\tbestGuess = [literals[m],target.length];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t}\n\t\tif (bestGuess==null){\n\t\t\treturn false;\n\t\t}\n\n\t\tif (typeof(meaning)==\"string\"){\n\t\t\tmeaning=[meaning];\n\t\t}\n\t\tfor (let m of meaning){\n\t\t\tif (m.length\u003E1){\n\t\t\t\tlet o=new MultipleMeanings(m,bestGuess[0]);\n\t\t\t\tfor (let mAtt of m){\n\t\t\t\t\t_currGuess[mAtt]=o;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse {\n\t\t\t\t_currGuess[m]=bestGuess[0];\n\t\t\t}\n\t\t}\n\t\t_nSteps=bestGuess[1];\n\t\tif (forced){\n\t\t\t_forced=meaning;\n\t\t}\n\t\treturn true;\n\n\t}\n\tfunction defineLiteralFunction(f,meaning, forced=false){\n\t\tlet bestGuess=f(elements,iAtt);\n\t\tif (bestGuess==null){\n\t\t\treturn false;\n\t\t}\n\n\t\tif (typeof(meaning)==\"string\"){\n\t\t\tmeaning=[meaning];\n\t\t}\n\t\tfor (let m of meaning){\n\t\t\tif (m.length\u003E1){\n\t\t\t\tlet o=new MultipleMeanings(m,bestGuess[0]);\n\t\t\t\tfor (let mAtt of m){\n\t\t\t\t\t_currGuess[mAtt]=o;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse {\n\t\t\t\t_currGuess[m]=bestGuess[0];\n\t\t\t}\n\t\t}\n\t\t_nSteps=bestGuess[1];\n\t\tif (forced){\n\t\t\t_forced=meaning;\n\t\t}\n\t\treturn true;\n\t}\n\tfunction defineConstraint(literals, meaning, position, compMode=NORMAL){\n\n\t\tlet bestGuess=null;\n\t\tconst compFunc= compMode==LENIENT ? lenientComp : lessLenientComp;\n\t\tfor (let m of literals){\n\t\t\tlet target=m.split(\" \");\n\t\t\tlet ok=true;\n\t\t\tfor (let t=0; t\u003Ctarget.length; ++t){\n\t\t\t\tif (elements[iAtt+t]==undefined || !compFunc(elements[iAtt+t],target[t])){\n\t\t\t\t\tok=false;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (ok){\n\t\t\t\tif (bestGuess == null || bestGuess\u003Ctarget.length){\n\t\t\t\t\tbestGuess = target.length;\n\t\t\t\t}\n\t\t\t}\n\n\t\t}\n\t\tif (bestGuess==null){\n\t\t\treturn false;\n\t\t}\n\t\t\n\n\t\tif (typeof(meaning)==\"string\"){\n\t\t\tmeaning=[meaning];\n\t\t}\n\t\t\n\t\t_constraintsList.push({pos:possibilities.length, meaning:meaning, type: position});\n\n\t\t_nSteps=bestGuess;\n\t\t_isToBeIgnored=true;\n\t\treturn true;\n\t}\n\tfunction defineConstraintFunction(f,meaning,position){\n\n\t\tlet bestGuess=f(elements,iAtt);\n\t\tif (bestGuess==null){\n\t\t\treturn false;\n\t\t}\n\n\t\tif (typeof(meaning)==\"string\"){\n\t\t\tmeaning=[meaning];\n\t\t}\n\t\t_constraintsList.push({pos:possibilities.length, meaning:meaning, type: position});\n\t\t_nSteps=bestGuess;\n\t\t_isToBeIgnored=true;\n\t\treturn true;\n\t}\n\n\tfunction lenientComp(a,b){\n\t\ta=a.toLowerCase().replaceAll(/,|\\.|;|:/g,\"\");\n\t\tb=b.toLowerCase();\n\t\tif (a==\"\") return false;\n\t\treturn a==b.substring(0,a.length);\n\t}\n\n\tfunction lessLenientComp(a,b){\n\t\ta=a.toLowerCase().replaceAll(/,|\\.|;|:/g,\"\");\n\t\tb=b.toLowerCase();\n\t\tif (a==\"\") return false;\n\t\treturn a==b;\n\t}\n\n\tfunction extractNumber(s){\n\t\tlet res=/-?[0-9]+/.exec(s);\n\t\tif (res!=null){\n\t\t\treturn BigInt(res);\n\t\t}\n\t\treturn null;\n\t}\n\n\tfunction isLeapYear(y){\n\t\treturn ((y \u0026 3n) == 0n \u0026\u0026\n\t\t\t((y % 25n) != 0n \n\t\t\t|| (y \u0026 15n) == 0n));\n\t}\n\t\n\tfunction lengthOfMonth(m,isLeap){\n\t\tif (m==1) \n\t\t\treturn isLeap ? 29 : 28;\n\t\telse \n\t\t\treturn 30+(1+m+Math.floor(m/7))%2;\n\t}\n\t\n\tfunction isValidDate(d){\n\t\tif (d==null || d.K1==undefined || d.K2==undefined || d.K3==undefined){\n\t\t\treturn false;\n\t\t}\n\t\tif (!isFinite(d.K2) || !isFinite(d.K3)){\n\t\t\treturn false;\n\t\t}\n\t\tlet isLeap=isLeapYear(d.K1);\n\t\tif (d.K2\u003C0 || d.K2\u003E11){\n\t\t\treturn false;\n\t\t}\n\t\tif (d.K3\u003C1 || d.K3\u003ElengthOfMonth(d.K2,isLeap)){\n\t\t\treturn false;\n\t\t}\n\t\treturn true;\n\t}\n\n\t\n\t/**************** START TOKENISATION ***********************/\n\n\tinput=input.replaceAll(/-|—|‒|–|—|⸺|⸺/g,\"-\");\n\n\n\tvar elements=[\"\"];\n\tfor (let i=0; i\u003Cinput.length;){\n\t\tlet s=separators.find((v)=\u003E input.substring(i,i+v.length)==v);\n\t\tif (s!==undefined){\n\t\t\tif(elements[elements.length-1]!=\"\")\n\t\t\t\telements.push(\"\");\n\t\t\ti+=s.length;\n\t\t\tcontinue;\n\t\t}\n\t\telements[elements.length-1]+=input[i++];\n\t}\n\tif(elements[elements.length-1]==\"\") elements.pop();\n\n\n\tlet elSeparato=[];\n\tfor (let i=0; i\u003Celements.length; ++i){\n\t\t//Separate numbers from text\n\t\tfor (let e of elements[i].matchAll(/((?:(?\u003C=^|\\s)[\\-\\+])?[0-9]+)?(?:\\-?([^0-9\\-]+))?/g)){\n\t\t\telSeparato.push(e.splice(1))\n\t\t}\n\t}\n\telSeparato=elSeparato.flat();\n\telements=elSeparato.filter((v)=\u003E(v!=null \u0026\u0026 v!=\"\"));\n\n\t// Wikifunctions.Debug(\"elements:\");\n\t// Wikifunctions.Debug(elements);\n\n\t/**************** END TOKENISATION ***********************/\n\t/**************** START FINDING POSSIBILITIES ***********************/\n\tvar possibilities=[];\n\n\tvar _constraintsList=[];\n\tvar _nSteps=1;\n\n\tfor(var iAtt=0; iAtt\u003Celements.length; iAtt+=_nSteps){\n\t\t_nSteps=1;\n\t\tlet n=extractNumber(elements[iAtt]);\n\t\tvar _currGuess={};\t//Object containing all the current guesses\n\t\tvar _forced=null;\n\t\tvar _isToBeIgnored=false;\n\n\t\t//////////\n\n\t\tlanguageSpecificOptions();\n\n\t\tfor (let i of numericElements){\n\t\t\tif ((numericElementMin[i]==null || n\u003E=numericElementMin[i]) \u0026\u0026 (numericElementMax[i]==null || n\u003C=numericElementMax[i])){\n\t\t\t\t_currGuess[i]??=n;\n\t\t\t}\n\t\t}\n\n\n\n\t\tif (_forced!=null){\n\t\t\tfor (let j in _currGuess){\n\t\t\t\tif (_forced.find((v)=\u003E(v==j)) == undefined){\n\t\t\t\t\t_currGuess[j]=null;\t\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (!_isToBeIgnored)\n\t\t\tpossibilities.push(_currGuess);\n\t}\n\t\n\n\tif (_constraintsList.length\u003E0){\n\t\tfor (let pAtt=0; pAtt\u003C possibilities.length; ++pAtt){\n\t\t\tfor (let c of _constraintsList){\n\t\t\t\tif ((c.type==AFTER \u0026\u0026 pAtt!=c.pos-1) ||\n\t\t\t\t    (c.type==BEFORE \u0026\u0026 pAtt!=c.pos) ||\n\t\t\t\t    (c.type==BEFORE_OR_AFTER \u0026\u0026 pAtt!=c.pos-1 \u0026\u0026 pAtt!=c.pos)){\n\t\t\t\t\tfor(let m of c.meaning){\n\t\t\t\t\t\tpossibilities[pAtt][m]=null;\t\n\t\t\t\t\t}\n\t\t\t\t} else if ((c.type==AFTER \u0026\u0026 pAtt==c.pos-1) ||\n\t\t\t\t\t(c.type==BEFORE \u0026\u0026 pAtt==c.pos)){\n\t\t\t\t\tfor (let m in possibilities[pAtt]){\n\t\t\t\t\t\tif (c.meaning.find((x)=\u003E x==m)==undefined){\n\t\t\t\t\t\t\tpossibilities[pAtt][m]=null;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\t/**************** END FINDING POSSIBILITIES ***********************/\n\n\n\tpossibilities=possibilities.filter((v)=\u003E(Object.entries(v).filter((x)=\u003Ex[1]!=null).length\u003E0));\n\n\t//remove elements that are not present\n\tlet lettersToRemove=\"\";\n\tif(delete_chain.length\u003Epossibilities.length){\n\t\tfor (let i of delete_chain){\n\t\t\tif (possibilities.find((p)=\u003Ep[i]!=null)==undefined){\n\t\t\t\tlettersToRemove+=i;\n\t\t\t}\n\t\t}\n\t}\n\n\t//save tokens that have only one possibility\n\tlet nLettersToMantain=0;\n\tfor (let p of possibilities){\n\t\tlet currn=1;\n\t\tfor (let e in p){\n\t\t\tif (p[e] instanceof MultipleMeanings){\n\t\t\t\tcurrn=Math.max(currn,Object.entries(p[e]).length);\n\t\t\t}\n\t\t}\n\t\tnLettersToMantain+=currn;\n\t}\n\t\n\tlet safeLetters=\"\";\n\tlet compulsoryLetters=\"\";\n\tif(delete_chain.length\u003EnLettersToMantain){\n\t\tfor (let p of possibilities){\n\t\t\tif (Object.entries(p).filter((x)=\u003Ex[1]!=null).length ==1){\n\t\t\t\tsafeLetters+=Object.entries(p).filter((x)=\u003Ex[1]!=null)[0][0];\n\t\t\t}\n\t\t}\n\t}\n\t\n\tfor (let c of _constraintsList){\n\t\tif (c.meaning.length!==1){\n\t\t\tcontinue;\n\t\t}\n\t\tif(!compulsoryLetters.includes(c.meaning[0])){\n\t\t\tcompulsoryLetters+=c.meaning[0];\n\t\t}\n\t}\n\n\n\t\n\t\t/**************** CHECK OF ALL ORDERS ***********************/\n\t\n\tfor (let i=0; i\u003CprefOptions.length; ++i){\n\t\tlet actPref=prefOptions[i];\n\t\tlet elementsFound={};\n\t\t\n\t\tlet localLettersToRemove=lettersToRemove;\n\t\t//remove elements according to the deletion chain\n\t\tfor (let i=0; i\u003Cdelete_chain.length; ++i){\n\t\t\tif (actPref.indexOf(delete_chain[i])===-1){\n\t\t\t\tlocalLettersToRemove+=delete_chain[i];\n\t\t\t}\n\t\t}\n\t\tfor(let i=0; delete_chain.length-localLettersToRemove.length\u003EnLettersToMantain \u0026\u0026 i\u003Cdelete_chain.length; ++i){\n\t\t\tif (localLettersToRemove.indexOf(delete_chain[i])== -1 \u0026\u0026 safeLetters.indexOf(delete_chain[i])==-1){\n\t\t\t\tlocalLettersToRemove+= delete_chain[i];\n\t\t\t}\n\t\t}\n\t\t\n\t\tfor (let l of localLettersToRemove){\n\t\t\tactPref=actPref.replace(l,\"\");\n\t\t}\n\t\tlet actPrefIt=actPref[Symbol.iterator]();\n\t\tlet currActPrefObj=actPrefIt.next();\n\t\t\n\t\tlet ok=true;\n\t\tfor (let j=0; j\u003Cpossibilities.length \u0026\u0026 !currActPrefObj.done; ++j){\n\t\t\twhile (elementsFound[currActPrefObj.value]!=undefined){\n\t\t\t\tcurrActPrefObj=actPrefIt.next();\n\t\t\t\tif (currActPrefObj.done){\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (currActPrefObj.done){\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif (possibilities[j]?.[currActPrefObj.value] instanceof MultipleMeanings){\n\t\t\t\tfor (let m in possibilities[j][currActPrefObj.value]){\n\t\t\t\t\telementsFound[m]=possibilities[j][currActPrefObj.value][m];\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\telementsFound[currActPrefObj.value]=possibilities[j]?.[currActPrefObj.value];\n\t\t\t\tif (elementsFound[currActPrefObj.value] == null){\n\t\t\t\t\tok=false;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\t\n\t\t\tcurrActPrefObj=actPrefIt.next();\n\t\t}\n\t\tfor (let f of safeLetters){\n\t\t\tif (actPref.includes(f) \u0026\u0026 elementsFound[f]==null){\n\t\t\t\tok=false;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tfor (let f of compulsoryLetters){\n\t\t\tif (elementsFound[f]==null){\n\t\t\t\tok=false;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif (ok){\n\t\t\tlet r= formatOutput(elementsFound);\n\t\t\tif (isValidDate(r)){\n\t\t\t\treturn r;\n\t\t\t}\n\t\t}\n\t}\n\t\n\tWikifunctions.Error(\"Z28131\",[input,\"dag;en-us\"]);\n\n\n}"
        }
    },
    "Z2K3": {
        "Z1K1": "Z12",
        "Z12K1": [
            "Z11",
            {
                "Z1K1": "Z11",
                "Z11K1": "Z1787",
                "Z11K2": "leggi Data, en, dag (mga), preparato per Hijri"
            }
        ]
    },
    "Z2K4": {
        "Z1K1": "Z32",
        "Z32K1": [
            "Z31"
        ]
    },
    "Z2K5": {
        "Z1K1": "Z12",
        "Z12K1": [
            "Z11"
        ]
    }
}