import { dateRule, numberRule, extendNumberRule, chnNumberRule, chnWeek2Rule, chnWeek3Rule, loopSeriesRule, otherRule } from "./rules";

export class AutoFillService {
    constructor() {
        this._rules = [], this._init();
    }
    _init() {
        this._rules = [ dateRule, numberRule, extendNumberRule, chnNumberRule, chnWeek2Rule, chnWeek3Rule, loopSeriesRule, otherRule ].sort(((a, b) => b.priority - a.priority));
    }
    registerRule(rule) {
        if (this._rules.find((r => r.type === rule.type))) throw new Error(`Registry rule failed, type '${rule.type}' already exist!`);
        const index = this._rules.findIndex((r => r.priority < rule.priority));
        this._rules.splice(-1 === index ? this._rules.length : index, 0, rule);
    }
    getRules() {
        return this._rules;
    }
}
//# sourceMappingURL=auto-fill-services.js.map