// Generated by purs version 0.14.5
"use strict";
var $foreign = require("./foreign.js");
var Data_Enum = require("../Data.Enum/index.js");
var Data_Maybe = require("../Data.Maybe/index.js");
var Data_Ordering = require("../Data.Ordering/index.js");
var Unsafe_Coerce = require("../Unsafe.Coerce/index.js");
var Web_Internal_FFI = require("../Web.Internal.FFI/index.js");
var Standard = (function () {
    function Standard() {

    };
    Standard.value = new Standard();
    return Standard;
})();
var Left = (function () {
    function Left() {

    };
    Left.value = new Left();
    return Left;
})();
var Right = (function () {
    function Right() {

    };
    Right.value = new Right();
    return Right;
})();
var Numpad = (function () {
    function Numpad() {

    };
    Numpad.value = new Numpad();
    return Numpad;
})();
var toUIEvent = Unsafe_Coerce.unsafeCoerce;
var toEvent = Unsafe_Coerce.unsafeCoerce;
var toEnumKeyLocation = function (v) {
    if (v === 0) {
        return new Data_Maybe.Just(Standard.value);
    };
    if (v === 1) {
        return new Data_Maybe.Just(Left.value);
    };
    if (v === 2) {
        return new Data_Maybe.Just(Right.value);
    };
    if (v === 3) {
        return new Data_Maybe.Just(Numpad.value);
    };
    return Data_Maybe.Nothing.value;
};
var fromUIEvent = Web_Internal_FFI.unsafeReadProtoTagged("KeyboardEvent");
var fromEvent = Web_Internal_FFI.unsafeReadProtoTagged("KeyboardEvent");
var fromEnumKeyLocation = function (v) {
    if (v instanceof Standard) {
        return 0;
    };
    if (v instanceof Left) {
        return 1;
    };
    if (v instanceof Right) {
        return 2;
    };
    if (v instanceof Numpad) {
        return 3;
    };
    throw new Error("Failed pattern match at Web.UIEvent.KeyboardEvent (line 107, column 3 - line 111, column 16): " + [ v.constructor.name ]);
};
var eqKeyLocation = {
    eq: function (x) {
        return function (y) {
            if (x instanceof Standard && y instanceof Standard) {
                return true;
            };
            if (x instanceof Left && y instanceof Left) {
                return true;
            };
            if (x instanceof Right && y instanceof Right) {
                return true;
            };
            if (x instanceof Numpad && y instanceof Numpad) {
                return true;
            };
            return false;
        };
    }
};
var ordKeyLocation = {
    compare: function (x) {
        return function (y) {
            if (x instanceof Standard && y instanceof Standard) {
                return Data_Ordering.EQ.value;
            };
            if (x instanceof Standard) {
                return Data_Ordering.LT.value;
            };
            if (y instanceof Standard) {
                return Data_Ordering.GT.value;
            };
            if (x instanceof Left && y instanceof Left) {
                return Data_Ordering.EQ.value;
            };
            if (x instanceof Left) {
                return Data_Ordering.LT.value;
            };
            if (y instanceof Left) {
                return Data_Ordering.GT.value;
            };
            if (x instanceof Right && y instanceof Right) {
                return Data_Ordering.EQ.value;
            };
            if (x instanceof Right) {
                return Data_Ordering.LT.value;
            };
            if (y instanceof Right) {
                return Data_Ordering.GT.value;
            };
            if (x instanceof Numpad && y instanceof Numpad) {
                return Data_Ordering.EQ.value;
            };
            throw new Error("Failed pattern match at Web.UIEvent.KeyboardEvent (line 81, column 1 - line 81, column 50): " + [ x.constructor.name, y.constructor.name ]);
        };
    },
    Eq0: function () {
        return eqKeyLocation;
    }
};
var enumKeyLocation = {
    succ: Data_Enum.defaultSucc(toEnumKeyLocation)(fromEnumKeyLocation),
    pred: Data_Enum.defaultPred(toEnumKeyLocation)(fromEnumKeyLocation),
    Ord0: function () {
        return ordKeyLocation;
    }
};
var boundedKeyLocation = {
    bottom: Standard.value,
    top: Numpad.value,
    Ord0: function () {
        return ordKeyLocation;
    }
};
var boundedEnumKeyLocation = {
    cardinality: 4,
    toEnum: toEnumKeyLocation,
    fromEnum: fromEnumKeyLocation,
    Bounded0: function () {
        return boundedKeyLocation;
    },
    Enum1: function () {
        return enumKeyLocation;
    }
};
var location = function (dictPartial) {
    var $13 = Data_Maybe.fromJust();
    var $14 = Data_Enum.toEnum(boundedEnumKeyLocation);
    return function ($15) {
        return $13($14($foreign.locationIndex($15)));
    };
};
module.exports = {
    fromUIEvent: fromUIEvent,
    fromEvent: fromEvent,
    toUIEvent: toUIEvent,
    toEvent: toEvent,
    location: location,
    Standard: Standard,
    Left: Left,
    Right: Right,
    Numpad: Numpad,
    toEnumKeyLocation: toEnumKeyLocation,
    fromEnumKeyLocation: fromEnumKeyLocation,
    eqKeyLocation: eqKeyLocation,
    ordKeyLocation: ordKeyLocation,
    boundedKeyLocation: boundedKeyLocation,
    enumKeyLocation: enumKeyLocation,
    boundedEnumKeyLocation: boundedEnumKeyLocation,
    key: $foreign.key,
    code: $foreign.code,
    locationIndex: $foreign.locationIndex,
    ctrlKey: $foreign.ctrlKey,
    shiftKey: $foreign.shiftKey,
    altKey: $foreign.altKey,
    metaKey: $foreign.metaKey,
    repeat: $foreign.repeat,
    isComposing: $foreign.isComposing,
    getModifierState: $foreign.getModifierState
};
