(function (global, factory) {
    typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
    typeof define === 'function' && define.amd ? define('@iotize/tap/protocol/api', ['exports'], factory) :
    (global = global || self, factory((global.iotize = global.iotize || {}, global.iotize.tap = global.iotize.tap || {}, global.iotize.tap.protocol = global.iotize.tap.protocol || {}, global.iotize.tap.protocol.api = {})));
}(this, (function (exports) { 'use strict';

    (function (ConnectionState) {
        ConnectionState[ConnectionState["DISCONNECTED"] = 0] = "DISCONNECTED";
        ConnectionState[ConnectionState["CONNECTING"] = 1] = "CONNECTING";
        ConnectionState[ConnectionState["CONNECTED"] = 2] = "CONNECTED";
        ConnectionState[ConnectionState["DISCONNECTING"] = 3] = "DISCONNECTING";
    })(exports.ConnectionState || (exports.ConnectionState = {}));

    var __extends = (this && this.__extends) || (function () {
        var extendStatics = function (d, b) {
            extendStatics = Object.setPrototypeOf ||
                ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
                function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
            return extendStatics(d, b);
        };
        return function (d, b) {
            extendStatics(d, b);
            function __() { this.constructor = d; }
            d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
        };
    })();

    (function (ComProtocol) {
        var Errors = /** @class */ (function (_super) {
            __extends(Errors, _super);
            // private static fromErrorCode(code: ErrorCode) {
            //     return new ComProtocolError(code, ComProtocolError.errorCodeToMessage(code));
            // }
            // public static errorCodeToMessage(code: ErrorCode): string {
            //     switch (code) {
            //         case ErrorCode.ProtocolNotConnected:
            //             return
            //         case ErrorCode.TimeoutError:
            //             return "request timeout";
            //         default:
            //             return "unknown error"
            //     }
            // }
            function Errors(code, msg) {
                var _this = _super.call(this, msg) || this;
                _this.code = code;
                return _this;
            }
            Errors.operationCanceled = function () {
                return new Errors(ErrorCode.OperationCancelled, 'Communication protocol operation cancelled');
            };
            Errors.notConnected = function (info) {
                return new Errors(ErrorCode.ProtocolNotConnected, 'Communication protocol is not connected');
            };
            Errors.timeoutError = function (info) {
                return new Errors(ErrorCode.TimeoutError, info.msg || 'Communication protocol timeout');
            };
            Errors.unknownError = function () {
                return new Errors(ErrorCode.UnknownError, 'Unnown communication protocol error');
            };
            return Errors;
        }(Error));
        ComProtocol.Errors = Errors;
        var ErrorCode;
        (function (ErrorCode) {
            ErrorCode["ProtocolNotConnected"] = "ProtocolNotConnected";
            ErrorCode["TimeoutError"] = "TimeoutError";
            ErrorCode["UnknownError"] = "UnknownError";
            ErrorCode["OperationCancelled"] = "OperationCancelled";
        })(ErrorCode = ComProtocol.ErrorCode || (ComProtocol.ErrorCode = {}));
    })(exports.ComProtocol || (exports.ComProtocol = {}));

    Object.defineProperty(exports, '__esModule', { value: true });

})));
//# sourceMappingURL=iotize-tap-protocol-api.umd.js.map
