
/*
* 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 graphic from '../../util/graphic.js';
import ComponentModel from '../../model/Component.js';
import ComponentView from '../../view/Component.js';
import { windowOpen } from '../../util/format.js';
var LogoModel = /** @class */function (_super) {
  __extends(LogoModel, _super);
  function LogoModel() {
    var _this = _super !== null && _super.apply(this, arguments) || this;
    _this.type = LogoModel.type;
    _this.layoutMode = {
      type: 'box',
      ignoreSize: true
    };
    return _this;
  }
  LogoModel.type = 'logo';
  LogoModel.defaultOption = {
    // zlevel: 0,
    z: 6,
    show: true,
    src: '',
    target: 'blank',
    left: 0,
    top: 0,
    backgroundColor: 'rgba(0,0,0,0)',
    padding: 5,
    itemGap: 10
  };
  return LogoModel;
}(ComponentModel);
// View
var LogoView = /** @class */function (_super) {
  __extends(LogoView, _super);
  function LogoView() {
    var _this = _super !== null && _super.apply(this, arguments) || this;
    _this.type = LogoView.type;
    return _this;
  }
  LogoView.prototype.render = function (logoModel, ecModel, api) {
    this.group.removeAll();
    if (!logoModel.get('show')) {
      return;
    }
    var group = this.group;
    var src = logoModel.get('src');
    var imageEl = new graphic.Image({
      style: {
        width: 160,
        height: 25,
        image: src,
        x: 20,
        y: api.getHeight() - 50
      },
      z2: 10
    });
    // const textRect = imageEl.getBoundingRect();
    var link = logoModel.get('link');
    var triggerEvent = logoModel.get('triggerEvent', true);
    imageEl.silent = !link && !triggerEvent;
    if (link) {
      imageEl.on('click', function () {
        windowOpen(link, '_' + logoModel.get('target'));
      });
    }
    group.add(imageEl);
  };
  LogoView.type = 'logo';
  return LogoView;
}(ComponentView);
export function install(registers) {
  registers.registerComponentModel(LogoModel);
  registers.registerComponentView(LogoView);
}