var __extends = (this && this.__extends) || (function () {
    var extendStatics = Object.setPrototypeOf ||
        ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
        function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var F01285;
(function (F01285) {
    var InterfaceRules = (function () {
        function InterfaceRules(_document) {
            this._document = _document;
        }
        InterfaceRules.prototype.FilterNPAStatuses = function () {
            var npaStatusesTable = ObasTableCollection.NpaStatusesSprTable;
            return npaStatusesTable.RecordKey.Value === 1 || npaStatusesTable.RecordKey.Value === 2;
        };
        InterfaceRules.prototype.CountMonthForCalcSheetFormatEventHandler = function (sheetId, row, column, groupIndex) {
            if (column > 1) {
                return SheetFormatCollection.Free;
            }
            else {
                return SheetFormatCollection.Default;
            }
        };
        InterfaceRules.prototype.CountMonthForCalcSheetCanEditEventHandler = function (sheetId, row, column, fieldId, rowLevel) {
            return column > 1;
        };
        InterfaceRules.prototype.ShiftDataMenuItemClickEventHandler = function () {
            this._document.UpdateRules.ShiftData();
        };
        InterfaceRules.prototype.CopyDataMenuItemClickEventHandler = function () {
            this._document.UpdateRules.CopyData();
        };
        InterfaceRules.prototype.RecalcDataMenuItemClickEventHandler = function () {
            this._document.UpdateRules.RecalcData();
        };
        return InterfaceRules;
    }());
    InterfaceRules.TotalRowName = "Всего";
    InterfaceRules.TotalRowCode = 90100;
    InterfaceRules.TotalRowCodeLength = 5;
    InterfaceRules.SubTotalRowName = "Итого по учреждению";
    InterfaceRules.FotRowCodeInfo = {
        Column: 1,
        Length: 3,
        LevelIncs: [10, 1],
        CalcTotalCode: function () {
            return -1;
        }
    };
    InterfaceRules.TotalRowInfo = {
        IsCalculated: false,
        Name: InterfaceRules.TotalRowName,
        Format: SheetFormatCollection.Default
    };
    InterfaceRules.TotalOrgRowInfo = {
        IsCalculated: false,
        Name: InterfaceRules.SubTotalRowName,
        Format: SheetFormatCollection.Default
    };
    F01285.InterfaceRules = InterfaceRules;
    var SheetP1RelRows;
    (function (SheetP1RelRows) {
        SheetP1RelRows[SheetP1RelRows["Fot"] = 0] = "Fot";
        SheetP1RelRows[SheetP1RelRows["Change"] = 1] = "Change";
        SheetP1RelRows[SheetP1RelRows["Total"] = 2] = "Total";
    })(SheetP1RelRows || (SheetP1RelRows = {}));

    var YearsSheetTyped = (function (_super) {
        __extends(YearsSheetTyped, _super);
        function YearsSheetTyped(id, _document, _rowCodeInfo, _totalRowCount) {
            if (_totalRowCount === void 0) { _totalRowCount = 1; }
            var _this = _super.call(this, id, false) || this;
            _this._document = _document;
            _this._rowCodeInfo = _rowCodeInfo;
            _this._totalRowCount = _totalRowCount;
            _this._lastColumn = null;
            _this._rowCodeColumn = _rowCodeInfo.Column;
            _this._rowNameColumn = _this._rowCodeColumn - 1;
            return _this;
        }
        Object.defineProperty(YearsSheetTyped.prototype, "Document", {
            get: function () {
                return this._document;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(YearsSheetTyped.prototype, "YearsCount", {
            get: function () {
                return this._document.Settings.YearsCount;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(YearsSheetTyped.prototype, "StartDataColumn", {
            get: function () {
                return this.RowCodeColumn + 1;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(YearsSheetTyped.prototype, "RowCodeColumn", {
            get: function () {
                return this._rowCodeColumn;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(YearsSheetTyped.prototype, "RowNameColumn", {
            get: function () {
                return this._rowNameColumn;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(YearsSheetTyped.prototype, "LastColumn", {
            get: function () {
                if (this._lastColumn == null) {
                    this._lastColumn = this.ColumnCount - 1;
                }
                return this._lastColumn;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(YearsSheetTyped.prototype, "RowCodeInfo", {
            get: function () {
                return this._rowCodeInfo;
            },
            enumerable: true,
            configurable: true
        });
        YearsSheetTyped.prototype.CalcRelColumn = function (column) {
            return this.CalcOffsetCol(column) % this.YearsCount;
        };
        YearsSheetTyped.prototype.CalcOffsetCol = function (column) {
            return column - this.StartDataColumn;
        };
        YearsSheetTyped.prototype.CalcStartBlockColumn = function (block) {
            return this.StartDataColumn + this.YearsCount * block;
        };
        YearsSheetTyped.prototype.CalcEndBlockColumn = function (block) {
            return this.StartDataColumn + this.YearsCount * (block + 1) - 1;
        };
        YearsSheetTyped.prototype.IsDataColumn = function (column) {
            return this.CalcOffsetCol(column) >= 0;
        };
        YearsSheetTyped.prototype.CalcDataColumnBlock = function (column) {
            return (this.CalcOffsetCol(column) / this.YearsCount) | 0;
        };
        YearsSheetTyped.prototype.IsColumnInDataBlock = function (column, block) {
            return ((this.CalcDataColumnBlock(column) === block) && this.IsDataColumn(column));
        };
        YearsSheetTyped.prototype.IsFooterRow = function (row) {
            return this.Document.CommonRules.IsFooterRow(this, row, this._totalRowCount);
        };
        Object.defineProperty(YearsSheetTyped.prototype, "TotalRowCount", {
            get: function () {
                return this._totalRowCount;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(YearsSheetTyped.prototype, "StartFooterRow", {
            get: function () {
                return this.RowCount - this.TotalRowCount;
            },
            enumerable: true,
            configurable: true
        });
        YearsSheetTyped.prototype.CalcRowCode = function (row) {
            return ObasHelper.FillWithCharacter(row + this._rowCodeInfo.LevelIncs[this._rowCodeInfo.LevelIncs.length - 1], this._rowCodeInfo.Length);
        };
        return YearsSheetTyped;
    }(Sheet));
    var YearsSheet = (function (_super) {
        __extends(YearsSheet, _super);
        function YearsSheet() {
            return _super !== null && _super.apply(this, arguments) || this;
        }
        return YearsSheet;
    }(YearsSheetTyped));
    var RelRowsYearsSheetTyped = (function (_super) {
        __extends(RelRowsYearsSheetTyped, _super);
        function RelRowsYearsSheetTyped(id, document, rowCodeInfo, _relRowCount, totalRowCount) {
            if (_relRowCount === void 0) { _relRowCount = 1; }
            if (totalRowCount === void 0) { totalRowCount = _relRowCount; }
            var _this = _super.call(this, id, document, rowCodeInfo, totalRowCount) || this;
            _this._relRowCount = _relRowCount;
            return _this;
        }
        Object.defineProperty(RelRowsYearsSheetTyped.prototype, "RelRowCount", {
            get: function () {
                return this._relRowCount;
            },
            enumerable: true,
            configurable: true
        });
        RelRowsYearsSheetTyped.prototype.CalcRelRow = function (row) {
            return row % this._relRowCount;
        };
        RelRowsYearsSheetTyped.prototype.GetRowByRelRow = function (curRow, relRow) {
            var orgNum = (curRow / this.RelRowCount) | 0;
            return relRow + orgNum * this.RelRowCount;
        };
        RelRowsYearsSheetTyped.prototype.CalcRelRowGroupIndex = function (row) {
            return (row / this.RelRowCount) | 0;
        };
        RelRowsYearsSheetTyped.prototype.CalcRelRowCode = function (row) {
            var relRow = (row + 1) % this.RelRowCount;
            var relRow2 = ((row + 1) / this.RelRowCount) | 0;
            var code = relRow2 * this.RowCodeInfo.LevelIncs[0];
            if (relRow !== 0) {
                code += relRow * this.RowCodeInfo.LevelIncs[1];
            }
            return ObasHelper.FillWithCharacter(code, this.RowCodeInfo.Length);
        };
        return RelRowsYearsSheetTyped;
    }(YearsSheetTyped));
    F01285.RelRowsYearsSheetTyped = RelRowsYearsSheetTyped;
    var RelRowsYearsSheet = (function (_super) {
        __extends(RelRowsYearsSheet, _super);
        function RelRowsYearsSheet() {
            return _super !== null && _super.apply(this, arguments) || this;
        }
        return RelRowsYearsSheet;
    }(RelRowsYearsSheetTyped));
    F01285.RelRowsYearsSheet = RelRowsYearsSheet;

    var SheetPXSp2 = (function (_super) {
        __extends(SheetPXSp2, _super);
        function SheetPXSp2(id, _document) {
            var _this = _super.call(this, id, false) || this;
            _this._document = _document;
            return _this;
        }
        SheetPXSp2.prototype.CalcRelRow = function (row) {
            return row % SheetPXSp2._relRowCount;
        };
        SheetPXSp2.prototype.FormatEventHandler = function (sheetId, row, column, groupIndex) {
            if (!this._document.CommonRules.IsFooterRow(this, row, SheetPXSp2._totalRowCount)) {
                if (column < 2) {
                    return SheetFormatCollection.Related;
                }
                else if (column < 4) {
                    return SheetFormatCollection.Default;
                }
                else {
                    var relRow = this.CalcRelRow(row);
                    if (relRow === (SheetPXSp2._relRowCount - 1)) {
                        return SheetFormatCollection.Calc;
                    }
                    else {
                        return SheetFormatCollection.Related;
                    }
                }
            }
            else {
                if (column < 4) {
                    return SheetFormatCollection.Default;
                }
                else {
                    return SheetFormatCollection.Calc;
                }
            }
        };
        return SheetPXSp2;
    }(Sheet));
    SheetPXSp2._relRowCount = ObasHelper.GetEnumLength(SheetP1RelRows);
    SheetPXSp2._totalRowCount = SheetPXSp2._relRowCount + 1;
    F01285.SheetPXSp2 = SheetPXSp2;
    var SheetP3ColumnBlocks;
    (function (SheetP3ColumnBlocks) {
        SheetP3ColumnBlocks[SheetP3ColumnBlocks["Usd"] = 0] = "Usd";
        SheetP3ColumnBlocks[SheetP3ColumnBlocks["Rub"] = 1] = "Rub";
    })(SheetP3ColumnBlocks || (SheetP3ColumnBlocks = {}));
    var SheetP5 = (function (_super) {
        __extends(SheetP5, _super);
        function SheetP5(id, _document) {
            var _this = _super.call(this, id, false) || this;
            _this._document = _document;
            return _this;
        }
        SheetP5.prototype.IsFooterRow = function (row) {
            return this._document.CommonRules.IsFooterRow(this, row);
        };
        SheetP5.prototype.FormatEventHandler = function (sheetId, row, column, groupIndex) {
            switch (column) {
                case 1:
                    return SheetFormatCollection.Default;
                case 2:
                case 6:
                    return SheetFormatCollection.Spr;
                default:
                    return SheetFormatCollection.Free;
            }
        };
        SheetP5.prototype.CalcEventHandler = function (sheetId, row, column, fieldId) {
            if (BaseObasTableFields.StrCodeField.Equal(fieldId)) {
                return ObasHelper.FillWithCharacter(row + 1, 3);
            }
            return undefined;
        };
        return SheetP5;
    }(Sheet));
    F01285.SheetP5 = SheetP5;
    var P2GroupSheet = (function (_super) {
        __extends(P2GroupSheet, _super);
        function P2GroupSheet() {
            return _super !== null && _super.apply(this, arguments) || this;
        }
        Object.defineProperty(P2GroupSheet.prototype, "SheetInfo", {
            get: function () {
                return P2GroupSheet._sheetInfo;
            },
            enumerable: true,
            configurable: true
        });
        P2GroupSheet.prototype.CanEditEventHandler = function (sheetId, row, column, fieldId, rowLevel) {
            return column > 1 &&
                this.Document.CommonRules
                    .CantEditPrevCurYearsEditingCellEventHandler(sheetId, row, column, fieldId, rowLevel);
        };
        return P2GroupSheet;
    }(HierarchyYearGroupSheet));
    P2GroupSheet._codeInfo = {
        Column: 3,
        Length: InterfaceRules.TotalRowCodeLength,
        LevelIncs: [100, 1],
        CalcTotalCode: function () {
            return InterfaceRules.TotalRowCode;
        }
    };
    P2GroupSheet._totalRowInfo = {
        IsCalculated: false,
        Name: InterfaceRules.TotalRowName,
        Format: SheetFormatCollection.Default
    };
    P2GroupSheet._subTotalRowInfo = {
        IsCalculated: false,
        Name: "Итого по учреждению",
        Format: SheetFormatCollection.Default
    };
    P2GroupSheet._freeColConstAll = {
        Cell: { Type: SheetCellTypes.Free },
        SubTotalRow: P2GroupSheet._subTotalRowInfo,
        TotalRow: P2GroupSheet._totalRowInfo
    };
    P2GroupSheet._sheetInfo = {
        MaxLevel: 2,
        CodeInfo: P2GroupSheet._codeInfo,
        ColumnsInfo: [
            SheetColumnInfoCollection.SprColDefaultTotal,
            SheetColumnInfoCollection.FreeColDefaultTotal,
            P2GroupSheet._freeColConstAll,
            SheetColumnInfoCollection.AllDefault,
            SheetColumnInfoCollection.FreeColAllCalc,
            SheetColumnInfoCollection.FreeColAllX,
            SheetColumnInfoCollection.FreeColAllX,
            SheetColumnInfoCollection.FreeColAllX,
            SheetColumnInfoCollection.FreeColAllX,
            SheetColumnInfoCollection.FreeColAllX,
            SheetColumnInfoCollection.CalcColAllCalc,
            SheetColumnInfoCollection.CalcColAllCalc
        ]
    };
    F01285.P2GroupSheet = P2GroupSheet;
    var P2Sp2RelRows;
    (function (P2Sp2RelRows) {
        P2Sp2RelRows[P2Sp2RelRows["AllOfficers"] = 0] = "AllOfficers";
        P2Sp2RelRows[P2Sp2RelRows["SeniorOfficers"] = 1] = "SeniorOfficers";
        P2Sp2RelRows[P2Sp2RelRows["MiddleOfficers"] = 2] = "MiddleOfficers";
        P2Sp2RelRows[P2Sp2RelRows["JuniorOfficers"] = 3] = "JuniorOfficers";
        P2Sp2RelRows[P2Sp2RelRows["Ensigns"] = 4] = "Ensigns";
        P2Sp2RelRows[P2Sp2RelRows["OtherContracts"] = 5] = "OtherContracts";
        P2Sp2RelRows[P2Sp2RelRows["Total"] = 6] = "Total";
    })(P2Sp2RelRows || (P2Sp2RelRows = {}));
    var FotSheetColumnBlocks;
    (function (FotSheetColumnBlocks) {
        FotSheetColumnBlocks[FotSheetColumnBlocks["Total"] = 0] = "Total";
        FotSheetColumnBlocks[FotSheetColumnBlocks["FotUsd"] = 1] = "FotUsd";
        FotSheetColumnBlocks[FotSheetColumnBlocks["FotRub"] = 2] = "FotRub";
    })(FotSheetColumnBlocks || (FotSheetColumnBlocks = {}));
    var FotSheet = (function (_super) {
        __extends(FotSheet, _super);
        function FotSheet(id, document) {
            return _super.call(this, id, document, InterfaceRules.FotRowCodeInfo) || this;
        }
        FotSheet.prototype.IsFotTotalColumn = function (column) {
            return this.IsColumnInDataBlock(column, FotSheetColumnBlocks.Total);
        };
        FotSheet.prototype.IsFotDataColumn = function (column) {
            return column > this.CalcEndBlockColumn(FotSheetColumnBlocks.Total);
        };
        FotSheet.prototype.FormatEventHandler = function (sheetId, row, column, groupIndex) {
            if (this.IsFotTotalColumn(column)) {
                return SheetFormatCollection.Calc;
            }
            if (this.IsFotDataColumn(column)) {
                switch (row) {
                    case 0:
                        return SheetFormatCollection.Related;
                    case 1:
                        return SheetFormatCollection.Free;
                }
            }
            if (this.IsFooterRow(row)) {
                if (column > this.RowCodeColumn) {
                    return SheetFormatCollection.Calc;
                }
                else {
                    return SheetFormatCollection.Default;
                }
            }
            else {
                switch (column) {
                    case this.RowCodeColumn:
                    case this.RowNameColumn:
                        return SheetFormatCollection.Default;
                    default:
                        if (column < this.RowNameColumn) {
                            return SheetFormatCollection.Related;
                        }
                }
            }
            return SheetFormatCollection.Default;
        };
        FotSheet.prototype.CalcEventHandler = function (sheetId, row, column, fieldId) {
            if (this.IsFotTotalColumn(column)) {
                var result = new SheetCalcResult(BaseFormulas.SUM);
                result.AddCoordinates(new CellCoordinate(row, column + this.YearsCount));
                result.AddCoordinates(new CellCoordinate(row, column + this.YearsCount * 2));
                return result.ToArray();
            }
            return undefined;
        };
        FotSheet.prototype.EditingCellEventHandler = function (sheetId, row, column, fieldId, rowLevel) {
            return (this.IsFotDataColumn(column) && (row === 1));
        };
        FotSheet.prototype.GetTotalFotYearsCaptionEventHandler = function (tableId, index, defaultCaption, fieldCaption) {
            return this.Document.CommonRules.CalcColumnCaption(index, this.StartDataColumn + this.YearsCount * FotSheetColumnBlocks.FotUsd + 1, 2);
        };
        return FotSheet;
    }(RelRowsYearsSheet));
    F01285.FotSheet = FotSheet;
    var SheetP1 = (function (_super) {
        __extends(SheetP1, _super);
        function SheetP1() {
            return _super !== null && _super.apply(this, arguments) || this;
        }
        SheetP1.prototype.FormatEventHandler = function (sheetId, row, column, groupIndex) {
            if (this.IsFotTotalColumn(column)) {
                return SheetFormatCollection.Calc;
            }
            if (this.IsFotDataColumn(column)) {
                switch (row) {
                    case 0:
                        return SheetFormatCollection.Calc;
                    case 1:
                    case 2:
                        return SheetFormatCollection.Related;
                    case 3:
                        return SheetFormatCollection.Free;
                }
            }
            return SheetFormatCollection.Default;
        };
        SheetP1.prototype.EditingCellEventHandler = function (sheetId, row, column, fieldId, rowLevel) {
            return (this.IsFotDataColumn(column) && (row === 3));
        };
        return SheetP1;
    }(FotSheet));
    F01285.SheetP1 = SheetP1;
    var P2Sp2Sp2GroupSheet = (function (_super) {
        __extends(P2Sp2Sp2GroupSheet, _super);
        function P2Sp2Sp2GroupSheet(document) {
            var _this = _super.call(this, document) || this;
            _this._footerSumCalcOptions = {
                Filter: _this.FooterSumFilter
            };
            _this._sheet = null;
            return _this;
        }
        P2Sp2Sp2GroupSheet.prototype.IsFooterRow = function (row) {
            return this.Document.CommonRules.IsFooterRow(this._sheet, row);
        };
        P2Sp2Sp2GroupSheet.prototype.CalcRelRow = function (row) {
            return row % P2Sp2Sp2GroupSheet._relRowsCount;
        };
        P2Sp2Sp2GroupSheet.prototype.IsCalcCol = function (column) {
            return column === 4 || column > 6;
        };
        P2Sp2Sp2GroupSheet.prototype.IsXCol = function (column) {
            return column === 5 || column === 6;
        };
        P2Sp2Sp2GroupSheet.prototype.FormatTotalRow = function (column) {
            if (this.IsCalcCol(column)) {
                return SheetFormatCollection.Calc;
            }
            else {
                return SheetFormatCollection.Default;
            }
        };
        P2Sp2Sp2GroupSheet.prototype.FormatEventHandler = function (sheetId, row, column, groupIndex) {
            this._sheet = this.Document.Sheets.getValue(sheetId);
            if (this.IsFooterRow(row)) {
                return this.FormatTotalRow(column);
            }
            else {
                if (column < 2) {
                    return SheetFormatCollection.Spr;
                }
                else if (column < 4) {
                    return SheetFormatCollection.Default;
                }
                else {
                    var relRow = this.CalcRelRow(row);
                    switch (relRow) {
                        case P2Sp2RelRows.Total:
                        case P2Sp2RelRows.AllOfficers:
                            return this.FormatTotalRow(column);
                        default:
                            if (column < 7) {
                                return SheetFormatCollection.Free;
                            }
                            else if (column === 8) {
                                return SheetFormatCollection.Related;
                            }
                            else {
                                return SheetFormatCollection.Calc;
                            }
                    }
                }
            }
        };
        P2Sp2Sp2GroupSheet.prototype.FooterSumFilter = function (sheet, row, column, document) {
            var relRow = row % P2Sp2Sp2GroupSheet._relRowsCount;
            return relRow !== P2Sp2RelRows.Total;
        };
        P2Sp2Sp2GroupSheet.prototype.CalcStrCode = function (row, column) {
            var orgNum = (row / P2Sp2Sp2GroupSheet._relRowsCount) | 0;
            var code = parseInt(this._sheet.GetCellValue(row, column, false), 10);
            code += orgNum * 1000;
            return ObasHelper.FillWithCharacter(code, P2Sp2Sp2GroupSheet._strCodeLength);
        };
        P2Sp2Sp2GroupSheet.prototype.GetRowByRelRow = function (curRow, relRow) {
            var orgNum = (curRow / P2Sp2Sp2GroupSheet._relRowsCount) | 0;
            return relRow + orgNum * P2Sp2Sp2GroupSheet._relRowsCount;
        };
        P2Sp2Sp2GroupSheet.prototype.GetSumFormula = function (row, column, posts) {
            var result = new SheetCalcResult(BaseFormulas.SUM);
            for (var i = 0, len = posts.length; i < len; i++) {
                result.AddCoordinates(new CellCoordinate(this.GetRowByRelRow(row, posts[i]), column));
            }
            return result.ToArray();
        };
        P2Sp2Sp2GroupSheet.prototype.CalcEventHandler = function (sheetId, row, column, fieldId) {
            this._sheet = this.Document.Sheets.getValue(sheetId);
            if (this.IsFooterRow(row)) {
                switch (column) {
                    case P2Sp2Sp2GroupSheet._groupNameColumn:
                        return InterfaceRules.TotalRowName;
                    case P2Sp2Sp2GroupSheet._strCodeColumn:
                        return P2Sp2Sp2GroupSheet._totalRowCode;
                    default:
                        if (this.IsXCol(column)) {
                            return ObasHelper.X;
                        }
                        else if (this.IsCalcCol(column)) {
                            return this.Document.CommonRules.GetFooterSum(this._sheet, row, column, this._footerSumCalcOptions);
                        }
                }
            }
            else {
                if (column === P2Sp2Sp2GroupSheet._strCodeColumn) {
                    return this.CalcStrCode(row, column);
                }
                else if (column > P2Sp2Sp2GroupSheet._strCodeColumn) {
                    var relRow = this.CalcRelRow(row);
                    switch (relRow) {
                        case P2Sp2RelRows.Total:
                            if (this.IsXCol(column)) {
                                return ObasHelper.X;
                            }
                            else if (this.IsCalcCol(column)) {
                                return this.GetSumFormula(row, column, [P2Sp2RelRows.AllOfficers, P2Sp2RelRows.Ensigns, P2Sp2RelRows.OtherContracts]);
                            }
                        case P2Sp2RelRows.AllOfficers:
                            if (this.IsXCol(column)) {
                                return ObasHelper.X;
                            }
                            else if (this.IsCalcCol(column)) {
                                return this.GetSumFormula(row, column, [
                                    P2Sp2RelRows.SeniorOfficers, P2Sp2RelRows.MiddleOfficers, P2Sp2RelRows.JuniorOfficers
                                ]);
                            }
                    }
                }
            }
            return undefined;
        };
        P2Sp2Sp2GroupSheet.prototype.CanEditEventHandler = function (sheetId, row, column, fieldId, rowLevel) {
            return this.Document.CommonRules
                .CantEditPrevCurYearsEditingCellEventHandler(sheetId, row, column, fieldId, rowLevel) && column > 1;
        };
        return P2Sp2Sp2GroupSheet;
    }(YearGroupSheet));
    P2Sp2Sp2GroupSheet._relRowsCount = ObasHelper.GetEnumLength(P2Sp2RelRows);
    P2Sp2Sp2GroupSheet._groupNameColumn = 2;
    P2Sp2Sp2GroupSheet._strCodeColumn = 3;
    P2Sp2Sp2GroupSheet._strCodeLength = 7;
    P2Sp2Sp2GroupSheet._totalRowCode = 9000000;
    F01285.P2Sp2Sp2GroupSheet = P2Sp2Sp2GroupSheet;
    var PxSp2Sp3GroupSheet = (function (_super) {
        __extends(PxSp2Sp3GroupSheet, _super);
        function PxSp2Sp3GroupSheet(document, _payTable) {
            var _this = _super.call(this, document) || this;
            _this._payTable = _payTable;
            _this._totalPostRowInfo = {
                IsCalculated: false,
                Name: _this.TotalPostRowName,
                Format: SheetFormatCollection.Default
            };
            _this._subTotalRowInfos = [InterfaceRules.TotalOrgRowInfo, _this._totalPostRowInfo];
            _this._freeColConstAll = {
                Cell: { Type: SheetCellTypes.Free },
                SubTotalRow: _this._subTotalRowInfos,
                TotalRow: InterfaceRules.TotalRowInfo
            };
            _this._sheetInfo = {
                MaxLevel: 3,
                CodeInfo: {
                    Column: 4,
                    Length: 8,
                    LevelIncs: [1000, 100, 1],
                    CalcTotalCode: function () {
                        return 90000000;
                    }
                },
                ColumnsInfo: [
                    SheetColumnInfoCollection.RelatedColDefaultTotal,
                    SheetColumnInfoCollection.RelatedColDefaultTotal,
                    SheetColumnInfoCollection.RelatedColDefaultTotalFirstSubTotal,
                    _this._freeColConstAll,
                    SheetColumnInfoCollection.AllDefault,
                    SheetColumnInfoCollection.SprColAllX,
                    SheetColumnInfoCollection.FreeColAllX,
                    SheetColumnInfoCollection.FreeColAllX,
                    SheetColumnInfoCollection.FreeColAllX,
                    SheetColumnInfoCollection.SprColAllX,
                    SheetColumnInfoCollection.FreeColAllX,
                    SheetColumnInfoCollection.FreeColAllCalc
                ]
            };
            return _this;
        }
        Object.defineProperty(PxSp2Sp3GroupSheet.prototype, "SheetInfo", {
            get: function () {
                return this._sheetInfo;
            },
            enumerable: true,
            configurable: true
        });
        PxSp2Sp3GroupSheet.prototype.EditEventHandler = function (sheetId, row, column, fieldId, rowLevel) {
            var sheet = this.Document.Sheets.getValue(sheetId);
            return column > 2 &&
                sheet.Table.GetKeyBySourceTable(this._payTable) != null &&
                this.Document.CommonRules.CantEditPrevCurYearsEditingCellEventHandler(sheetId, row, column, fieldId, rowLevel);
        };
        return PxSp2Sp3GroupSheet;
    }(HierarchyYearGroupSheet));
    var P2Sp2Sp3GroupSheet = (function (_super) {
        __extends(P2Sp2Sp3GroupSheet, _super);
        function P2Sp2Sp3GroupSheet() {
            return _super !== null && _super.apply(this, arguments) || this;
        }
        Object.defineProperty(P2Sp2Sp3GroupSheet.prototype, "TotalPostRowName", {
            get: function () {
                return P2Sp2Sp3GroupSheet._totalPostRowName;
            },
            enumerable: true,
            configurable: true
        });
        return P2Sp2Sp3GroupSheet;
    }(PxSp2Sp3GroupSheet));
    P2Sp2Sp3GroupSheet._totalPostRowName = "Итого по составу военнослужащих";
    F01285.P2Sp2Sp3GroupSheet = P2Sp2Sp3GroupSheet;
    var P3Sp2Sp3GroupSheet = (function (_super) {
        __extends(P3Sp2Sp3GroupSheet, _super);
        function P3Sp2Sp3GroupSheet() {
            return _super !== null && _super.apply(this, arguments) || this;
        }
        Object.defineProperty(P3Sp2Sp3GroupSheet.prototype, "TotalPostRowName", {
            get: function () {
                return P3Sp2Sp3GroupSheet._totalPostRowName;
            },
            enumerable: true,
            configurable: true
        });
        return P3Sp2Sp3GroupSheet;
    }(PxSp2Sp3GroupSheet));
    P3Sp2Sp3GroupSheet._totalPostRowName = "Итого по категории сотрудников";
    F01285.P3Sp2Sp3GroupSheet = P3Sp2Sp3GroupSheet;
    var P3Sp2Sp2GroupSheet = (function (_super) {
        __extends(P3Sp2Sp2GroupSheet, _super);
        function P3Sp2Sp2GroupSheet(document) {
            return _super.call(this, document) || this;
        }
        Object.defineProperty(P3Sp2Sp2GroupSheet.prototype, "SheetInfo", {
            get: function () {
                return P3Sp2Sp2GroupSheet._sheetInfo;
            },
            enumerable: true,
            configurable: true
        });
        P3Sp2Sp2GroupSheet.prototype.CanEditEventHandler = function (sheetId, row, column, fieldId, rowLevel) {
            return this.Document.CommonRules
                .CantEditPrevCurYearsEditingCellEventHandler(sheetId, row, column, fieldId, rowLevel) && column > 1;
        };
        return P3Sp2Sp2GroupSheet;
    }(HierarchyYearGroupSheet));
    P3Sp2Sp2GroupSheet._sprColConstAll = {
        Cell: { Type: SheetCellTypes.Spr },
        SubTotalRow: InterfaceRules.TotalOrgRowInfo,
        TotalRow: InterfaceRules.TotalRowInfo
    };
    P3Sp2Sp2GroupSheet._sheetInfo = {
        MaxLevel: 2,
        CodeInfo: {
            Column: 3,
            Length: 6,
            LevelIncs: [100, 1],
            CalcTotalCode: function () {
                return 900100;
            }
        },
        ColumnsInfo: [
            SheetColumnInfoCollection.SprColDefaultTotal,
            SheetColumnInfoCollection.SprColDefaultTotal,
            P3Sp2Sp2GroupSheet._sprColConstAll,
            SheetColumnInfoCollection.AllDefault,
            SheetColumnInfoCollection.FreeColAllCalc,
            SheetColumnInfoCollection.RelatedColAllX,
            SheetColumnInfoCollection.FreeColAllX,
            SheetColumnInfoCollection.CalcColAllCalc,
            SheetColumnInfoCollection.RelatedColAllCalc,
            SheetColumnInfoCollection.CalcColAllCalc,
            SheetColumnInfoCollection.CalcColAllCalc
        ]
    };
    F01285.P3Sp2Sp2GroupSheet = P3Sp2Sp2GroupSheet;
})(F01285 || (F01285 = {}));
