import { __decorate, __extends } from "tslib";
import Vue from 'vue';
import Component from 'vue-class-component';
import { Emit, Prop } from 'vue-property-decorator';
import { ICON_NAME } from '../component-names';
import WithRender from './icon.html?style=./icon.scss';
var MIcon = /** @class */ (function (_super) {
    __extends(MIcon, _super);
    function MIcon() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    MIcon.prototype.onClick = function (event) { };
    MIcon.prototype.onKeydown = function (event) { };
    MIcon.prototype.onMouseOver = function (event) { };
    MIcon.prototype.onMouseLeave = function (event) { };
    Object.defineProperty(MIcon.prototype, "hasSvgTitle", {
        get: function () {
            return !!this.svgTitle;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MIcon.prototype, "spriteId", {
        get: function () {
            var svg = this.$svg;
            if (document.getElementById(this.name)) {
                return '#' + this.name;
            }
            else if (document.getElementById('m-svg__' + this.name)) {
                return '#m-svg__' + this.name;
            }
            else if (svg && svg.getExternalSpritesFromSpriteId(this.name)) {
                return svg.getExternalSpritesFromSpriteId(this.name);
            }
            else if (svg && svg.getExternalSpritesFromSpriteId('m-svg__' + this.name)) {
                return svg.getExternalSpritesFromSpriteId('m-svg__' + this.name);
            }
            else if (this.name) {
                Vue.prototype.$log.warn('"' + this.name + '" is not a valid svg id. Make sure that the sprite has been loaded via the $svg instance service.');
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MIcon.prototype, "showNameAsClassInHtml", {
        get: function () {
            return this.showNameAsClass ? this.name : '';
        },
        enumerable: false,
        configurable: true
    });
    __decorate([
        Prop({ required: true })
    ], MIcon.prototype, "name", void 0);
    __decorate([
        Prop()
    ], MIcon.prototype, "svgTitle", void 0);
    __decorate([
        Prop({ default: '20px' })
    ], MIcon.prototype, "size", void 0);
    __decorate([
        Prop({ default: false })
    ], MIcon.prototype, "showNameAsClass", void 0);
    __decorate([
        Emit('click')
    ], MIcon.prototype, "onClick", null);
    __decorate([
        Emit('keydown')
    ], MIcon.prototype, "onKeydown", null);
    __decorate([
        Emit('mouseover')
    ], MIcon.prototype, "onMouseOver", null);
    __decorate([
        Emit('mouseleave')
    ], MIcon.prototype, "onMouseLeave", null);
    MIcon = __decorate([
        WithRender,
        Component
    ], MIcon);
    return MIcon;
}(Vue));
export { MIcon };
var IconPlugin = {
    install: function (v, options) {
        v.prototype.$log.debug(ICON_NAME, 'plugin.install');
        v.component(ICON_NAME, MIcon);
    }
};
export default IconPlugin;
//# sourceMappingURL=icon.js.map