"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var core_1 = require("../..");
var index_1 = require("./index");
var PDFAcroButton = /** @class */ (function (_super) {
    tslib_1.__extends(PDFAcroButton, _super);
    function PDFAcroButton(dict) {
        return _super.call(this, dict) || this;
    }
    PDFAcroButton.fromDict = function (dict) {
        var _a;
        var fieldFlags = ((_a = dict.lookupMaybe(core_1.PDFName.Ff, core_1.PDFNumber)) === null || _a === void 0 ? void 0 : _a.value()) || 0;
        var pushButtonFlag = 1 << 16;
        var radioButtonFlag = 1 << 15;
        var isPushButton = !!(fieldFlags & pushButtonFlag);
        var isRadioButton = !!(fieldFlags & radioButtonFlag);
        if (isPushButton && isRadioButton) {
            throw new Error('Invalid button field flags');
        }
        else if (isPushButton) {
            return index_1.PDFPushButton.fromDict(dict);
        }
        else if (isRadioButton) {
            return index_1.PDFRadioButton.fromDict(dict);
        }
        else {
            return index_1.PDFCheckBox.fromDict(dict);
        }
    };
    return PDFAcroButton;
}(index_1.PDFTerminalField));
exports.default = PDFAcroButton;
//# sourceMappingURL=PDFAcroButton.js.map