var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
import { Injectable } from '@angular/core';
import { ElLayoutDirectionService } from '../../../services/direction.service';
export var ElGlobalLogicalPosition;
(function (ElGlobalLogicalPosition) {
    ElGlobalLogicalPosition["TOP_START"] = "top-start";
    ElGlobalLogicalPosition["TOP_END"] = "top-end";
    ElGlobalLogicalPosition["BOTTOM_START"] = "bottom-start";
    ElGlobalLogicalPosition["BOTTOM_END"] = "bottom-end";
})(ElGlobalLogicalPosition || (ElGlobalLogicalPosition = {}));
export var ElGlobalPhysicalPosition;
(function (ElGlobalPhysicalPosition) {
    ElGlobalPhysicalPosition["TOP_RIGHT"] = "top-right";
    ElGlobalPhysicalPosition["TOP_LEFT"] = "top-left";
    ElGlobalPhysicalPosition["BOTTOM_RIGHT"] = "bottom-right";
    ElGlobalPhysicalPosition["BOTTOM_LEFT"] = "bottom-left";
})(ElGlobalPhysicalPosition || (ElGlobalPhysicalPosition = {}));
let ElPositionHelper = class ElPositionHelper {
    constructor(layoutDirection) {
        this.layoutDirection = layoutDirection;
    }
    toLogicalPosition(position) {
        if (Object.values(ElGlobalLogicalPosition).includes(position)) {
            return position;
        }
        if (this.layoutDirection.isLtr()) {
            return this.toLogicalPositionWhenLtr(position);
        }
        else {
            return this.toLogicalPositionWhenRtl(position);
        }
    }
    toPhysicalPosition(position) {
        if (Object.values(ElGlobalPhysicalPosition).includes(position)) {
            return position;
        }
        if (this.layoutDirection.isLtr()) {
            return this.toPhysicalPositionWhenLtr(position);
        }
        else {
            return this.toPhysicalPositionWhenRtl(position);
        }
    }
    isTopPosition(position) {
        const logicalPosition = this.toLogicalPosition(position);
        return logicalPosition === ElGlobalLogicalPosition.TOP_END
            || logicalPosition === ElGlobalLogicalPosition.TOP_START;
    }
    isRightPosition(position) {
        const physicalPosition = this.toPhysicalPosition(position);
        return physicalPosition === ElGlobalPhysicalPosition.TOP_RIGHT
            || physicalPosition === ElGlobalPhysicalPosition.BOTTOM_RIGHT;
    }
    toLogicalPositionWhenLtr(position) {
        switch (position) {
            case ElGlobalPhysicalPosition.TOP_RIGHT:
                return ElGlobalLogicalPosition.TOP_END;
            case ElGlobalPhysicalPosition.TOP_LEFT:
                return ElGlobalLogicalPosition.TOP_START;
            case ElGlobalPhysicalPosition.BOTTOM_RIGHT:
                return ElGlobalLogicalPosition.BOTTOM_END;
            case ElGlobalPhysicalPosition.BOTTOM_LEFT:
                return ElGlobalLogicalPosition.BOTTOM_START;
        }
    }
    toLogicalPositionWhenRtl(position) {
        switch (position) {
            case ElGlobalPhysicalPosition.TOP_RIGHT:
                return ElGlobalLogicalPosition.TOP_START;
            case ElGlobalPhysicalPosition.TOP_LEFT:
                return ElGlobalLogicalPosition.TOP_END;
            case ElGlobalPhysicalPosition.BOTTOM_RIGHT:
                return ElGlobalLogicalPosition.BOTTOM_START;
            case ElGlobalPhysicalPosition.BOTTOM_LEFT:
                return ElGlobalLogicalPosition.BOTTOM_END;
        }
    }
    toPhysicalPositionWhenLtr(position) {
        switch (position) {
            case ElGlobalLogicalPosition.TOP_START:
                return ElGlobalPhysicalPosition.TOP_LEFT;
            case ElGlobalLogicalPosition.TOP_END:
                return ElGlobalPhysicalPosition.TOP_RIGHT;
            case ElGlobalLogicalPosition.BOTTOM_START:
                return ElGlobalPhysicalPosition.BOTTOM_LEFT;
            case ElGlobalLogicalPosition.BOTTOM_END:
                return ElGlobalPhysicalPosition.BOTTOM_RIGHT;
        }
    }
    toPhysicalPositionWhenRtl(position) {
        switch (position) {
            case ElGlobalLogicalPosition.TOP_START:
                return ElGlobalPhysicalPosition.TOP_RIGHT;
            case ElGlobalLogicalPosition.TOP_END:
                return ElGlobalPhysicalPosition.TOP_LEFT;
            case ElGlobalLogicalPosition.BOTTOM_START:
                return ElGlobalPhysicalPosition.BOTTOM_RIGHT;
            case ElGlobalLogicalPosition.BOTTOM_END:
                return ElGlobalPhysicalPosition.BOTTOM_LEFT;
        }
    }
};
ElPositionHelper = __decorate([
    Injectable(),
    __metadata("design:paramtypes", [ElLayoutDirectionService])
], ElPositionHelper);
export { ElPositionHelper };
//# sourceMappingURL=position-helper.js.map