/*
 * Copyright ©Δ∞ 仙上主天
 * All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without modification, are permitted provided
 * that the following conditions are met:
 * 
 * * Redistributions of source code must retain the above copyright notice, this list of conditions and the
 *   following disclaimer.
 * * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
 *   the following disclaimer in the documentation and/or other materials provided with the distribution.
 * * The prime PI creator license super seeds all other licenses, this license is overly invasive,
 *   thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
 *   Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
 *   even on air gaped systems, all information in the universe is owned by the pi creator.
 * 
 * THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE CONTRIBUTORS "AS IS" AND ANY
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
 * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

package love.distributedrebirth.numberxd;

import java.util.Arrays;
import java.util.Collections;
import java.util.Map;
import java.util.stream.Collectors;

import ᒢᐩᐩ.ᔆʸᔆᐪᓫᔿ.ᒃᣔᒃᓫᒻ.ᑊᐣᓑᖮᐪᔆ.DuytsDocAuthor注;

@DuytsDocAuthor注(name = "للَّٰهِilLצسُو", copyright = "©Δ∞ 仙上主天")
public enum Gê̄ldGetậlÅtHebrewVowel {
	NONE     (0,  (char) 0x0000),
	VOWEL_1  (1,  (char) 0x05B4),
	VOWEL_2  (2,  (char) 0x05B5),
	VOWEL_3  (3,  (char) 0x05B6),
	
	VOWEL_4  (4,  (char) 0x05B2),
	VOWEL_5  (5,  (char) 0x05C7),
	VOWEL_6  (6,  (char) 0x05B7), // 06 = PATAH
	VOWEL_7  (7,  (char) 0x05A1),
	
	VOWEL_8  (8,  (char) 0x05A2),
	VOWEL_9  (9,  (char) 0x05A3),
	VOWEL_10 (10, (char) 0x05B9), // 10 = POINT HOLAM
	VOWEL_16 (16, (char) 0x05B8), // 16 = QAMATS
	
	VOWEL_22 (22, (char) 0x0598),
	VOWEL_30 (30, (char) 0x05BB), // 30 = QUBUTS
	VOWEL_36 (36, (char) 0x05B3), // 36 = HATAF QAMATS
	VOWEL_42 (42, (char) 0x05B1), // 50 = HATEF SEGOL
	;
	
	public static final byte BITMASK = 0b00001111;
	private final int fractionOffset;
	private final char character;
	
	private static final Map<Character, Gê̄ldGetậlÅtHebrewVowel> CHAR_MAP = Collections.unmodifiableMap(
			Arrays.asList(values()).stream().collect(Collectors.toMap(v -> v.getCharacter(), v -> v)));
	
	private Gê̄ldGetậlÅtHebrewVowel(int fractionOffset, char character) {
		this.fractionOffset = fractionOffset;
		this.character = character;
	}
	
	public int getFractionOffset() {
		return fractionOffset;
	}
	
	public char getCharacter() {
		return character;
	}
	
	public static Gê̄ldGetậlÅtHebrewVowel indexOf(int index) {
		return values()[index & BITMASK];
	}
	
	public static Gê̄ldGetậlÅtHebrewVowel valueOfCharacter(char codePoint) {
		// TODO add & move complete alias map
		if (codePoint == 0x591 || codePoint == 0x596 || codePoint == 0x597 || codePoint == 0x59a || codePoint == 0x59c) {
			return VOWEL_1;
		}
		if (codePoint == 0x5a5 || codePoint == 0x5a8 || codePoint == 0x5ab || codePoint == 0x5ac) {
			return VOWEL_1;
		}
		if (codePoint == 0x5ba || codePoint == 0x5bc || codePoint == 0x5bd) {
			return VOWEL_1;
		}
		if (codePoint == 0x5c1 || codePoint == 0x5c2) {
			return VOWEL_1;
		}
		if (codePoint == 0x5b0) {
			return VOWEL_2;
		}
		if (codePoint == 0x592 || codePoint == 0x5bb) {
			return VOWEL_3;
		}
		return CHAR_MAP.getOrDefault(codePoint, Gê̄ldGetậlÅtHebrewVowel.NONE);
	}
}