import { __awaiter, __extends, __generator } from "tslib";
import { BasePage, By } from '../../common/BasePage';
import { FOCUSZONE_CIRCLE_NAV_SWITCH, FOCUSZONE_DEFAULT_TABBABLE_SWITCH, FOCUSZONE_DIRECTION_ID, FOCUSZONE_DIRECTION_PICKER, FOCUSZONE_DISABLED_SWITCH, FOCUSZONE_GRID_AFTER, FOCUSZONE_GRID_BEFORE, FOCUSZONE_GRID_BUTTON, FOCUSZONE_TESTPAGE, FOCUSZONE_TEST_COMPONENT, FOCUSZONE_TWO_DIM_SWITCH, HOMEPAGE_FOCUSZONE_BUTTON, } from '../consts';
var FocusZonePageObject = /** @class */ (function (_super) {
    __extends(FocusZonePageObject, _super);
    function FocusZonePageObject() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    FocusZonePageObject.prototype.resetTest = function () {
        return __awaiter(this, void 0, void 0, function () {
            return __generator(this, function (_a) {
                switch (_a.label) {
                    case 0: return [4 /*yield*/, this.configureGridFocusZone('SetDirection', 'bidirectional')];
                    case 1:
                        _a.sent();
                        return [4 /*yield*/, this.configureGridFocusZone('Set2DNavigation', false)];
                    case 2:
                        _a.sent();
                        return [4 /*yield*/, this.configureGridFocusZone('SetCircularNavigation', false)];
                    case 3:
                        _a.sent();
                        return [4 /*yield*/, this.configureGridFocusZone('Disable', false)];
                    case 4:
                        _a.sent();
                        return [2 /*return*/];
                }
            });
        });
    };
    FocusZonePageObject.prototype.configureGridFocusZone = function (option, arg) {
        return __awaiter(this, void 0, void 0, function () {
            var switchElement, _a, switchValue;
            var _this = this;
            return __generator(this, function (_b) {
                switch (_b.label) {
                    case 0:
                        _a = option;
                        switch (_a) {
                            case 'SetDirection': return [3 /*break*/, 1];
                            case 'Set2DNavigation': return [3 /*break*/, 7];
                            case 'SetCircularNavigation': return [3 /*break*/, 9];
                            case 'UseDefaultTabbableElement': return [3 /*break*/, 11];
                            case 'Disable': return [3 /*break*/, 13];
                        }
                        return [3 /*break*/, 15];
                    case 1: return [4 /*yield*/, this._directionPicker];
                    case 2: return [4 /*yield*/, (_b.sent()).click()];
                    case 3:
                        _b.sent();
                        return [4 /*yield*/, browser.waitUntil(function () { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
                                switch (_a.label) {
                                    case 0: return [4 /*yield*/, this._getGridFocusZoneMenuOption(arg)];
                                    case 1: return [4 /*yield*/, (_a.sent()).isDisplayed()];
                                    case 2: return [2 /*return*/, _a.sent()];
                                }
                            }); }); })];
                    case 4:
                        _b.sent();
                        return [4 /*yield*/, this._getGridFocusZoneMenuOption(arg)];
                    case 5: return [4 /*yield*/, (_b.sent()).click()];
                    case 6:
                        _b.sent();
                        return [2 /*return*/];
                    case 7: return [4 /*yield*/, this._twoDimSwitch];
                    case 8:
                        switchElement = _b.sent();
                        return [3 /*break*/, 15];
                    case 9: return [4 /*yield*/, this._circleNavSwitch];
                    case 10:
                        switchElement = _b.sent();
                        return [3 /*break*/, 15];
                    case 11: return [4 /*yield*/, this._defaultTabbableElementSwitch];
                    case 12:
                        switchElement = _b.sent();
                        return [3 /*break*/, 15];
                    case 13: return [4 /*yield*/, this._disabledSwitch];
                    case 14:
                        switchElement = _b.sent();
                        return [3 /*break*/, 15];
                    case 15: return [4 /*yield*/, switchElement.isSelected()];
                    case 16:
                        switchValue = _b.sent();
                        if (!(switchValue !== arg)) return [3 /*break*/, 18];
                        return [4 /*yield*/, switchElement.click()];
                    case 17:
                        _b.sent();
                        _b.label = 18;
                    case 18: return [2 /*return*/];
                }
            });
        });
    };
    FocusZonePageObject.prototype.gridButton = function (button) {
        return __awaiter(this, void 0, void 0, function () {
            return __generator(this, function (_a) {
                switch (_a.label) {
                    case 0: return [4 /*yield*/, By(FOCUSZONE_GRID_BUTTON(button))];
                    case 1: return [2 /*return*/, _a.sent()];
                }
            });
        });
    };
    FocusZonePageObject.prototype._getGridFocusZoneMenuOption = function (direction) {
        return __awaiter(this, void 0, void 0, function () {
            return __generator(this, function (_a) {
                switch (_a.label) {
                    case 0: return [4 /*yield*/, By(FOCUSZONE_DIRECTION_ID(direction))];
                    case 1: return [2 /*return*/, _a.sent()];
                }
            });
        });
    };
    Object.defineProperty(FocusZonePageObject.prototype, "_pageName", {
        /*****************************************/
        /**************** Getters ****************/
        /*****************************************/
        get: function () {
            return FOCUSZONE_TESTPAGE;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(FocusZonePageObject.prototype, "_primaryComponentName", {
        get: function () {
            return FOCUSZONE_TEST_COMPONENT;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(FocusZonePageObject.prototype, "_pageButtonName", {
        get: function () {
            return HOMEPAGE_FOCUSZONE_BUTTON;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(FocusZonePageObject.prototype, "_directionPicker", {
        get: function () {
            return By(FOCUSZONE_DIRECTION_PICKER);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(FocusZonePageObject.prototype, "_twoDimSwitch", {
        get: function () {
            return By(FOCUSZONE_TWO_DIM_SWITCH);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(FocusZonePageObject.prototype, "_disabledSwitch", {
        get: function () {
            return By(FOCUSZONE_DISABLED_SWITCH);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(FocusZonePageObject.prototype, "_circleNavSwitch", {
        get: function () {
            return By(FOCUSZONE_CIRCLE_NAV_SWITCH);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(FocusZonePageObject.prototype, "_defaultTabbableElementSwitch", {
        get: function () {
            return By(FOCUSZONE_DEFAULT_TABBABLE_SWITCH);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(FocusZonePageObject.prototype, "_beforeButton", {
        get: function () {
            return By(FOCUSZONE_GRID_BEFORE);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(FocusZonePageObject.prototype, "_afterButton", {
        get: function () {
            return By(FOCUSZONE_GRID_AFTER);
        },
        enumerable: false,
        configurable: true
    });
    return FocusZonePageObject;
}(BasePage));
export default new FocusZonePageObject();
//# sourceMappingURL=FocusZonePageObject.js.map