
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements.  See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership.  The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License.  You may obtain a copy of the License at
*
*   http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied.  See the License for the
* specific language governing permissions and limitations
* under the License.
*/


/**
 * AUTO-GENERATED FILE. DO NOT MODIFY.
 */

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements.  See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership.  The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License.  You may obtain a copy of the License at
*
*   http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied.  See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import { __extends } from "tslib";
import * as zrUtil from 'tvrender/lib/core/util.js';
import ComponentModel from '../../model/Component.js';
var AlarmModel = /** @class */function (_super) {
  __extends(AlarmModel, _super);
  function AlarmModel() {
    var _this = _super !== null && _super.apply(this, arguments) || this;
    _this.type = AlarmModel.type;
    _this.preventAutoZ = true;
    return _this;
    // /**
    //  * Set the current painting alarm option.
    //  */
    // setAlarmOption(brushOption: AlarmCoverCreatorConfig): void {
    // }
  }
  // optionUpdated(newOption: AlarmOption, isInit: boolean): void {
  //     const thisOption = this.option;
  // }
  /**
  //  * If `areas` is null/undefined, range state remain.
  //  */
  AlarmModel.prototype.mergeAlarms = function (alarms) {
    if (process.env.NODE_ENV !== 'production') {
      zrUtil.assert(zrUtil.isArray(alarms));
    }
    if (!alarms) {
      return;
    }
    var alarmById = {};
    zrUtil.each(alarms, function (alarm) {
      alarmById[alarm.id] = alarm;
    });
    var newAlarms = zrUtil.map(this.option.alarms, function (alarm) {
      var updateAlarm = alarmById[alarm.id];
      if (updateAlarm) {
        alarmById[alarm.id] = void 0;
        return zrUtil.merge(alarm, updateAlarm, true);
      }
      return alarm;
    });
    var addAlarms = Object.keys(alarmById).map(function (key) {
      return alarmById[key];
    }).filter(Boolean);
    this.option.alarms = newAlarms.concat(addAlarms).filter(function (item) {
      return item.action !== 'remove';
    });
  };
  AlarmModel.prototype.setSelectedId = function (id) {
    this.option.selectedId = id;
  };
  AlarmModel.type = 'alarm';
  AlarmModel.dependencies = ['geo', 'grid', 'xAxis', 'yAxis'];
  AlarmModel.defaultOption = {
    alarmStyle: {
      color: '#d10c0c',
      backgroundColor: '#000',
      splitColor: 'rgb(46,46,46)',
      disabledColor: 'rgb(99,99,99)',
      disabledIconColor: 'rgb(46,46,46)'
    },
    showLine: true,
    throttleType: 'fixRate',
    throttleDelay: 0,
    alarms: [],
    selectedId: '',
    zlevel: 2,
    z: 100,
    precision: 5
  };
  return AlarmModel;
}(ComponentModel);
export default AlarmModel;