import { __assign, __extends, __rest } from "tslib";
import { omit } from '@antv/util';
import { CompositeLayer } from '../../core/composite-layer';
import { TextLayer } from '../../core-layers/text-layer';
import { PointLayer } from '../../core-layers/point-layer';
import { getDefaultState } from './adaptor';
import { DEFAULT_OPTIONS, DEFAULT_STATE } from './constants';
import { getLabelLayerOptions } from '../common/label-layer';
import { CompositeLayerEvent } from '../../core/constants';
var IconLayer = /** @class */ (function (_super) {
    __extends(IconLayer, _super);
    function IconLayer(options) {
        var _this = _super.call(this, options) || this;
        /**
         * 图层交互状态配置
         */
        _this.layerState = DEFAULT_STATE;
        /**
         * 复合图层类型
         */
        _this.type = CompositeLayer.LayerType.IconImageLayer;
        /**
         * 图层是否具有交互属性
         */
        _this.interaction = true;
        return _this;
        // this.initSubLayersEvent();
    }
    Object.defineProperty(IconLayer.prototype, "layer", {
        /**
         * 主图层
         */
        get: function () {
            return this.iconLayer;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(IconLayer.prototype, "iconLayer", {
        /**
         * 图标图层
         */
        get: function () {
            return this.subLayers.getLayer('iconLayer');
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(IconLayer.prototype, "labelLayer", {
        /**
         * 标注文本图层
         */
        get: function () {
            return this.subLayers.getLayer('labelLayer');
        },
        enumerable: false,
        configurable: true
    });
    /**
     * 添加到场景
     */
    IconLayer.prototype.addTo = function (scene) {
        this.scene = scene;
        this.initAssets();
        this.subLayers.addTo(scene);
        this.emit(CompositeLayerEvent.ADD);
    };
    /**
     * 获取图标图层配置项
     */
    IconLayer.prototype.getIconLayerOptions = function () {
        var _a = omit(this.options, ['source']), visible = _a.visible, minZoom = _a.minZoom, maxZoom = _a.maxZoom, _b = _a.zIndex, zIndex = _b === void 0 ? 0 : _b, radius = _a.radius, opacity = _a.opacity, icon = _a.icon, color = _a.color, iconStyle = _a.iconStyle, baseConfig = __rest(_a, ["visible", "minZoom", "maxZoom", "zIndex", "radius", "opacity", "icon", "color", "iconStyle"]);
        var defaultState = this.layerState;
        var fillState = {
            active: false,
            select: false,
        };
        var fillStyle = __assign({ opacity: opacity }, iconStyle);
        var options = __assign(__assign({}, baseConfig), { visible: visible, minZoom: minZoom, maxZoom: maxZoom, zIndex: zIndex, shape: icon, size: radius, state: fillState, color: color, style: fillStyle });
        return options;
    };
    IconLayer.prototype.createSubLayers = function () {
        var source = this.source;
        this.layerState = getDefaultState(this.options.state);
        // 映射图标图层
        var iconLayer = new PointLayer(__assign(__assign({}, this.getIconLayerOptions()), { id: 'iconLayer', source: source }));
        var labelLayer = new TextLayer(__assign(__assign({}, getLabelLayerOptions(this.options)), { id: 'labelLayer', source: source }));
        var subLayers = [iconLayer, labelLayer];
        return subLayers;
    };
    IconLayer.prototype.updateSubLayers = function (options) {
        this.iconLayer.update(this.getIconLayerOptions());
        this.labelLayer.update(getLabelLayerOptions(this.options));
    };
    /**
     * 默认配置项
     */
    IconLayer.DefaultOptions = DEFAULT_OPTIONS;
    return IconLayer;
}(CompositeLayer));
export { IconLayer };
//# sourceMappingURL=icon.js.map