"use strict";
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
const tslib_es6 = require("../../node_modules/tslib/tslib.es6.js");
const axisDefault = require("./axisDefault.js");
const layout = require("../util/layout.js");
const OrdinalMeta = require("../data/OrdinalMeta.js");
const axisCommonTypes = require("./axisCommonTypes.js");
const util = require("../../../../../zrender@5.4.4/node_modules/zrender/lib/core/util.js");
function axisModelCreator(registers, axisName, BaseAxisModelClass, extraDefaultOption) {
  util.each(axisCommonTypes.AXIS_TYPES, function(v, axisType) {
    var defaultOption = util.merge(util.merge({}, axisDefault.default[axisType], true), extraDefaultOption, true);
    var AxisModel = (
      /** @class */
      function(_super) {
        tslib_es6.__extends(AxisModel2, _super);
        function AxisModel2() {
          var _this = _super !== null && _super.apply(this, arguments) || this;
          _this.type = axisName + "Axis." + axisType;
          return _this;
        }
        AxisModel2.prototype.mergeDefaultAndTheme = function(option, ecModel) {
          var layoutMode = layout.fetchLayoutMode(this);
          var inputPositionParams = layoutMode ? layout.getLayoutParams(option) : {};
          var themeModel = ecModel.getTheme();
          util.merge(option, themeModel.get(axisType + "Axis"));
          util.merge(option, this.getDefaultOption());
          option.type = getAxisType(option);
          if (layoutMode) {
            layout.mergeLayoutParam(option, inputPositionParams, layoutMode);
          }
        };
        AxisModel2.prototype.optionUpdated = function() {
          var thisOption = this.option;
          if (thisOption.type === "category") {
            this.__ordinalMeta = OrdinalMeta.default.createByAxisModel(this);
          }
        };
        AxisModel2.prototype.getCategories = function(rawData) {
          var option = this.option;
          if (option.type === "category") {
            if (rawData) {
              return option.data;
            }
            return this.__ordinalMeta.categories;
          }
        };
        AxisModel2.prototype.getOrdinalMeta = function() {
          return this.__ordinalMeta;
        };
        AxisModel2.type = axisName + "Axis." + axisType;
        AxisModel2.defaultOption = defaultOption;
        return AxisModel2;
      }(BaseAxisModelClass)
    );
    registers.registerComponentModel(AxisModel);
  });
  registers.registerSubTypeDefaulter(axisName + "Axis", getAxisType);
}
function getAxisType(option) {
  return option.type || (option.data ? "category" : "value");
}
exports.default = axisModelCreator;
