import { __extends } from "tslib";
import { PDFName, PDFNumber } from "../..";
import { PDFCheckBox, PDFPushButton, PDFRadioButton, PDFTerminalField, } from './index';
var PDFAcroButton = /** @class */ (function (_super) {
    __extends(PDFAcroButton, _super);
    function PDFAcroButton(dict) {
        return _super.call(this, dict) || this;
    }
    PDFAcroButton.fromDict = function (dict) {
        var _a;
        var fieldFlags = ((_a = dict.lookupMaybe(PDFName.Ff, 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 PDFPushButton.fromDict(dict);
        }
        else if (isRadioButton) {
            return PDFRadioButton.fromDict(dict);
        }
        else {
            return PDFCheckBox.fromDict(dict);
        }
    };
    return PDFAcroButton;
}(PDFTerminalField));
export default PDFAcroButton;
//# sourceMappingURL=PDFAcroButton.js.map