import { __extends } from "tslib";
import { PDFAnnotation, PDFDict, PDFName } from "../..";
import { acroFormFieldTypes, PDFAcroButton, PDFAcroChoice, PDFAcroField, PDFAcroText, PDFSignature, } from './index';
var PDFTerminalField = /** @class */ (function (_super) {
    __extends(PDFTerminalField, _super);
    function PDFTerminalField(dict) {
        var _this = _super.call(this, dict) || this;
        _this.validateFieldType();
        return _this;
    }
    PDFTerminalField.fromDict = function (dict) {
        var fieldType = dict.lookup(PDFName.FT, PDFName);
        switch (fieldType) {
            case PDFName.Btn:
                return PDFAcroButton.fromDict(dict);
            case PDFName.Tx:
                return PDFAcroText.fromDict(dict);
            case PDFName.Ch:
                return PDFAcroChoice.fromDict(dict);
            case PDFName.Sig:
                return PDFSignature.fromDict(dict);
            default:
                return new PDFTerminalField(dict);
        }
    };
    PDFTerminalField.prototype.FT = function () {
        return this.lookupMaybeInheritableAttribute(PDFName.FT, PDFName);
    };
    PDFTerminalField.prototype.getKids = function () {
        var _a, _b;
        var kidDicts = (_a = this.Kids()) === null || _a === void 0 ? void 0 : _a.lookupElements(PDFDict);
        return (_b = kidDicts) === null || _b === void 0 ? void 0 : _b.map(function (childDict) { return PDFAnnotation.fromDict(childDict); });
    };
    PDFTerminalField.prototype.validateFieldType = function () {
        var fieldType = this.FT();
        var hasValidFieldType = acroFormFieldTypes.includes(fieldType);
        if (!hasValidFieldType) {
            throw new Error('Invalid PDFAcroField Type');
        }
    };
    return PDFTerminalField;
}(PDFAcroField));
export default PDFTerminalField;
//# sourceMappingURL=PDFTerminalField.js.map