"use strict";

var __createBinding = this && this.__createBinding || (Object.create ? function(o, m, k, k2) {
    void 0 === k2 && (k2 = k);
    var desc = Object.getOwnPropertyDescriptor(m, k);
    desc && !("get" in desc ? !m.__esModule : desc.writable || desc.configurable) || (desc = {
        enumerable: !0,
        get: function() {
            return m[k];
        }
    }), Object.defineProperty(o, k2, desc);
} : function(o, m, k, k2) {
    void 0 === k2 && (k2 = k), o[k2] = m[k];
}), __exportStar = this && this.__exportStar || function(m, exports) {
    for (var p in m) "default" === p || Object.prototype.hasOwnProperty.call(exports, p) || __createBinding(exports, m, p);
};

Object.defineProperty(exports, "__esModule", {
    value: !0
}), exports.AutoFillPlugin = void 0;

const vtable_1 = require("@visactor/vtable"), auto_fill_manager_1 = require("./auto-fill-manager");

__exportStar(require("./formula-integration"), exports), __exportStar(require("./types"), exports), 
__exportStar(require("./rules"), exports);

class AutoFillPlugin {
    constructor(options) {
        this.id = "auto-fill", this.name = "Auto Fill", this.runTime = [ vtable_1.TABLE_EVENT_TYPE.MOUSEDOWN_FILL_HANDLE, vtable_1.TABLE_EVENT_TYPE.DRAG_FILL_HANDLE_END, vtable_1.TABLE_EVENT_TYPE.DBLCLICK_FILL_HANDLE ], 
        this.autoFillManager = new auto_fill_manager_1.AutoFillManager(options);
    }
    run(...args) {
        var _a, _b;
        if (args[1] === vtable_1.TABLE_EVENT_TYPE.MOUSEDOWN_FILL_HANDLE) {
            const [, , table] = args;
            this.table = table, this.autoFillManager.setTable(this.table), this.autoFillManager.handleStartDrag(null === (_a = this.table) || void 0 === _a ? void 0 : _a.getSelectedCellRanges()[0]);
        } else if (args[1] === vtable_1.TABLE_EVENT_TYPE.DRAG_FILL_HANDLE_END) {
            const [{direction: direction}] = args;
            this.autoFillManager.handleEndDrag(null === (_b = this.table) || void 0 === _b ? void 0 : _b.getSelectedCellRanges()[0], direction);
        } else args[1] === vtable_1.TABLE_EVENT_TYPE.DBLCLICK_FILL_HANDLE && this.autoFillManager.handleDbClick();
    }
}

exports.AutoFillPlugin = AutoFillPlugin;
//# sourceMappingURL=index.js.map