export class MockRouter {
    constructor() {
        this._routes = [];
    }
    //     constructor() {
    //         this._routes = [];
    //     }
    get routes() {
        return this._routes;
    }
    findRoute(request) {
        const candidates = this._routes.filter((r) => r.predicate(request));
        if (candidates.length === 0) {
            return undefined;
        }
        else {
            return candidates[0].adapter(request);
        }
    }
    // addRoutes(map: RouteMapping) {
    //     // throw new Error('Method not implemented.');
    //     // TODO
    // }
    addRoute(predicate, adapter) {
        // var filter: Predicate<Command>;
        // if (typeof left === 'string') {
        //     left = Util.parseApiRequestString(left);
        // }
        // if (left instanceof ApiRequest) {
        //     filter = new EqualRequestFilter(left);
        // } else if (left instanceof RegExp) {
        //     filter = new RegExpFilter(left);
        // } else if (typeof left === 'function') {
        //     filter = {
        //         test: left
        //     };
        // } else {
        //     filter = left as Predicate<Command>;
        // }
        // var adapter: ResponseAdapter<T>;
        // if (right instanceof ResponseImpl) {
        //     adapter = new (class Tmp implements ResponseAdapter<T> {
        //         public adapt(command: Command) {
        //             return right;
        //         }
        //     })();
        // } else if (right instanceof Uint8Array) {
        //     adapter = new (class Tmp implements ResponseAdapter<T> {
        //         public adapt(command: Command) {
        //             return new ResponseImpl<T>(right);
        //         }
        //     })();
        // } else if (typeof right === 'function') {
        //     adapter = {
        //         adapt: right
        //     };
        // } else {
        //     adapter = right as ResponseAdapter<T>;
        // }
        this._routes.push({
            predicate,
            adapter,
        });
        return this;
    }
    //     /**
    //      * Mapping a command (represented as a string with format "<request-type> <path> [data]"
    //      * ie: GET /3//3 0xABCD or POST /1024//0 0xtest
    //      *
    //      * TapResponse must either be:
    //      *  - an hexadecimal data represented as a string (0xABCD)
    //      *  - An object with a coreRet and a body
    //      *  - A Uint8Array
    //      */
    // addRoutes(map: { [key: string]: RouteType }): this {
    //     for (const pathString in map) {
    //         const info = map[pathString];
    //         const command: Command = Util.parseApiRequestString(pathString);
    //         let response;
    //         if (info instanceof Uint8Array) {
    //             response = new ResponseImpl(info);
    //         } else if (info instanceof ResponseImpl) {
    //             response = info;
    //         } else if (typeof info === 'number') {
    //             response = ResponseImpl.create(info);
    //         } else if (typeof info === 'string') {
    //             response = new ResponseImpl(
    //                 hexStringToBuffer(info)
    //             );
    //         } else if (typeof info === 'object') {
    //             const codeRet: number = (info as RouteTypeObject).codeRet;
    //             response = new ResponseImpl(
    //                 KaitaiStreamWriter.mergeArrays(
    //                     Uint8Array.from([codeRet]),
    //                     (info as RouteTypeObject).body || new Uint8Array(0)
    //                 )
    //             );
    //         } else {
    //             throw new Error(
    //                 `Invalid response type ${typeof info} with value: ${JSON.stringify(
    //                     info
    //                 )}`
    //             );
    //         }
    //         debug(TAG, `\t- Add map ${command} -> ${response}`);
    //         this.addRoute(command, response);
    //     }
    //     return this;
    // }
    clearRoutes() {
        this._routes = [];
        return this;
    }
}
// /**
//  * @deprecated in favor of {@link #addRoute}
//  */
// public mapResponse<T>(
//     left:
//         | FilterFunction<TapRequestFrame>
//         | Predicate<TapRequestFrame>
//         | TapRequestFrame,
//     right:
//         | ResponseAdapterFunction<T>
//         | ResponseAdapter<T>
//         | TapResponse<T>
//         | Uint8Array
// ): this {
//     return this.addRoute(left, right);
// }
// public addRoute<T>(
//     left:
//         | FilterFunction<TapRequestFrame>
//         | Predicate<TapRequestFrame>
//         | TapRequestFrame,
//     right:
//         | ResponseAdapterFunction<T>
//         | ResponseAdapter<T>
//         | TapResponse<T>
//         | Uint8Array
// ): this {
//     this.router.addRoute(left, right);
//     return this;
// }
// //     public Configuration getConfiguration() {
// //     return configuration;
// // }
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibW9jay1yb3V0ZXIuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi90ZXN0aW5nL3NyYy9tb2NrL21vY2stcm91dGVyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUdBLE1BQU0sT0FBTyxVQUFVO0lBQXZCO1FBQ0UsWUFBTyxHQUdELEVBQUU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