'use strict';

var util = require('../../../../../../zrender@6.0.0/node_modules/zrender/lib/core/util.js');
var createSeriesData = require('../../chart/helper/createSeriesData.js');
var axisHelper = require('../../coord/axisHelper.js');
var axisModelCommonMixin = require('../../coord/axisModelCommonMixin.js');
var Model = require('../../model/Model.js');
var layout = require('../../util/layout.js');
var dataStackHelper = require('../../data/helper/dataStackHelper.js');
var innerStore = require('../../util/innerStore.js');
var labelStyle = require('../../label/labelStyle.js');
var createDimensions = require('../../data/helper/createDimensions.js');
var symbol = require('../../util/symbol.js');
var states = require('../../util/states.js');

/**
 * Create a multi dimension List structure from seriesModel.
 */
function createList(seriesModel) {
  return createSeriesData.default(null, seriesModel);
}
var dataStack = {
  isDimensionStacked: dataStackHelper.isDimensionStacked,
  enableDataStack: dataStackHelper.enableDataStack,
  getStackedDimension: dataStackHelper.getStackedDimension
};
/**
 * Create scale
 * @param {Array.<number>} dataExtent
 * @param {Object|module:echarts/Model} option If `optoin.type`
 *        is secified, it can only be `'value'` currently.
 */
function createScale(dataExtent, option) {
  var axisModel = option;
  if (!(option instanceof Model.default)) {
    axisModel = new Model.default(option);
    // FIXME
    // Currently AxisModelCommonMixin has nothing to do with the
    // the requirements of `axisHelper.createScaleByModel`. For
    // example the methods `getCategories` and `getOrdinalMeta`
    // are required for `'category'` axis, and ecModel is required
    // for `'time'` axis. But occasionally echarts-gl happened
    // to only use `'value'` axis.
    // zrUtil.mixin(axisModel, AxisModelCommonMixin);
  }
  var scale = axisHelper.createScaleByModel(axisModel);
  scale.setExtent(dataExtent[0], dataExtent[1]);
  axisHelper.niceScaleExtent(scale, axisModel);
  return scale;
}
/**
 * Mixin common methods to axis model,
 *
 * Include methods
 * `getFormattedLabels() => Array.<string>`
 * `getCategories() => Array.<string>`
 * `getMin(origin: boolean) => number`
 * `getMax(origin: boolean) => number`
 * `getNeedCrossZero() => boolean`
 */
function mixinAxisModelCommonMethods(Model) {
  util.mixin(Model, axisModelCommonMixin.AxisModelCommonMixin);
}
function createTextStyle(textStyleModel, opts) {
  opts = opts || {};
  return labelStyle.createTextStyle(textStyleModel, null, null, opts.state !== 'normal');
}

exports.getLayoutRect = layout.getLayoutRect;
exports.getECData = innerStore.getECData;
exports.createDimensions = createDimensions.createDimensions;
exports.createSymbol = symbol.createSymbol;
exports.enableHoverEmphasis = states.enableHoverEmphasis;
exports.createList = createList;
exports.createScale = createScale;
exports.createTextStyle = createTextStyle;
exports.dataStack = dataStack;
exports.mixinAxisModelCommonMethods = mixinAxisModelCommonMethods;
