"use strict";
var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        if (typeof b !== "function" && b !== null)
            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var framepay_error_1 = __importDefault(require("../../framepay-error"));
var base_element_1 = __importDefault(require("./base-element"));
var ApplePayElement = /** @class */ (function (_super) {
    __extends(ApplePayElement, _super);
    function ApplePayElement() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    ApplePayElement.prototype.setupElement = function () {
        var _this = this;
        var Framepay = this.props.Framepay;
        var makeElement = function () {
            // elementNode already checked in BaseElement.handleSetupElement
            // just ts checks fix
            if (!_this.elementNode) {
                throw (0, framepay_error_1.default)({
                    code: framepay_error_1.default.codes.elementMountError,
                    details: "ApplePayElement invalid elementNode",
                });
            }
            try {
                return Framepay.applePay.mount(_this.elementNode);
            }
            catch (e) {
                throw (0, framepay_error_1.default)({
                    code: framepay_error_1.default.codes.elementMountError,
                    details: "ApplePayElement error in remote api call",
                    trace: e,
                });
            }
        };
        var element = makeElement();
        this.setState({ element: element });
    };
    return ApplePayElement;
}(base_element_1.default));
exports.default = ApplePayElement;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXBwbGVwYXktZWxlbWVudC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3NyYy9saWIvY29tcG9uZW50cy9lbGVtZW50c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