// 
// Decompiled by Procyon v0.6.0
// 

package org.jline.utils;

public class AttributedStyle
{
    public static final int BLACK = 0;
    public static final int RED = 1;
    public static final int GREEN = 2;
    public static final int YELLOW = 3;
    public static final int BLUE = 4;
    public static final int MAGENTA = 5;
    public static final int CYAN = 6;
    public static final int WHITE = 7;
    public static final int BRIGHT = 8;
    static final long F_BOLD = 1L;
    static final long F_FAINT = 2L;
    static final long F_ITALIC = 4L;
    static final long F_UNDERLINE = 8L;
    static final long F_BLINK = 16L;
    static final long F_INVERSE = 32L;
    static final long F_CONCEAL = 64L;
    static final long F_CROSSED_OUT = 128L;
    static final long F_FOREGROUND_IND = 256L;
    static final long F_FOREGROUND_RGB = 512L;
    static final long F_FOREGROUND = 768L;
    static final long F_BACKGROUND_IND = 1024L;
    static final long F_BACKGROUND_RGB = 2048L;
    static final long F_BACKGROUND = 3072L;
    static final long F_HIDDEN = 4096L;
    static final long MASK = 8191L;
    static final int FG_COLOR_EXP = 15;
    static final int BG_COLOR_EXP = 39;
    static final long FG_COLOR = 549755781120L;
    static final long BG_COLOR = 9223371487098961920L;
    public static final AttributedStyle DEFAULT;
    public static final AttributedStyle BOLD;
    public static final AttributedStyle BOLD_OFF;
    public static final AttributedStyle INVERSE;
    public static final AttributedStyle INVERSE_OFF;
    public static final AttributedStyle HIDDEN;
    public static final AttributedStyle HIDDEN_OFF;
    final long style;
    final long mask;
    
    public AttributedStyle() {
        this(0L, 0L);
    }
    
    public AttributedStyle(final AttributedStyle s) {
        this(s.style, s.mask);
    }
    
    public AttributedStyle(final long style, final long mask) {
        this.style = style;
        this.mask = ((mask & 0x1FFFL) | (((style & 0x300L) != 0x0L) ? 549755781120L : 0L) | (((style & 0xC00L) != 0x0L) ? 9223371487098961920L : 0L));
    }
    
    public AttributedStyle bold() {
        return new AttributedStyle(this.style | 0x1L, this.mask | 0x1L);
    }
    
    public AttributedStyle boldOff() {
        return new AttributedStyle(this.style & 0xFFFFFFFFFFFFFFFEL, this.mask | 0x1L);
    }
    
    public AttributedStyle boldDefault() {
        return new AttributedStyle(this.style & 0xFFFFFFFFFFFFFFFEL, this.mask & 0xFFFFFFFFFFFFFFFEL);
    }
    
    public AttributedStyle faint() {
        return new AttributedStyle(this.style | 0x2L, this.mask | 0x2L);
    }
    
    public AttributedStyle faintOff() {
        return new AttributedStyle(this.style & 0xFFFFFFFFFFFFFFFDL, this.mask | 0x2L);
    }
    
    public AttributedStyle faintDefault() {
        return new AttributedStyle(this.style & 0xFFFFFFFFFFFFFFFDL, this.mask & 0xFFFFFFFFFFFFFFFDL);
    }
    
    public AttributedStyle italic() {
        return new AttributedStyle(this.style | 0x4L, this.mask | 0x4L);
    }
    
    public AttributedStyle italicOff() {
        return new AttributedStyle(this.style & 0xFFFFFFFFFFFFFFFBL, this.mask | 0x4L);
    }
    
    public AttributedStyle italicDefault() {
        return new AttributedStyle(this.style & 0xFFFFFFFFFFFFFFFBL, this.mask & 0xFFFFFFFFFFFFFFFBL);
    }
    
    public AttributedStyle underline() {
        return new AttributedStyle(this.style | 0x8L, this.mask | 0x8L);
    }
    
    public AttributedStyle underlineOff() {
        return new AttributedStyle(this.style & 0xFFFFFFFFFFFFFFF7L, this.mask | 0x8L);
    }
    
    public AttributedStyle underlineDefault() {
        return new AttributedStyle(this.style & 0xFFFFFFFFFFFFFFF7L, this.mask & 0xFFFFFFFFFFFFFFF7L);
    }
    
    public AttributedStyle blink() {
        return new AttributedStyle(this.style | 0x10L, this.mask | 0x10L);
    }
    
    public AttributedStyle blinkOff() {
        return new AttributedStyle(this.style & 0xFFFFFFFFFFFFFFEFL, this.mask | 0x10L);
    }
    
    public AttributedStyle blinkDefault() {
        return new AttributedStyle(this.style & 0xFFFFFFFFFFFFFFEFL, this.mask & 0xFFFFFFFFFFFFFFEFL);
    }
    
    public AttributedStyle inverse() {
        return new AttributedStyle(this.style | 0x20L, this.mask | 0x20L);
    }
    
    public AttributedStyle inverseNeg() {
        final long s = ((this.style & 0x20L) != 0x0L) ? (this.style & 0xFFFFFFFFFFFFFFDFL) : (this.style | 0x20L);
        return new AttributedStyle(s, this.mask | 0x20L);
    }
    
    public AttributedStyle inverseOff() {
        return new AttributedStyle(this.style & 0xFFFFFFFFFFFFFFDFL, this.mask | 0x20L);
    }
    
    public AttributedStyle inverseDefault() {
        return new AttributedStyle(this.style & 0xFFFFFFFFFFFFFFDFL, this.mask & 0xFFFFFFFFFFFFFFDFL);
    }
    
    public AttributedStyle conceal() {
        return new AttributedStyle(this.style | 0x40L, this.mask | 0x40L);
    }
    
    public AttributedStyle concealOff() {
        return new AttributedStyle(this.style & 0xFFFFFFFFFFFFFFBFL, this.mask | 0x40L);
    }
    
    public AttributedStyle concealDefault() {
        return new AttributedStyle(this.style & 0xFFFFFFFFFFFFFFBFL, this.mask & 0xFFFFFFFFFFFFFFBFL);
    }
    
    public AttributedStyle crossedOut() {
        return new AttributedStyle(this.style | 0x80L, this.mask | 0x80L);
    }
    
    public AttributedStyle crossedOutOff() {
        return new AttributedStyle(this.style & 0xFFFFFFFFFFFFFF7FL, this.mask | 0x80L);
    }
    
    public AttributedStyle crossedOutDefault() {
        return new AttributedStyle(this.style & 0xFFFFFFFFFFFFFF7FL, this.mask & 0xFFFFFFFFFFFFFF7FL);
    }
    
    public AttributedStyle foreground(final int color) {
        return new AttributedStyle((this.style & 0xFFFFFF8000007FFFL) | 0x100L | ((long)color << 15 & 0x7FFFFF8000L), this.mask | 0x100L);
    }
    
    public AttributedStyle foreground(final int r, final int g, final int b) {
        return this.foregroundRgb(r << 16 | g << 8 | b);
    }
    
    public AttributedStyle foregroundRgb(final int color) {
        return new AttributedStyle((this.style & 0xFFFFFF8000007FFFL) | 0x200L | (((long)color & 0xFFFFFFL) << 15 & 0x7FFFFF8000L), this.mask | 0x200L);
    }
    
    public AttributedStyle foregroundOff() {
        return new AttributedStyle(this.style & 0xFFFFFF8000007FFFL & 0xFFFFFFFFFFFFFCFFL, this.mask | 0x300L);
    }
    
    public AttributedStyle foregroundDefault() {
        return new AttributedStyle(this.style & 0xFFFFFF8000007FFFL & 0xFFFFFFFFFFFFFCFFL, this.mask & 0xFFFFFF8000007CFFL);
    }
    
    public AttributedStyle background(final int color) {
        return new AttributedStyle((this.style & 0x8000007FFFFFFFFFL) | 0x400L | ((long)color << 39 & 0x7FFFFF8000000000L), this.mask | 0x400L);
    }
    
    public AttributedStyle background(final int r, final int g, final int b) {
        return this.backgroundRgb(r << 16 | g << 8 | b);
    }
    
    public AttributedStyle backgroundRgb(final int color) {
        return new AttributedStyle((this.style & 0x8000007FFFFFFFFFL) | 0x800L | (((long)color & 0xFFFFFFL) << 39 & 0x7FFFFF8000000000L), this.mask | 0x800L);
    }
    
    public AttributedStyle backgroundOff() {
        return new AttributedStyle(this.style & 0x8000007FFFFFFFFFL & 0xFFFFFFFFFFFFF3FFL, this.mask | 0xC00L);
    }
    
    public AttributedStyle backgroundDefault() {
        return new AttributedStyle(this.style & 0x8000007FFFFFFFFFL & 0xFFFFFFFFFFFFF3FFL, this.mask & 0x8000007FFFFFF3FFL);
    }
    
    public AttributedStyle hidden() {
        return new AttributedStyle(this.style | 0x1000L, this.mask | 0x1000L);
    }
    
    public AttributedStyle hiddenOff() {
        return new AttributedStyle(this.style & 0xFFFFFFFFFFFFEFFFL, this.mask | 0x1000L);
    }
    
    public AttributedStyle hiddenDefault() {
        return new AttributedStyle(this.style & 0xFFFFFFFFFFFFEFFFL, this.mask & 0xFFFFFFFFFFFFEFFFL);
    }
    
    public long getStyle() {
        return this.style;
    }
    
    public long getMask() {
        return this.mask;
    }
    
    @Override
    public boolean equals(final Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || this.getClass() != o.getClass()) {
            return false;
        }
        final AttributedStyle that = (AttributedStyle)o;
        return this.style == that.style && this.mask == that.mask;
    }
    
    @Override
    public int hashCode() {
        return 31 * Long.hashCode(this.style) + Long.hashCode(this.mask);
    }
    
    public String toAnsi() {
        final AttributedStringBuilder sb = new AttributedStringBuilder();
        sb.styled(this, " ");
        final String s = sb.toAnsi(16777216, AttributedCharSequence.ForceMode.None);
        return (s.length() > 1) ? s.substring(2, s.indexOf(109)) : s;
    }
    
    @Override
    public String toString() {
        return "AttributedStyle{style=" + this.style + ", mask=" + this.mask + ", ansi=" + this.toAnsi() + '}';
    }
    
    static {
        DEFAULT = new AttributedStyle();
        BOLD = AttributedStyle.DEFAULT.bold();
        BOLD_OFF = AttributedStyle.DEFAULT.boldOff();
        INVERSE = AttributedStyle.DEFAULT.inverse();
        INVERSE_OFF = AttributedStyle.DEFAULT.inverseOff();
        HIDDEN = AttributedStyle.DEFAULT.hidden();
        HIDDEN_OFF = AttributedStyle.DEFAULT.hiddenOff();
    }
}
