'use strict';

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

const index$o = require('./index-0b1e2673.js');
const _commonjsHelpers = require('./_commonjsHelpers-937cd5b3.js');
require('./index-ab186017.js');
const index$m = require('./index-10a0b195.js');
const index$n = require('./index-8a61808f.js');
const model = require('./model-b8df1873.js');

var Verifier_1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Verifier = void 0;

const algorithms = {
    production: index$m.dist.Algorithm.RS256("MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEArZFavKxpyvdY5hv1ZKegVXPfcoI0Tx4CIN7lAxdW80M9bROncr3tVngC48iWzbX/6ziw5xGwujXG/j1qSNIZlTOWx2imlWCl5doTSPb1yt0CX3pREdlBfR5RJGQHRhGpiQA51HO9wA9Y9OAq4kqaFcCkEpJeqvNjvXPJSTM97x4rksil63WalUFSjmWK6lEiQIo/cnLCi6l6MkSxYBZTwS6jGjGvBcYeNPwVHToRLl4Yz0KRdYFyMcO5wk9B6hQ+fA3rkhXezU0squlzPCBZnoyp2T+OqM/ztLuykVlQjVN5RNP89O02jcmsviYH3aRxtYmnaoRKlhXtBmiXmi873wIDAQAB"),
    development: index$m.dist.Algorithm.RS256("MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAzWkKmoMsdU6TRKeMYFlwwRxb7uuA3Xh1zsya9m9QLcF7FhSLxsaDF7hHWmbBLsKBCDT35hl8mIxOssQGcq5CvhntAmI7RgWExs/VgtyJK1uRxgUKS7wCuWxlB3akXY4f2UXcFn+wOqBdhh1yep726MvB/Jh4nDusXb5G4evVJLIrMKc8vvLqmEo9x8wuXz5s6qvIlHf6h7KLICNsX0ZCv6Tf3OYbZlfd0us+gQTvqhk+dj6P2UaUlQmsEAOerLvSKWDa1KNe0i58/aoDgC9FZGCmpg1mtPegQ09IAVgCaqQ6zqA1wPIWiOO89pWWne28tRCNYGvNY0eXUSG6qXv5LQIDAQAB"),
};
class Verifier {
    constructor(backends) {
        this.backends = backends;
    }
    async verify(token) {
        return (await Promise.all(this.backends.map(async ([a, v]) => await (v === null || v === void 0 ? void 0 : v.verify(token, a))))).find(p => p);
    }
    add(...argument) {
        this.backends.forEach(([_, b]) => b === null || b === void 0 ? void 0 : b.add(...argument));
        return this;
    }
    static create() {
        return new Verifier(Object.entries(algorithms).map(([audience, algorithm]) => [
            audience,
            index$m.dist.Verifier.create(algorithm),
        ]));
    }
}
exports.Verifier = Verifier;

});

const Verifier = /*@__PURE__*/_commonjsHelpers.getDefaultExportFromCjs(Verifier_1);

var Account_1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Account = void 0;


var Account;
(function (Account) {
    function is(value) {
        return (typeof value == "object" &&
            index$m.dist.Identifier.is(value.id) &&
            (value.reference == undefined || typeof value.reference == "string"));
    }
    Account.is = is;
    const transformers = [new index$m.dist.Property.Typeguard(is)];
    const verifier = Verifier_1.Verifier.create().add(...transformers);
    async function verify(token) {
        return verifier.verify(token);
    }
    Account.verify = verify;
})(Account = exports.Account || (exports.Account = {}));

});

const Account = /*@__PURE__*/_commonjsHelpers.getDefaultExportFromCjs(Account_1);

var Result_1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Result = void 0;
var Result;
(function (Result) {
    function is(value) {
        return typeof (value) == "object" &&
            typeof (value.status) == "number";
    }
    Result.is = is;
    function hasBody(value) {
        return typeof (value) == "object" &&
            typeof (value.status) == "number" &&
            value.body != undefined && value.body != null;
    }
    Result.hasBody = hasBody;
    function getBody(value, fallback) {
        return hasBody(value) ? value.body : fallback;
    }
    Result.getBody = getBody;
})(Result = exports.Result || (exports.Result = {}));

});

const Result = /*@__PURE__*/_commonjsHelpers.getDefaultExportFromCjs(Result_1);

var _Error = _commonjsHelpers.createCommonjsModule(function (module, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Error = void 0;

var Error;
(function (Error) {
    function is(value) {
        return typeof (value) == "object" &&
            typeof (value.type) == "string" &&
            Result_1.Result.is(value) && value.status >= 400;
    }
    Error.is = is;
})(Error = exports.Error || (exports.Error = {}));

});

const _Error$1 = /*@__PURE__*/_commonjsHelpers.getDefaultExportFromCjs(_Error);

var Flaw_1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Flaw = void 0;
var Flaw;
(function (Flaw) {
    function is(value) {
        return typeof (value) == "object" &&
            (value.property == undefined || typeof (value.property) == "string") &&
            typeof (value.type) == "string" &&
            (value.flaws == undefined || Array.isArray(value.flaws) && value.flaws.every(Flaw.is)) &&
            (value.condition == undefined || typeof (value.condition) == "string");
    }
    Flaw.is = is;
})(Flaw = exports.Flaw || (exports.Flaw = {}));

});

const Flaw = /*@__PURE__*/_commonjsHelpers.getDefaultExportFromCjs(Flaw_1);

var created_1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.created = void 0;

function created(body) {
    return { status: 201, body };
}
exports.created = created;
(function (created) {
    function is(value) {
        return typeof (value) == "object" &&
            value.body &&
            Result_1.Result.is(value) &&
            value.status == 201;
    }
    created.is = is;
})(created = exports.created || (exports.created = {}));

});

const created = /*@__PURE__*/_commonjsHelpers.getDefaultExportFromCjs(created_1);

var noContent_1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.noContent = void 0;

function noContent() {
    return { status: 204 };
}
exports.noContent = noContent;
(function (noContent) {
    function is(value) {
        return Result_1.Result.is(value) && value.status == 204;
    }
    noContent.is = is;
})(noContent = exports.noContent || (exports.noContent = {}));

});

const noContent = /*@__PURE__*/_commonjsHelpers.getDefaultExportFromCjs(noContent_1);

var ok_1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ok = void 0;

function ok(body) {
    return { status: 200, body };
}
exports.ok = ok;
(function (ok) {
    function is(value) {
        return typeof (value) == "object" &&
            value.body &&
            Result_1.Result.is(value) &&
            value.status == 200;
    }
    ok.is = is;
})(ok = exports.ok || (exports.ok = {}));

});

const ok = /*@__PURE__*/_commonjsHelpers.getDefaultExportFromCjs(ok_1);

var success = _commonjsHelpers.createCommonjsModule(function (module, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ok = exports.noContent = exports.created = void 0;

Object.defineProperty(exports, "created", { enumerable: true, get: function () { return created_1.created; } });

Object.defineProperty(exports, "noContent", { enumerable: true, get: function () { return noContent_1.noContent; } });

Object.defineProperty(exports, "ok", { enumerable: true, get: function () { return ok_1.ok; } });

});

const index = /*@__PURE__*/_commonjsHelpers.getDefaultExportFromCjs(success);

var permanent_1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.permanent = void 0;

function permanent(location) {
    return { status: 301, location };
}
exports.permanent = permanent;
(function (permanent) {
    function is(value) {
        return Result_1.Result.is(value) && value.status == 301;
    }
    permanent.is = is;
})(permanent = exports.permanent || (exports.permanent = {}));

});

const permanent = /*@__PURE__*/_commonjsHelpers.getDefaultExportFromCjs(permanent_1);

var found_1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.found = void 0;

function found(location) {
    return { status: 302, location };
}
exports.found = found;
(function (found) {
    function is(value) {
        return Result_1.Result.is(value) && value.status == 302;
    }
    found.is = is;
})(found = exports.found || (exports.found = {}));

});

const found = /*@__PURE__*/_commonjsHelpers.getDefaultExportFromCjs(found_1);

var redirect = _commonjsHelpers.createCommonjsModule(function (module, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.found = exports.permanent = void 0;

Object.defineProperty(exports, "permanent", { enumerable: true, get: function () { return permanent_1.permanent; } });

Object.defineProperty(exports, "found", { enumerable: true, get: function () { return found_1.found; } });

});

const index$1 = /*@__PURE__*/_commonjsHelpers.getDefaultExportFromCjs(redirect);

var flawedContent_1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.flawedContent = void 0;

function flawedContent(content) {
    return { status: 400, type: "flawed content", content };
}
exports.flawedContent = flawedContent;
(function (flawedContent) {
    function is(value) {
        return _Error.Error.is(value) && value.status == 400 && value.type == "flawed content";
    }
    flawedContent.is = is;
})(flawedContent = exports.flawedContent || (exports.flawedContent = {}));

});

const flawedContent = /*@__PURE__*/_commonjsHelpers.getDefaultExportFromCjs(flawedContent_1);

var invalidContent_1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.invalidContent = void 0;

function invalidContent(type, description, details) {
    return { status: 400, type: "invalid content", content: { type, description, details } };
}
exports.invalidContent = invalidContent;
(function (invalidContent) {
    function is(value) {
        return _Error.Error.is(value) && value.status == 400 && value.type == "invalid content";
    }
    invalidContent.is = is;
})(invalidContent = exports.invalidContent || (exports.invalidContent = {}));

});

const invalidContent = /*@__PURE__*/_commonjsHelpers.getDefaultExportFromCjs(invalidContent_1);

var invalidPathArgument_1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.invalidPathArgument = void 0;

function invalidPathArgument(pattern, name, type, description) {
    return { status: 400, type: "invalid path argument", pattern, argument: { name, type, description } };
}
exports.invalidPathArgument = invalidPathArgument;
(function (invalidPathArgument) {
    function is(value) {
        return _Error.Error.is(value) && value.status == 400 && value.type == "invalid path argument";
    }
    invalidPathArgument.is = is;
})(invalidPathArgument = exports.invalidPathArgument || (exports.invalidPathArgument = {}));

});

const invalidPathArgument = /*@__PURE__*/_commonjsHelpers.getDefaultExportFromCjs(invalidPathArgument_1);

var invalidQueryArgument_1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.invalidQueryArgument = void 0;

function invalidQueryArgument(name, type, description) {
    return { status: 400, type: "invalid query argument", argument: { name, type, description } };
}
exports.invalidQueryArgument = invalidQueryArgument;
(function (invalidQueryArgument) {
    function is(value) {
        return _Error.Error.is(value) && value.status == 400 && value.type == "invalid query argument";
    }
    invalidQueryArgument.is = is;
})(invalidQueryArgument = exports.invalidQueryArgument || (exports.invalidQueryArgument = {}));

});

const invalidQueryArgument = /*@__PURE__*/_commonjsHelpers.getDefaultExportFromCjs(invalidQueryArgument_1);

var malformedContent_1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.malformedContent = void 0;

function malformedContent(property, type, description, details) {
    return { status: 400, type: "malformed content", content: { property, type, description } };
}
exports.malformedContent = malformedContent;
(function (malformedContent) {
    function is(value) {
        return _Error.Error.is(value) && value.status == 400 && value.type == "malformed content";
    }
    malformedContent.is = is;
})(malformedContent = exports.malformedContent || (exports.malformedContent = {}));

});

const malformedContent = /*@__PURE__*/_commonjsHelpers.getDefaultExportFromCjs(malformedContent_1);

var methodNotAllowed_1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.methodNotAllowed = void 0;

const methods = ["GET", "POST", "DELETE", "HEAD", "PATCH", "PUT", "OPTIONS", "TRACE", "CONNECT"];
function methodNotAllowed(...allow) {
    return { status: 405, type: "method not allowed", header: { allow } };
}
exports.methodNotAllowed = methodNotAllowed;
(function (methodNotAllowed) {
    function is(value) {
        return typeof value == "object" &&
            value.status == 405 &&
            value.type == "method not allowed" &&
            typeof value.header == "object" &&
            Array.isArray(value.header.allow) &&
            value.header.allow.every((m) => methods.some(m)) &&
            _Error.Error.is(value);
    }
    methodNotAllowed.is = is;
})(methodNotAllowed = exports.methodNotAllowed || (exports.methodNotAllowed = {}));

});

const methodNotAllowed = /*@__PURE__*/_commonjsHelpers.getDefaultExportFromCjs(methodNotAllowed_1);

var missingProperty_1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.missingProperty = void 0;

function missingProperty(property, type, description) {
    return { status: 400, type: "missing property", content: typeof description == "string" ? { property, type, description } : Object.assign({ property, type }, description) };
}
exports.missingProperty = missingProperty;
(function (missingProperty) {
    function is(value) {
        return _Error.Error.is(value) && value.status == 400 && value.type == "missing property";
    }
    missingProperty.is = is;
})(missingProperty = exports.missingProperty || (exports.missingProperty = {}));

});

const missingProperty = /*@__PURE__*/_commonjsHelpers.getDefaultExportFromCjs(missingProperty_1);

var missingQueryArgument_1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.missingQueryArgument = void 0;

function missingQueryArgument(name, type, description) {
    return { status: 400, type: "missing query argument", argument: { name, type, description } };
}
exports.missingQueryArgument = missingQueryArgument;
(function (missingQueryArgument) {
    function is(value) {
        return _Error.Error.is(value) && value.status == 400 && value.type == "missing query argument";
    }
    missingQueryArgument.is = is;
})(missingQueryArgument = exports.missingQueryArgument || (exports.missingQueryArgument = {}));

});

const missingQueryArgument = /*@__PURE__*/_commonjsHelpers.getDefaultExportFromCjs(missingQueryArgument_1);

var notFound_1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.notFound = void 0;

function notFound() {
    return { status: 404, type: "not found" };
}
exports.notFound = notFound;
(function (notFound) {
    function is(value) {
        return _Error.Error.is(value) && value.status == 404 && value.type == "not found";
    }
    notFound.is = is;
})(notFound = exports.notFound || (exports.notFound = {}));

});

const notFound = /*@__PURE__*/_commonjsHelpers.getDefaultExportFromCjs(notFound_1);

var unauthorized_1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.unauthorized = void 0;

function unauthorized() {
    return { status: 401, type: "not authorized" };
}
exports.unauthorized = unauthorized;
(function (unauthorized) {
    function is(value) {
        return _Error.Error.is(value) && value.status == 401 && value.type == "not authorized";
    }
    unauthorized.is = is;
})(unauthorized = exports.unauthorized || (exports.unauthorized = {}));

});

const unauthorized = /*@__PURE__*/_commonjsHelpers.getDefaultExportFromCjs(unauthorized_1);

var client = _commonjsHelpers.createCommonjsModule(function (module, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });

Object.defineProperty(exports, "flawedContent", { enumerable: true, get: function () { return flawedContent_1.flawedContent; } });

Object.defineProperty(exports, "invalidContent", { enumerable: true, get: function () { return invalidContent_1.invalidContent; } });

Object.defineProperty(exports, "invalidPathArgument", { enumerable: true, get: function () { return invalidPathArgument_1.invalidPathArgument; } });

Object.defineProperty(exports, "invalidQueryArgument", { enumerable: true, get: function () { return invalidQueryArgument_1.invalidQueryArgument; } });

Object.defineProperty(exports, "malformedContent", { enumerable: true, get: function () { return malformedContent_1.malformedContent; } });

Object.defineProperty(exports, "methodNotAllowed", { enumerable: true, get: function () { return methodNotAllowed_1.methodNotAllowed; } });

Object.defineProperty(exports, "missingProperty", { enumerable: true, get: function () { return missingProperty_1.missingProperty; } });

Object.defineProperty(exports, "missingQueryArgument", { enumerable: true, get: function () { return missingQueryArgument_1.missingQueryArgument; } });

Object.defineProperty(exports, "notFound", { enumerable: true, get: function () { return notFound_1.notFound; } });

Object.defineProperty(exports, "unauthorized", { enumerable: true, get: function () { return unauthorized_1.unauthorized; } });

});

const index$2 = /*@__PURE__*/_commonjsHelpers.getDefaultExportFromCjs(client);

var backendFailure_1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.backendFailure = void 0;

function backendFailure(backend, details, reference) {
    if (backend != "string" && details == undefined && reference == undefined) {
        details = backend;
        backend = "unknown";
    }
    return { status: 502, type: "backend failure", backend, details, reference };
}
exports.backendFailure = backendFailure;
(function (backendFailure) {
    function is(value) {
        return _Error.Error.is(value) && value.status == 502 && value.type == "backend failure" && typeof value.backend == "string";
    }
    backendFailure.is = is;
})(backendFailure = exports.backendFailure || (exports.backendFailure = {}));

});

const backendFailure = /*@__PURE__*/_commonjsHelpers.getDefaultExportFromCjs(backendFailure_1);

var backendTimeout_1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.backendTimeout = void 0;

function backendTimeout() {
    return { status: 504, type: "backend timeout" };
}
exports.backendTimeout = backendTimeout;
(function (backendTimeout) {
    function is(value) {
        return _Error.Error.is(value) && value.status == 504 && value.type == "backend timeout";
    }
    backendTimeout.is = is;
})(backendTimeout = exports.backendTimeout || (exports.backendTimeout = {}));

});

const backendTimeout = /*@__PURE__*/_commonjsHelpers.getDefaultExportFromCjs(backendTimeout_1);

var databaseFailure_1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.databaseFailure = void 0;

function databaseFailure(details) {
    return { status: 502, type: "database failure", details };
}
exports.databaseFailure = databaseFailure;
(function (databaseFailure) {
    function is(value) {
        return _Error.Error.is(value) && value.status == 502 && value.type == "database failure";
    }
    databaseFailure.is = is;
})(databaseFailure = exports.databaseFailure || (exports.databaseFailure = {}));

});

const databaseFailure = /*@__PURE__*/_commonjsHelpers.getDefaultExportFromCjs(databaseFailure_1);

var databaseTimeout_1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.databaseTimeout = void 0;

function databaseTimeout() {
    return { status: 504, type: "database timeout" };
}
exports.databaseTimeout = databaseTimeout;
(function (databaseTimeout) {
    function is(value) {
        return _Error.Error.is(value) && value.status == 504 && value.type == "database timeout";
    }
    databaseTimeout.is = is;
})(databaseTimeout = exports.databaseTimeout || (exports.databaseTimeout = {}));

});

const databaseTimeout = /*@__PURE__*/_commonjsHelpers.getDefaultExportFromCjs(databaseTimeout_1);

var missconfigured_1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.missconfigured = void 0;

function missconfigured(key, description) {
    return { status: 503, type: "missing configuration", key, description };
}
exports.missconfigured = missconfigured;
(function (missconfigured) {
    function is(value) {
        return _Error.Error.is(value) && value.status == 503 && value.type == "missing configuration";
    }
    missconfigured.is = is;
})(missconfigured = exports.missconfigured || (exports.missconfigured = {}));

});

const missconfigured = /*@__PURE__*/_commonjsHelpers.getDefaultExportFromCjs(missconfigured_1);

var unavailable_1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.unavailable = void 0;

function unavailable() {
    return { status: 503, type: "service unavailable" };
}
exports.unavailable = unavailable;
(function (unavailable) {
    function is(value) {
        return _Error.Error.is(value) && value.status == 503 && value.type == "service unavailable";
    }
    unavailable.is = is;
})(unavailable = exports.unavailable || (exports.unavailable = {}));

});

const unavailable = /*@__PURE__*/_commonjsHelpers.getDefaultExportFromCjs(unavailable_1);

var unknown_1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.unknown = void 0;

function unknown(error) {
    return { status: 500, type: "unknown error", error };
}
exports.unknown = unknown;
(function (unknown) {
    function is(value) {
        return _Error.Error.is(value) && value.status == 500 && value.type == "unknown error";
    }
    unknown.is = is;
})(unknown = exports.unknown || (exports.unknown = {}));

});

const unknown = /*@__PURE__*/_commonjsHelpers.getDefaultExportFromCjs(unknown_1);

var server = _commonjsHelpers.createCommonjsModule(function (module, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.unknown = exports.unavailable = exports.missconfigured = exports.databaseTimeout = exports.databaseFailure = exports.backendTimeout = exports.backendFailure = void 0;

Object.defineProperty(exports, "backendFailure", { enumerable: true, get: function () { return backendFailure_1.backendFailure; } });

Object.defineProperty(exports, "backendTimeout", { enumerable: true, get: function () { return backendTimeout_1.backendTimeout; } });

Object.defineProperty(exports, "databaseFailure", { enumerable: true, get: function () { return databaseFailure_1.databaseFailure; } });

Object.defineProperty(exports, "databaseTimeout", { enumerable: true, get: function () { return databaseTimeout_1.databaseTimeout; } });

Object.defineProperty(exports, "missconfigured", { enumerable: true, get: function () { return missconfigured_1.missconfigured; } });

Object.defineProperty(exports, "unavailable", { enumerable: true, get: function () { return unavailable_1.unavailable; } });

Object.defineProperty(exports, "unknown", { enumerable: true, get: function () { return unknown_1.unknown; } });

});

const index$3 = /*@__PURE__*/_commonjsHelpers.getDefaultExportFromCjs(server);

var dist = _commonjsHelpers.createCommonjsModule(function (module, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.server = exports.client = exports.redirect = exports.success = exports.Result = exports.Flaw = exports.Error = void 0;

Object.defineProperty(exports, "Error", { enumerable: true, get: function () { return _Error.Error; } });

Object.defineProperty(exports, "Flaw", { enumerable: true, get: function () { return Flaw_1.Flaw; } });

Object.defineProperty(exports, "Result", { enumerable: true, get: function () { return Result_1.Result; } });

exports.success = success;

exports.redirect = redirect;

exports.client = client;

exports.server = server;

});

const index$4 = /*@__PURE__*/_commonjsHelpers.getDefaultExportFromCjs(dist);

var Bin_1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Bin = void 0;

var Bin;
(function (Bin) {
    function is(value) {
        return (typeof value == "object" &&
            (value.amex == undefined || typeof value.amex == "string") &&
            (value.dankort == undefined || typeof value.dankort == "string") &&
            (value.diners == undefined || typeof value.diners == "string") &&
            (value.discover == undefined || typeof value.discover == "string") &&
            (value.electron == undefined || typeof value.electron == "string") &&
            (value.interpayment == undefined || typeof value.interpayment == "string") &&
            (value.jcb == undefined || typeof value.jcb == "string") &&
            (value.maestro == undefined || typeof value.maestro == "string") &&
            (value.mastercard == undefined || typeof value.mastercard == "string") &&
            (value.unionpay == undefined || typeof value.unionpay == "string") &&
            (value.visa == undefined || typeof value.visa == "string"));
    }
    Bin.is = is;
    function flaw(value) {
        return {
            type: "model.Acquirer.Bin",
            flaws: typeof value.bin != "object"
                ? undefined
                : [
                    typeof value.bin.amex == "string" ||
                        value.bin.amex == undefined || { property: "amex", type: "string | undefined" },
                    typeof value.bin.dankort == "string" ||
                        value.bin.dankort == undefined || { property: "dankort", type: "string | undefined" },
                    typeof value.bin.diners == "string" ||
                        value.bin.diners == undefined || { property: "diners", type: "string | undefined" },
                    typeof value.bin.discover == "string" ||
                        value.bin.discover == undefined || { property: "discover", type: "string | undefined" },
                    typeof value.bin.electron == "string" ||
                        value.bin.electron == undefined || { property: "electron", type: "string | undefined" },
                    typeof value.bin.interpayment == "string" ||
                        value.bin.interpayment == undefined || { property: "interpayment", type: "string | undefined" },
                    typeof value.bin.jcb == "string" ||
                        value.bin.jcb == undefined || { property: "jcb", type: "string | undefined" },
                    typeof value.bin.maestro == "string" ||
                        value.bin.maestro == undefined || { property: "maestro", type: "string | undefined" },
                    typeof value.bin.mastercard == "string" ||
                        value.bin.mastercard == undefined || { property: "mastercard", type: "string | undefined" },
                    typeof value.bin.unionpay == "string" ||
                        value.bin.unionpay == undefined || { property: "unionpay", type: "string | undefined" },
                    typeof value.bin.visa == "string" ||
                        value.bin.visa == undefined || { property: "visa", type: "string | undefined" },
                ].filter(dist.Flaw.is),
        };
    }
    Bin.flaw = flaw;
})(Bin = exports.Bin || (exports.Bin = {}));

});

const Bin = /*@__PURE__*/_commonjsHelpers.getDefaultExportFromCjs(Bin_1);

var Protocol_1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Protocol = void 0;
var Protocol;
(function (Protocol) {
    function is(value) {
        return typeof value == "string" && value == "clearhaus";
    }
    Protocol.is = is;
})(Protocol = exports.Protocol || (exports.Protocol = {}));

});

const Protocol = /*@__PURE__*/_commonjsHelpers.getDefaultExportFromCjs(Protocol_1);

var Creatable_1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Creatable = void 0;


var Creatable;
(function (Creatable) {
    function is(value) {
        return (typeof value == "object" &&
            (value.id == undefined || typeof value.id == "string") &&
            (value.protocol == undefined || Protocol_1.Protocol.is(value.protocol)) &&
            (value.url == undefined || typeof value.url == "string") &&
            (value.key == undefined || typeof value.key == "string") &&
            (value.bin == undefined || Bin_1.Bin.is(value.bin)));
    }
    Creatable.is = is;
})(Creatable = exports.Creatable || (exports.Creatable = {}));

});

const Creatable = /*@__PURE__*/_commonjsHelpers.getDefaultExportFromCjs(Creatable_1);

var Acquirer_1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Acquirer = void 0;



var Acquirer;
(function (Acquirer) {
    function is(value) {
        return (typeof value == "object" &&
            (value.id == undefined || typeof value.id == "string") &&
            Protocol_1.Protocol.is(value.protocol) &&
            typeof value.url == "string" &&
            typeof value.key == "string" &&
            (value.bin == undefined || Bin_1.Bin.is(value.bin)));
    }
    Acquirer.is = is;
    let Bin;
    (function (Bin) {
        Bin.is = Bin_1.Bin.is;
        Bin.flaw = Bin_1.Bin.flaw;
    })(Bin = Acquirer.Bin || (Acquirer.Bin = {}));
    let Creatable;
    (function (Creatable) {
        Creatable.is = Creatable_1.Creatable.is;
    })(Creatable = Acquirer.Creatable || (Acquirer.Creatable = {}));
})(Acquirer = exports.Acquirer || (exports.Acquirer = {}));

});

const index$5 = /*@__PURE__*/_commonjsHelpers.getDefaultExportFromCjs(Acquirer_1);

var Cancel_1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Cancel = void 0;


var Cancel;
(function (Cancel) {
    function is(value) {
        return (typeof value == "object" &&
            index$m.dist.Identifier.is(value.id) &&
            (value.descriptor == undefined || typeof value.descriptor == "string") &&
            typeof value.reference == "string" &&
            index$n.dist.DateTime.is(value.created));
    }
    Cancel.is = is;
})(Cancel = exports.Cancel || (exports.Cancel = {}));

});

const index$6 = /*@__PURE__*/_commonjsHelpers.getDefaultExportFromCjs(Cancel_1);

var Creatable_1$1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Creatable = void 0;
var Creatable;
(function (Creatable) {
    function is(value) {
        return (typeof value == "object" &&
            (value.descriptor == undefined || typeof value.descriptor == "string") &&
            (value.amount == undefined || typeof value.amount == "number"));
    }
    Creatable.is = is;
})(Creatable = exports.Creatable || (exports.Creatable = {}));

});

const Creatable$1 = /*@__PURE__*/_commonjsHelpers.getDefaultExportFromCjs(Creatable_1$1);

var Capture_1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Capture = void 0;



var Capture;
(function (Capture) {
    function is(value) {
        return (typeof value == "object" &&
            index$m.dist.Identifier.is(value.id) &&
            typeof value.reference == "string" &&
            (value.descriptor == undefined || typeof value.descriptor == "string") &&
            index$n.dist.DateTime.is(value.created) &&
            typeof value.amount == "number");
    }
    Capture.is = is;
    let Creatable;
    (function (Creatable) {
        Creatable.is = Creatable_1$1.Creatable.is;
    })(Creatable = Capture.Creatable || (Capture.Creatable = {}));
})(Capture = exports.Capture || (exports.Capture = {}));

});

const index$7 = /*@__PURE__*/_commonjsHelpers.getDefaultExportFromCjs(Capture_1);

var Creatable_1$2 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Creatable = void 0;
var Creatable;
(function (Creatable) {
    function is(value) {
        return (typeof value == "object" &&
            (value.colorDepth == undefined || typeof value.colorDepth == "string") &&
            (value.java == undefined || typeof value.java == "boolean") &&
            (value.javascript == undefined || typeof value.javascript == "boolean") &&
            (value.language == undefined || typeof value.language == "string") &&
            (value.timezone == undefined || typeof value.timezone == "string") &&
            (value.height == undefined || typeof value.height == "string") &&
            (value.width == undefined || typeof value.width == "string") &&
            (value.parent == undefined || typeof value.parent == "string"));
    }
    Creatable.is = is;
})(Creatable = exports.Creatable || (exports.Creatable = {}));

});

const Creatable$2 = /*@__PURE__*/_commonjsHelpers.getDefaultExportFromCjs(Creatable_1$2);

var Browser_1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Browser = void 0;

var Browser;
(function (Browser) {
    function is(value) {
        return (typeof value == "object" &&
            (value.acceptHeader == undefined || typeof value.acceptHeader == "string") &&
            (value.userAgent == undefined || typeof value.userAgent == "string") &&
            (value.ip == undefined || typeof value.ip == "string") &&
            Creatable.is(value));
    }
    Browser.is = is;
    let Creatable;
    (function (Creatable) {
        Creatable.is = Creatable_1$2.Creatable.is;
    })(Creatable = Browser.Creatable || (Browser.Creatable = {}));
})(Browser = exports.Browser || (exports.Browser = {}));

});

const index$8 = /*@__PURE__*/_commonjsHelpers.getDefaultExportFromCjs(Browser_1);

var Month_1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Month = void 0;
var Month;
(function (Month) {
    function is(value) {
        return (value == 1 ||
            value == 2 ||
            value == 3 ||
            value == 4 ||
            value == 5 ||
            value == 6 ||
            value == 7 ||
            value == 8 ||
            value == 9 ||
            value == 10 ||
            value == 11 ||
            value == 12);
    }
    Month.is = is;
})(Month = exports.Month || (exports.Month = {}));

});

const Month = /*@__PURE__*/_commonjsHelpers.getDefaultExportFromCjs(Month_1);

var Year_1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Year = void 0;
var Year;
(function (Year) {
    function is(value) {
        return (value == 0 ||
            value == 1 ||
            value == 2 ||
            value == 3 ||
            value == 4 ||
            value == 5 ||
            value == 6 ||
            value == 7 ||
            value == 8 ||
            value == 9 ||
            value == 10 ||
            value == 11 ||
            value == 12 ||
            value == 13 ||
            value == 14 ||
            value == 15 ||
            value == 16 ||
            value == 17 ||
            value == 18 ||
            value == 19 ||
            value == 20 ||
            value == 21 ||
            value == 22 ||
            value == 23 ||
            value == 24 ||
            value == 25 ||
            value == 26 ||
            value == 27 ||
            value == 28 ||
            value == 29 ||
            value == 30 ||
            value == 31 ||
            value == 32 ||
            value == 33 ||
            value == 34 ||
            value == 35 ||
            value == 36 ||
            value == 37 ||
            value == 38 ||
            value == 39 ||
            value == 40 ||
            value == 41 ||
            value == 42 ||
            value == 43 ||
            value == 44 ||
            value == 45 ||
            value == 46 ||
            value == 47 ||
            value == 48 ||
            value == 49 ||
            value == 50 ||
            value == 51 ||
            value == 52 ||
            value == 53 ||
            value == 54 ||
            value == 55 ||
            value == 56 ||
            value == 57 ||
            value == 58 ||
            value == 59 ||
            value == 60 ||
            value == 61 ||
            value == 62 ||
            value == 63 ||
            value == 64 ||
            value == 65 ||
            value == 66 ||
            value == 67 ||
            value == 68 ||
            value == 69 ||
            value == 70 ||
            value == 71 ||
            value == 72 ||
            value == 73 ||
            value == 74 ||
            value == 75 ||
            value == 76 ||
            value == 77 ||
            value == 78 ||
            value == 79 ||
            value == 80 ||
            value == 81 ||
            value == 82 ||
            value == 83 ||
            value == 84 ||
            value == 85 ||
            value == 86 ||
            value == 87 ||
            value == 88 ||
            value == 89 ||
            value == 90 ||
            value == 91 ||
            value == 92 ||
            value == 93 ||
            value == 94 ||
            value == 95 ||
            value == 96 ||
            value == 97 ||
            value == 98 ||
            value == 99);
    }
    Year.is = is;
})(Year = exports.Year || (exports.Year = {}));

});

const Year = /*@__PURE__*/_commonjsHelpers.getDefaultExportFromCjs(Year_1);

var Expires_1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Expires = void 0;


var Expires;
(function (Expires) {
    function is(value) {
        return Array.isArray(value) && value.length == 2 && Month_1.Month.is(value[0]) && Year_1.Year.is(value[1]);
    }
    Expires.is = is;
    let Month;
    (function (Month) {
        Month.is = Month_1.Month.is;
    })(Month = Expires.Month || (Expires.Month = {}));
    let Year;
    (function (Year) {
        Year.is = Year_1.Year.is;
    })(Year = Expires.Year || (Expires.Year = {}));
})(Expires = exports.Expires || (exports.Expires = {}));

});

const index$9 = /*@__PURE__*/_commonjsHelpers.getDefaultExportFromCjs(Expires_1);

var Change_1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Change = void 0;



var Change;
(function (Change) {
    function is(value) {
        return (typeof value == "object" &&
            (value.pan == undefined || typeof value.pan == "string") &&
            (value.expires == undefined || Expires_1.Expires.is(value.expires)) &&
            (value.csc == undefined || typeof value.csc == "string") &&
            (value.verification == undefined ||
                (typeof value.verification == "object" &&
                    (value.verification.type == "pares" ||
                        value.verification.type == "method" ||
                        value.verification.type == "challenge") &&
                    (value.verification.data == undefined ||
                        typeof value.verification.data == "string" ||
                        (typeof value.verification.data == "object" &&
                            Object.values(value.verification.data).every(item => typeof item == "string"))))) &&
            (value.client == undefined ||
                (typeof value.client == "object" &&
                    (value.client.ip == undefined || typeof value.client.ip == "string") &&
                    (value.client.browser == undefined ||
                        Browser_1.Browser.is(value.client.browser) ||
                        Browser_1.Browser.Creatable.is(value.client.browser)))));
    }
    Change.is = is;
    function flaw(value) {
        return {
            type: "model.Card.Change",
            flaws: typeof value != "object"
                ? undefined
                : [
                    value.pan == undefined || typeof value.pan == "string" || { property: "pan", type: "string | undefined" },
                    value.expires == undefined ||
                        Expires_1.Expires.is(value.expires) || { property: "expires", type: "string | undefined" },
                    value.csc == undefined || typeof value.csc == "string" || { property: "csc", type: "string | undefined" },
                    value.verification == undefined ||
                        (typeof value.verification == "object" &&
                            (value.verification.type == "pares" ||
                                value.verification.type == "method" ||
                                value.verification.type == "challenge") &&
                            (value.verification.data == undefined ||
                                typeof value.verification.data == "string" ||
                                (typeof value.verification.data == "object" &&
                                    Object.values(value.verification.data).every(item => typeof item == "string")))) || {
                        property: "verification",
                        type: '{ type: "pares" | "method" | "challenge", data?: string | { [property: string]: string }} | undefined',
                    },
                    value.client == undefined ||
                        (typeof value.client == "object" &&
                            (value.client.ip == undefined || typeof value.client.ip == "string") &&
                            (value.client.browser == undefined ||
                                Browser_1.Browser.is(value.client.browser) ||
                                Browser_1.Browser.Creatable.is(value.client.browser))) || {
                        property: "client",
                        type: "{ ip: string | undefined, browser: Browser | Browser.Creatable | undefined",
                    },
                ].filter(dist.Flaw.is),
        };
    }
    Change.flaw = flaw;
})(Change = exports.Change || (exports.Change = {}));

});

const Change = /*@__PURE__*/_commonjsHelpers.getDefaultExportFromCjs(Change_1);

var Creatable_1$3 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Creatable = void 0;


var Creatable;
(function (Creatable) {
    function is(value) {
        return (typeof value == "object" &&
            typeof value.pan == "string" &&
            Expires_1.Expires.is(value.expires) &&
            (value.csc == undefined || typeof value.csc == "string") &&
            (value.verification == undefined ||
                (typeof value.verification == "object" &&
                    (value.verification.type == "pares" ||
                        value.verification.type == "method" ||
                        value.verification.type == "challenge") &&
                    (value.verification.data == undefined ||
                        typeof value.verification.data == "string" ||
                        typeof value.verification.data == "object"))) &&
            (value.client == undefined ||
                (typeof value.client == "object" &&
                    (value.client.ip == undefined || typeof value.client.ip == "string") &&
                    (value.client.browser == undefined ||
                        Browser_1.Browser.is(value.client.browser) ||
                        Browser_1.Browser.Creatable.is(value.client.browser)))));
    }
    Creatable.is = is;
})(Creatable = exports.Creatable || (exports.Creatable = {}));

});

const Creatable$3 = /*@__PURE__*/_commonjsHelpers.getDefaultExportFromCjs(Creatable_1$3);

var Scheme_1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Scheme = void 0;
var Scheme;
(function (Scheme) {
    function is(value) {
        return (typeof value == "string" &&
            (value == "unknown" ||
                value == "amex" ||
                value == "dankort" ||
                value == "diners" ||
                value == "discover" ||
                value == "electron" ||
                value == "interpayment" ||
                value == "jcb" ||
                value == "maestro" ||
                value == "mastercard" ||
                value == "unionpay" ||
                value == "visa"));
    }
    Scheme.is = is;
})(Scheme = exports.Scheme || (exports.Scheme = {}));

});

const Scheme = /*@__PURE__*/_commonjsHelpers.getDefaultExportFromCjs(Scheme_1);

var Pan_1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Pan = void 0;

var Pan;
(function (Pan) {
    function is(value) {
        return (typeof value == "string" &&
            value.length >= 12 &&
            value.length <= 19 &&
            Array.from(value).every(c => c >= "0" && c <= "9"));
    }
    Pan.is = is;
    function scheme(pan) {
        let result = "unknown";
        for (const key in schemes)
            if (Object.prototype.hasOwnProperty.call(schemes, key) &&
                schemes[key].identification.test(pan) &&
                Scheme_1.Scheme.is(key)) {
                result = key;
                break;
            }
        return result;
    }
    Pan.scheme = scheme;
    function valid(pan) {
        const s = scheme(pan);
        return s != undefined && schemes[s].verification.test(pan);
    }
    Pan.valid = valid;
    function iin(pan) {
        return pan.substring(0, 6);
    }
    Pan.iin = iin;
    function last4(pan) {
        return pan.substring(pan.length - 4);
    }
    Pan.last4 = last4;
})(Pan = exports.Pan || (exports.Pan = {}));
const schemes = {
    amex: { verification: /^3[47][0-9]{13}$/, identification: /^3[47]/, length: 18, icon: "amex" },
    dankort: { verification: /^(5019)\d+$/, identification: /^(5019)\d+/, length: 19, icon: "generic" },
    diners: {
        verification: /^3(?:0[0-5]|[68][0-9])[0-9]{11}$/,
        identification: /^3(?:0[0-5]|[68][0-9])/,
        length: 14,
        icon: "diners",
    },
    discover: {
        verification: /^6(?:011|5[0-9]{2})[0-9]{12}$/,
        identification: /^6(?:011|5[0-9]{2})/,
        length: 19,
        icon: "generic",
    },
    electron: {
        verification: /^(4026|417500|4405|4508|4844|4913|4917)\d+$/,
        identification: /^(4026|417500|4405|4508|4844|4913|4917)/,
        length: 19,
        icon: "generic",
    },
    interpayment: { verification: /^(636)\d+$/, identification: /^(636)/, length: 19, icon: "generic" },
    jcb: {
        verification: /^(?:2131|1800|35\d{3})\d{11}$/,
        identification: /^(?:2131|1800|35\d{3})/,
        length: 19,
        icon: "generic",
    },
    maestro: {
        verification: /^(5018|5020|5038|5612|5893|6304|6759|6761|6762|6763|0604|6390)\d+$/,
        identification: /^(5018|5020|5038|5612|5893|6304|6759|6761|6762|6763|0604|6390)/,
        length: 19,
        icon: "maestro",
    },
    mastercard: { verification: /^5[1-5][0-9]{14}$/, identification: /^5[1-5][0-9]/, length: 19, icon: "mastercard" },
    unionpay: { verification: /^(62|88)\d+$/, identification: /^(62|88)/, length: 19, icon: "generic" },
    visa: { verification: /^4[0-9]{12}(?:[0-9]{3})?$/, identification: /^4[0-9]/, length: 16, icon: "visa" },
};

});

const Pan = /*@__PURE__*/_commonjsHelpers.getDefaultExportFromCjs(Pan_1);

var Token_1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Token = void 0;




var Token;
(function (Token) {
    function is(value) {
        return (typeof value == "object" &&
            ["production", "development"].some(a => a == value.audience) &&
            index$n.dist.DateTime.is(value.created) &&
            value.issuer == "card" &&
            typeof value.encrypted == "string" &&
            Expires_1.Expires.is(value.expires) &&
            (value.verification == undefined ||
                (typeof value.verification == "object" &&
                    (value.verification.type == "pares" ||
                        value.verification.type == "method" ||
                        value.verification.type == "challenge") &&
                    (value.verification.data == undefined ||
                        typeof value.verification.data == "string" ||
                        typeof value.verification.data == "object"))));
    }
    Token.is = is;
    function getVerificationTarget(token, baseUrl, parent) {
        return (baseUrl +
            "/card/" +
            token.encrypted +
            token.expires[0].toString().padStart(2, "0") +
            token.expires[1].toString().padStart(2, "0") +
            "/verification?mode=iframe&parent=" +
            parent);
    }
    Token.getVerificationTarget = getVerificationTarget;
    const transformers = [
        new index$m.dist.Property.Typeguard(is),
        new index$m.dist.Property.Renamer({
            encrypted: "enc",
            verification: "ver",
            expires: "xpr",
            audience: "aud",
            issuer: "iss",
            created: "iat",
        }),
        new index$m.dist.Property.Converter({
            iat: {
                forward: value => (index$n.dist.DateTime.is(value) ? index$n.dist.DateTime.parse(value).getTime() : value),
                backward: value => (typeof value == "number" ? index$n.dist.DateTime.create(new Date(value * 1000)) : value),
            },
        }),
    ];
    const verifier = Verifier_1.Verifier.create().add(...transformers);
    async function verify(token) {
        return await verifier.verify(token);
    }
    Token.verify = verify;
})(Token = exports.Token || (exports.Token = {}));

});

const Token = /*@__PURE__*/_commonjsHelpers.getDefaultExportFromCjs(Token_1);

var Type_1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Type = void 0;
var Type;
(function (Type) {
    function is(value) {
        return typeof value == "string" && (value == "debit" || value == "credit");
    }
    Type.is = is;
})(Type = exports.Type || (exports.Type = {}));

});

const Type = /*@__PURE__*/_commonjsHelpers.getDefaultExportFromCjs(Type_1);

var Token_1$1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Token = void 0;




var Token;
(function (Token) {
    function is(value) {
        return (typeof value == "object" &&
            (value.type == "single use" || value.type == "recurring") &&
            index$m.dist.Identifier.is(value.card) &&
            (value.scheme == undefined || Scheme_1.Scheme.is(value.scheme)) &&
            (value.iin == undefined || (typeof value.iin == "string" && value.iin.length == 6)) &&
            (value.last4 == undefined || (typeof value.last4 == "string" && value.last4.length == 4)) &&
            (value.expires == undefined || Expires_1.Expires.is(value.expires)) &&
            (value.verification == undefined ||
                (typeof value.verification == "object" &&
                    ((value.verification.type == "pares" && value.verification.data == undefined) ||
                        value.verification.type == "method" ||
                        value.verification.type == "challenge") &&
                    (value.verification.data == undefined ||
                        typeof value.verification.data == "string" ||
                        typeof value.verification.data == "object"))));
    }
    Token.is = is;
    function hasInfo(value) {
        return (is(value) &&
            Scheme_1.Scheme.is(value.scheme) &&
            typeof value.iin == "string" &&
            value.iin.length == 6 &&
            typeof value.last4 == "string" &&
            value.last4.length == 4 &&
            Expires_1.Expires.is(value.expires));
    }
    Token.hasInfo = hasInfo;
    const transformers = [new index$m.dist.Property.Typeguard(is)];
    const verifier = Verifier_1.Verifier.create().add(...transformers);
    async function verify(token) {
        return await verifier.verify(token);
    }
    Token.verify = verify;
})(Token = exports.Token || (exports.Token = {}));

});

const Token$1 = /*@__PURE__*/_commonjsHelpers.getDefaultExportFromCjs(Token_1$1);

var V1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Card = void 0;







var Card;
(function (Card) {
    function is(value) {
        return (typeof value == "object" &&
            index$m.dist.Identifier.is(value.id) &&
            (value.reference == undefined || typeof value.reference == "string") &&
            (value.account == undefined || index$m.dist.Token.is(value.account)) &&
            Scheme_1.Scheme.is(value.scheme) &&
            typeof value.iin == "string" &&
            value.iin.length == 6 &&
            typeof value.last4 == "string" &&
            value.last4.length == 4 &&
            Expires_1.Expires.is(value.expires) &&
            (value.type == undefined || Type_1.Type.is(value.type)));
    }
    Card.is = is;
    function from(value) {
        let result;
        if (Creatable_1$3.Creatable.is(value))
            result = {
                scheme: Pan_1.Pan.scheme(value.pan),
                iin: Pan_1.Pan.iin(value.pan),
                last4: Pan_1.Pan.last4(value.pan),
                expires: value.expires,
            };
        else {
            result = {};
            if (value.pan) {
                result = {
                    ...result,
                    scheme: Pan_1.Pan.scheme(value.pan),
                    iin: Pan_1.Pan.iin(value.pan),
                    last4: Pan_1.Pan.last4(value.pan),
                };
            }
            if (value.expires)
                result = { ...result, expires: value.expires };
        }
        return result;
    }
    Card.from = from;
    function generateId() {
        return index$m.dist.Identifier.generate(8);
    }
    Card.generateId = generateId;
    let Token;
    (function (Token) {
        Token.is = Token_1$1.Token.is;
        Token.hasInfo = Token_1$1.Token.hasInfo;
        Token.verify = Token_1$1.Token.verify;
    })(Token = Card.Token || (Card.Token = {}));
})(Card = exports.Card || (exports.Card = {}));

});

const index$a = /*@__PURE__*/_commonjsHelpers.getDefaultExportFromCjs(V1);

var Card_1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Card = void 0;








var Card;
(function (Card) {
    function is(value) {
        return (typeof value == "object" &&
            Scheme_1.Scheme.is(value.scheme) &&
            typeof value.iin == "string" &&
            value.iin.length == 6 &&
            typeof value.last4 == "string" &&
            value.last4.length == 4 &&
            Expires_1.Expires.is(value.expires) &&
            (value.type == undefined || Type_1.Type.is(value.type)));
    }
    Card.is = is;
    function from(value) {
        let result;
        if (Creatable_1$3.Creatable.is(value))
            result = {
                scheme: Pan_1.Pan.scheme(value.pan),
                iin: Pan_1.Pan.iin(value.pan),
                last4: Pan_1.Pan.last4(value.pan),
                expires: value.expires,
            };
        else {
            result = {};
            if (value.pan) {
                result = {
                    ...result,
                    scheme: Pan.scheme(value.pan),
                    iin: Pan.iin(value.pan),
                    last4: Pan.last4(value.pan),
                };
            }
            if (value.expires)
                result = { ...result, expires: value.expires };
        }
        return result;
    }
    Card.from = from;
    let Change;
    (function (Change) {
        Change.is = Change_1.Change.is;
        Change.flaw = Change_1.Change.flaw;
    })(Change = Card.Change || (Card.Change = {}));
    let Creatable;
    (function (Creatable) {
        Creatable.is = Creatable_1$3.Creatable.is;
    })(Creatable = Card.Creatable || (Card.Creatable = {}));
    let Pan;
    (function (Pan) {
        Pan.is = Pan_1.Pan.is;
        Pan.scheme = Pan_1.Pan.scheme;
        Pan.valid = Pan_1.Pan.valid;
        Pan.iin = Pan_1.Pan.iin;
        Pan.last4 = Pan_1.Pan.last4;
    })(Pan = Card.Pan || (Card.Pan = {}));
    let Scheme;
    (function (Scheme) {
        Scheme.is = Scheme_1.Scheme.is;
    })(Scheme = Card.Scheme || (Card.Scheme = {}));
    let Expires;
    (function (Expires) {
        Expires.is = Expires_1.Expires.is;
        let Month;
        (function (Month) {
            Month.is = Expires_1.Expires.Month.is;
        })(Month = Expires.Month || (Expires.Month = {}));
        let Year;
        (function (Year) {
            Year.is = Expires_1.Expires.Year.is;
        })(Year = Expires.Year || (Expires.Year = {}));
        let Type;
        (function (Type) {
            Type.is = Type_1.Type.is;
        })(Type = Expires.Type || (Expires.Type = {}));
    })(Expires = Card.Expires || (Card.Expires = {}));
    let Token;
    (function (Token) {
        Token.is = Token_1.Token.is;
        Token.verify = Token_1.Token.verify;
        Token.getVerificationTarget = Token_1.Token.getVerificationTarget;
    })(Token = Card.Token || (Card.Token = {}));
    let V1$1;
    (function (V1$1) {
        V1$1.is = V1.Card.is;
        V1$1.from = V1.Card.from;
        V1$1.generateId = V1.Card.generateId;
        let Token;
        (function (Token) {
            Token.is = V1.Card.Token.is;
            Token.verify = V1.Card.Token.verify;
            Token.hasInfo = V1.Card.Token.hasInfo;
        })(Token = V1$1.Token || (V1$1.Token = {}));
    })(V1$1 = Card.V1 || (Card.V1 = {}));
})(Card = exports.Card || (exports.Card = {}));

});

const index$b = /*@__PURE__*/_commonjsHelpers.getDefaultExportFromCjs(Card_1);

var Creatable_1$4 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Creatable = void 0;
var Creatable;
(function (Creatable) {
    function is(value) {
        return ((value.amount == undefined || typeof value.amount == "number") &&
            (value.descriptor == undefined || typeof value.descriptor == "string") &&
            Object.keys(value).every(key => key == "amount" || key == "descriptor"));
    }
    Creatable.is = is;
})(Creatable = exports.Creatable || (exports.Creatable = {}));

});

const index$c = /*@__PURE__*/_commonjsHelpers.getDefaultExportFromCjs(Creatable_1$4);

var Refund_1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Refund = void 0;



var Refund;
(function (Refund) {
    function is(value) {
        return (typeof value == "object" &&
            index$m.dist.Identifier.is(value.id) &&
            typeof value.amount == "number" &&
            (value.descriptor == undefined || typeof value.descriptor == "string") &&
            index$n.dist.DateTime.is(value.created));
    }
    Refund.is = is;
    let Creatable;
    (function (Creatable) {
        Creatable.is = Creatable_1$4.Creatable.is;
    })(Creatable = Refund.Creatable || (Refund.Creatable = {}));
})(Refund = exports.Refund || (exports.Refund = {}));

});

const index$d = /*@__PURE__*/_commonjsHelpers.getDefaultExportFromCjs(Refund_1);

var Base_1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Base = void 0;


var Base;
(function (Base) {
    function is(value) {
        return (typeof value == "object" &&
            (value.number == undefined || typeof value.number == "string") &&
            (value.descriptor == undefined || typeof value.descriptor == "string") &&
            (value.ip == undefined || typeof value.ip == "string") &&
            ((value.amount == undefined && value.currency == undefined) ||
                (typeof value.amount == "number" && index$n.dist.Currency.is(value.currency))) &&
            (value.account == "create" || value.account == undefined || index$m.dist.Token.is(value.account)) &&
            (value.callback == undefined || typeof value.callback == "string"));
    }
    Base.is = is;
})(Base = exports.Base || (exports.Base = {}));

});

const Base = /*@__PURE__*/_commonjsHelpers.getDefaultExportFromCjs(Base_1);

var Safe_1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Safe = void 0;


var Safe;
(function (Safe) {
    function is(value) {
        return typeof value == "object" && (value.card == undefined || index$m.dist.Token.is(value.card)) && Base_1.Base.is(value);
    }
    Safe.is = is;
})(Safe = exports.Safe || (exports.Safe = {}));

});

const Safe = /*@__PURE__*/_commonjsHelpers.getDefaultExportFromCjs(Safe_1);

var Unsafe_1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Unsafe = void 0;




var Unsafe;
(function (Unsafe) {
    function is(value) {
        return (typeof value == "object" &&
            ((typeof value.amount == "number" &&
                index$n.dist.Currency.is(value.currency) &&
                ((Card_1.Card.Creatable.is(value.card) && (value.account == "create" || value.account == undefined)) ||
                    index$m.dist.Token.is(value.account))) ||
                (value.amount == undefined &&
                    value.currency == undefined &&
                    Card_1.Card.Creatable.is(value.card) &&
                    value.account == "create")) &&
            Base_1.Base.is(value));
    }
    Unsafe.is = is;
})(Unsafe = exports.Unsafe || (exports.Unsafe = {}));

});

const Unsafe = /*@__PURE__*/_commonjsHelpers.getDefaultExportFromCjs(Unsafe_1);

var Creatable_1$5 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Creatable = void 0;



var Creatable;
(function (Creatable) {
    function is(value) {
        return Safe_1.Safe.is(value) || Unsafe_1.Unsafe.is(value);
    }
    Creatable.is = is;
    let Base;
    (function (Base) {
        Base.is = Base_1.Base.is;
    })(Base = Creatable.Base || (Creatable.Base = {}));
    let Safe;
    (function (Safe) {
        Safe.is = Safe_1.Safe.is;
    })(Safe = Creatable.Safe || (Creatable.Safe = {}));
    let Unsafe;
    (function (Unsafe) {
        Unsafe.is = Unsafe_1.Unsafe.is;
    })(Unsafe = Creatable.Unsafe || (Creatable.Unsafe = {}));
})(Creatable = exports.Creatable || (exports.Creatable = {}));

});

const index$e = /*@__PURE__*/_commonjsHelpers.getDefaultExportFromCjs(Creatable_1$5);

var Authorization_1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Authorization = void 0;








var Authorization;
(function (Authorization) {
    function is(value) {
        return (typeof value == "object" &&
            index$m.dist.Identifier.is(value.id) &&
            (value.number == undefined || typeof value.number == "string") &&
            typeof value.reference == "string" &&
            (value.descriptor == undefined || typeof value.descriptor == "string") &&
            (value.ip == undefined || typeof value.ip == "string") &&
            index$n.dist.DateTime.is(value.created) &&
            ((typeof value.amount == "number" && index$n.dist.Currency.is(value.currency)) ||
                (value.amount == undefined && value.currency == undefined)) &&
            Card_1.Card.is(value.card) &&
            Array.isArray(value.capture) &&
            value.capture.every(Capture_1.Capture.is) &&
            Array.isArray(value.refund) &&
            value.refund.every(Refund_1.Refund.is) &&
            (value.cancel == undefined || Cancel_1.Cancel.is(value.cancel)) &&
            (value.callback == undefined || typeof value.callback == "string"));
    }
    Authorization.is = is;
    const transformers = [new index$m.dist.Property.Typeguard(is)];
    const verifier = Verifier_1.Verifier.create().add(...transformers);
    async function verify(token) {
        return verifier.verify(token);
    }
    Authorization.verify = verify;
    let Creatable;
    (function (Creatable) {
        Creatable.is = Creatable_1$5.Creatable.is;
        let Base;
        (function (Base) {
            Base.is = Creatable_1$5.Creatable.Base.is;
        })(Base = Creatable.Base || (Creatable.Base = {}));
        let Safe;
        (function (Safe) {
            Safe.is = Creatable_1$5.Creatable.Safe.is;
        })(Safe = Creatable.Safe || (Creatable.Safe = {}));
        let Unsafe;
        (function (Unsafe) {
            Unsafe.is = Creatable_1$5.Creatable.Unsafe.is;
        })(Unsafe = Creatable.Unsafe || (Creatable.Unsafe = {}));
    })(Creatable = Authorization.Creatable || (Authorization.Creatable = {}));
})(Authorization = exports.Authorization || (exports.Authorization = {}));

});

const index$f = /*@__PURE__*/_commonjsHelpers.getDefaultExportFromCjs(Authorization_1);

var CategoryCode_1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.CategoryCode = void 0;
var CategoryCode;
(function (CategoryCode) {
    function is(value) {
        return typeof value == "string" && value.length == 4 && Array.from(value).every(c => c >= "0" && c <= "9");
    }
    CategoryCode.is = is;
    function flaw(value) {
        return { type: "string", condition: "Four digits." };
    }
    CategoryCode.flaw = flaw;
})(CategoryCode = exports.CategoryCode || (exports.CategoryCode = {}));

});

const CategoryCode = /*@__PURE__*/_commonjsHelpers.getDefaultExportFromCjs(CategoryCode_1);

var Protocol_1$1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Protocol = void 0;
var Protocol;
(function (Protocol) {
    function is(value) {
        return value == "ch3d1" || value == "ch3d2";
    }
    Protocol.is = is;
    function flaw(value) {
        return { type: "model.Merchant.Emv3d.Protocol", condition: '"ch3d1" | "ch3d2"' };
    }
    Protocol.flaw = flaw;
})(Protocol = exports.Protocol || (exports.Protocol = {}));

});

const Protocol$1 = /*@__PURE__*/_commonjsHelpers.getDefaultExportFromCjs(Protocol_1$1);

var Configuration_1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Configuration = void 0;


var Configuration;
(function (Configuration) {
    function is(value) {
        return (typeof value == "object" &&
            Protocol_1$1.Protocol.is(value.protocol) &&
            typeof value.url == "string" &&
            typeof value.key == "string");
    }
    Configuration.is = is;
    function flaw(value) {
        return {
            type: "model.Merchant.Emv3d.Configuration",
            flaws: typeof value != "object"
                ? undefined
                : [
                    Protocol_1$1.Protocol.is(value.protocol) || Protocol_1$1.Protocol.flaw(value.protocol),
                    typeof value.url == "string" || { property: "url", type: "string" },
                    typeof value.key == "string" || { property: "key", type: "string" },
                ].filter(dist.Flaw.is),
        };
    }
    Configuration.flaw = flaw;
})(Configuration = exports.Configuration || (exports.Configuration = {}));

});

const Configuration = /*@__PURE__*/_commonjsHelpers.getDefaultExportFromCjs(Configuration_1);

var Emv3d_1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Emv3d = void 0;


var Emv3d;
(function (Emv3d) {
    function is(value) {
        return Configuration_1.Configuration.is(value) || (Array.isArray(value) && value.every(Configuration_1.Configuration.is));
    }
    Emv3d.is = is;
    function flaw(value) {
        return {
            type: "model.Merchant.Emv3d",
            condition: "model.Merchant.Emv3d.Configuration | model.Merchant.Emv3d.Configuration[]",
        };
    }
    Emv3d.flaw = flaw;
    let Configuration;
    (function (Configuration) {
        Configuration.is = Configuration_1.Configuration.is;
        Configuration.flaw = Configuration_1.Configuration.flaw;
    })(Configuration = Emv3d.Configuration || (Emv3d.Configuration = {}));
    let Protocol;
    (function (Protocol) {
        Protocol.is = Protocol_1$1.Protocol.is;
        Protocol.flaw = Protocol_1$1.Protocol.flaw;
    })(Protocol = Emv3d.Protocol || (Emv3d.Protocol = {}));
})(Emv3d = exports.Emv3d || (exports.Emv3d = {}));

});

const index$g = /*@__PURE__*/_commonjsHelpers.getDefaultExportFromCjs(Emv3d_1);

var Creatable_2 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Creatable = void 0;






var Creatable;
(function (Creatable) {
    function is(value) {
        return (typeof value == "object" &&
            (value.descriptor == undefined || typeof value.descriptor == "string") &&
            (value.country == undefined || index$n.dist.CountryCode.Alpha2.is(value.country)) &&
            (value.acquirer == undefined || Creatable_1.Creatable.is(value.acquirer)) &&
            (value.mid == undefined || typeof value.mid == "string") &&
            (value.mcc == undefined || CategoryCode_1.CategoryCode.is(value.mcc)) &&
            (value.emv3d == undefined || Emv3d_1.Emv3d.is(value.emv3d)) &&
            (value.url == undefined || typeof value.url == "string") &&
            (value.id == undefined || index$m.dist.Identifier.is(value.id)));
    }
    Creatable.is = is;
    function flaw(value) {
        return {
            type: "model.Merchant.Card.Creatable",
            flaws: typeof value != "object"
                ? undefined
                : [
                    value.descriptor == undefined ||
                        typeof value.descriptor == "string" || { property: "descriptor", type: "string | undefined" },
                    value.country == undefined ||
                        index$n.dist.CountryCode.Alpha2.is(value.country) || {
                        property: "country",
                        type: "isoly.CountryCode | undefined",
                    },
                    value.acquirer == undefined ||
                        Creatable_1.Creatable.is(value.acquirer) || {
                        property: "acquirer",
                        type: "model.Acquirer.Creatable | undefined",
                    },
                    value.mid == undefined || typeof value.mid == "string" || { property: "mid", type: "string | undefined" },
                    value.mcc == undefined ||
                        CategoryCode_1.CategoryCode.is(value.mcc) || { property: "mcc", type: "model.Merchant.CategoryCode | undefined" },
                    value.emv3d == undefined || Emv3d_1.Emv3d.is(value.emv3d) || { property: "emv3d", ...Emv3d_1.Emv3d.flaw(value.emv3d) },
                    value.url == undefined || typeof value.url == "string" || { property: "url", type: "string | undefined" },
                    value.id == undefined ||
                        index$m.dist.Identifier.is(value.id) || { property: "id", type: "authly.Identifier | undefined" },
                ].filter(dist.Flaw.is),
        };
    }
    Creatable.flaw = flaw;
})(Creatable = exports.Creatable || (exports.Creatable = {}));

});

const Creatable$4 = /*@__PURE__*/_commonjsHelpers.getDefaultExportFromCjs(Creatable_2);

var Card_1$1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Card = void 0;







var Card;
(function (Card) {
    function is(value) {
        return (typeof value == "object" &&
            (value.descriptor == undefined || typeof value.descriptor == "string") &&
            index$n.dist.CountryCode.Alpha2.is(value.country) &&
            Acquirer_1.Acquirer.is(value.acquirer) &&
            (value.mid == undefined || typeof value.mid == "string") &&
            (value.mcc == undefined || CategoryCode_1.CategoryCode.is(value.mcc)) &&
            (value.emv3d == undefined || Emv3d_1.Emv3d.is(value.emv3d)) &&
            (value.url == undefined || typeof value.url == "string") &&
            (value.id == undefined || index$m.dist.Identifier.is(value.id)));
    }
    Card.is = is;
    function flaw(value) {
        return {
            type: "model.Merchant.Card",
            flaws: typeof value != "object"
                ? undefined
                : [
                    value.descriptor == undefined ||
                        typeof value.descriptor == "string" || { property: "descriptor", type: "string | undefined" },
                    index$n.dist.CountryCode.Alpha2.is(value.country) || { property: "country", type: "isoly.CountryCode" },
                    Acquirer_1.Acquirer.is(value.acquirer) || { property: "acquirer", type: "model.Acquirer" },
                    value.mid == undefined || typeof value.mid == "string" || { property: "mid", type: "string | undefined" },
                    value.mcc == undefined ||
                        CategoryCode_1.CategoryCode.is(value.mcc) || { property: "mcc", type: "model.Merchant.CategoryCode | undefined" },
                    value.emv3d == undefined || Emv3d_1.Emv3d.is(value.emv3d) || { property: "emv3d", ...Emv3d_1.Emv3d.flaw(value.emv3d) },
                    typeof value.url == "string" || { property: "url", type: "string" },
                    value.id == undefined ||
                        index$m.dist.Identifier.is(value.id) || { property: "id", type: "authly.Identifier | undefined" },
                ].filter(dist.Flaw.is),
        };
    }
    Card.flaw = flaw;
    let Creatable;
    (function (Creatable) {
        Creatable.is = Creatable_2.Creatable.is;
        Creatable.flaw = Creatable_2.Creatable.flaw;
    })(Creatable = Card.Creatable || (Card.Creatable = {}));
})(Card = exports.Card || (exports.Card = {}));

});

const index$h = /*@__PURE__*/_commonjsHelpers.getDefaultExportFromCjs(Card_1$1);

var Audience_1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Audience = void 0;
var Audience;
(function (Audience) {
    function is(value) {
        return value == "agent" || value == "private" || value == "account" || value == "public";
    }
    Audience.is = is;
})(Audience = exports.Audience || (exports.Audience = {}));

});

const Audience = /*@__PURE__*/_commonjsHelpers.getDefaultExportFromCjs(Audience_1);

var Key_1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Key = void 0;





var Key;
(function (Key) {
    function is(value) {
        return (typeof value == "object" &&
            index$m.dist.Identifier.is(value.sub) &&
            typeof value.iss == "string" &&
            (Audience_1.Audience.is(value.aud) || (Array.isArray(value.aud) && value.aud.every(Audience_1.Audience.is))) &&
            typeof value.iat == "number" &&
            typeof value.name == "string" &&
            typeof value.url == "string" &&
            Card_1$1.Card.is(value.card));
    }
    Key.is = is;
    function flaw(value) {
        var _a;
        return {
            type: "model.Merchant.Key",
            flaws: typeof value != "object"
                ? undefined
                : [
                    typeof value.sub == "string" || {
                        property: "sub",
                        type: "authly.Identifier",
                        condition: "Merchant identifier.",
                    },
                    typeof value.iss == "string" || { property: "iss", type: "string", condition: "Key issuer." },
                    Audience.is(value.aud) ||
                        (Array.isArray(value.aud) && value.aud.every(Audience.is)) || {
                        property: "aud",
                        type: `"agent" | "account" | "public" | "private"`,
                        condition: "Key audience.",
                    },
                    typeof value.iat == "number" || { property: "iat", type: "number", condition: "Issued timestamp." },
                    typeof value.name == "string" || { property: "name", type: "string" },
                    typeof value.url == "string" || { property: "url", type: "string" },
                    ...((_a = Creatable_2.Creatable.flaw(value.card).flaws) !== null && _a !== void 0 ? _a : [
                        { property: "card", type: "model.Merchant.Card.Creatable", flaws: undefined },
                    ]),
                ].filter(dist.Flaw.is),
        };
    }
    Key.flaw = flaw;
    function upgrade(key) {
        return key == undefined
            ? undefined
            : is(key)
                ? key
                : {
                    sub: key.sub,
                    iss: key.iss,
                    aud: key.aud,
                    iat: key.iat,
                    name: key.name,
                    url: key.url,
                    card: {
                        url: key.iss,
                        id: key.sub,
                        country: key.country,
                        acquirer: key.acquirer,
                        mid: key.mid,
                        mcc: key.mcc,
                        emv3d: key.emv3d,
                    },
                };
    }
    Key.upgrade = upgrade;
    async function extractCardUrl(key, ...audience) {
        var _a;
        let result;
        let unpacked;
        if (key) {
            unpacked = await index$m.dist.Verifier.create().verify(key, ...audience);
            if (unpacked && ((_a = unpacked.option) === null || _a === void 0 ? void 0 : _a.card)) {
                unpacked = await index$m.dist.Verifier.create().verify(unpacked.option.card, ...audience);
                result = unpacked === null || unpacked === void 0 ? void 0 : unpacked.iss;
            }
            else if (unpacked)
                result =
                    typeof unpacked.card == "object" && !Array.isArray(unpacked.card) && typeof unpacked.card.url == "string"
                        ? unpacked.card.url
                        : unpacked.iss;
        }
        return result;
    }
    Key.extractCardUrl = extractCardUrl;
    let Audience;
    (function (Audience) {
        Audience.is = Audience_1.Audience.is;
    })(Audience = Key.Audience || (Key.Audience = {}));
})(Key = exports.Key || (exports.Key = {}));

});

const index$i = /*@__PURE__*/_commonjsHelpers.getDefaultExportFromCjs(Key_1);

var V1$1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Key = void 0;



var Key;
(function (Key) {
    function is(value) {
        return (typeof value == "object" &&
            index$m.dist.Identifier.is(value.sub) &&
            typeof value.iss == "string" &&
            typeof value.iat == "number" &&
            (value.aud == "public" || value.aud == "private") &&
            typeof value.name == "string" &&
            typeof value.url == "string" &&
            Card_1$1.Card.is(value));
    }
    Key.is = is;
    function flaw(value) {
        return {
            type: "model.Merchant.V1.Key",
            flaws: typeof value != "object"
                ? undefined
                : [
                    typeof value.sub == "string" || {
                        property: "sub",
                        type: "authly.Identifier",
                        condition: "Merchant identifier.",
                    },
                    typeof value.iss == "string" || { property: "iss", type: "string", condition: "Key issuer." },
                    typeof value.aud == "string" || {
                        property: "aud",
                        type: `"public" | "private"`,
                        condition: "Key audience.",
                    },
                    typeof value.iat == "number" || { property: "iat", type: "number", condition: "Issued timestamp." },
                    typeof value.name == "string" || { property: "name", type: "string" },
                    typeof value.url == "string" || { property: "url", type: "string" },
                    ...(Card_1$1.Card.flaw(value).flaws || []),
                ].filter(dist.Flaw.is),
        };
    }
    Key.flaw = flaw;
})(Key = exports.Key || (exports.Key = {}));

});

const index$j = /*@__PURE__*/_commonjsHelpers.getDefaultExportFromCjs(V1$1);

var Merchant_1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Merchant = void 0;







var Merchant;
(function (Merchant) {
    function is(value) {
        return (typeof value == "object" &&
            index$m.dist.Identifier.is(value.id) &&
            typeof value.name == "string" &&
            typeof value.url == "string" &&
            Card_1$1.Card.is(value.card) &&
            typeof value.card.url == "string" &&
            (value.card.id == undefined || index$m.dist.Identifier.is(value.card.id)));
    }
    Merchant.is = is;
    function flaw(value) {
        var _a;
        return {
            type: "model.Merchant",
            flaws: typeof value != "object"
                ? undefined
                : [
                    index$m.dist.Identifier.is(value.id) || { property: "id", type: "authly.Identifier" },
                    typeof value.name == "string" || { property: "name", type: "string" },
                    typeof value.url == "string" || { property: "url", type: "string" },
                    ...((_a = Card_1$1.Card.flaw(value.card).flaws) !== null && _a !== void 0 ? _a : [
                        { property: "card", type: "model.Merchant.Configuration", flaws: undefined },
                    ]),
                ].filter(dist.Flaw.is),
        };
    }
    Merchant.flaw = flaw;
    let Card;
    (function (Card) {
        Card.is = Card_1$1.Card.is;
        Card.flaw = Card_1$1.Card.flaw;
        let Creatable;
        (function (Creatable) {
            Creatable.is = Creatable_2.Creatable.is;
            Creatable.flaw = Creatable_2.Creatable.flaw;
        })(Creatable = Card.Creatable || (Card.Creatable = {}));
    })(Card = Merchant.Card || (Merchant.Card = {}));
    let Emv3d;
    (function (Emv3d) {
        Emv3d.is = Emv3d_1.Emv3d.is;
        Emv3d.flaw = Emv3d_1.Emv3d.flaw;
        let Configuration;
        (function (Configuration) {
            Configuration.is = Emv3d_1.Emv3d.Configuration.is;
            Configuration.flaw = Emv3d_1.Emv3d.Configuration.flaw;
        })(Configuration = Emv3d.Configuration || (Emv3d.Configuration = {}));
        let Protocol;
        (function (Protocol) {
            Protocol.is = Emv3d_1.Emv3d.Protocol.is;
            Protocol.flaw = Emv3d_1.Emv3d.Protocol.flaw;
        })(Protocol = Emv3d.Protocol || (Emv3d.Protocol = {}));
    })(Emv3d = Merchant.Emv3d || (Merchant.Emv3d = {}));
    let Key;
    (function (Key) {
        Key.is = Key_1.Key.is;
        Key.flaw = Key_1.Key.flaw;
        Key.extractCardUrl = Key_1.Key.extractCardUrl;
        Key.upgrade = Key_1.Key.upgrade;
        let Audience;
        (function (Audience) {
            Audience.is = Key_1.Key.Audience.is;
        })(Audience = Key.Audience || (Key.Audience = {}));
    })(Key = Merchant.Key || (Merchant.Key = {}));
    let V1;
    (function (V1) {
        let Key;
        (function (Key) {
            Key.is = V1$1.Key.is;
            Key.flaw = V1$1.Key.flaw;
        })(Key = V1.Key || (V1.Key = {}));
    })(V1 = Merchant.V1 || (Merchant.V1 = {}));
})(Merchant = exports.Merchant || (exports.Merchant = {}));

});

const index$k = /*@__PURE__*/_commonjsHelpers.getDefaultExportFromCjs(Merchant_1);

var dist$1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Refund = exports.Merchant = exports.Card = exports.Cancel = exports.Capture = exports.Browser = exports.Authorization = exports.Acquirer = exports.Account = void 0;

Object.defineProperty(exports, "Account", { enumerable: true, get: function () { return Account_1.Account; } });

Object.defineProperty(exports, "Acquirer", { enumerable: true, get: function () { return Acquirer_1.Acquirer; } });

Object.defineProperty(exports, "Authorization", { enumerable: true, get: function () { return Authorization_1.Authorization; } });

Object.defineProperty(exports, "Browser", { enumerable: true, get: function () { return Browser_1.Browser; } });

Object.defineProperty(exports, "Cancel", { enumerable: true, get: function () { return Cancel_1.Cancel; } });

Object.defineProperty(exports, "Capture", { enumerable: true, get: function () { return Capture_1.Capture; } });

Object.defineProperty(exports, "Card", { enumerable: true, get: function () { return Card_1.Card; } });

Object.defineProperty(exports, "Merchant", { enumerable: true, get: function () { return Merchant_1.Merchant; } });

Object.defineProperty(exports, "Refund", { enumerable: true, get: function () { return Refund_1.Refund; } });

});

const index$l = /*@__PURE__*/_commonjsHelpers.getDefaultExportFromCjs(dist$1);

const styleCss = ".sc-payfunc-card-input-h{display:block;height:83px;overflow:hidden;width:100%}[hidden].sc-payfunc-card-input-h{display:none}.sc-payfunc-card-input-h>smoothly-dialog.sc-payfunc-card-input{top:60px}.sc-payfunc-card-input-h>smoothly-dialog.sc-payfunc-card-input>*.sc-payfunc-card-input{border:none}";

const PayfuncCardInput = class {
  constructor(hostRef) {
    index$o.registerInstance(this, hostRef);
    this.changed = index$o.createEvent(this, "changed", 7);
    this.state = "created";
  }
  async componentWillLoad() {
    this.merchant = await model.MerchantKeyInfoUnpack(this.apiKey);
    const styleLink = document.querySelector("link[rel=stylesheet][href^='https://theme.payfunc.com/']");
    if (styleLink) {
      const themeLink = styleLink.href.substring(26);
      this.theme = themeLink.substring(0, themeLink.indexOf("/"));
    }
  }
  async handleTrigger(event) {
    var _a, _b, _c, _d, _e, _f;
    if (event.detail.value &&
      event.detail.value.status == 400 &&
      event.detail.value.type == "missing property" &&
      event.detail.value.content &&
      event.detail.value.content.property == "pares") {
      this.verify = {
        show: true,
        data: { pareq: event.detail.value.content.pareq },
        url: event.detail.value.content.url,
        issuer: (_c = (_b = (_a = this.merchant) === null || _a === void 0 ? void 0 : _a.card) === null || _b === void 0 ? void 0 : _b.url) !== null && _c !== void 0 ? _c : "",
      };
    }
    else if (event.detail.value &&
      event.detail.value.status == 400 &&
      event.detail.value.type == "malformed content" &&
      event.detail.value.content &&
      event.detail.value.content.description == "verification required" &&
      event.detail.value.content.details &&
      event.detail.value.content.details.url) {
      this.verify = {
        show: event.detail.value.content.details.visible,
        data: event.detail.value.content.details.data,
        url: event.detail.value.content.details.url,
        issuer: (_f = (_e = (_d = this.merchant) === null || _d === void 0 ? void 0 : _d.card) === null || _e === void 0 ? void 0 : _e.url) !== null && _f !== void 0 ? _f : "",
      };
    }
    else if (event.detail.name == "card") {
      this.verify = undefined;
      if (index$m.dist.Token.is(event.detail.value)) {
        this.value = event.detail.value;
        await this.updateCard();
      }
      this.frame.send("card", {
        name: "cardCheck",
        value: { card: this.value, key: this.apiKey, parent: window.location.origin },
      });
    }
    else {
      this.verify = undefined;
      if (index$m.dist.Token.is(event.detail.value)) {
        this.changed.emit((this.value = event.detail.value));
        await this.updateCard();
      }
      this.state = event.detail.name == "cardTokenSuccess" ? (this.state = "succeeded") : (this.state = "failed");
      if (this.received) {
        this.received(this.state, event.detail.value);
        this.received = undefined;
      }
    }
  }
  async updateCard() {
    var _a, _b, _c, _d, _e;
    if (this.value) {
      const verified = (_e = (_d = (_c = (_b = (await ((_a = index$m.dist.Verifier.create()) === null || _a === void 0 ? void 0 : _a.verify(this.value)))) === null || _b === void 0 ? void 0 : _b.card) !== null && _c !== void 0 ? _c : (await dist$1.Card.Token.verify(this.value))) !== null && _d !== void 0 ? _d : this.value) !== null && _e !== void 0 ? _e : "error";
      if (typeof verified == "string" || dist$1.Card.Token.is(verified))
        this.cardId = verified;
    }
  }
  submit(input, error) {
    if (index$m.dist.Token.is(input))
      this.value = input;
    return new Promise(callback => {
      if (this.frame) {
        this.received = (_, response) => callback(response);
        const value = { card: this.value, key: this.apiKey, parent: window.location.origin };
        this.frame.send("card", !error ? { name: "submit", value } : { name: "cardCheck", value: Object.assign(Object.assign({}, value), { error }) });
        this.state = "processing";
      }
    });
  }
  getIframeUrl(data) {
    var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
    const callback = dist$1.Card.Token.is(this.cardId) && ((_a = this.verify) === null || _a === void 0 ? void 0 : _a.issuer)
      ? dist$1.Card.Token.getVerificationTarget(this.cardId, (_b = this.verify) === null || _b === void 0 ? void 0 : _b.issuer, encodeURIComponent(window.location.origin))
      : `${(_c = this.verify) === null || _c === void 0 ? void 0 : _c.issuer}/card/${this.cardId}/verification?mode=iframe&merchant=${(_h = (_f = (_e = (_d = this.merchant) === null || _d === void 0 ? void 0 : _d.card) === null || _e === void 0 ? void 0 : _e.id) !== null && _f !== void 0 ? _f : (_g = this.merchant) === null || _g === void 0 ? void 0 : _g.sub) !== null && _h !== void 0 ? _h : "error"}&parent=${encodeURIComponent(window.location.origin)}`;
    console.log("Callback is ", callback);
    data = (_l = (_k = (_j = this.ch3d1Data(data, callback)) !== null && _j !== void 0 ? _j : this.ch3d2MethodData(data, callback)) !== null && _k !== void 0 ? _k : this.ch3d2ChallengeData(data, callback)) !== null && _l !== void 0 ? _l : data;
    const result = typeof data == "object" && Object.entries(data).length > 0
      ? Object.entries(data).reduce((a, b) => a + "&" + encodeURIComponent(b[0]) + "=" + encodeURIComponent(b[1]), "")
      : "";
    return "https://api.payfunc.com/redirect/post?target=" + encodeURIComponent((_o = (_m = this.verify) === null || _m === void 0 ? void 0 : _m.url) !== null && _o !== void 0 ? _o : "") + result;
  }
  ch3d1Data(data, callback) {
    var _a;
    let result = undefined;
    if (data.PaReq || data.pareq) {
      result = Object.assign({}, data);
      if (result.pareq) {
        result.PaReq = result.pareq;
        delete result.pareq;
      }
      if (!result.TermUrl)
        result.TermUrl = callback;
      if (!result.MD)
        result.MD = (_a = this.value) !== null && _a !== void 0 ? _a : "error";
    }
    return result;
  }
  ch3d2MethodData(data, callback) {
    let result = undefined;
    if (data.type == "method" && data.threeDSServerTransID) {
      result = {
        threeDSMethodData: index$m.dist.Base64.encode(JSON.stringify({
          threeDSServerTransID: data.threeDSServerTransID,
          threeDSMethodNotificationURL: callback,
        }), "url", "="),
      };
    }
    return result;
  }
  ch3d2ChallengeData(data, callback) {
    let result = undefined;
    if (data.type == "challenge" && data.threeDSServerTransID) {
      result = {
        creq: index$m.dist.Base64.encode(JSON.stringify({
          threeDSServerTransID: data.threeDSServerTransID,
          acsTransID: data.acsTransID,
          messageVersion: data.messageVersion,
          messageType: data.messageType,
          challengeWindowSize: data.challengeWindowSize,
        }), "url", "="),
      };
    }
    return result;
  }
  render() {
    var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
    return [
      this.merchant ? (index$o.h("smoothly-frame", { url: ((_b = (_a = this.merchant) === null || _a === void 0 ? void 0 : _a.card) === null || _b === void 0 ? void 0 : _b.url) + "/ui/card-tokenizer/" + (this.theme ? "?theme=" + this.theme : ""), origin: ((_d = (_c = this.merchant) === null || _c === void 0 ? void 0 : _c.card) === null || _d === void 0 ? void 0 : _d.url) ? new URL((_f = (_e = this.merchant) === null || _e === void 0 ? void 0 : _e.card) === null || _f === void 0 ? void 0 : _f.url).origin : undefined, name: "card", ref: (element) => (this.frame = element) })) : ([]),
      this.verify ? (this.verify.show ? (index$o.h("smoothly-dialog", { color: "default", closable: true }, index$o.h("smoothly-frame", { url: this.getIframeUrl(this.verify.data), origin: ((_h = (_g = this.merchant) === null || _g === void 0 ? void 0 : _g.card) === null || _h === void 0 ? void 0 : _h.url) ? new URL((_k = (_j = this.merchant) === null || _j === void 0 ? void 0 : _j.card) === null || _k === void 0 ? void 0 : _k.url).origin : undefined, name: "parent", style: { height: "90vh" } }))) : (index$o.h("smoothly-frame", { hidden: true, url: this.getIframeUrl(this.verify.data), origin: ((_m = (_l = this.merchant) === null || _l === void 0 ? void 0 : _l.card) === null || _m === void 0 ? void 0 : _m.url) ? new URL((_p = (_o = this.merchant) === null || _o === void 0 ? void 0 : _o.card) === null || _p === void 0 ? void 0 : _p.url).origin : undefined, name: "parent", style: { height: "90vh" } }))) : ([]),
    ];
  }
};
PayfuncCardInput.style = styleCss;

exports.payfunc_card_input = PayfuncCardInput;
